// JavaScript Document
var City = {

	xmlHttp: false,
	qs: '',
	method: 'POST',
	headerType: 'Content-Type',
	headerValue: 'application/x-www-form-urlencoded',
	url: 'index__/city.php',
	xmlHttpResult: null,
	
	XmlHttpInit: function(){
		var XHRO = false;
		
		try {
			// Firefox, Opera 8.0+, Safari
			XHRO=new XMLHttpRequest();
		} catch (e) {
			// Internet Explorer
			try {
				XHRO=new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				XHRO=new ActiveXObject("Microsoft.XMLHTTP");
			}
		}
		
		return XHRO;
	},
	
	XmlHttpSetHeaderType: function(headerType){
		this.headerType = headerType;				
	},
	
	XmlHttpSetHeaderValue: function(headerValue){
		this.headerValue = headerValue;				
	},
	
	XmlHttpSetMethod: function(method){
		this.method = method;
	},
	
	XmlHttpSendRequest: function(){
		
			
		if(City.xmlHttp != null){
			City.xmlHttp.open(this.method,this.url);
			City.xmlHttp.setRequestHeader(this.headerType, this.headerValue);
			
			City.xmlHttp.onreadystatechange = function(){
				
				if(City.xmlHttp.readyState == 4 && City.xmlHttp.status == 200){
					City.xmlHttpResult = City.xmlHttp.responseText;
				}
			}
		
			if(this.method == 'POST') City.xmlHttp.send(this.qs);
			
		} else {
			
			alert("Your browser does not support AJAX");
			return;
		}
		
	},
	
	
	ShowCity: function(country){
		
		//alert("Country ID : "+country);
		
		switch(country){
			case "0": City.ShowList(1,0,0,0); break;	
			case "1": City.ShowList(0,1,0,0); break;	
			case "2": City.ShowList(0,0,1,0); break;	
			case "3": City.ShowList(0,0,0,1); break;	
		}
		
	},
	
	ShowList: function(c0, c1, c2, c3){
		
		var cityarray = new Array(c0,c1,c2,c3);
		var citydiv = new Array("cityDiv0","cityDiv1","cityDiv2","cityDiv3");
		var citylist = new Array("city_list0","city_list1","city_list2","city_list3");
		
		/*if(c1 == 0 && c2 == 0 && c3 == 0){
			document.getElementById("citytitle").innerHTML= "&nbsp;";
		} else {
			document.getElementById("citytitle").innerHTML = "City";
		}*/
		//document.getElementById("citytitle").innerHTML = "City";
		/*
		if(c1 == 0 && c2 == 0 && c3 == 0){
			document.getElementById("cityDiv0").style.visibility = "visible";
			document.getElementById("cityDiv0").style.display = "block";

		} else {
			document.getElementById("cityDiv0").style.visibility = "hidden";
			document.getElementById("cityDiv0").style.display = "none";
		}
		*/

		for(var i=0; i<citydiv.length; i++){
			if(cityarray[i] == 0){
				document.getElementById(citydiv[i]).style.visibility = "hidden";
				document.getElementById(citydiv[i]).style.display = "none";
			} else {
				document.getElementById(citydiv[i]).style.visibility = "visible";
				document.getElementById(citydiv[i]).style.display = "block";
				document.getElementById("city_selected").value = document.getElementById(citylist[i]).value;
			}
		}
		
	}


}