var xmlHttp

function _doPopulateCity(conname)
{
    //alert(conname);
	var url="citypopulate.php?conname=" + conname;

	xmlHttp = GetXmlHttpObject(ReturnCity)

	xmlHttp.open("GET", url , true)

	xmlHttp.send(null)

}

function _doPopulateEmail(listing_type)

{
    //alert(conname);
	var url="emailpopulate.php?listing_type=" + listing_type;

	xmlHttp = GetXmlHttpObject(ReturnEmail)

	xmlHttp.open("GET", url , true)

	xmlHttp.send(null)

}


function _doPopulateCatalogCity(conname)

{
    //alert(conname);
	var url="citycatalogpopulate.php?conname=" + conname;

	xmlHttp = GetXmlHttpObject(ReturnCatalogCity)

	xmlHttp.open("GET", url , true)

	xmlHttp.send(null)

}


function _doPopulateCategory(conname)

{
    //alert(conname);
	var url="categorypopulate.php?conname=" + conname;

	xmlHttp = GetXmlHttpObject(ReturnCategory)

	xmlHttp.open("GET", url , true)

	xmlHttp.send(null)

}


function changeme(x)
{
	alert(x);
	var url="citypopulate_new.php?x="+x;
	xmlHttp = GetXmlHttpObject(ReturnMytest)
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function doState()
{
	//alert(x);
	var city = document.getElementById('city').value ;
	var url="state.php?city="+city;
	xmlHttp = GetXmlHttpObject(ReturnMystate)
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function _doPopulateCompany()
{
	//alert(x);
	var email = document.getElementById('email').value ;
	var listing_type = document.getElementById('listing_type').value ;
	var url="company.php?email="+email+"&listing_type="+listing_type;
	xmlHttp = GetXmlHttpObject(ReturnCompany)
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}


function doCatalogState()
{
	//alert(x);
	var city = document.getElementById('ccity').value ;
	var url="statecatalog.php?city="+city;
	xmlHttp = GetXmlHttpObject(ReturnMyCatelogstate)
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}



function _doCheckUser(strUser) {

	var url="ajax.user.php?user=" + strUser;

	xmlHttp = GetXmlHttpObject(UserChange)

	xmlHttp.open("GET", url , true)

	xmlHttp.send(null)

}


function _doAdvCost(date,addType,picture) {

	var url="ajax.cost.php?date=" + date + "&type=" + addType + "&picture=" + picture;

	xmlHttp = GetXmlHttpObject(ReturnCost)

	xmlHttp.open("GET", url , true)

	xmlHttp.send(null)

}


function _DoPopulateSubcategory(home_cat_id)
{
    //alert(conname);
	var url="subcategorypopulate.php?home_cat_id=" + home_cat_id;

	xmlHttp = GetXmlHttpObject(ReturnSubCategory)

	xmlHttp.open("GET", url , true)

	xmlHttp.send(null)

}

function _DoPopulateAdminSubcategory(home_cat_id)
{
    //alert(conname);
	var url="subcategorypopulate.php?home_cat_id=" + home_cat_id;

	xmlHttp = GetXmlHttpObject(ReturnSubCategory)

	xmlHttp.open("GET", url , true)

	xmlHttp.send(null)

}


function ReturnSubCategory() {

	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {

		var content = document.getElementById("popsubcategory").innerHTML;
		document.getElementById("popsubcategory").innerHTML = content + xmlHttp.responseText;
	}	

}


function ReturnCity() {

	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {

		document.getElementById("popcity").innerHTML = xmlHttp.responseText;

	}	

}

function ReturnEmail() {

	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {

		document.getElementById("popemail").innerHTML = xmlHttp.responseText;

	}	

}


function ReturnCatalogCity() {

	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {

		document.getElementById("popccity").innerHTML = xmlHttp.responseText;

	}	

}


function ReturnCategory() {

	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {

		document.getElementById("popcategory").innerHTML = xmlHttp.responseText;

	}	

}


function ReturnMytest()
{
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
		//document.getElementById("errorMessageAd").innerHTML = '';
		//alert(xmlHttp.responseText);
		var str=xmlHttp.responseText;
		var arr=str.split(",");
		//alert(arr.length);
		for(i=0;i<arr.length-1;i++)
		{
			//alert(arr[i]);
			document.getElementById("city").options[i]=new Option(arr[i],arr[i]);
		}
		//document.getElementById("test").innerHTML = xmlHttp.responseText;
	}	
}

function ReturnMystate()
{
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
		document.getElementById('state').value = xmlHttp.responseText;
	}	
}

function ReturnCompany()
{
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
		document.getElementById('company').value = xmlHttp.responseText;
	}	
}



function ReturnMyCatelogstate()
{
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
		document.getElementById('cstate').value = xmlHttp.responseText;
	}	
}


function ReturnCost() {

	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {

		document.getElementById("idCost").innerText = "INR " + xmlHttp.responseText;

	}	

}



function UserChange() { 

	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {

		document.getElementById("idUser").innerHTML = xmlHttp.responseText;

	} 

}



function GetXmlHttpObject(handler) { 

	var objXmlHttp=null



	if (navigator.userAgent.indexOf("Opera")>=0) {

		alert("This example doesn't work in Opera") 

		return; 

	}

	if (navigator.userAgent.indexOf("MSIE")>=0)	{ 

		var strName="Msxml2.XMLHTTP"

		if (navigator.appVersion.indexOf("MSIE 5.5")>=0)

		{

			strName="Microsoft.XMLHTTP"

		} 

		try	{ 

			objXmlHttp=new ActiveXObject(strName)

			objXmlHttp.onreadystatechange=handler 

			return objXmlHttp

		} catch(e) { 

			alert("Error. Scripting for ActiveX might be disabled") 

			return 

		} 

	} 

	if (navigator.userAgent.indexOf("Mozilla")>=0) {

		objXmlHttp=new XMLHttpRequest()

		objXmlHttp.onload=handler

		objXmlHttp.onerror=handler 

		return objXmlHttp

	}

}

