function populate(){
	retrieve();
}

function isInt(x){
   var y=parseInt(x);
   if (isNaN(y)) return false;
   return x==y && x.toString()==y.toString();
} 

function doPopulate(transport,json){
	var t;
	var json;
	var new_str="";
	var i=0;
	//alert(transport.responseText);
	if(transport.responseText>' '){
		//alert(1);
		t=transport.responseText;
		json=t.evalJSON();
		for(b in json){
			temp = json[b];
			new_str+="<optgroup label=\""+b+"\">";
			for(c in json[b]){
				if(isInt(c)){
					var selected="";
					//alert(temp[c]);
/*					if(zona_selectata>' ' && zona_selectata==temp[c]){
						selected="selected";
					}*/
					new_str+="<option "+selected+">"+temp[c]+"</option>";
	//				$('filterEQ[ZONA]').options[i] = new Option(temp[c],temp[c]);
					i++;
				}
			}
			new_str+="</optgroup>";
		}
	}
	//alert(new_str);
	if(i==0) new_str="Zona:<br /><select name='zona' id='filterEQ_ZONA' style='width:250px'><option>Nu exista oferte</option></select>";
    else
		new_str="Zona:<br /><select name='filterClassic[ZONA][]' id='filterEQ_ZONA'  style='width:250px' multiple size=8><option value=''>"+i+" zone selectate</option>"+new_str+"</select>";
	$('zona_select').innerHTML=new_str;
	//alert(new_str);	
}

function retrieve(){
	var url='/oferte/index.php?screen=zone&client=velesxml';
	url +="&tip_tranz="+$F('filterClassic_TIP_TRANZ');
	url +="&tip_imobil="+$F('filterClassic_TIP_IMOBIL');
	//url +="&oras="+$F('filterEQ_ORAS');
	//alert(url);
	if($F('filterClassic_TIP_TRANZ')>' ' && $F('filterClassic_TIP_TRANZ')!=4){
		var reg = new Ajax.Request(url,{method:'get',evalScripts:true,onSuccess:doPopulate});
	} else{
		$('zona_select').innerHTML="Zona:<br /><select name='zona' id='filterEQ_ZONA' style='width:250px'><option value=''>Orice zona</option></select>";
	}
}