
/**
 * @author Sydney
 * @since 2007-10-22 
 * @abstract contains a few Ajax functions that help in the auto completion
 * of the institution names.
 * @params str: string to match the insitution list.
 * @return dropdown list of institutions that match the str at the beginning. 
 */
function autoCompleteInstitution(str){
	if (str.length==0){ 
  		document.getElementById("instList").innerHTML="";
  		return;
  	}
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null){
  		alert ("Your browser does not support AJAX!");
  		return;
  	} 
	var url="getInstitution.php";
	url=url+"?inst="+str;
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

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 stateChanged(){
	if (xmlHttp.readyState==4){ 
		document.getElementById("instList").innerHTML=xmlHttp.responseText;
	}
}