// JavaScript Document
var xmlHttp;

function byCollege(str)
 { 
 xmlHttp=GetXmlHttpObject();
 if (xmlHttp==null)
  {
  alert ("Browser does not support HTTP Request");
  return;
  } 
 var url="http://admissions.siuc.edu/forms/majorCollegeProcess.php";
 url=url+"?q="+str;
 url=url+"&sid="+Math.random();
//alert("the url  " + url);
 xmlHttp.open("GET",url,true);
 xmlHttp.onreadystatechange=stateChanged; 
 xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
 xmlHttp.send(null);
 }
 
 function stateChanged() 
{ 
//alert(xmlHttp.responseText + " responseText");
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
  
		if (xmlHttp.status == 200)
			{
			 //alert("Server is done!");
			 if (!xmlHttp.responseText)
			 {
				  //alert ("No response text, please try again.");
				 //document.location.href="http://131.230.213.192/admissions/forms/2testopenhouse.php";
				  return;
			 }
			 else{
			 	//alert("in the else" + xmlHttp.responseText + " responseText");
			 	document.getElementById("themajors").innerHTML=xmlHttp.responseText;
			 }
			}
       else if (xmlHttp.status == 404)
	        alert("Request URL does not exist Error: status code is " + xmlHttp.status);
       else
         alert("Error: status code is " + xmlHttp.status);
 } 

} 
 
 
 
 //for alphabetical search
function byAlpha(str)
 { 
 xmlHttp=GetXmlHttpObject();
 if (xmlHttp==null)
  {
  alert ("Browser does not support HTTP Request");
  return;
  } 
 var url="http://admissions.siuc.edu/forms/majorAlphaProcess.php";
 url=url+"?q="+str;
 url=url+"&sid="+Math.random();
//alert("the url  " + url);
 xmlHttp.open("GET",url,true);
 xmlHttp.onreadystatechange=stateChanged; 
 xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
 xmlHttp.send(null);
 }

 // for the view all section
function listAll(str)
 { 
 xmlHttp=GetXmlHttpObject();
 if (xmlHttp==null)
  {
  alert ("Browser does not support HTTP Request");
  return;
  } 
 var url="http://admissions.siuc.edu/forms/majorListAll.php";
 url=url+"?q="+str;
 url=url+"&sid="+Math.random();
//alert("the url  " + url);
 xmlHttp.open("GET",url,true);
 xmlHttp.onreadystatechange=stateChanged; 
 xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
 xmlHttp.send(null);
 }






 //for major details
function displayMajorInfo(str)
 { 
 xmlHttp=GetXmlHttpObject();
 if (xmlHttp==null)
  {
  alert ("Browser does not support HTTP Request");
  return;
  } 
 var url="http://admissions.siuc.edu/forms/majorDisplayInfo.php";
 url=url+"?q="+str;
 //url=url+"&collcode="+clgcode;
 url=url+"&sid="+Math.random();
//alert("the url  " + url);
 xmlHttp.open("GET",url,true);
 xmlHttp.onreadystatechange=listDetails; 
 xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
 xmlHttp.send(null);
 }

function listDetails() 
{ 
//alert(xmlHttp.responseText + " responseText");
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
  
		if (xmlHttp.status == 200)
			{
			 //alert("Server is done!");
			 if (!xmlHttp.responseText)
			 {
				  alert ("No response text, please try again.");
				 //document.location.href="http://131.230.213.192/admissions/forms/2testopenhouse.php";
				  return;
			 }
			 else{
			 	//alert("in the else" + xmlHttp.responseText + " responseText");
			 	document.getElementById("theinfo").innerHTML=xmlHttp.responseText;
			 }
			}
       else if (xmlHttp.status == 404)
	        alert("Request URL does not exist Error: status code is " + xmlHttp.status);
       else
         alert("Error: status code is " + xmlHttp.status);
 } 

} 




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;
}