var xmlHttpStateCountry
var strStateCountry

var globalVar
var url

function showAjax(strStateCountry)
{ 
	//alert ('1' + strStateCountry);

    if(strStateCountry == "")
	    return false;

    xmlHttpStateCountry=GetXmlHttpObject();
        
    if (xmlHttpStateCountry==null)
    {
         alert ("Browser does not support HTTP Request");
         return;
    }

	if (strStateCountry == 'ctl00_ContentPlaceHolder2_cmbCity')
	{

	    globalVar = document.getElementById('ctl00_ContentPlaceHolder2_cmbCity').value;
		
		//alert('otherOut');
		if (globalVar == 'Other')
		{
			//alert('otherin');
			document.getElementById('ctl00_ContentPlaceHolder2_txtCity').style.visibility = 'visible';
			return;
		}
		else
		{
			//alert('otherinElse');
			document.getElementById('ctl00_ContentPlaceHolder2_txtCity').style.visibility = 'hidden';
			url="ComboServerInputs.aspx";
		    //alert('City IN' + globalVar);
		}
	}

    if (strStateCountry == 'ctl00_ContentPlaceHolder2_txtUserName')
	{
		globalVar = document.getElementById('ctl00_ContentPlaceHolder2_txtUserName').value;
//		alert(globalVar);
		url="ServerValidations.aspx";
//        alert('UN IN' + globalVar);
	}

		url=url+"?q="+globalVar;
		url=url+"&sid="+Math.random();

//	alert('url' + url);

    xmlHttpStateCountry.onreadystatechange=stateChanged;
    xmlHttpStateCountry.open("GET",url,true);
    
    xmlHttpStateCountry.send(null);  //in case of GET send 'null' & in case of POST send the Parameters
}

function stateChanged() 
{ 
    if (xmlHttpStateCountry.readyState==4 || xmlHttpStateCountry.readyState=="complete")
    {
	    arr = xmlHttpStateCountry.responseText;
	
//	    alert('responseText' + arr);

		var newarr = arr.split("~");
		
		if (newarr[0] == 'flagCountry')
		{
			document.getElementById('ctl00_ContentPlaceHolder2_cmbState').value = newarr[1] ;
			//document.getElementById('ctl00_ContentPlaceHolder2_txtState').value = newarr[1] ;

			document.getElementById('ctl00_ContentPlaceHolder2_cmbCountry').value = newarr[2] ;
			//document.getElementById('ctl00_ContentPlaceHolder2_txtCountry').value = newarr[2] ;
		    return;
		}

		if (newarr[0] == 'flagUserName')
		
		{
			if (newarr[1] == '1')
			{

				alert("UserName is already exist, Please Select other UserName");
				document.getElementById('ctl00_ContentPlaceHolder2_txtUserName').focus();
				document.getElementById('ctl00_ContentPlaceHolder2_txtUserName').value ='';
			}
		    return;	
		}		

     } 
}
function GetXmlHttpObject()
{
    var xmlHttpStateCountry=null;
    try
     {
         // Firefox, Opera 8.0+, Safari
         xmlHttpStateCountry=new XMLHttpRequest();
     }
    catch (e)
    {
 //Internet Explorer
     try
      {
        xmlHttpStateCountry=new ActiveXObject("Msxml2.XMLHTTP");
      }
     catch (e)
      {
      xmlHttpStateCountry=new ActiveXObject("Microsoft.XMLHTTP");
      }
 }
return xmlHttpStateCountry;
}



