var xmlHttp;
var responseText;
 
function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}

function getSubcourses(mid,num)
{  	
	
	var numb = num.split("$$"); 
	num = numb[0];
	if(numb.length<2)
	{
		numb[1] ="";
		numb[2] ="";		
	}
	
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  }

    xmlHttp.onreadystatechange=function()
      {
      	if(xmlHttp.readyState==4)
      	{         		  
      		var result_string = xmlHttp.responseText; //alert(result_string);
      		
      		document.getElementById("val").innerHTML=result_string;
      		document.getElementById("val1").innerHTML="<strong>Duration</strong>";			
      		document.getElementById("val2").innerHTML=":";
			
			for(k=0;k<num;k++)
			{
				//alert(cod[k]);
				if(id[k]==mid)
				{
				var codes=cod[k];
					break;
				}
			}
      		document.register.code.value=codes;
			for(k=0;k<num;k++)
			{
				//alert(mode[k]);
				if(id[k]==mid)
				{
				var modes=mode[k];
					break;
				}
			}
			//
			var modess = modes.split(","); 
					//alert(modess);	
										
					var text="<select name='cmode' id='cmode'>";
					     text+="<option value=\""+modess[0]+"\">"+((modess[0]!=0)?"full time":"partime")+"</option>";
						 if(modess[1])
			            {
			           text+="<option value=\""+modess[1]+"\">"+((modess[1]!=0)?"full time":"partime")+"</option>";
			            }
						text+="</select>";  
						document.getElementById("mod1").innerHTML="<strong>Study mode</strong>";			
						document.getElementById("mod2").innerHTML=":";			
						document.getElementById("mod").innerHTML=text;
			 
				if(numb[1]!="" && numb[2]!="")
				{
					for(i=0;i<document.register.cduration.options.length;i++)
					{
					if(document.register.cduration.options[i].value ==numb[1])
					document.register.cduration.selectedIndex = i;
					}
					for(i=0;i<document.register.cmode.options.length;i++)
					{
					if(document.register.cmode.options[i].value ==numb[2])
					document.register.cmode.selectedIndex = i;
					}
				}
      	}
      }
	
	//var location = document.getElementById(txtEle).value;
	

		xmlHttp.open("GET","../amscms/getcourses.php?mid="+mid,true);
		xmlHttp.send(null); 
				
}	

function clearSubCourses()
{
	document.register.code.value="";
	document.getElementById("mod").innerHTML="";
	document.getElementById("mod1").innerHTML="";
	document.getElementById("val").innerHTML="";	
	document.getElementById("val1").innerHTML="";
	document.getElementById("mod2").innerHTML="";	
	document.getElementById("val2").innerHTML="";	
}

function getSubcoursesUser(mid,num)
{  	
	document.getElementById("loading_image_show").innerHTML = "<img src=\"images/ajax-loader.gif\" alt=\"Course details \" /><br/><b>Loading....</b>";		
	var numb = num.split("$$"); 
	num = numb[0];
	if(numb.length<2)
	{
		numb[1] ="";
		numb[2] ="";		
	}
	
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  }

    xmlHttp.onreadystatechange=function()
      {
      	if(xmlHttp.readyState==4)
      	{         		  
      		var result_string = xmlHttp.responseText; //alert(result_string);
      		
      		document.getElementById("val").innerHTML=result_string;
      		document.getElementById("val1").innerHTML="<strong>Duration</strong>";			
			
			for(k=0;k<num;k++)
			{
				//alert(cod[k]);
				if(id[k]==mid)
				{
				var codes=cod[k];
					break;
				}
			}
      		document.register.code.value=codes;
			for(k=0;k<num;k++)
			{
				//alert(mode[k]);
				if(id[k]==mid)
				{
				var modes=mode[k];
					break;
				}
			}

			var modess = modes.split(","); 
					//alert(modess);	
										
					var text="<select name='cmode' id='cmode'>";
					     text+="<option value=\""+modess[0]+"\">"+((modess[0]!=0)?"full time":"partime")+"</option>";
						 if(modess[1])
			            {
			           text+="<option value=\""+modess[1]+"\">"+((modess[1]!=0)?"full time":"partime")+"</option>";
			            }
						text+="</select>";  
						document.getElementById("mod1").innerHTML="<strong>Study mode</strong>";					
						document.getElementById("mod").innerHTML=text;
			 
				if(numb[1]!="" && numb[2]!="")
				{
					for(i=0;i<document.register.cduration.options.length;i++)
					{
					if(document.register.cduration.options[i].value ==numb[1])
					document.register.cduration.selectedIndex = i;
					}
					for(i=0;i<document.register.cmode.options.length;i++)
					{
					if(document.register.cmode.options[i].value ==numb[2])
					document.register.cmode.selectedIndex = i;
					}
				}
				
				document.getElementById("loading_image_show").innerHTML = "";					
      	}
      }
	
	//var location = document.getElementById(txtEle).value;		
		//xmlHttp.open("GET","http://youtube.com",true);
		xmlHttp.open("GET","amscms/getcourses.php?mid="+mid,true);		
		xmlHttp.send(null); 
				
}	

function getcourses(val)
{  	
	
	
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  }

    xmlHttp.onreadystatechange=function()
      {
      	if(xmlHttp.readyState==4)
      	{         		  
      		var result_string = xmlHttp.responseText; //alert(result_string);
      		
      		document.getElementById("val").innerHTML=result_string;
      		document.getElementById("val1").innerHTML="<strong>Duration</strong>";			
      		document.getElementById("val2").innerHTML=":";
			
			for(k=0;k<num;k++)
			{
				//alert(cod[k]);
				if(id[k]==mid)
				{
				var codes=cod[k];
					break;
				}
			}
      		document.register.code.value=codes;
			for(k=0;k<num;k++)
			{
				//alert(mode[k]);
				if(id[k]==mid)
				{
				var modes=mode[k];
					break;
				}
			}
			//
			var modess = modes.split(","); 
					//alert(modess);	
										
					var text="<select name='cmode' id='cmode'>";
					     text+="<option value=\""+modess[0]+"\">"+((modess[0]!=0)?"full time":"partime")+"</option>";
						 if(modess[1])
			            {
			           text+="<option value=\""+modess[1]+"\">"+((modess[1]!=0)?"full time":"partime")+"</option>";
			            }
						text+="</select>";  
						document.getElementById("mod1").innerHTML="<strong>Study mode</strong>";			
      		document.getElementById("mod2").innerHTML=":";
			
			document.getElementById("mod").innerHTML=text;
			 
			//alert(document.getElementById("mod").innerHTML);

      	}
      }
	
	//var location = document.getElementById(txtEle).value;
	

		xmlHttp.open("GET","../amscms/courses.php?mid="+val,true);
		xmlHttp.send(null); 
				
}	 
function getadmission(val)
{  
//alert(val);
	if(val=="")
	{
		alert("Please enter the reference number");
		return false;
	}
	
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  }

    xmlHttp.onreadystatechange=function()
      {
		  
      	if(xmlHttp.readyState==4)
      	{         		  
      		var result_string = xmlHttp.responseText; 
			//alert(result_string);
      		//document.getElementById('pdiv').style.display='block';
      	//	document.getElementById("admission").innerHTML=result_string;
      		
			 	document.getElementById("admission").innerHTML=result_string;
			//alert(document.getElementById("mod").innerHTML);

      	}
      }
	
	//var location = document.getElementById(txtEle).value;
	 // document.getElementById('pdiv').style.display='block';
      document.getElementById("admission").innerHTML="<br/><br/><div style='text-align:center'><img src='images/ajax-loader.gif' /> <br>loading...</div>";
	  	var randomnumber=Math.floor(Math.random()*11);
		xmlHttp.open("GET","admission-status-display.php?mid="+val+"&"+randomnumber,true);
		//xmlHttp.open("GET","http://www.thamarai.com",true);
		xmlHttp.send(null); 
				
}	 




