var xmlHttp
//Mehwar code starts here for build your network
function check_user_exist()
{
var email = document.getElementById('friend_email').value;
//alert(email);
xmlHttp = GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request");
	 	return;
	} 
	var url = "../ajax_user/ajax_server.php"
	url=url+"?q="+email
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=stateChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}
function stateChanged() 
{ 
if (xmlHttp.readyState != 4 || xmlHttp.readyState != "complete")
	{
	document.getElementById('waiting').style.display = "block";
	}
if (xmlHttp.readyState == 4 || xmlHttp.readyState=="complete")
	{ 
	document.getElementById('waiting').style.display = "none";
	document.getElementById("response").innerHTML=xmlHttp.responseText 

	}
}
//Mehwar code ends here
function showCity(str, val)
{
	//alert('start');
	if (str.length == 0 && val != 1)
	{ 
		document.getElementById("city_span").innerHTML = "";
		return;
	}
	xmlHttp = GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request");
	 	return;
	} 
	var url = "../ajax_user/city.php"

	url=url+"?q="+str+"&type="+val
	url=url+"&sid="+Math.random()
	//alert(url);
	if(val == 1)
		xmlHttp.onreadystatechange=stateChangesCompany
	else
		xmlHttp.onreadystatechange=stateChanges
	
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function stateChanges() 
{
	if (xmlHttp.readyState != 4 || xmlHttp.readyState != "complete")
	{
		//document.getElementById("cbocountry").disabled = true;
		document.getElementById("city_span").innerHTML = '<select style="font-family:verdana; font-size: 11px" disabled="disabled"><option>Processing ... </option></select>';
	}

	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		//alert(document.getElementById("cbocountry").value);
		if(document.getElementById("cbocountry").value == '223')
			document.getElementById("id_state").style.display = 'block';
		else
			document.getElementById("id_state").style.display = 'none';

		if(xmlHttp.responseText != '')
		{
			document.getElementById("city_span").innerHTML = xmlHttp.responseText;
		}
		else
		{
			document.getElementById("city_span").innerHTML = '<input name="cbocity" maxlength="200" class="txtBox" type="text" />';
		}
		document.getElementById("cbocountry").disabled = false;
		
		/*document.getElementById("phone_span").innerHTML = '<input name="txtphone_country_code" value="" class="txtBoxSmal" size="3" maxlength="5" type="text" /> - <input name="txtphone_city_code" class="txtBoxSmal" size="3" maxlength="6" type="text" /> - <input maxlength="4" name="txtphone" class="txtBox" type="text" /> xxx xxx-xxxx';
		document.getElementById("mobile_span").innerHTML = '<input name="txtmobile_country_code" value="" class="txtBoxSmal" size="3" maxlength="5" type="text" /> - <input name="txtmobile_city_code" value="" class="txtBoxSmal" size="3" maxlength="3" type="text" /> - <input name="txtmobile" maxlength="4" class="txtBox" type="text" /> xxx xxx-xxxx';*/
		//alert("Pak");
		
	}
}

function stateChangesCompany() 
{
	if (xmlHttp.readyState != 4 || xmlHttp.readyState != "complete")
	{
		//document.getElementById("cbocountry_company").disabled = true;
		document.getElementById("city_span_company").innerHTML = '<select style="font-family:verdana; font-size: 11px" disabled="disabled"><option>Processing ... </option></select>';
	}
		
		
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		//alert(document.getElementById("id_state_country"));
		if(document.getElementById("cbocountry_company").value == '223')
			document.getElementById("id_state_country").style.display = 'block';
		else
			document.getElementById("id_state_country").style.display = 'none';
		
		if(xmlHttp.responseText != '')
		{
			document.getElementById("city_span_company").innerHTML = xmlHttp.responseText;
		}
		else
		{
			document.getElementById("city_span_company").innerHTML = '<input name="cbocity_company" maxlength="200" class="txtBox" type="text" />';
		}
		document.getElementById("cbocountry_company").disabled = false;
	}
}


function GetXmlHttpObject()
{
	var xmlHttp = null;
	try
	{
		 // Firefox, Opera 8.0+, Safari
		 xmlHttp = new XMLHttpRequest();
	}
	catch (e)
	{
		// Internet Explorer
		try
		{
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}
