var geoFilter=null;
function geoSearch(_1){
var _2=_1;
var _3="geoSearchForm";
var _4="geoDropdown";
var _5="geoActiveFilter";
var _6;
var _7;
var _8;
this.distances=new Array();
this.distances[0]=999999900;
this.distances[1]=350000000;
this.distances[2]=3500000;
this.distances[3]=1000000;
this.distances[4]=100000;
this.distances[5]=30000;
this.distances[6]=1000;
this.distances[7]=500;
this.distances[8]=500;
this.distances[9]=500;
var _9=false;
var _a="";
var _b=false;
this.sf=dojo.byId("nearbySearch");
this.resL=dojo.byId("geoDropdown");
var _c;
var _d=null;
var _e=50000;
this.init=function(){
_9=new GClientGeocoder();
_6=dojo.byId(_3);
_7=dojo.byId(_4);
_8=dojo.byId(_5);
dojo.connect(window,"onresize",dojo.hitch(this,this.onResize));
dojo.connect(window,"onclick",dojo.hitch(this,this.closeAltResultList));
defaultValueActAsHint(this.sf);
this.onResize();
};
this.onResize=function(){
var c=dojo.coords(this.sf,true);
console.log("Reisze values left:"+c.x+" top:"+(c.y+c.h));
this.resL.style.left=c.x+"px";
this.resL.style.top=(c.y+c.h)+"px";
_c=c.w+"px";
this.resL.style.width=_c;
};
this.search=function(_10,_11){
searchval=dojo.byId("nearbySearch").value;
_a=searchval;
if(_11==true){
_b=true;
if(_9){
_9.getLocations(searchval,dojo.hitch(this,this.handleCallBack));
}
}else{
if(searchval.length>2){
_b=false;
if(_9){
_9.getLocations(searchval,dojo.hitch(this,this.handleCallBack));
}
}
}
return false;
};
this.handleCallBack=function(_12){
snConsole.debug("GeoSearech result code: ",_12.Status.code);
switch(_12.Status.code){
case 200:
snConsole.debug("Success",_12.Placemark.length);
if(_12.name==_a&&_a!=""){
this.showPMlist(_12.Placemark);
if(_b==true){
this.filter(_12.Placemark[0]);
_b=false;
this.closeAltResultList();
}else{
this.showAltResultList();
}
}
return;
break;
case 400:
snConsole.debug("Error 400 G_GEO_BAD_REQUEST","no Result");
this.showErrorResult("Error 400 G_GEO_BAD_REQUEST");
break;
case 500:
default:
snConsole.debug("Error G_GEO_SERVER_ERROR= 500 ","no Result");
this.showErrorResult("Error G_GEO_SERVER_ERROR= 500 ");
break;
case 600:
snConsole.debug("Error G_GEO_MISSING_QUERY= 601","no Result");
this.showErrorResult("Error G_GEO_MISSING_QUERY= 601");
break;
case 601:
snConsole.debug("Error G_GEO_MISSING_ADDRESS = 601","no Result");
this.showErrorResult("Error G_GEO_MISSING_ADDRESS = 601");
break;
case 602:
if(_12.name==_a&&_a!=""){
if(_b==true){
var _13=dojo.byId("result");
for(var i=_13.rows.length;i>0;i--){
try{
map.removeOverlay(markers[i-1]);
}
catch(e){
}
_13.deleteRow(i-1);
}
var tr=document.createElement("tr");
var td1=document.createElement("td");
td1.style.verticalAlign="top";
td1.innerHTML=i18n.NO_TOURS_FOUND;
tr.appendChild(td1);
_13.appendChild(tr);
}else{
this.closeAltResultList();
}
}
return;
break;
case 603:
snConsole.debug("Error _GEO_UNAVAILABLE_ADDRESS= 603","no Result");
this.showErrorResult("Error _GEO_UNAVAILABLE_ADDRESS= 603");
break;
case 604:
snConsole.debug("Error G_GEO_UNKNOWN_DIRECTIONS= 604","no Result");
this.showErrorResult("Error G_GEO_UNKNOWN_DIRECTIONS= 604");
break;
case 610:
snConsole.debug("Error G_GEO_BAD_KEY= 610","no Result");
this.showErrorResult("Error G_GEO_BAD_KEY= 610");
break;
case 620:
snConsole.debug("Error G_GEO_TOO_MANY_QUERIES= 620","no Result");
this.showErrorResult("Error G_GEO_TOO_MANY_QUERIES= 620 ");
break;
}
this.closeAltResultList();
};
this.showPMlist=function(_17){
if(_7!=undefined){
if(_7.hasChildNodes()){
_7.removeChild(_7.firstChild);
}
var _18=document.createElement("tbody");
for(var i=0;i<5&&i<_17.length;i++){
var row=document.createElement("tr");
var _1b=document.createElement("td");
_1b.style.width=_c;
_1b.innerHTML=_17[i].address;
_1b.id="vl"+i;
var cb=new cellBean(i);
dojo.connect(_1b,"onclick",this,this.chooserSearch);
dojo.connect(_1b,"onmouseover",dojo.hitch(cb,"highlight"));
dojo.connect(_1b,"onmouseout",dojo.hitch(cb,"lowlight"));
row.appendChild(_1b);
_18.appendChild(row);
}
var row=document.createElement("tr");
var _1b=document.createElement("td");
_1b.style.width=_c;
_1b.style.textAlign="right";
_1b.innerHTML="<a href=\"#\">"+i18n.CLOSE+"</a>";
dojo.connect(_1b,"onclick",this,this.closeAltResultList);
row.appendChild(_1b);
_18.appendChild(row);
_7.appendChild(_18);
}
};
this.closeAltResultList=function(){
this.showPMlist(new Array);
if(_7!=undefined){
_7.style.display="none";
}
};
this.showAltResultList=function(){
if(_7!=undefined){
_7.style.display="block";
}
};
this.clear=function(){
dojo.byId("clearfilter").style.display="none";
_8.innerHTML="none";
_d=null;
_2.unfilterStore();
};
this.chooserSearch=function(_1d){
console.debug(_1d.target.innerHTML);
this.closeAltResultList();
this.search(_1d.target.innerHTML,true);
};
this.showErrorResult=function(_1e){
snConsole.debug("Geo search error:"+_1e);
};
this.filter=function(_1f){
if(_8!=undefined){
name=_1f.address;
_d=_1f;
if(name.length>20){
name=name.slice(0,name.slice(0,20).lastIndexOf(" "));
if(name.charAt(name.length-1)!="."||name.charAt(name.length-1)!=","){
name=name.slice(0,name.length-1);
}
name+="...";
}
_8.innerHTML=name;
_2.filterStore(new GLatLng(_1f.Point.coordinates[1],_1f.Point.coordinates[0]),_e);
dojo.byId("clearfilter").style.display="inline";
}
};
this.radiusChange=function(){
if(_d==null){
return;
}
var _20=document.forms.geosearchform.radius;
for(var i=0;i<_20.length;i++){
if(_20[i].checked){
_e=parseInt(_20[i].value*1000);
break;
}
}
_2.filterStore(new GLatLng(_d.Point.coordinates[1],_d.Point.coordinates[0]),_e);
};
this.init();
};
function cellBean(i){
var myI=i;
this.highlight=function(){
console.log("high"+i);
dojo.byId("vl"+myI).style.backgroundColor="#EEEEEE";
};
this.lowlight=function(){
console.log("low"+i);
dojo.byId("vl"+myI).style.backgroundColor="";
};
};


