//onchange country create options for state


	function selectState4search(state) {
			
			f1 = document.frmsearch;
					
			f1.elements["SearchState"].length = 0;
			f1.elements["SearchCity"].length = 0;
			
			//newOption = document.createElement("OPTION");					
			//f1.elements["SearchState"].options.add(newOption);
		   // newOption.text ="Any";
			//newOption.value = "0";
			
			
			var ajaxRequest;
			var val;
			//var k = 0;
			for (i = 1; i <  f1.elements["SearchCountry[]"].length; i++) {
				if (f1.elements["SearchCountry[]"][i].selected) {
					//if (k==0) {
						val = f1.elements["SearchCountry[]"][i].value;
						
						//} else {
						//val = val + "," + f1.elements["SearchCountry[]"][i].value;
					//}
					//k++;	
				}
			}			
			if (val == "") { val = 0; }			
			var result;
			var newOption;
			
			try {
				ajaxRequest = new XMLHttpRequest();
			} catch (e) {
				try {
					ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
				} catch (e) {
					try{
						ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
					} catch (e) {
						alert("Your browser does not support ajax!");
						return false;
					}
				}
			}
			ajaxRequest.onreadystatechange = function() {
				f1 = document.frmsearch;	
							
				if (ajaxRequest.readyState == 4) {					
					result = ajaxRequest.responseText;					
					string1 = result.split("#");

					for ( var i = 0; i < string1.length - 1; i++) {						
						string2 = string1[i].split("_");
						newOption = document.createElement("OPTION");					
						f1.elements["SearchState"].options.add(newOption);
					    newOption.text = string2[1];
						newOption.value = string2[0];						
					}//for i
					if (state) {						
						f1 = document.frmsearch;
					//	str = state.split(",");			
					//	for (i = 0; i < str.length; i++) {					
							for (j=0; j< f1.elements["SearchState"].length; j++)	{
								if (f1.elements["SearchState"][j].value == state) {
									f1.elements["SearchState"][j].selected = true;
								//}
							}
						}	
					}
					
				}				
			}
			ajaxRequest.open("GET","includes/fill_state_city_ajax.php?action=GetState&countryid=" + val, true);
			ajaxRequest.send(null);
			
			
		}
		 
				
				
//onchange state create options for city

		
	function selectCity4search(city) {
		
			
			
			f1 = document.frmsearch;
					
			f1.elements["SearchCity"].length = 0;
			
			//newOption = document.createElement("OPTION");					
			//f1.elements["SearchCity"].options.add(newOption);
		    //newOption.text ="Any";
			//newOption.value = "0";
			
			
			var ajaxRequest;
			var val;
			var k = 0;
			for (i = 0; i <  f1.elements["SearchState"].length; i++) {
				if (f1.elements["SearchState"][i].selected) {
					if (k==0) {
						val = f1.elements["SearchState"][i].value;
					} else {
						val = val + "," + f1.elements["SearchState"][i].value;
					}
					k++;	
				}
			}	
			
			
			
			if (val == "") { val = 0; }			
			var result;
			var newOption;
			try {
				ajaxRequest = new XMLHttpRequest();
			} catch (e) {
				try {
					ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
				} catch (e) {
					try{
						ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
					} catch (e) {
						alert("Your browser does not support ajax!");
						return false;
					}
				}
			}
			ajaxRequest.onreadystatechange = function() {
				f1 = document.frmsearch;	
				
				
				
							
				if (ajaxRequest.readyState == 4) {
					result = ajaxRequest.responseText;	
					result=result.substring(6, result.length);
					string1 = result.split("#");

					for ( var i = 0; i < string1.length - 1; i++) {						
						string2 = string1[i].split("_");
						newOption = document.createElement("OPTION");					
						f1.elements["SearchCity"].options.add(newOption);
					    newOption.text = string2[1];
						newOption.value = string2[0];		
						}//for i
						
						
						//for other city
						//newOption = document.createElement("OPTION");					
						//f1.elements["SearchCity"].options.add(newOption);
		   				//newOption.text ="Other Cities";
						//newOption.value = "0";
					
					if (city) {						
						f1 = document.frmsearch;
						//for (i = 0; i < str.length; i++) {					
							for (j=0; j< f1.elements["SearchCity"].length; j++)	{
								if (f1.elements["SearchCity"][j].value == city) {
									f1.elements["SearchCity"][j].selected = true;
								//}
							}
						}	
					}
					
				}				
			}
			
			
			ajaxRequest.open("GET","includes/fill_state_city_ajax.php?action=GetCity&stateid=" + val, true);
			ajaxRequest.send(null);

		}
		 
		 
		 
/*other city text box		
		
function check_other_cities(value,control1)
{
	//alert(value);
	var obj = document.getElementById(control1);
	if(value == 0)
	{
		obj.style.display = '';
	}
	else
	{
		obj.style.display = 'none';
	}
document.frmsearch.city_id.value=value;
}
		*/	
