function retrieveMandals()   
{   
	var fr = document.getElementById('ins_districtId');  
	//alert("FR:"+fr);
	if(fr.selectedIndex==0) { 
       return;  
    }  
    selectedOption = fr.options[fr.selectedIndex].value; 
    url="NEWAJAX.do?selectedOption="+selectedOption+"&type=1";          
    if (window.XMLHttpRequest) 
    { 
        // Non-IE browsers  
    	req = new XMLHttpRequest();  
	    req.onreadystatechange = populateSecondBoxMandals; 
    	try 
    	{
	      	req.open("GET", url, true); 
    	}
    	catch (e) 
    	{
	        alert("Cannot connect to server"); 
    	}
		req.send(null);
    }
    else if (window.ActiveXObject) 
    {   
        // IE browser        
    	req = new ActiveXObject("Microsoft.XMLHTTP");
      	if (req) 
      	{
        	req.onreadystatechange = populateSecondBoxMandals;
	        req.open("GET", url, true);
    	    req.send();
      	}
    }
}
//Callback function 
function populateSecondBoxMandals() 
{ 
	document.getElementById('ins_mandalId').options.length = 0;
    if (req.readyState == 4) 
    {   // Complete 
    	if (req.status == 200) 
    	{   // OK response
        	textToSplit = req.responseText
	    	if(textToSplit == '803')
	    	{
				alert("No select option available on the server")
			}
			returnElements=textToSplit.split("||")
			for ( var i=0; i<returnElements.length; i++ )
			{
            	valueLabelPair = returnElements[i].split(",")
	 		    document.getElementById('ins_mandalId').options[i] = new Option(valueLabelPair[1], valueLabelPair[0]);
          	}
        }
	} 
	else {  
        //alert("Bad response by the server");   
    }     
}


function retrieveVillages()    
{   
    
    var dcode = document.forms[0].ins_district.value;   
	var fr = document.getElementById('ins_mandalId');   
	if(fr.selectedIndex==0) { 
       return;  
    } 
    selectedOption = fr.options[fr.selectedIndex].value; 
    url="NEWAJAX.do?distcode="+dcode+"&selectedOption="+selectedOption+"&type=2"; 
            
    if (window.XMLHttpRequest) 
    { 
        // Non-IE browsers  
    	req = new XMLHttpRequest();  
	    req.onreadystatechange = populateSecondBoxVillages; 
    	try 
    	{
	      	req.open("GET", url, true); 
    	}
    	catch (e) 
    	{
	        alert("Cannot connect to server"); 
    	}
		req.send(null);
    }
    else if (window.ActiveXObject) 
    {   
        // IE browser        
    	req = new ActiveXObject("Microsoft.XMLHTTP");
      	if (req) 
      	{
        	req.onreadystatechange = populateSecondBoxVillages;
	        req.open("GET", url, true);
    	    req.send();
      	}
    }
} 

//Callback function 
function populateSecondBoxVillages() 
{   
    
	document.getElementById('ins_localityId').options.length = 0;
    if (req.readyState == 4) 
    {   // Complete 
    	if (req.status == 200) 
    	{   // OK response
        	textToSplit = req.responseText
	    	if(textToSplit == '803')
	    	{
				alert("No select option available on the server")
			}
			returnElements=textToSplit.split("||")
			for ( var i=0; i<returnElements.length; i++ )
			{
            	valueLabelPair = returnElements[i].split(",")
	 		    document.getElementById('ins_localityId').options[i] = new Option(valueLabelPair[1], valueLabelPair[0]);
          	}
        }
	}  
	else {  
        //alert("Bad response by the server");   
    }      
}  


function retrieveBankBranches()    
{   
    
    var bcode = document.forms[0].corebank.value;   
	var fr = document.getElementById('ins_districtId');   
	if(fr.selectedIndex==0) { 
       return;  
    } 
    selectedOption = fr.options[fr.selectedIndex].value; 
    url="NEWAJAX.do?bankcode="+bcode+"&selectedOption="+selectedOption+"&type=3"; 
            
    if (window.XMLHttpRequest) 
    { 
        // Non-IE browsers  
    	req = new XMLHttpRequest();  
	    req.onreadystatechange = populateSecondBoxBranches; 
    	try 
    	{
	      	req.open("GET", url, true); 
    	}
    	catch (e) 
    	{
	        alert("Cannot connect to server"); 
    	}
		req.send(null);
    }
    else if (window.ActiveXObject) 
    {   
        // IE browser        
    	req = new ActiveXObject("Microsoft.XMLHTTP");
      	if (req) 
      	{
        	req.onreadystatechange = populateSecondBoxBranches;
	        req.open("GET", url, true);
    	    req.send();
      	}
    }
} 

//Callback function 
function populateSecondBoxBranches() 
{   
    
	document.getElementById('bank_branchId').options.length = 0;
    if (req.readyState == 4) 
    {   // Complete 
    	if (req.status == 200) 
    	{   // OK response
        	textToSplit = req.responseText
	    	if(textToSplit == '803')
	    	{
				alert("No select option available on the server")
			}
			returnElements=textToSplit.split("||")
			for ( var i=0; i<returnElements.length; i++ )
			{
            	valueLabelPair = returnElements[i].split(",")
	 		    document.getElementById('bank_branchId').options[i] = new Option(valueLabelPair[1], valueLabelPair[0]);
          	}
        }
	}  
	else {  
        //alert("Bad response by the server");   
    }
}




   
function retrieveCollegesList()
{   
    var dcode = document.forms[0].district.value;   
	var fr = document.getElementById('ins_mandalId'); 
	if(fr.selectedIndex==0) { 
       return;  
    } 
    selectedOption = fr.options[fr.selectedIndex].value; 
    url="NEWAJAX.do?district="+dcode+"&selectedOption="+selectedOption+"&type=4"; 
            
    if (window.XMLHttpRequest) 
    { 
        // Non-IE browsers  
    	req = new XMLHttpRequest();  
	    req.onreadystatechange = populateCollegesList; 
    	try 
    	{
	      	req.open("GET", url, true); 
    	}
    	catch (e) 
    	{
	        alert("Cannot connect to server"); 
    	}
		req.send(null);
    }
    else if (window.ActiveXObject) 
    {   
        // IE browser        
    	req = new ActiveXObject("Microsoft.XMLHTTP");
      	if (req) 
      	{
        	req.onreadystatechange = populateCollegesList;
	        req.open("GET", url, true);
    	    req.send();
      	}
    }
} 

//Callback function 
function populateCollegesList() 
{   
    
	document.getElementById('collegesId').options.length = 0;
    if (req.readyState == 4) 
    {   // Complete 
    	if (req.status == 200) 
    	{   // OK response
        	textToSplit = req.responseText
	    	if(textToSplit == '803')
	    	{
				alert("No select option available on the server")
			}
			returnElements=textToSplit.split("||")
			for ( var i=0; i<returnElements.length; i++ )
			{
            	valueLabelPair = returnElements[i].split(",")
	 		    document.getElementById('collegesId').options[i] = new Option(valueLabelPair[1], valueLabelPair[0]);
          	}
        }
	}  
	else {  
        //alert("Bad response by the server");   
    }
}
