var _request=null;
var _stopme="<a href='javascript:killseeker()'>Stop Search</a>";
var _detailUrl;
var _stopSearch;
var _hid;
var _r=new Array();
var _lm=new Array();
var _ptypeLookup=new Object();
var _filtered=new Array();
var _totalrows=0;
var _totalmatches=0;
var _screenseq=0;
var _lastsort=null;
var _lastdirection=false;
var _priceascending=true;
var _ratingascending=false;
var _nameascending=true;
var _distanceascending=true;
var _pricesortid="pricesort";
var _usdlosortid="usdlowsort";
var _ratingsortid="ratingsort";
var _namesortid="namesort";
var _distsortid="distsort";

var _privatesortid="privatesort";
var _sharedsortid="sharedsort";

var _lastsortid=null;
var _currentsortid=null;
var _pricewidth="15%";
var _pricewidthinterim="20%";
var _ratingwidth="10%";
var _namewidth="65%";
var _distwidth="10%";
/*var _sortprice="<a href='javascript:sortresults(sortprice);addAdt(_pricesortid);'>";
var _sortusdlo="<a href='javascript:sortresults(sortusdlo);addAdt(_usdlosortid);'>";
var _sortrating="<a href='javascript:sortresults(sortrating);addAdt(_ratingsortid);'>";
var _sortname="<a href='javascript:sortresults(sortname);addAdt(_namesortid);'>";
var _sortdistance="<a href='javascript:sortresults(sortdistance);addAdt(_distsortid);'>";*/
var _sortprice="<a href='javascript: sortresults(sortprice);'>";
var _sortusdlo="<a href='javascript: sortresults(sortusdlo);'>";
var _sortprivate="<a href='javascript: sortresults(sortprivate);'>";
var _sortshared="<a href='javascript: sortresults(sortshared);'>";
var _sortrating="<a href='javascript: sortresults(sortrating);'>";
var _sortname="<a href='javascript: sortresults(sortname);'>";
var _sortdistance="<a href='javascript: sortresults(sortdistance);'>";
var showAmenities=false;
var showAddress=true;

function sortprice(x,_2) {
        if(x!=null) {
                _lastdirection=x;
        } else {
                if(_lastsortid==_pricesortid) {
                        _lastdirection=(_lastdirection?false:true);
                } else {
                        _lastdirection=_priceascending;
                }
        }
        
        _currentsortid=_pricesortid;
        document.resultUI.lastsortid.value=_currentsortid;
        _lastsort=sortprice;
        setTop(0);
        
        function pricecompare(a,b) {
                var _5=_r[a];
                var _6=_r[b];
                var _7=parseFloat(_5._price);
                var _8=parseFloat(_6._price);
                if(_7<0) {
                        if(_lastdirection) {
                                if(_5._alt==2){
                                        _7=999999;
                                } else {
                                        _7=999998;
                                }
                        } else {
                                if(_5._alt==2){
                                        _7=-2;
                                } else {
                                        _7=-1;
                                }
                        }
                }
                
                if(_8<0) {
                        if(_lastdirection) {
                                if(_6._alt==2) {
                                        _8=999999;
                                } else {
                                        _8=999998;
                                }
                        } else {
                                if(_6._alt==2) {
                                        _8=-2;
                                } else {
                                        _8=-1;
                                }
                        }
                }
                
                var _9=_7-_8;
                if(_9==0) {
                        _9=parseFloat(_5._rank)-parseFloat(_6._rank);
                }
                if(!_lastdirection) {
                        return 0-_9;
                } else {
                        return _9;
                }
        }
        
        _filtered.sort(pricecompare);
        if(!_2){
                _2="sortprice"+(_lastdirection?"_asc":"_desc");
        }
        updateTable(_2);        
}

function sortusdlo(x,_b) {
        if(x!=null) {
                _lastdirection=x;
        } else {
                if(_lastsortid==_usdlosortid) {
                        _lastdirection=(_lastdirection?false:true);
                } else {
                        _lastdirection=_priceascending;
                }
        }
        
        _currentsortid=_usdlosortid;
        document.resultUI.lastsortid.value=_currentsortid;
        _lastsort=sortusdlo;
        setTop(0);
        
        function usdlocompare(a,b) {
                var _e=_r[a];
                var _f=_r[b];
                var _10;
                var _11;
                
                if(_e._rlot=="") {
                        if(_lastdirection) {
                                _10=999999;
                        } else {
                                _10=-1;
                        }
                } else {
                        _10=parseFloat(_e._rlot);
                }
                
                if(_f._rlot=="") {
                        if(_lastdirection) {
                                _11=999999;
                        } else {
                                _11=-1;
                        }
                } else {
                        _11=parseFloat(_f._rlot);
                }
                
                var _12=_10-_11;
                
                if(_12==0) {
                        _12=parseFloat(_e._rank)-parseFloat(_f._rank);
                }
                
                if(!_lastdirection) {
                        return 0-_12;
                } else{
                        return _12;
                }
        }
        
        _filtered.sort(usdlocompare);
        if(!_b) {
                _b="sortprice"+(_lastdirection?"_asc":"_desc");
        }
        
        updateTable(_b);
}

function sortprivate(x,_b) {
        if(x!=null) {
                _lastdirection=x;
        } else {
                if(_lastsortid==_privatesortid) {
                        _lastdirection=(_lastdirection?false:true);
                } else {
                        _lastdirection=_priceascending;
                }
        }
        
        _currentsortid=_privatesortid;
        document.resultUI.lastsortid.value=_currentsortid;
        _lastsort=sortprivate;
        setTop(0);
        
        function privatecompare(a,b) {
                var _e=_r[a];
                var _f=_r[b];
                var _10;
                var _11;
                
                if(_e._privatePrice=="") {
                        if(_lastdirection) {
                                _10=999999;
                        } else {
                                _10=-1;
                        }
                } else {
                        _10=parseFloat(_e._privatePrice);
                }
                
                if(_f._privatePrice=="") {
                        if(_lastdirection) {
                                _11=999999;
                        } else {
                                _11=-1;
                        }
                } else {
                        _11=parseFloat(_f._privatePrice);
                }
                
                var _12=_10-_11;
                
                if(_12==0) {
                        _12=parseFloat(_e._rank)-parseFloat(_f._rank);
                }
                
                if(!_lastdirection) {
                        return 0-_12;
                } else{
                        return _12;
                }
        }
        
        _filtered.sort(privatecompare);
        if(!_b) {
                _b="sortprice"+(_lastdirection?"_asc":"_desc");
        }
        
        updateTable(_b);
}

function sortshared(x,_b) {
        if(x!=null) {
                _lastdirection=x;
        } else {
                if(_lastsortid==_sharedsortid) {
                        _lastdirection=(_lastdirection?false:true);
                } else {
                        _lastdirection=_priceascending;
                }
        }
        
        _currentsortid=_sharedsortid;
        document.resultUI.lastsortid.value=_currentsortid;
        _lastsort=sortshared;
        setTop(0);
        
        function sharedcompare(a,b) {
                var _e=_r[a];
                var _f=_r[b];
                var _10;
                var _11;
                
                if(_e._sharedPrice=="") {
                        if(_lastdirection) {
                                _10=999999;
                        } else {
                                _10=-1;
                        }
                } else {
                        _10=parseFloat(_e._sharedPrice);
                }
                
                if(_f._sharedPrice=="") {
                        if(_lastdirection) {
                                _11=999999;
                        } else {
                                _11=-1;
                        }
                } else {
                        _11=parseFloat(_f._sharedPrice);
                }
                
                var _12=_10-_11;
                
                if(_12==0) {
                        _12=parseFloat(_e._rank)-parseFloat(_f._rank);
                }
                
                if(!_lastdirection) {
                        return 0-_12;
                } else{
                        return _12;
                }
        }
        
        _filtered.sort(sharedcompare);
        if(!_b) {
                _b="sortprice"+(_lastdirection?"_asc":"_desc");
        }
        
        updateTable(_b);
}

function sortrating(x,_14) {
        if(x!=null) {
                _lastdirection=x;
        } else {
                if(_lastsortid==_ratingsortid) {
                        _lastdirection=(_lastdirection?false:true);
                } else {
                        _lastdirection=_ratingascending;
                }
        }
        _currentsortid=_ratingsortid;
        document.resultUI.lastsortid.value=_currentsortid;
        _lastsort=sortrating;
        setTop(0);
        
        function ratingcompare(a,b) {
                var _17=_r[a];
                var _18=_r[b];
                var _19=parseFloat(_17._rtg)-parseFloat(_18._rtg);
                if(!_lastdirection) {
                        return 0-_19;
                } else {
                        return _19;
                }
        }
        
        _filtered.sort(ratingcompare);
        if(!_14) {
                _14="sortrating"+(_lastdirection?"_asc":"_desc");
        }
        updateTable(_14);
}

function sortname(x,_1b) {
        if(x!=null) {
                _lastdirection=x;
        } else {
                if(_lastsortid==_namesortid) {
                        _lastdirection=(_lastdirection?false:true);
                } else {
                        _lastdirection=_nameascending;
                }
        }
        
        _currentsortid=_namesortid;
        document.resultUI.lastsortid.value=_currentsortid;
        _lastsort=sortname;
        setTop(0);
        
        function namecompare(a,b) {
                var _1e=_r[a]._name;
                var _1f=_r[b]._name;
                var _20=_1e.localeCompare(_1f);
                
                if(!_lastdirection) {
                        return 0-_20;
                }else{
                        return _20;
                }
        }
        
        _filtered.sort(namecompare);
        if(!_1b) {
                _1b="sortname"+(_lastdirection?"_asc":"_desc");
        }
        updateTable(_1b);
}

function sortdistance(x,_22) {
        if(x!=null){
                _lastdirection=x;
        } else {
                if(_lastsortid==_distsortid) {
                        _lastdirection=(_lastdirection?false:true);
                } else {
                        _lastdirection=_distanceascending;
                }
        }
        
        _currentsortid=_distsortid;
        document.resultUI.lastsortid.value=_currentsortid;
        _lastsort=sortdistance;
        setTop(0);
        
        function distancecompare(a,b) {
                var _25=_r[a];
                var _26=_r[b];
                var _27=parseFloat(_25._dist)-parseFloat(_26._dist);
                if(!_lastdirection){
                        return 0-_27;
                } else {
                        return _27;
                }
        }
        // _filtered.sort(distancecompare);
        if(!_22){
        _22="sortdistance"+(_lastdirection?"_asc":"_desc");
        }
        updateTable(_22);
}

function sortrank(x,_29) {
        _lastsort=sortrank;
        _lastsortid=null;
        document.resultUI.lastsortid.value="";
        
        function rankcompare(a,b) {
                var _2c=_r[a];
                var _2d=_r[b];
                var _2e=parseFloat(_2c._rank)-parseFloat(_2d._rank);
                
                if(_2e==0) {
                        _2e=parseFloat(_2c._dist)-parseFloat(_2d._dist);
                }
                
                return _2e;
        }
        _filtered.sort(rankcompare);
        
        if(!_29){
                _29="sortrank_asc";
        }
        updateTable(_29);
}

function FilterFunctions() {
        this.requiredFunc=null;
        this.setup=function(){
                this.requiredFunc=new Array();
                var _2f=getFilteredOutReasons().funclist;
                /*if(_2f["onlinereq"]!=null){
                this.requiredFunc.push(this.checkBookOnline);
                }
                if(_2f["stars"]!=null){
                this.requiredFunc.push(this.checkStars);
                }*/
                if(_2f["price"]!=null){
                this.requiredFunc.push(this.checkPrice);
                }
                if(_2f["price2"]!=null){
                this.requiredFunc.push(this.checkPrice2);
                }
                /*if(_2f["distance"]!=null){
                this.requiredFunc.push(this.checkDistance);
                }*/
                if(_2f["hotelname"]!=null){
                this.requiredFunc.push(this.checkName);
                }
                /*if(_2f["brand"]!=null){
                this.requiredFunc.push(this.checkBrand);
                }*/
                if(_2f["ptype"]!=null){
                this.requiredFunc.push(this.checkPropertyType);
                }
                /*if(_2f["perbed"]!=null){
                this.requiredFunc.push(this.checkPriceType);
                }
                if(_2f["neighborhood"]!=null){
                this.requiredFunc.push(this.checkNeighborhood);
                }
                if(_2f["amenities"]!=null){
                this.requiredFunc.push(this.checkAmenities);
                }*/
                //this.requiredFunc.push(this.checkProvider);
        };
        this.includeRow=function(i){
                for(var j=0;j<this.requiredFunc.length;j++){
                        if(!this.requiredFunc[j](i)){
                                return false;
                        }                       
                }
                return true;
        };
        this.checkBookOnline=function(i){
                if(_r[i]._p.length==0){
                return false;
                }
                return true;
        };
        this.checkStars=function(i){
        if(document.getElementById("allstars")!=null&&!document.getElementById("allstars").checked){
                try{
                var _34=parseInt(_r[i]._rtg.slice(0,1));
                if(document.getElementById("stars"+_34)==null||!document.getElementById("stars"+_34).checked){
                return false;
                }
                }
                catch(ignored){
                return false;
                }
                }
                return true;
        };
        this.checkPrice=function(i){
                if((parseInt(_r[i]._sharedPrice)>0)&&((parseInt(_r[i]._sharedPrice)>_maxprice)||(parseInt(_r[i]._sharedPrice)<_minprice)) || _r[i]._sharedPrice == ''){
                return false;
                }
                return true;
        };
        this.checkPrice2=function(i){
                if((parseInt(_r[i]._privatePrice)>0)&&((parseInt(_r[i]._privatePrice)>_maxprice2)||(parseInt(_r[i]._privatePrice)<_minprice2)) || _r[i]._privatePrice == ''){
                return false;
                }
                return true;
        };
        this.checkDistance=function(i){
                if(document.resultUI.landmark.options.length>0){
                if(parseFloat(_r[i]._dist)>document.resultUI.distance[document.resultUI.distance.selectedIndex].value){
                return false;
                }
                }
                return true;
        };
        this.checkName=function(i){
                if(_r[i]._name.toUpperCase().indexOf(document.resultUI.hotel_name.value.toUpperCase())<0){
                return false;
                }
                return true;
        };
        this.checkBrand=function(i){
                if((_r[i]._chain!=document.resultUI.brand.value)&&(_r[i]._pchain!=document.resultUI.brand.value)){
                return false;
                }
                return true;
        };
        this.checkPropertyType=function(i){
                if(_r[i]._pt==""||pTypes[_r[i]._pt]!=_r[i]._pt){
                        return false;
                }
                return true;
        };
        this.checkPriceType=function(i){
                if(_r[i]._p.length>0&&_r[i]._p[0]._type=="b"){
                return false;
                }
                return true;
        };
        this.checkNeighborhood=function(i){
                if(_r[i]._nbhd==""||neighborhoods[_r[i]._nbhd]!=_r[i]._nbhd){
                return false;
                }
                return true;
        };
        this.checkAmenities=function(i){
                if(amenities!=null){
                for(var _3d in amenities){
                if(!_r[i]._a[_3d]){
                return false;
                }
                }
                }
                return true;
        };
        this.checkProvider=function(i){
                /*if(!singleProvider(i)){
                return false;
                }
                return true;*/
        };
}

function getFilteredOutReasons()
{
        var _3f=new Array();
        var _40=new Object();
        
        try {
                var _41=document.resultUI;
                var _42=priceSlider.getValue();
                var _422=priceSlider2.getValue();
                
                //Geting Distance&Landmar Filtering values
                /*if(_41.distance[_41.distance.selectedIndex].value<9999) {
                        _3f.push({heading:"Distance",sectionname:"distance"});
                        _40["distance"]=true;
                }*/
                
                //Geting PRICE Range Filtering values
                if(_42[0]<_42[1]) {
                        if(_42[0]!=priceSlider.minVal||_42[1]!=priceSlider.maxVal) {
                                _3f.push({heading:"Price Shared",sectionname:"price"});
                                _40["price"]=true;
                        }
                }
                
                if(_422[0]<_422[1]) {
                        if(_422[0]!=priceSlider2.minVal||_422[1]!=priceSlider2.maxVal) {
                                _3f.push({heading:"Price Private",sectionname:"price2"});
                                _40["price2"]=true;
                        }
                }
                                
                //Some shit)
                /*if(document.getElementById("cbshowunpriced")!=null&&!document.getElementById("cbshowunpriced").checked) {
                        _3f.push({heading:"Require online rates",sectionname:"price"});
                        _40["onlinereq"]=true;
                }
                
                if(document.getElementById("cbshowperbed")!=null&&!document.getElementById("cbshowperbed").checked){
                        _3f.push({heading:"Per bed pricing",sectionname:"price"});
                        _40["perbed"]=true;
                }
                
                //Geting Stars Filtering values
                if(document.getElementById("allstars")!=null&&!document.getElementById("allstars").checked) {
                        var _43="";
                        for(var i=1;i<=5;i++) {
                                if(document.getElementById("stars"+i)!=null&&document.getElementById("stars"+i).checked) {
                                        if(_43.length>0) {
                                        _43+=" or ";
                                        }
                                        _43+=""+i;
                                }
                        }
                        _3f.push({heading:"Star Rating",sectionname:"stars"});
                        _40["stars"]=true;
                }*/
                
                //Geting HotelName Filtering values
                if(_41.hotel_name.value.length>0) {
                        _3f.push({heading:"Hotel Name Contains",sectionname:"brandname"});
                        _40["hotelname"]=true;
                }
                /*
                //Geting Brand Filtering values
                if(_41.brand!=null&&_41.brand.value>=0) {
                        _3f.push({heading:"Hotel Brand",sectionname:"brandname"});
                        _40["brand"]=true;
                }
                
                //Geting Amenities Filtering values
                if(amenities!=null) {
                        var _45="";
                        
                        for(var _46 in amenities) {
                                if(_45.length>0) {
                                        _45+=" and ";
                                }
                                
                                _45+=_46.slice(0,1).toUpperCase()+_46.slice(1);
                        }
                        if(_45.length>0) {
                                _3f.push({heading:"Amenities",sectionname:"amenities"});
                                _40["amenities"]=true;
                        }
                }*/
                
                var _47="";
                var _48=0;
                var _49=0;
                
                //Geting Property types Filtering values
                for(var _4a in pTypes) {
                        if(_47.length>0) {
                                _47+=" or ";
                        }               
                        _47+=_ptypeLookup[_4a];
                        _48++;          
                }
                
                for(var _4a in _ptypeLookup) {
                        _49++;
                }
                
                if(_47.length==0) {
                        //_3f.push({heading:"Property Type",sectionname:"propertytypes"});
                        //_3f.push({heading:"Accommodation Type",sectionname:"propertytypes"});
                        //_40["ptype"]=true;
                } else {
                        if(_48!=_49){
                                //_3f.push({heading:"Property Type",sectionname:"propertytypes"});
                                _3f.push({heading:"Accommodation Type",sectionname:"propertytypes"});
                                _40["ptype"]=true;
                        }
                }
                
                /*//Geting Neighbours Filtering values
                if(document.getElementById("allneighborhoods")!=null&&!document.getElementById("allneighborhoods").checked) {
                        var _4b="";
                        
                        for(var _4c in neighborhoods) {
                                if(_4b.length>0){
                                        _4b+=" or ";
                                }
                                _4b+=neighborhoods[_4c];
                        }
                        
                        _3f.push({heading:"Neighborhood",sectionname:"neighborhood"});
                        _40["neighborhood"]=true;
                }*/
        } catch(e) {
        }
        
        //Making Object: (reasons - all filtering values, funclist - names of active filters)
        var _4d=new Object();
        _4d.reasons=_3f;
        _4d.funclist=_40;
        return _4d;
}

function optionTag(_4e,_4f,_50){
var _51="<option value="+_4e;
if(_50){
_51+=" selected";
}
_51+=">"+_4f+"</option>";
return _51;
}

function showLowest(_52) {
        for(var i=0;i<_r.length;i++){
        if(_r[i]._vs<0){
        _r[i]._vs=0;
        }
        }
        _maxprice=999999;
        _minprice=1;
        _maxprice2=999999;
        _minprice2=1;
        priceSlider.setValue([priceSlider.minVal,priceSlider.maxVal]);
        priceSlider2.setValue([priceSlider2.minVal,priceSlider2.maxVal]);
        displayPriceRange();
        displayPriceRange2();
        //document.resultUI.distance.selectedIndex=0;
        //document.getElementById("allstars").checked=true;
        //starsChg(document.getElementById("allstars"));
        document.resultUI.hotel_name.value="";
        if(document.resultUI.brand!=null){
        document.resultUI.brand.selectedIndex=0;
        }
        //clearNHoods();
        selectAllPropertyTypes();
        //clearAmenities();
        if(document.getElementById("allneighborhoods")!=null){
        document.getElementById("allneighborhoods").checked=true;
        setFilterSectionText("neighborhood","any");
        }
        if(_52==1){
        //_lastsort=sortprice;
        _lastsort=sortdistance;
        _lastdirection=true;
        }
        if(document.getElementById("cbshowperbed")!=null){
        document.getElementById("cbshowperbed").checked=true;
        }
        if(document.getElementById("cbshowunpriced")!=null){
        document.getElementById("cbshowunpriced").checked=true;
        }
        //setBrandNameText();
        //setDistanceText();
        refilter(noop,false,"show_lowestprice");
}

function distanceFromLandmark(){
calculateDistances();
_lastsort=sortdistance;
_lastdirection=true;
try{
recenteronlandmark();
}
catch(ignored){
}
}

function calculateDistances(){
/*var _54=document.resultUI.landmark.selectedIndex;
if(_lm[_54]){
var _55=_lm[_54][1];
var _56=_lm[_54][2];
for(var i=0;i<_r.length;i++){
if(_r[i]._lat!=0&&_r[i]._lon!=0){
_r[i]._dist=""+distance(_56,_55,_r[i]._lat,_r[i]._lon);
}
}
}*/
}

function distance(_58,_59,_5a,_5b){
var R=3956;
var _5d=degreesToRadians(_58);
var _5e=degreesToRadians(_59);
var _5f=degreesToRadians(_5a);
var _60=degreesToRadians(_5b);
var _61=_60-_5e;
var _62=_5f-_5d;
var s1=Math.sin(_62/2);
var s2=Math.sin(_61/2);
var a=s1*s1+Math.cos(_5d)*Math.cos(_5f)*s2*s2;
var c=2*Math.atan2(Math.sqrt(a),Math.sqrt(1-a));
var d=R*c;
return d;
}

function degreesToRadians(_68){
var _69=0.017453293;
return _68*_69;
}

function displayDistance(_6a) {
        var _6b=_6a;
        var _6c=parseInt(_6a);
        if(_6a){
        if(_6a=="9999.0"||_6c>=250||_6a=="0"){
        _6b="NA";
        }else{
        /*var _6d=Math.round(_6a*10)/10;
        _6b=_6d=""+_6d;
        var _6e=_6d.indexOf(".");
        if(_6e!=-1&&_6d.length>_6e+2){
        _6b=_6d.substring(0,_6e+2);
        }*/
        _6b+="&nbsp;%";
        }
        }
        return _6b;
}

function displayRating(_6f){
if(_6f=="-1.0"||_6f=="0.0"||_6f==""){
_6f="NA";
}else{
_6f="<img src=\""+www_root+"/img/kstar"+_6f+".gif\">";
}
return _6f;
}
function displayPrice(_70){
var _71=(_70*1)+0.5;
return parseInt(_71);
}

function displayPriceRange(_72)
{
        if(_72==null) {
                _72=false;
        }
        if(_maxprice>_minprice&&_minprice>0&&_maxprice>0) {
                var _73=priceSlider.getValue();
                document.getElementById("low_price").innerHTML=""+displayPrice(_73[0]);
                document.getElementById("high_price").innerHTML=""+displayPrice(_73[1]);
        } else {
                if(_72) {
                        if(document.getElementById("cbshowunpriced")!=null) {
                                document.getElementById("cbshowunpriced").checked=true;
                        }
                }
        }
        setPriceText();
}

function displayPriceRange2(_72)
{
        if(_72==null) {
                _72=false;
        }
        if(_maxprice>_minprice&&_minprice>0&&_maxprice>0) {
                var _73=priceSlider2.getValue();
                document.getElementById("low_price2").innerHTML=""+displayPrice(_73[0]);
                document.getElementById("high_price2").innerHTML=""+displayPrice(_73[1]);
        } else {
                if(_72) {
                        if(document.getElementById("cbshowunpriced")!=null) {
                                document.getElementById("cbshowunpriced").checked=true;
                        }
                }
        }
        setPriceText();
}

function updateTable(_74)
{
        setHTML(document,"content_div",maketable(_74));
        setSortArrow();
        pgNums();
        try{
                window.setTimeout("redrawMap()",1);
                window.setTimeout("redrawMap()",1000);
        } catch(ignored) {
        }
}

function price_slider_change(_75,_76,_77,_78)
{
        displayPriceRange();    
        if(!_78){
                price_slider_done(_75,_76,_77);
        }
}

function price_slider_done(_79,_7a,_7b)
{
        displayPriceRange();
        _minprice=_7a[0];
        document.resultUI.minprice.value=_minprice;
        _maxprice=_7a[1];
        document.resultUI.maxprice.value=_maxprice;
        refilter(noop,false,"filter_price_"+_minprice+"_"+_maxprice);
}

function price_slider_change2(_75,_76,_77,_78)
{
        displayPriceRange2();   
        if(!_78){
                price_slider_done2(_75,_76,_77);
        }
}

function price_slider_done2(_79,_7a,_7b)
{
        displayPriceRange2();
        _minprice2=_7a[0];
        document.resultUI.minprice2.value=_minprice2;
        _maxprice2=_7a[1];
        document.resultUI.maxprice2.value=_maxprice2;
        refilter(noop,false,"filter_price2_"+_minprice2+"_"+_maxprice2);
}

function init_price_slider(_7c,_7d,_7e,_7f,_80)
{
        priceSlider=new Bs_Slider2();
        priceSlider.attachOnChange(price_slider_change);
        priceSlider.attachOnSlideEnd(price_slider_done);
        priceSlider.width=205;
        priceSlider.height=24;
        priceSlider.minVal=_7d;
        priceSlider.maxVal=_7e;
        priceSlider.valueInterval=_7f;
        priceSlider.arrowAmount=0;
        priceSlider.valueDefault=[_7d,_80];
        priceSlider.imgDir=www_root+"/img/slider/";
        priceSlider.setBackgroundImage("sliderbgwticks205px.gif","no-repeat");
        priceSlider.setSliderIcon("sliderthumbgrey12x19.gif",12,19);
        priceSlider.useInputField=0;
        priceSlider.styleValueFieldClass="sliderInput";
        priceSlider.drawInto(_7c);
}

function init_price_slider2(_7c,_7d,_7e,_7f,_80)
{
        priceSlider2=new Bs_Slider2();
        priceSlider2.attachOnChange(price_slider_change2);
        priceSlider2.attachOnSlideEnd(price_slider_done2);
        priceSlider2.width=205;
        priceSlider2.height=24;
        priceSlider2.minVal=_7d;
        priceSlider2.maxVal=_7e;
        priceSlider2.valueInterval=_7f;
        priceSlider2.arrowAmount=0;
        priceSlider2.valueDefault=[_7d,_80];
        priceSlider2.imgDir=www_root+"/img/slider/";
        priceSlider2.setBackgroundImage("sliderbgwticks205px.gif","no-repeat");
        priceSlider2.setSliderIcon("sliderthumbgrey12x19.gif",12,19);
        priceSlider2.useInputField=0;
        priceSlider2.styleValueFieldClass="sliderInput";
        priceSlider2.drawInto(_7c);
}

function restoreState()
{
        buildPropertyTypes();
        buildNeighborhoods();
        buildAmenities();
        if(document.resultUI.maxprice.value!=-1&&document.resultUI.minprice.value!=-1){
                priceSlider.setValue([document.resultUI.minprice.value,document.resultUI.maxprice.value]);
        }
        if(document.resultUI.maxprice2.value!=-1&&document.resultUI.minprice2.value!=-1){
                priceSlider2.setValue([document.resultUI.minprice2.value,document.resultUI.maxprice2.value]);
        }
}

function showprices(id,_82,_83){
        var _84=(_82!=null&&_82);
        var _85=(_83!=null&&_83);
        if(document.getElementById("dtl"+id)!=null){
                if(_84||document.getElementById("dtl"+id).style.display=="none"){
                        if(_isIE){
                                document.getElementById("dtl"+id).style.display="block";
                        }else{
                                document.getElementById("dtl"+id).style.display="table-row";
                        }
                        _r[id]._ds=1;
                        
                        if(_85) {
                                try{
                                        document.getElementById("tbd"+id).scrollIntoView();
                                }
                                        catch(ignored){
                                }
                        }
                }else{
                        document.getElementById("dtl"+id).style.display="none";
                        _r[id]._ds=0;
                }
        }
}

function nonavailsearch() {
        if(document.searchUI.checkin_date_dom.value.length==0) {
                alert("Please enter a check-in date.");
                return false;
        }
        if(document.searchUI.checkout_date_dom.value.length==0) {
                alert("Please enter a check-out date.");
                return false;
        }
        
        showmessage(getUpdateMessage('Please, wait...'));
        return true;
}

function clearStars() {
if(document.resultUI.rating!=null){
for(var i=0;i<document.resultUI.rating.length;i++){
document.resultUI.rating[i].checked=false;
}
}
}
function starsChg(_87){
if(_87.id=="allstars"&&_87.checked){
clearStars();
}else{
document.getElementById("allstars").checked=false;
}
var _88="stars"+stripSpaces(_87.value)+((_87.checked)?".on":".off");
refilter(noop,false,"filter_"+_88);
addAdt(_88);
setStarsText();
}
var pTypes=null;

function buildPropertyTypes() {
        pTypes=new Array();
        var _89=true;
        if(document.resultUI.ptype!=null){
                if(typeof document.resultUI["ptype"].length=="undefined"){
                if(document.resultUI.ptype.checked){
                        pTypes[document.resultUI.ptype.value]=document.resultUI.ptype.value;
                        }else{
                        _89=false;
                        }
                        }else{
                        for(var i=0;i<document.resultUI.ptype.length;i++){
                                if(document.resultUI.ptype[i].checked){
                                pTypes[document.resultUI.ptype[i].value]=document.resultUI.ptype[i].value;
                                }else{
                                _89=false;
                                }
                        }
                }
                if(_89){
                        setFilterSectionText("propertytypes","any");
                }else{
                        setFilterSectionText("propertytypes","custom");
                }
        }
}

var neighborhoods=null;
function buildNeighborhoods(){
neighborhoods=new Array();
if(document.resultUI.neighborhood!=null){
for(var i=0;i<document.resultUI.neighborhood.length;i++){
if(document.resultUI.neighborhood[i].checked){
neighborhoods[document.resultUI.neighborhood[i].value]=document.resultUI.neighborhood[i].value;
}
}
}
if(document.getElementById("allneighborhoods")!=null&&document.getElementById("allneighborhoods").checked){
setFilterSectionText("neighborhood","any");
}else{
setFilterSectionText("neighborhood","custom");
}
}

function clearNHoods(){
if(document.resultUI.neighborhood!=null){
for(var i=0;i<document.resultUI.neighborhood.length;i++){
document.resultUI.neighborhood[i].checked=false;
}
}
}

function nhoodChg(_8d){
if(_8d.id=="allneighborhoods"&&_8d.checked){
clearNHoods();
}else{
document.getElementById("allneighborhoods").checked=false;
}
var _8e="nbhd"+stripSpaces(_8d.value)+((_8d.checked)?".on":".off");
refilter(buildNeighborhoods,false,"filter_"+_8e);
addAdt(_8e);
}

function ptypeChg(_8f) {
        var _90="ptype"+stripSpaces(_8f.value)+((_8f.checked)?".on":".off");    
        refilter(buildPropertyTypes,false,"filter_"+_90);
        addAdt(_90);
}

var amenities=null;
function buildAmenities(){
var _91=false;
amenities=new Object();
if(document.resultUI.amenity!=null){
for(var i=0;i<document.resultUI.amenity.length;i++){
if(document.resultUI.amenity[i].checked){
amenities[document.resultUI.amenity[i].value]=document.resultUI.amenity[i].value;
_91=true;
}
}
}
if(!_91){
setFilterSectionText("amenities","none required");
}else{
setFilterSectionText("amenities","custom");
}
}

function clearAmenities(){
if(document.resultUI.amenity!=null){
for(var i=0;i<document.resultUI.amenity.length;i++){
document.resultUI.amenity[i].checked=false;
}
}
buildAmenities();
}

function amenityChg(_94){
var _95="amenity"+stripSpaces(_94.value)+((_94.checked)?".on":".off");
refilter(buildAmenities,false,"filter_"+_95);
addAdt(_95);
}

function scroll(_96){
var obj=document.getElementById("list2"+_96);
obj.style.display="block";
obj=document.getElementById(_96);
obj.style.height="82px";
obj.style.overflow="auto";
obj.style.borderColor="#ccc";
obj.style.borderStyle="solid";
obj.style.borderWidth="1px";
obj=document.getElementById("seeall"+_96);
obj.style.display="none";
document.getElementById("close"+_96).style.display="block";
}

function closex(_98){
var obj=document.getElementById(_98);
obj.style.height="auto";
obj.style.overflow="hidden";
obj.style.borderStyle="none";
obj=document.getElementById("close"+_98);
obj.style.display="none";
document.getElementById("list2"+_98).style.display="none";
document.getElementById("seeall"+_98).style.display="inline";
return true;
}

function clearName(){
document.resultUI.hotel_name.value="";
addAdt("hotelnameclr");
refilter(noop,false,"filter_hotelnameclear");
}

function selectPtype(id) {
        document.getElementById("ptcb"+id).checked=true;
        for(var _9b in pTypes) {
                try{
                        document.getElementById("ptcb"+_9b).checked=(_9b==id);
                }
                        catch(ignored){
                }
        }
        ptypeChg(document.getElementById("ptcb"+id));
}

function selectAmenity(id){
var _9d="amcb"+id;
for(var i=0;i<document.resultUI.amenity.length;i++){
if(document.resultUI.amenity[i].id==_9d){
document.resultUI.amenity[i].checked=true;
}else{
document.resultUI.amenity[i].checked=false;
}
}
amenityChg(document.getElementById(_9d));
}

/*
        Google Map Functions
*/

var mapwindow=null;
function mapfiltered() {
        var _9f="";
        for(var j=0;j<_filtered.length;j++){
                var i=_filtered[j];
                
                if(_r[i]._lat!=0) {
                        if(_9f.length>0) {
                                _9f+=",";
                        }
                        _9f+=_r[i]._id;
                }
        }
        if(_9f.length>0){
        addToMap(_9f);
        }
}

function addToMap(_a2) {
        if(mapwindow==null||mapwindow.closed) {
                var _a3="/s/hotelresultmap.jsp?searchid=${param.searchid}&w=800&h=600&hid="+_a2;
                mapwindow=window.open(_a3,"map","width=750,height=400,scrollbars,titlebar,resizable");
        }else {
                var _a4=_a2.split(",");
                for(var i=0;i<_a4.length;i++){
                        mapwindow.addHotelToList(_a4[i],(_a4.length==1));
                }
                mapwindow.focus();
        }
}

function selectAllPropertyTypes(){
        if(document.resultUI.ptype!=null) {
                if(typeof document.resultUI["ptype"].length=="undefined") {
                        document.resultUI.ptype.checked=true;
                }else{
                        for(var i=0;i<document.resultUI.ptype.length;i++){
                                document.resultUI.ptype[i].checked=true;
                        }
                }
        }
        buildPropertyTypes();
}

function toggleAmenityDisplay(_a7){
showmessage(getUpdateMessage("Updating results"));
showAmenities=_a7;
updateTable("filteramenity");
window.setTimeout(hidemessage,1);
setHotelDisplayCookie();
}

function toggleAddressDisplay(_a8){
showmessage(getUpdateMessage("Updating results"));
showAddress=_a8;
updateTable("filteraddress");
window.setTimeout(hidemessage,1);
setHotelDisplayCookie();
}
function togglecustomloc(_a9){
if(_a9){
document.getElementById("custommsgarea").innerHTML="";
document.getElementById("custommsgarea").style.display="none";
document.getElementById("addcustomloc").style.display="none";
document.getElementById("customlocentry").style.display="block";
}else{
document.getElementById("customlocentry").style.display="none";
document.getElementById("addcustomloc").style.display="block";
}
}

function addcustomlocation(_aa) {
var _ab=document.resultUI;
if(_ab.customaddress.value.length==0){
alert("Please enter a street address.");
try{
_ab.customaddress.focus();
}
catch(ignored){
}
return;
}
if(_ab.customlocation.value.length==0){
alert("Please enter a city.");
try{
_ab.customlocation.focus();
}
catch(ignored){
}
return;
}
if(_ab.customlabel.value.length==0){
alert("Please enter a place name for your custom place.");
try{
_ab.customlabel.focus();
}
catch(ignored){
}
return;
}

var _ac=/\(.*\)/g;
var url=_aa+"?alias="+escape(_ab.customlabel.value);
url+="&street="+escape(_ab.customaddress.value);
url+="&fullcity="+escape(_ab.customlocation.value.replace(_ac,""));
url+="&postalcode="+escape(_ab.customzip.value);
url+="&ctid="+escape(_ab.customhint.value);
url+="&ptag="+escape(_ab.placetag.value);
url+="&stype="+escape(_ab.savetype.value);
var _ae=new R9HTTPXml();
_ae.init(url);
try{
window.status="Retrieving lat/long";
_ae.setTimeout(5000);
_ae.asyncGET(new customLocCallback(_ab.customlabel.value));
}
catch(e){
alert(e);
}
}

function resetlandmarks(){
var _af=document.getElementById("landmarklist");
_af.options.length=0;
for(var i=0;i<_lm.length;i++){
_af.options[i]=new Option(_lm[i][0],i,(i==0),(i==0));
}
refilter(distanceFromLandmark,false,"filter_landmarkreset");
}

function customLocCallback(_b1){
this.onError=function(_b2,_b3){
alert("Sorry, your location was not added! Out of range or unknown. Please try again.");
};
this.onLoad=function done(_b4){
window.status="";
var _b5=_b4.getTags("location");
var _b6=_b4.getTagText(_b5[0],"status",0);
if(_b6.indexOf("OK")!=0){
alert("Sorry, your location was not added! Out of range or unknown. Please try again.");
return;
}
var _b7=_b4.getTagText(_b5[0],"latitude",0);
var _b8=_b4.getTagText(_b5[0],"longitude",0);
var _b9=new Array();
_b9[0]=_b1;
_b9[1]=_b8;
_b9[2]=_b7;
_lm.unshift(_b9);
resetlandmarks();
togglecustomloc(false);
document.resultUI.customlabel.value="";
document.resultUI.customaddress.value="";
var msg="<div class=\"success\">Success</div>The Distance to all hotels has been updated to be relative to <b>"+_b1+"</b>.";
if(document.resultUI.savetype.value!="2"){
msg+=" <b>"+_b1+"</b> has also been added to your member page where you may edit it at any time. You may select this and other relevant custom places on future searches!";
}
document.getElementById("custommsgarea").style.display="block";
document.getElementById("custommsgarea").innerHTML=msg;
selectByValue(document.resultUI.savetype,"0");
selectByValue(document.resultUI.placetag,"0");
};
}

function landmarkchanged(_bb){
if(parseInt(_bb.value)>=0){
refilter(distanceFromLandmark,false,"filter_landmarkchanged_"+stripSpaces(_bb.options[_bb.selectedIndex].text));
addAdt("landmark");
setDistanceText();
try{
document.resultUI.hotel_name.focus();
}
catch(ignored){
}
return true;
}else{
return false;
}
}

function getrates(_bc) {
        try{
                document.searchUI.hid.value=_r[_bc]._id;
                document.getElementById("ratelookuphotelname").innerHTML="&ndash; Show "+_r[_bc]._name+" at top";
                document.getElementById("datelesssearchbox").scrollIntoView();
        }
                catch(ignored){
        }
}

function onlyShowFavorites(){
if(document.getElementById("onlymapfavorites")!=null&&document.getElementById("onlymapfavorites").checked){
document.resultUI.onlymapfav.value="Y";
}else{
document.resultUI.onlymapfav.value="N";
}
updateTable();
}
function availsearch(){
document.resultUI.action="/hotels?action=dohotels";
document.resultUI.method="POST";
document.resultUI.submit();
}

function setPriceText() {
        if(_maxprice<priceSlider.maxVal||_minprice>priceSlider.minVal) {
                setFilterSectionText("price","custom");
        } else {
                setFilterSectionText("price","any");
        }
}

function setPriceText2() {
        if(_maxprice<priceSlider2.maxVal||_minprice>priceSlider2.minVal) {
                setFilterSectionText("price2","custom");
        } else {
                setFilterSectionText("price2","any");
        }
}

function setDistanceText(){
/*if((document.resultUI.distance[document.resultUI.distance.selectedIndex].value-0)<9999){
setFilterSectionText("distance","custom");
}else{
setFilterSectionText("distance","any");
}*/
}

function setStarsText(){
/*if(document.getElementById("allstars").checked){
setFilterSectionText("stars","any");
}else{
setFilterSectionText("stars","custom");
}*/
}

function setBrandNameText(){
var _bd=document.resultUI;
if((_bd.brand!=null&&_bd.brand.value>=0)||_bd.hotel_name.value.length>0){
setFilterSectionText("brandname","custom");
}else{
setFilterSectionText("brandname","any");
}
}
// r9compressed

