// JavaScript Document
var req=false;

function loadXML(){
	
		req=false;
		
		if(window.XMLHttpRequest){
			
			try{
				
				req = new XMLHttpRequest();	
				
			}catch(e){
				
				req=false;
			
			}	
			
		}else if(window.ActiveXObject){
			
			try{	
			
				req = new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch(e){
				
				req=false;	
			}
			
		}
		
	}
	var sc;
	function getCountry(city,select_country){
		
		sc=select_country;
		
		if(city.length==0){
		
			alert("Lütfen şehir seçin");
			
			return(false);
		}
		
		
		loadXML();//Browsera göre HttpRequest ayarlanıyor
		
		if(req){
			req.open("GET","http://www.temizlikrehberi.org/ajaxReq/country_req.php?city_id="+city,true);
			req.onreadystatechange=setCountry;
			req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      		req.setRequestHeader("Connection", "close");			
			req.send(null);
			
		}
		
		
	} 
	
	function setCountry(){
		
		if(req.readyState==4){
			
			gelen=req.responseText;
			
			var opt = document.getElementById('country');
			
			boyut=opt.options.length;
			
			for(j=0;j<boyut;j++){
			
				opt.remove(opt.options[j]);
			
			}

			
			var satirlar=gelen.split("--satir--");
			
			var satSay=satirlar.length;
			//var sonuc="";
			for(var i=0; i<satSay; i++){
				
				var sutunlar=satirlar[i].split("--sutun--");

				if(sutunlar[0]!="undefined"){
					
					if(sutunlar[0]!=""){	
						//sonuc+=sutunlar[1];
						opt.options[i]=new Option(sutunlar[1],sutunlar[0]);
						
						if(sutunlar[0]==sc){
						
							opt.options[i].selected=true;
							
						}
					}
				}
				
			}
			
			
			//alert(sonuc);
			
		}
		
		
	}
	

