function sendRequest(fid)
{
	var oForm = document.forms[fid];
	if(fid==1)
	{
		var sBody = getRequestBody(oForm);
		var oXmlHttp = zXmlHttp.createRequest();
		oXmlHttp.open("POST", oForm.action, true);
		oXmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		oXmlHttp.onreadystatechange = function () {
		if (oXmlHttp.readyState == 4) {
			if (oXmlHttp.status == 200) {
					saveResult(oXmlHttp.responseText,fid);
			} else {
					saveResult("An error occurred: " + oXmlHttp.statusText,fid);
			}
			}            
		};
		oXmlHttp.send(sBody); 
	}
	if(fid==0)
	{
		var sBody = getRequestBody(oForm);
		var oXmlHttp = zXmlHttp.createRequest();
		oXmlHttp.open("POST", oForm.action, true);
		oXmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		oXmlHttp.onreadystatechange = function () {
		if (oXmlHttp.readyState == 4) {
			if (oXmlHttp.status == 200) {
					saveResult(oXmlHttp.responseText,fid);
			} else {
					saveResult("An error occurred: " + oXmlHttp.statusText,fid);
			}
			}            
		};
		oXmlHttp.send(sBody); 
	}
	if(fid==2)
	{
		var sBody = getRequestBody(oForm);
		var oXmlHttp = zXmlHttp.createRequest();
		oXmlHttp.open("POST", oForm.action, true);
		oXmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		oXmlHttp.onreadystatechange = function () {
		if (oXmlHttp.readyState == 4) {
			if (oXmlHttp.status == 200) {
					saveResult(oXmlHttp.responseText,fid);
			} else {
					saveResult("An error occurred: " + oXmlHttp.statusText,fid);
			}
			}            
		};
		oXmlHttp.send(sBody); 
	}
	if(fid==3)
	{
		var sBody = getRequestBody(oForm);
		var oXmlHttp = zXmlHttp.createRequest();
		oXmlHttp.open("POST", oForm.action, true);
		oXmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		oXmlHttp.onreadystatechange = function () {
		if (oXmlHttp.readyState == 4) {
			if (oXmlHttp.status == 200) {
					saveResult(oXmlHttp.responseText,fid);
			} else {
					saveResult("An error occurred: " + oXmlHttp.statusText,fid);
			}
			}            
		};
		oXmlHttp.send(sBody); 
	}
	if(fid==4)
	{
		var sBody = getRequestBody(oForm);
		var oXmlHttp = zXmlHttp.createRequest();
		oXmlHttp.open("POST", oForm.action, true);
		oXmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		oXmlHttp.onreadystatechange = function () {
		if (oXmlHttp.readyState == 4) {
			if (oXmlHttp.status == 200) {
					saveResult(oXmlHttp.responseText,fid);
			} else {
					saveResult("An error occurred: " + oXmlHttp.statusText,fid);
			}
			}            
		};
		oXmlHttp.send(sBody); 
	}
	
	if(fid==5)
	{
		
		var sBody = getRequestBody(oForm);
		var oXmlHttp = zXmlHttp.createRequest();
		oXmlHttp.open("POST", oForm.action, true);
		oXmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		oXmlHttp.onreadystatechange = function () {
		if (oXmlHttp.readyState == 4) {
			if (oXmlHttp.status == 200) {
					saveResult(oXmlHttp.responseText,fid);
			} else {
					saveResult("An error occurred: " + oXmlHttp.statusText,fid);
			}
			}            
		};
		oXmlHttp.send(sBody); 
	}
	if(fid==6)
	{
		var sBody = getRequestBody(oForm);
		var oXmlHttp = zXmlHttp.createRequest();
		oXmlHttp.open("POST", oForm.action, true);
		oXmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		oXmlHttp.onreadystatechange = function () {
		if (oXmlHttp.readyState == 4) {
			if (oXmlHttp.status == 200) {
					saveResult(oXmlHttp.responseText,fid);
			} else {
					saveResult("An error occurred: " + oXmlHttp.statusText,fid);
			}
			}            
		};
		oXmlHttp.send(sBody); 
	}	
	
}
    function getRequestBody(oForm) {
            var aParams = new Array();
            for (var i=0 ; i < oForm.elements.length; i++) {
                var sParam = encodeURIComponent(oForm.elements[i].name);
                sParam += "=";
                sParam += encodeURIComponent(oForm.elements[i].value);
                aParams.push(sParam);
            } 
            return aParams.join("&");        
        }
        
        function saveResult(sMessage,fid)
		{
			if(fid==1)
			{
			var divStatus = document.getElementById("zonenewarea");
				divStatus.innerHTML = sMessage;  
			}
			if(fid==0)
			{
			var divStatus = document.getElementById("localitynewarea");
				divStatus.innerHTML = sMessage;  
			}
			if(fid==2)
			{
			var divStatus = document.getElementById("DivSubscribe");
				divStatus.innerHTML = sMessage;  
			}
				if(fid==3)
			{
				var divStatus = document.getElementById("zonepropertyadd");
				divStatus.innerHTML = sMessage;  
			}
			
				if(fid==4)
			{
				var divStatus = document.getElementById("localitypropertyadd");
				divStatus.innerHTML = sMessage;  
			}
			
			if(fid==5)
			{
				var divStatus = document.getElementById("zonenewarea_rent");
				divStatus.innerHTML = sMessage;  
			}
			
			if(fid==6)
			{
				var divStatus = document.getElementById("localitynewarea_rent");
				divStatus.innerHTML = sMessage;  
			}
			
		}
function selsubmit()
{
     document.getElementById("category_id_city").value = document.getElementById("city").value;
	sendRequest(1);
}
function selsubmitlocality()
{
	document.getElementById("category_id").value = document.getElementById("zone").value;
	sendRequest(0);
}

function selsubmit_rent()
{

   document.getElementById("category_id_city_rent").value = document.getElementById("city_rent").value;
     sendRequest(5);
}
function selsubmitlocality_rent()
{
	document.getElementById("category_id_rent").value = document.getElementById("zone_rent").value;
	sendRequest(6);
}


function selsubmitadd()
{
	var othercity = document.getElementById("PropertyCity").value;
	if(othercity == "355")
	{
		// show hiddend city div of other fields
		// div_city_other  div_zone_other div_locality_other
		document.getElementById("div_city_other").style.display = "block";
	}
	else
	{
		document.getElementById("div_city_other").style.display = "none";	
	}
	
	document.getElementById("category_id_city_add").value = document.getElementById("PropertyCity").value;
	sendRequest(3);
}
function selsubmitlocalityadd()
{
	var othercity = document.getElementById("PropertyZone").value;
	if(othercity == "356")
	{
		// show hiddend city div of other fields
		// div_city_other  div_zone_other div_locality_other
		document.getElementById("div_zone_other").style.display = "block";
	}
	else
	{
		document.getElementById("div_zone_other").style.display = "none";	
	}
	document.getElementById("category_id_add_property").value = document.getElementById("PropertyZone").value;
	sendRequest(4);
}
function selsubmitlocalityadd_other()
{
	var othercity = document.getElementById("PropertyLocality").value;
	if(othercity == "357")
	{
		// show hiddend city div of other fields
		// div_city_other  div_zone_other div_locality_other
		document.getElementById("div_locality_other").style.display = "block";
	}
	else
	{
		document.getElementById("div_locality_other").style.display = "none";	
	}
	
}


function isEmailAddr(email)
{
  var result = false
  var theStr = new String(email)
  var index = theStr.indexOf("@");
  if (index > 0)
  {
    var pindex = theStr.indexOf(".",index);
    if ((pindex > index+1) && (theStr.length > pindex+1))
	result = true;
  }
  return result;
}

function onFocusText(id)
{
	formObj = document.subscribe;

	if(id == "youremail")
	{
		if(formObj.youremail.value == "Email Address....")
		{
			formObj.youremail.value = "";
		}
	}
}
function onFocusOut(id)
{
	formObj = document.subscribe;
	
	if(id == "youremail")
	{
		if(formObj.youremail.value == "")
		{
			formObj.youremail.value = "Email Address....";
		}
	}		

}

function validatesubscribeform()
{
	flag=0;
	formObj = document.subscribe;

	if(formObj.youremail.value=="Email Address....")
	{
		document.getElementById("contactdivemail").innerHTML="Email Id can not be blank!";
		flag=1;
		
	}
	else
	{
		document.getElementById("contactdivemail").innerHTML="";
		flag=0;
	}
	if (!isEmailAddr(formObj.youremail.value))
	{
		document.getElementById("contactdivemail").innerHTML = "Please enter valid email id!";
		flag=1;
	}
		else
	{
		document.getElementById("contactdivemail").innerHTML="";
		flag=0;
	}
		if(flag==1)
		{
		}
		else
		{
		
			document.getElementById("emailidsubscribe").value  = formObj.youremail.value;
			sendRequest(2);
		}
}
