

function fill_city(o_sss){ sss=''; 

	if(o_sss.value=='Type in a City Name or Property ID#'){ document.ff3.city_name.value=""; document.ff3.province.value=""; return;}
	if(isNumeric(o_sss.value)){return;}
	document.ff3.city_name.value=o_sss.value;
	
	var n_qty=0; var ii=-1; s_arr_city='';
	for(i=0; i<arrCity_s.length; ++i){
		if(arrCity_ss[i].toLowerCase().indexOf('#'+o_sss.value.toLowerCase())>0){
			arr_city=arrCity_ss[i].split("#"); 
			if(n_qty==0){ii=i;s_arr_city0=arr_city[0];s_arr_city1=arr_city[1];s_arr_city2=arr_city[2];s_arr_city=arr_city[2];}
			sss+='<a href="#" class="arial_12_6" onclick="fill_field(\''+ arr_city[0] +'\',\''+arr_city[1]+'\',\''+arr_city[2]+'\',\''+i+'\');return false;">'+arr_city[2]+", "+ arr_city[0] +"</a><br>";
			n_qty++;
			}
		
		}
		
		//document.ff3.recID.value='';
		document.ff3.city_name.value='';
		document.ff3.province.value='';
		if(sss==''){document.getElementById('div_city').style.display='none';
					document.getElementById('div_city').innerHTML=sss;}
		else{document.getElementById('div_city').style.display='block';
			document.getElementById('div_city').innerHTML="<div style='text-align:right;'><a href='#' class='arial_11' onclick='document.getElementById(\"div_city\").style.display=\"none\";return false;'>close</a></div>"+sss;
			if(n_qty==1){fill_field(s_arr_city0, s_arr_city1, s_arr_city2, ii); return;}
			if(ii!=-1){document.ff3.city_name.value=s_arr_city;
				//alert(arr_city[2]+' '+i +' '+ ii +' ');
				
				arr_city1=arrCity_s[ii].split("#");
				//alert(arr_city[2]+' '+i +' '+arr_city1[0]);
				
				document.ff3.province.value=arr_city1[0];}
				}
				
			
	}

function fill_field(n_province, n_city_id, s_city, n_i){ 
	arr_city_ss=arrCity_ss[n_i].split("#");
	arr_city=arrCity_s[n_i].split("#");
	document.ff3.province.value=arr_city[0];
	document.ff3.recID.value=s_city+', '+arr_city_ss[0];
	document.ff3.city_name.value=s_city;
	document.getElementById("div_city").style.display="none";
	}



	
function f_postal(content, arg){//alert(content);

	if(content=='0'){document.getElementById('div_city').style.display='block';
			document.getElementById('div_city').innerHTML="<div style='text-align:right;'><a href='#' class='arial_11_3' onclick='document.getElementById(\"div_city\").style.display=\"none\";return false;'>close</a></div><b>We did not find listings for "+arg +"</b><br />Check the spelling";}
	else{
	sUrl=content;
	var sUrladd='';
	var nUrl=0;
	if(document.ff3['type[]'][0].checked){ sUrladd='homes/'; nUrl+=1; }
	if(document.ff3['type[]'][1].checked){ sUrladd='condos/'; nUrl+=1;}
	if(document.ff3['type[]'][2].checked){ sUrladd='cottages/'; nUrl+=1;}
	if(document.ff3['type[]'][3].checked){ sUrladd='commercial/'; nUrl+=1;}
	if(document.ff3['type[]'][4].checked){ sUrladd='developments/'; nUrl+=1;}
	if(document.ff3['type[]'][5].checked){sUrladd='land/'; nUrl+=1;}
	if(document.ff3['type_all'].checked){nUrl=6;}
	if(nUrl>1) sUrladd='real-estate/';
	if(nUrl==6) sUrladd='';//real-estate/
	//if(sUrladd==''){alert('Select Real estate type please'); return false;}
	document.ff3.action=sUrl+sUrladd;
	//alert(sUrl+sUrladd);
		if(document.ff3.type_search.value == 1){
	document.ff3.submit();
		}else{
	
	
		//cargar el mapa
		LoadMap();
		
		///
	
	
	
		return false;
		}
	}	
			
}



//cambia links submit


function form_submit(){
	comprobar_recID();
		
	if(rePostal.test(replaceSubstring(document.ff3.recID.value, ' ', ''))){
			s_postal=replaceSubstring(document.ff3.recID.value, ' ', '').toUpperCase();
			makeRequest('/js/ajax/postal.php?tttt='+tttt()+'&zip='+s_postal, f_postal, s_postal);
			document.ff3.recID.value=s_postal;
			return;
			
			}
	
	if(isNumeric(document.ff3.recID.value)){
		
		if(document.ff3.type_search.value == 1){
		document.ff3.action='/search.php';
		document.ff3.submit();
		}else{
		provincia = document.ff3.province.value;
		//cargar el mapa
		LoadMap();
		
		///
	
		//return false;
		}
		return false;
		}
	
	sUrl=urlact;
	
	if(document.ff3.province.value!='')sUrl=arrProvinceID[document.ff3.province.value];
	//alert(document.ff3.province.value);
	if(sUrl=='') sUrl=urlact;
	if(document.ff3.recID.value!='' && document.ff3.recID.value!='Type in a City Name or Property ID#' && document.ff3.city_name.value==""){
		
		document.getElementById('div_city').style.display='block';
		document.getElementById('div_city').innerHTML="<div style='text-align:right;'><a href='#' class='arial_11_3' onclick='document.getElementById(\"div_city\").style.display=\"none\";return false;'>close</a></div><b>We did not find listings for "+document.ff3.recID.value +"</b><br />Check the spelling";
		return; }
	
	if(document.ff3.city_name.value==''){sUrl+=''; }//all-cities/   city_name
	else{
		sUrl+=replaceSubstring(replaceSubstring(document.ff3.city_name.value.toLowerCase(),' ', '-'),'`','-')+'/';
		
		}
	//else{sUrl+=replaceSubstring(document.ff3.cityID.options[document.ff3.cityID.selectedIndex].text.toLowerCase(),' ', '-')+'/';}
	var sUrladd='';
	var nUrl=0;
	//sUrladd='real-estate/';
	if(document.ff3['type[]'][0].checked){ sUrladd='homes/'; nUrl+=1; }
	if(document.ff3['type[]'][1].checked){ sUrladd='condos/'; nUrl+=1;}
	if(document.ff3['type[]'][2].checked){ sUrladd='cottages/'; nUrl+=1;}
	if(document.ff3['type[]'][3].checked){ sUrladd='commercial/'; nUrl+=1;}
	if(document.ff3['type[]'][4].checked){ sUrladd='developments/'; nUrl+=1;}
	if(document.ff3['type[]'][5].checked){sUrladd='land/'; nUrl+=1;}
	if(document.ff3['type_all'].checked){sUrladd='real-estate/'; nUrl=6;}
	if(document.ff3['type_all'].checked){nUrl=6;}
	if(nUrl>1) sUrladd='real-estate/';
	if(sUrladd==''){alert('Select Real estate type please'); return false;}
	if(nUrl==6) sUrladd='';
	if(nUrl==6 && document.ff3.city_name.value=='') {sUrl=urlact; sUrladd='homesforsale.php';}
	document.ff3.action=sUrl+sUrladd;
	//alert(sUrl+sUrladd);

	if(document.ff3.type_search.value == 1){
	document.ff3.submit();
		}else{
	provincia = document.ff3.province.value;
		//cargar el mapa
		LoadMap();
		
		///
	
		return false;
		}
		
		
		
	}

