xmlHttp1 = CreateXmlHttpObject();
function fnRadio()
{
if (document.frmRadio.RadioSrc[1].checked == true)
    {
    xmlHttp1.open('GET',"universitySearchForm.php",true);
    }/* set the Content-Type header for a POST request */

else
    {
    xmlHttp1.open('GET',"citySearchForm.php",true);
    }
    xmlHttp1.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
	xmlHttp1.onreadystatechange=handlefnRadio;
    xmlHttp1.send(null);	

}
function handlefnRadio()
{    

    if(xmlHttp1.readyState == 4)
    {
        if(xmlHttp1.status == 200)
        {
            var response = new String(xmlHttp1.responseText);
            document.getElementById("divsearch").innerHTML=response;						
        } 

    }  //end outer if
	else if(xmlHttp1.readyState == 1)
        {
            document.getElementById("divsearch").innerHTML="<span class=\"text4\">Loading . . . </span> &nbsp; &nbsp; " ; 

        }
    else if ( xmlHttp1.readyState == 2 || xmlHttp1.readyState == 3)
        {
            document.getElementById("divsearch").innerHTML="<img src=images/loading2.gif /> &nbsp; &nbsp;" ; 
        }
  
}

function cityUniSearch()
{ 
	var x = document.frmUniSearch.provinceUniSearch.selectedIndex;alert(x);
	alert (document.frmUniSearch.provinceUniSearch.selectedIndex.options[x].text);
	//var y = document.frmUniSearch.provinceUniSearch.selectedIndex.options[x].text;
	
    xmlHttp1.open('GET',"servercity.php?state=" + y,true);
    /* set the Content-Type header for a POST request */
    xmlHttp1.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
	xmlHttp1.onreadystatechange=handleResponse;
    xmlHttp1.send(null);	
}

function city()
{	
	var x = document.form1.state.selectedIndex;
	var y = document.form1.state.options[x].text;
    xmlHttp1.open('GET',"servercity.php?state=" + y,true);
    /* set the Content-Type header for a POST request */
    xmlHttp1.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
	xmlHttp1.onreadystatechange=handleResponse;
    xmlHttp1.send(null);	
}
function handleResponse()
{
    if(xmlHttp1.readyState == 4)
    {
        if(xmlHttp1.status == 200)
        {
            var response = new String(xmlHttp1.responseText);
			var opt = response.split(';');
			var opt1 = document.form1.City.options;
			opt1.length=0;
			for(i=0; i<opt.length-1; i++)
			{
				opt1[i] = new Option(opt[i],opt[i]);
			}
						
        } 
        else 
        {
            alert("A problem occurred with communicating between the XMLHttpRequest object and the server program.");
        }
    }

    //end outer if
}
