function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function PostForm(formaction)
{
	if(formaction!="")
	{
		document.frm.action=formaction;
	}
	
	document.frm.submit();

}
function PostBack(event)
{

	for( var i=1 ; i < arguments.length; i++ ) 
	{
	
		if(document.getElementById('hidArguments').value!="")
			document.getElementById('hidArguments').value=document.getElementById('hidArguments').value+",";
		document.getElementById('hidArguments').value=document.getElementById('hidArguments').value+arguments[i];
	}
	document.getElementById('hidEvent').value=event;
	
		document.frm.submit();
}


function PostForm(action,event)
{
	for( var i=2 ; i < arguments.length; i++ ) 
	{
		if(document.getElementById('hidArguments').value!="")
			document.getElementById('hidArguments').value=document.getElementById('hidArguments').value+",";
		document.getElementById('hidArguments').value=document.getElementById('hidArguments').value+arguments[i];
	}
	//document.getElementById('hidEvent').value=event;
	//document.frm.submit();
	
	document.getElementById('hidEvent').value=event;
	document.frm.action=action;
	document.frm.submit();
}

function PopulateList(obj,arr)
{
	alert(obj);

}


//=======================AJAX=================================================

/**
SAL - Simple Ajax Lib. 23-Sep-2005
by Nigel Liefrink
Email: leafrink@hotmail.com
*/

var debug = false;
/**
Browser Compatability function.
Returns the correct XMLHttpRequest depending on the current browser.
*/
function GetXmlHttp() {	
	var xmlhttp = false;
	if (window.XMLHttpRequest)
	{
		xmlhttp = new XMLHttpRequest();
  }
	else if (window.ActiveXObject)// code for IE
	{
		try 
		{
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		} 
		catch (e) 
		{
			try 
			{
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (E) {
				xmlhttp=false;
			}
		}
	}
	return xmlhttp;
}


/**
<summary>
Gets the response stream from the passed url, and then calls the callbackFuntion passing the response and the div_ids.
</summary>
<param name="url">The url to make the request to get the response data.</param>
<param name="callbackFunction">The function to call after the response has been recieved. the response <b>must</b> always be the first argument to the function.</param>
<param name="params"> (optional) Any other parameters you want to pass to the functions. (Note: only constants/strings/globals can be passed as params, most variables will be out of scope.) </param>
</summary>
<example>
	<code>
PassAjaxResponseToFunction('?getsomehtml=1', 'FunctionToHandleTheResponse', "\'div1\',\'div2\',\'div3\'');

function FunctionToHandleTheResponse(response, d1, d2, d3){
	var data = response.split(';');
	document.getElementById(d1).innerHTML = data[0];
	document.getElementById(d2).innerHTML = data[1];
	document.getElementById(d3).innerHTML = data[2];
}
	</code>
</example>
*/
function PassAjaxResponseToFunction(url, callbackFunction, params)
{		
  var xmlhttp = new GetXmlHttp();
  //now we got the XmlHttpRequest object, send the request.
  if (xmlhttp)
  {
    xmlhttp.onreadystatechange = function () 
                                {
	                                if (xmlhttp && xmlhttp.readyState==4)
	                                {//we got something back..
		                                if (xmlhttp.status==200)
		                                {
			                                var response = xmlhttp.responseText;
			                                var functionToCall = callbackFunction+'(response,'+params+')';
			                                if(debug){
				                                alert(response);
				                                alert (functionToCall);
			                                }
			                                eval(functionToCall);
		                                } else if(debug){
			                                document.write(xmlhttp.responseText);
		                                }
	                                }
                                }
    xmlhttp.open("GET",url,true);
    xmlhttp.send(null);
  }
}


/**
///<summary>
///Sets the innerHTML property of obj_id with the response from the passed url./
///</summary>
///<param name="url">The url to make the request to get the response data.</param>
///<param name="obj_id">The object or the id of the object to set the innerHTML for.</param>
*/

function AddCourse(course_id)
{		
					
		
	var url="coursesandevents";
	var xmlhttp = new GetXmlHttp();
	
  //now we got the XmlHttpRequest object, send the request.
  //alert(url);
  //alert(obj_id);
  if (xmlhttp)
  {
    xmlhttp.onreadystatechange = function () 
                                {
	                                if (xmlhttp && xmlhttp.readyState==4)
	                                {//we got something back..
		                                if (xmlhttp.status==200)
		                                {
			                               alert("The course has been added to the My Courses section.")
											document.location.reload();
											}
	                                }
                                }
    xmlhttp.open("POST",url,true);
	
	xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded;charset=UTF-8;');
	xmlhttp.send('hidEvent=btnAddCourse_OnClick_Ajax&hidArguments='+course_id+'');
		
  }
 }
  
 function BuyCourse(course_id)
{		

	var url="coursesandevents";
	var xmlhttp = new GetXmlHttp();
	
  //now we got the XmlHttpRequest object, send the request.
  //alert(url);
  //alert(obj_id);
  if (xmlhttp)
  {
    xmlhttp.onreadystatechange = function () 
                                {
	                                if (xmlhttp && xmlhttp.readyState==4)
	                                {//we got something back..
		                                if (xmlhttp.status==200)
		                                {
			                               alert("The course has been added to the shopping cart.")
											document.location.reload();
											}
	                                }
                                }
    xmlhttp.open("POST",url,true);
	
	xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded;charset=UTF-8;');
	xmlhttp.send('hidEvent=btnBuyCourse_OnClick_Ajax&hidArguments='+course_id+'');
		
  }
  }
function MarkAsRead(alert_id)
{		
					
		
	var url="alerts";
	var xmlhttp = new GetXmlHttp();
	
  //now we got the XmlHttpRequest object, send the request.
  //alert(url);
  //alert(obj_id);
  if (xmlhttp)
  {
    xmlhttp.onreadystatechange = function () 
                                {
	                                if (xmlhttp && xmlhttp.readyState==4)
	                                {//we got something back..
		                                if (xmlhttp.status==200)
		                                {
			                               alert("The alert has been marked as read.")
											document.location.reload();
											}
	                                }
                                }
    xmlhttp.open("POST",url,false);
	
	xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded;charset=UTF-8;');
	xmlhttp.send('hidEvent=btnMarkAsRead_OnClick_Ajax&hidArguments='+alert_id+'');
		
  }
}

function MarkAsRedeem(learnerid)
{			
	alert(learnerid);

	var dropdownIndex = document.getElementById('ssl_voucher').selectedIndex;
	var dropdownValue = document.getElementById('ssl_voucher')[dropdownIndex].value;	

	var url="learner";
	var xmlhttp = new GetXmlHttp();
	
  //now we got the XmlHttpRequest object, send the request. 
  if (xmlhttp)
  {
    xmlhttp.onreadystatechange = function () 
                                {
	                                if (xmlhttp && xmlhttp.readyState==4)
	                                {//we got something back..
		                                if (xmlhttp.status==200)
		                                {											
			                               alert("The selected voucher has been redeemed.")
											document.location.reload();
											}
	                                }
                                }
    xmlhttp.open("POST",url,false);
	
	xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded;charset=UTF-8;');	
	alert('hidEvent=btnMarkAsRedemeed_OnClick_Ajax&hidArguments='+dropdownValue+','+learnerid+'');
	xmlhttp.send('hidEvent=btnMarkAsRedemeed_OnClick_Ajax&hidArguments='+dropdownValue+','+learnerid+'');		
  }
}


function TinyMce()
{

tinyMCE.init({
		mode : "textareas",
		theme : "advanced",
		editor_selector : "editor",
		plugins : "style,table,paste",
		theme_advanced_statusbar_location : "bottom",
		theme_advanced_toolbar_align : "left",
		theme_advanced_toolbar_location : "top",
		paste_use_dialog : false,
		paste_auto_cleanup_on_paste : true,
		theme_advanced_buttons1 : "bold,italic,underline,bullist,numlist,link,hr,formatselect",
		theme_advanced_buttons2 : "",
		theme_advanced_buttons3 : "",
		theme_advanced_blockformats : "p,h2,h3",
		valid_elements : "a[href|target=_blank],strong/b,em/i,div[align],br,p,h1,h2,h3,h4,ul,ol,li,hr"
		});
	
}
function TinyMceFull()
{
tinyMCE.init({
		mode : "textareas",
		theme : "advanced",
		width : "50%",
		height : "400",
		plugins : "safari,spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,imagemanager,filemanager",
		theme_advanced_statusbar_location : "bottom",
		theme_advanced_toolbar_align : "left",
		theme_advanced_toolbar_location : "top",
		paste_use_dialog : false,
		force_p_newlines : false,
		force_br_newlines : true,
		paste_auto_cleanup_on_paste : true,
		theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,blockquote,pagebreak,|,insertfile,insertimage",
		theme_advanced_buttons2 : "justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect",
		theme_advanced_buttons3 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo",
		theme_advanced_buttons4 : "link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
		theme_advanced_buttons5 : "tablecontrols,|,hr,removeformat,visualaid",
		theme_advanced_buttons6 : "sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen,|,insertlayer,moveforward,movebackward,absolute,|,styleprops,spellchecker",
		theme_advanced_blockformats : "p,h2,h3"
		
		});
	
}
function Displaypreview()
{
   //window.open('http://localhost/aesic/admin/news/preview');
  //document.frm.submit();
  document.getElementById('hidcontent').value=document.getElementById('txtAreacontent').value;
  window.open("http://localhost/aesic/admin/news/preview");
}

function filterSubmit()
{
	document.getElementById('Submit').value='Filter';
	document.frm.submit();
}
/* for menu */


var timeout         = 5500;
var closetimer		= 0;
var ddmenuitem      = 0;

// open hidden layer


function mopen(id)
{	
	// cancel close timer
	
	mcancelclosetime();

	// close old layer
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';

	// get new layer and show it
	ddmenuitem = document.getElementById(id);
	ddmenuitem.style.visibility = 'visible';

}
// close showed layer
function mclose()
{
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
}

// go close timer
function mclosetime()
{
	closetimer = window.setTimeout(mclose, timeout);
}

// cancel close timer
function mcancelclosetime()
{
	if(closetimer)
	{
		window.clearTimeout(closetimer);
		closetimer = null;
	}
	
	
	
	
}


/* for menu */




