// JavaScript Document
var ajax = new Array();
function gethometown(obj)
{   
 var cityid = obj.selectedIndex;
 document.getElementById('home_city').selectedIndex=cityid;
 document.getElementById('InstCity').selectedIndex=cityid;
 getInstituteList(document.getElementById('InstCity'))
}

function definstitute(instid)
{
	getInstituteList(document.getElementById('InstCity'),instid);
}

function getInstituteList(ct, instid)
{
	var cityid = ct.options[ct.selectedIndex].value;
	document.getElementById('Institute').options.length = 0;	// Empty Degination select box
	if(cityid.length>0){
		var index = ajax.length;
		ajax[index] = new sack();
		ajax[index].requestFile = '/ajaxphp/candidates/getinstitute.php?cityid='+cityid+'&instid='+instid;	// Specifying which file to get
		ajax[index].onCompletion = function(){ createInstitute(index) };	// Specify function that will be executed after file has been found
		ajax[index].runAJAX();		// Execute AJAX function
	}
}

function createInstitute(index)
{	var obj = document.getElementById('Institute');
	eval(ajax[index].response);	// Executing the response from Ajax as Javascript code	
}

