function OHgetCity(){
	var url = "./js/getCity.php?Language_id="+ document.getElementById("lang").value +"&State_id="+ document.getElementById("state").value;
	var city = document.getElementById("city");
	
	while(city.options.length != 1){
		city.options[1] = null;
	}
	
  xmlhttp.open("GET", url, true);
  xmlhttp.onreadystatechange = function(){
  	if(xmlhttp.readyState == 4){
      if(xmlhttp.status == 200){
        fillCity(xmlhttp.responseXML);
	    }else{
        window.alert("Failed to get response: "+ xmlhttp.statusText);
      }
  	}
  }
  xmlhttp.send(null);
}

function fillCity(ajaxResponse){
	var data = ajaxResponse.getElementsByTagName("city");
	var city = document.getElementById("city");
	var othercity = document.getElementById("othercity");
	
	if(data.length <= 1){
		showAnotherCity(city, othercity);
	}else{
		hideAnotherCity(city, othercity);
		
		for(i = 1; i <= city.options.length; i++){
			city.options[i] = null;
		}
	
		for(i = 0; i < data.length; i++){
			var selectValue = data[i].getElementsByTagName("id_city")[0].firstChild.nodeValue;
			var selectText = data[i].getElementsByTagName("name_city")[0].firstChild.nodeValue;
			city.options[i+1] = new Option(selectText, selectValue);
		}
	}
}
function OHOtherCity(){
  	var city = document.getElementById("city");
	var othercity = document.getElementById("othercity");
	
  	if(city.value == -1){
	  	showOtherCity(city, othercity);
	} else {
	  	hideOtherCity(city, othercity);
	}
}
function showOtherCity(city, othercity){
	othercity.setAttribute("size", 30);
	othercity.style.visibility = "";
	othercity.value = "";
}

function hideOtherCity(city, othercity){
	othercity.setAttribute("size", 1);
	othercity.style.visibility = "hidden";
	othercity.value = "";
}
function showAnotherCity(city, othercity){
	city.style.width = "200px";
	city.disabled = true;
	othercity.setAttribute("size", 30);
	othercity.style.visibility = "";
	othercity.value = "";
}

function hideAnotherCity(city, othercity){
	city.style.width = "200px";
	city.disabled = false;
	othercity.setAttribute("size", 1);
	othercity.style.visibility = "hidden";
	othercity.value = "";
}