//onchange country create options for state


	function selectState4Post(state) {
		
			f1 = document.myform;
					
			f1.elements["State4Post"].length = 0;
			f1.elements["City123"].length = 0;
			
			newOption = document.createElement("OPTION");					
			f1.elements["State4Post"].options.add(newOption);
		    newOption.text ="--Select State--";
			newOption.value = "0";
			
			
			var ajaxRequest;
			var val;
			//var k = 0;
			for (i = 1; i <  f1.elements["Country4Post"].length; i++) {
				if (f1.elements["Country4Post"][i].selected) {
					//if (k==0) {
						val = f1.elements["Country4Post"][i].value;
						
						//} else {
						//val = val + "," + f1.elements["Country4Post"][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.myform;	
							
				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["State4Post"].options.add(newOption);
					    newOption.text = string2[1];
						newOption.value = string2[0];						
					}//for i
					if (state) {						
						f1 = document.myform;
						str = state.split(",");	
						
					//	for (i = 0; i < str.length; i++) {					
							for (j=0; j< f1.elements["State4Post"].length; j++)	{
								if (f1.elements["State4Post"][j].value == str[i]) {
									f1.elements["State4Post"][j].selected = true;
								//}
							}
						}	
					}
					
				}				
			}
			ajaxRequest.open("GET","includes/fill_state_city_ajax.php?action=GetState&countryid=" + val, true);
			ajaxRequest.send(null);
			
			//alert(val);
		}
		 
				
				
//onchange state create options for city

		
	function selectCity4Post(city) {
			
			f1 = document.myform;
					
			f1.elements["City123"].length = 0;
			
			newOption = document.createElement("OPTION");					
			f1.elements["City123"].options.add(newOption);
		    newOption.text ="--Select City--";
			newOption.value = "0";
			
			
			var ajaxRequest;
			var val;
			var k = 0;
			for (i = 0; i <  f1.elements["State4Post"].length; i++) {
				if (f1.elements["State4Post"][i].selected) {
					if (k==0) {
						val = f1.elements["State4Post"][i].value;
					} else {
						val = val + "," + f1.elements["State4Post"][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.myform;	
				
							
				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["City123"].options.add(newOption);
					    newOption.text = string2[1];
						newOption.value = string2[0];		
						}//for i
						
						
						//for other city
						newOption = document.createElement("OPTION");					
						f1.elements["City123"].options.add(newOption);
		   				newOption.text ="Other Cities";
						newOption.value = "0";
		
					
					if (city) {						
						f1 = document.myform;
						str = city.split(",");			
						//for (i = 0; i < str.length; i++) {					
							for (j=0; j< f1.elements["City123"].length; j++)	{
								if (f1.elements["City123"][j].value == str[i]) {
									f1.elements["City123"][j].selected = true;
								//}
							}
						}	
					}
					
				}				
			}
			ajaxRequest.open("GET","includes/fill_state_city_ajax.php?action=GetCity&stateid=" + val, true);
			ajaxRequest.send(null);
			
			//alert(val);
		}
		 
		 
		 
//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.myform.city_id.value=value;
}
			