/* The following function creates an XMLHttpRequest object... */

function createRequestObject(){
	var request_o; //declare the variable to hold the object.
	var browser = navigator.appName; //find the browser name
	if(browser == "Microsoft Internet Explorer"){
		/* Create the object using MSIE's method */
		request_o = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		/* Create the object using other browser's method */
		request_o = new XMLHttpRequest();
	}
	return request_o; //return the object
}

/* You can get more specific with version information by using 
	parseInt(navigator.appVersion)
	Which will extract an integer value containing the version 
	of the browser being used.
*/
/* The variable http will hold our new XMLHttpRequest object. */
var http = createRequestObject(); 
/*
function getCatO(){
//selVal=document.frm.city_name.options[document.frm.city_name.selectedIndex].value;

http.open('get', '1.php?cc=Others');


http.onreadystatechange = handleSC1; 
http.send(null);
}
*/
	var dTime = new Date();
tim=dTime.setHours(dTime.getHours(),dTime.getMinutes(),dTime.getSeconds());

function selectProf(){
selVal=document.faculty.special.options[document.faculty.special.selectedIndex].value;

http.open('get', 'profList.php?cat='+selVal+"&ti="+tim);
http.onreadystatechange = handleSC1; 
http.send(null);
}
// the below function is to display Faculty name and specialization
function profList(){ //alert("prof");
selVal=document.getElementById('sj').options[document.getElementById('sj').selectedIndex].value;

http.open('get', 'facultyList.php?cat='+selVal+"&ti="+tim);
http.onreadystatechange = handleSC2; 
http.send(null);
}

function profDet(){ //alert("Details1");
selVal=document.getElementById('sj1').options[document.getElementById('sj1').selectedIndex].value;
//alert("Details");
http.open('get', 'profDetails.php?cat='+selVal+"&ti="+tim);
http.onreadystatechange = handleSC2; 
http.send(null);
}



/* Function called to handle the list that was returned from the internal_request.php file.. */
function handleSC1(){
	
	obj='prof';//object name
	if(http.readyState == 1){load(obj);nosub(obj);};
	if(http.readyState == 4){ //Finished loading the response
		var response = http.responseText;
			if (response=="")
			{
			//	nosub(obj);//	nosub(obj1);//getLov();	//	load(obj2)
			}else{
//alert(response);
				pop(response,obj);
			}
	}
}


function handleSC2(){
	
	
	if(http.readyState == 1){};
	if(http.readyState == 4){ //Finished loading the response
		var response = http.responseText;
			if (response=="")
			{
			//	nosub(obj);//	nosub(obj1);//getLov();	//	load(obj2)
			}else{
				//alert(response);
				
				document.getElementById('pDetails').innerHTML=response;
				document.getElementById('pDetails').style.display="block";
				//alert('response');
			}
	}
}

function factDetails(val){ 
	//alert(val);
document.getElementById('dialog').innerHTML='';
http.open('get', 'http://greatlakes.edu.in/profDetails12.php?cat='+val);
http.onreadystatechange = handleSCFac; 
http.send(null);
}



/* Function called to handle the list that was returned from the internal_request.php file.. */
function handleSCFac(){
	
	if(http.readyState == 1){load(obj);nosub(obj);};
	if(http.readyState == 4){ //Finished loading the response
		var response = http.responseText;
			if (response=="")
			{
			}else{
				//alert(response);
				document.getElementById('dialog').innerHTML=response;
			}
	}
}

///////////////////////////////////////////////////////////////////////////////////////////

// No need to edit below this	

function pop(st1,obj)
{
		selNum=1;

		var selbox = eval('document.faculty.'+ obj);//eval('document.frm.s' + cnt);
		selbox.length=0;



	opt11 = "Select"; // for assigning thedefault value


			var opt = new Option(opt11,""); // for assigning thedefault value
		selbox.options[0] = opt;
			optStr=st1.split("~");



                        for (i=0;i<optStr.length - 1; i++)
                        {
							
							optStr1=optStr[i].split("-");
						
                        var optText=optStr1[0];
                        var optVal=optStr1[1];
                        var opt = new Option(optText,optVal);

                        selbox.options[selNum] = opt;opt.selected;
                        selNum=selNum+1;
						
                        }
selbox.disabled=0;
}



function load(obj)
{
		var selbox = eval('document.faculty.'+ obj);
		selbox.length=0;

		var opt = new Option("Loading....",""); // for assigning thedefault value
		selbox.options[0] = opt;
		
		selbox.disabled=1;
}

function nosub(obj)
{
		var selbox = eval('document.faculty.'+ obj);
		selbox.length=0;

		var opt = new Option("       ",""); // for assigning thedefault value
		selbox.options[0] = opt;
		
		selbox.disabled=1;
}

