
function retrieveStateOptionsInst(id){
                
    var req;
    var country= document.getElementById('inst_country');
    var countryid = country.options[country.selectedIndex].value;
    // alert(country_id);
    //    document.getElementById('inst_state').options.length = 0;
    //    document.getElementById('inst_city').options.length = 0;
    //    document.getElementById('inst_state').options[0]= new Option('Select','0');
    //    document.getElementById('inst_city').options[0]= new Option('Select','0');
    var url="./stateSelection.do?country_id="+countryid;
    //Do the Ajax call
    try
    {
        // Firefox, Opera 8.0+, Safari
        req=new XMLHttpRequest();

    }
    catch (e)
    {
        // Internet Explorer
        try
        {
            req=new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e)
        {
            try
            {
                req=new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (e)
            {
                alert("Your browser does not support AJAX!");
                return false;
            }
        }
    }

    //alert("True or False = "+country_id!="0");
    if(countryid!="0")
    {
        req.open("POST", url, true);
        req.send(countryid);
        req.onreadystatechange =function (){
            document.getElementById('inst_state').options.length = 0;
            if (req.readyState == 4) {
                document.getElementById('inst_state').options[0] = new Option("Select", "0");
                // Complete
                //var returnElements;
                var textToSplit = req.responseText;
                var returnElements=textToSplit.split("|");
                if (req.status == "200" |req.status ==200) {                                        // OK response
                    for ( var i=1; i<(returnElements .length)+1; i++ ){
                        var valueLabelPair = returnElements[i-1].split(",");
                        document.getElementById('inst_state').options[i] = new Option(valueLabelPair[0], valueLabelPair[1]);
                    }
                }
            }
        }
    }
    return true;
}




function retrieveStateList(selectedcountry_id,state_id)
{
    var req;
    var country= document.getElementById(selectedcountry_id);
    var countryid = country.options[country.selectedIndex].value;
    // alert(country_id);
    //    document.getElementById('inst_state').options.length = 0;
    //    document.getElementById('inst_city').options.length = 0;
    //    document.getElementById('inst_state').options[0]= new Option('Select','0');
    //    document.getElementById('inst_city').options[0]= new Option('Select','0');
    var url="./stateSelection.do?country_id="+countryid;
    //Do the Ajax call
    try
    {
        // Firefox, Opera 8.0+, Safari
        req=new XMLHttpRequest();

    }
    catch (e)
    {
        // Internet Explorer
        try
        {
            req=new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e)
        {
            try
            {
                req=new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (e)
            {
                alert("Your browser does not support AJAX!");
                return false;
            }
        }
    }

    //alert("True or False = "+country_id!="0");
    if(countryid !="0")
    {
        req.open("POST", url, true);
        req.send(countryid);
        req.onreadystatechange =function (){
            document.getElementById(state_id).options.length = 0;
            if (req.readyState == 4) {
                document.getElementById(state_id).options[0] = new Option("Select", "0");
                // Complete
                //var returnElements;
                var textToSplit = req.responseText;
                var returnElements=textToSplit.split("|");
                if (req.status == "200" |req.status ==200) {                                        // OK response
                    for ( var i=1; i<=(returnElements .length); i++ ){
                        var valueLabelPair = returnElements[i-1].split(",");
                        document.getElementById(state_id).options[i] = new Option(valueLabelPair[0], valueLabelPair[1]);
                    }
                }
            }
        }
    }
    return true;
}

function retrieveCollegeTypes(CollegeType, CollList)
{
    var req;
    var type = document.getElementById(CollegeType);
    var collType = type.options[type.selectedIndex].value;
//    alert(collType);
    //    document.getElementById('inst_state').options.length = 0;
    //    document.getElementById('inst_city').options.length = 0;
    //    document.getElementById('inst_state').options[0]= new Option('Select','0');
    //    document.getElementById('inst_city').options[0]= new Option('Select','0');
    var url="./collegesFromCollTypes.do?type="+collType;
    //Do the Ajax call
    try
    {
        // Firefox, Opera 8.0+, Safari
        req=new XMLHttpRequest();

    }
    catch (e)
    {
        // Internet Explorer
        try
        {
            req=new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e)
        {
            try
            {
                req=new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (e)
            {
                alert("Your browser does not support AJAX!");
                return false;
            }
        }
    }

    //alert("True or False = "+country_id!="0");
    if(collType != "0")
    {
        req.open("POST", url, true);
        req.send(collType);
        req.onreadystatechange =function (){
            document.getElementById(CollList).options.length = 0;
            if (req.readyState == 4) {
                document.getElementById(CollList).options[0] = new Option("Select", "%");
                // Complete
                //var returnElements;
                var textToSplit = req.responseText;
                var returnElements=textToSplit.split("|");
                if (req.status == "200" |req.status ==200) {                                        // OK response
                    for ( var i=1; i<=(returnElements .length); i++ ){
                        var valueLabelPair = returnElements[i-1].split(",");
                        document.getElementById(CollList).options[i] = new Option(valueLabelPair[0], valueLabelPair[1]);
                    }
                }
            }
        }
    }
    return true;
}

function retrieveCityList(selectedState_id,city_id ){
    var req;
    var state= document.getElementById(selectedState_id);
    var stateid = state.options[state.selectedIndex].value;
    document.getElementById(city_id).options.length = 0;
    document.getElementById(city_id).options[0]= new Option('Select','0');
    var url="./citySelection.do?state_id="+stateid;

    //Do the Ajax call
    try{
        // Firefox, Opera 8.0+, Safari
        req=new XMLHttpRequest();
    }catch (e){
        // Internet Explorer
        try
        {
            req=new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e)
        {
            try
            {
                req=new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (e)
            {
                alert("Your browser does not support AJAX!");
                return false;
            }
        }

    }
    if(stateid!="0")
    {
        req.open("POST", url, true);
        req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        req.send(stateid);
        req.onreadystatechange = function(){
            document.getElementById(city_id).options.length = 0;
            if (req.readyState == 4) {
                // Complete
                //var returnElements;
                var textToSplit = req.responseText;
                var returnElements=textToSplit.split("|");
                if (req.status =="200") {                                        // OK response
                    var i;
                    document.getElementById(city_id).options[0]=new Option("Select","0");
                    for (  i=1; i<=(returnElements .length); i++ ){
                        var valueLabelPair = returnElements[i-1].split(",");
                        document.getElementById(city_id).options[i] = new Option(valueLabelPair[0], valueLabelPair[1]);
                    }
                }
            }
        }
    }
    return true;
}