function makeObject()
{
	var x; 
	var browser = navigator.appName; 
	//detect the client browser
	if(browser == "Microsoft Internet Explorer"){
	x = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
	x = new XMLHttpRequest();
	}
	return x;
}

//call the function makeObject()
var request = makeObject();


//function send request
function ajax(url)
{
    if(document.plots_search.city_id.value !="all")
	{
	var page=url.split("?");
	var society_or_town=page[1].split("=");
	//alert(url);
	//alert(society_or_town[0]);
	request.open('get', url);	
	request.onreadystatechange = ajaxparseInfo;

	request.send('');
	}else{
				var dropdown_society = document.plots_search("soc_id");
				dropdown_society.length=0;
			    dropdown_society[0] = new Option('all','',false,false);			
	}
}
//function send data
function ajaxparseInfo()
{
  if(request.readyState == 4){ 
			
			var answer = request.responseText;
			var list=answer.split("=");
			//alert(list);
			var societies_name=list[0];
			var societies_id=list[1];
				//alert(cities_name);
				 var societiesname = societies_name.split(",");
				 
				 var societiesid=societies_id.split(",");
				 				
				var dropdown_society = document.getElementById("soc_id");
				
				 for(var i=0; i<dropdown_society.length;i++)
						   dropdown_society[i] = new Option('','',false,false);
						   dropdown_society.length=societiesname.length;
				 for(var i=0; i<societiesname.length;i++)
				 {
				 			
				dropdown_society[i] = new Option(societiesname[i],societiesid[i],false,false);			
					
				 }
				 
				 
				 //also effect occur on town if user again delselect the province
				 // ajax('<?//=MAIN_PATH?>city.php?city='+citiesid[1]+'');
			 //}//if
			
		}
}
/////for propety

function ajax_property(url)
{
    if(document.property_search.cityid.value !="all")
	{
	var page=url.split("?");
	var society_or_town=page[1].split("=");
	//alert(url);
	//alert(society_or_town[0]);
	request.open('get', url);	
	request.onreadystatechange = propparseInfo;

	request.send('');
	}else{
				var dropdown_society = document.property_search("socid");
				dropdown_society.length=0;
			    dropdown_society[0] = new Option('all','',false,false);			
	}
}
//function send data
function propparseInfo()
{
  if(request.readyState == 4){ 
			
			var answer = request.responseText;
			var list=answer.split("=");
			//alert(list);
			var societies_name=list[0];
			var societies_id=list[1];
				//alert(cities_name);
				 var societiesname = societies_name.split(",");
				 
				 var societiesid=societies_id.split(",");
				 				
				var dropdown_society = document.getElementById("socid");
				
				 for(var i=0; i<dropdown_society.length;i++)
						   dropdown_society[i] = new Option('','',false,false);
						   dropdown_society.length=societiesname.length;
				 for(var i=0; i<societiesname.length;i++)
				 {
				 			
				dropdown_society[i] = new Option(societiesname[i],societiesid[i],false,false);			
					
				 }
				 
				 
				 //also effect occur on town if user again delselect the province
				 // ajax('<?//=MAIN_PATH?>city.php?city='+citiesid[1]+'');
			 //}//if
			
		}
}
//function send request
function add_plot_ajax(url)
{
    if(document.add_plot.sity_id.value !="select")
	{
	var page=url.split("?");
	var society_or_town=page[1].split("=");
	//alert(url);
	//alert(society_or_town[0]);
	request.open('get', url);	
	request.onreadystatechange = plotparseInfo;

	request.send('');
	}else{
				var dropdown_society = document.add_plot("sok_id");
				dropdown_society.length=0;
			    dropdown_society[0] = new Option('select','',false,false);			
	}
}
//function send data
function plotparseInfo()
{
  if(request.readyState == 4){ 
			
			var answer = request.responseText;
			var list=answer.split("=");
			//alert(list);
			var societies_name=list[0];
			var societies_id=list[1];
				//alert(cities_name);
				 var societiesname = societies_name.split(",");
				 
				 var societiesid=societies_id.split(",");
				 				
				var dropdown_society = document.getElementById("sok_id");
				
				 for(var i=0; i<dropdown_society.length;i++)
						   dropdown_society[i] = new Option('','',false,false);
						   dropdown_society.length=societiesname.length;
				 for(var i=0; i<societiesname.length;i++)
				 {
				 			
				dropdown_society[i] = new Option(societiesname[i],societiesid[i],false,false);			
					
				 }
				 
				 
				 //also effect occur on town if user again delselect the province
				 // ajax('<?//=MAIN_PATH?>city.php?city='+citiesid[1]+'');
			 //}//if
			
		}
}
//function add property page send request
function add_property_ajax(url)
{
    if(document.add_property.sity_id.value !="select")
	{
	var page=url.split("?");
	var society_or_town=page[1].split("=");
	//alert(url);
	//alert(society_or_town[0]);
	request.open('get', url);	
	request.onreadystatechange = propertyparseInfo;

	request.send('');
	}else{
				var dropdown_society = document.add_property("sok_id");
				dropdown_society.length=0;
			    dropdown_society[0] = new Option('select','',false,false);			
	}
}
//function send data
function propertyparseInfo()
{
  if(request.readyState == 4){ 
			
			var answer = request.responseText;
			var list=answer.split("=");
			//alert(list);
			var societies_name=list[0];
			var societies_id=list[1];
				//alert(cities_name);
				 var societiesname = societies_name.split(",");
				 
				 var societiesid=societies_id.split(",");
				 				
				var dropdown_society = document.getElementById("sok_id");
				
				 for(var i=0; i<dropdown_society.length;i++)
						   dropdown_society[i] = new Option('','',false,false);
						   dropdown_society.length=societiesname.length;
				 for(var i=0; i<societiesname.length;i++)
				 {
				 			
				dropdown_society[i] = new Option(societiesname[i],societiesid[i],false,false);			
					
				 }
				 
				 
				 //also effect occur on town if user again delselect the province
				 // ajax('<?//=MAIN_PATH?>city.php?city='+citiesid[1]+'');
			 //}//if
			
		}
}

