var aMatchSuggestion=[];var aSuggestions=[];var prevAJAXTextBoxValue="";var reqStatus=204;function StateSuggestions(){this.airport=[]}StateSuggestions.prototype.requestSuggestions=function(oAutoSuggestControl,bTypeAhead){var sTextboxValue=oAutoSuggestControl.textbox.value;if(sTextboxValue.length>2){var temp=new String();temp=sTextboxValue;typeAhead_AutoComplete(temp,oAutoSuggestControl,bTypeAhead,temp)}else{if(sTextboxValue.length<=2&&sTextboxValue.length>0){populateDataInField("",oAutoSuggestControl,bTypeAhead,sTextboxValue)}}prevAJAXTextBoxValue=sTextboxValue};function populateDataInField(AJAXAirportList,oAutoSuggestControl,bTypeAhead,sTextboxValue){var aSuggestions=[];var airportName;var prevAirportName;airport=AJAXAirportList.split("||");var listLength=airport.length;for(var i=0;i<listLength;i++){airportName=airport[i];if(oAutoSuggestControl.textbox.name=="City"||oAutoSuggestControl.textbox.name=="innerCity"){if(airportName.toLowerCase().indexOf(sTextboxValue.toLowerCase())==0){aSuggestions.push(airportName)}else{if(airportName.indexOf("(")!=-1){if(airportName.substr(0,3).toLowerCase().indexOf(sTextboxValue.toLowerCase())==0){aSuggestions.push(airportName)}else{if(airportName.substring(airportName.indexOf(") - ")+4).toLowerCase().indexOf(sTextboxValue.toLowerCase())==0){aSuggestions.push(airportName)}}}}}else{if(airportName.indexOf("(")!=-1){if(airportName.substr(0,3).toLowerCase().indexOf(sTextboxValue.toLowerCase())==0){aSuggestions.push(airportName);if(prevAirportName.indexOf("(")==-1){aSuggestions.push(prevAirportName)}}else{if(airportName.substring(airportName.indexOf(") - ")+4).toLowerCase().indexOf(sTextboxValue.toLowerCase())==0){aSuggestions.push(airportName);if(prevAirportName.indexOf("(")==-1){aSuggestions.push(prevAirportName)}}}}}prevAirportName=airportName}oAutoSuggestControl.autosuggest(aSuggestions,bTypeAhead)}function typeAhead_AutoComplete(lookValue,cb1,cb2,sTextboxValue){var url="/autocomplete?action=complete&lookValue="+lookValue;var req=createXmlHttpReqObject();req.onreadystatechange=function(){if(req.readyState==4){if(req.status==200){reqStatus=200;populateDataInField(req.responseText,cb1,cb2,sTextboxValue)}else{if(req.status==204){return null}}}};req.open("GET",url,true);req.send(null)}function createXmlHttpReqObject(){var xmlHttpObj=null;if(window.XMLHttpRequest){xmlHttpObj=new XMLHttpRequest()}else{if(window.ActiveXObject){xmlHttpObj=new ActiveXObject("Microsoft.XMLHTTP")}}return xmlHttpObj}function getElemById(objectId){if(document.getElementById&&document.getElementById(objectId)){return document.getElementById(objectId)}else{if(document.all&&document.all(objectId)){return document.all(objectId)}else{return false}}}StateSuggestions.prototype.setAJAXCheck=function(name){if(name=="City"){document.hotelsForm.AJAXCheck.value="1";document.hotelsForm.cityId.value=selectedDivId;if(getElemById("hotelAdvertisers")){this.smartDisplay(1)}}else{if(name=="pickupCity"){document.carsForm.AJAXCheck.value="1";document.carsForm.cityId.value=selectedDivId}else{if(name=="DepartureCity"){document.flightsForm.AJAXCheck.value="1";document.flightsForm.cityId.value=selectedDivId;if(getElemById("flightAdvertisers")){this.smartDisplay(2)}}else{if(name=="ArrivalCity"){document.flightsForm.AJAXCheck1.value="1";document.flightsForm.cityId1.value=selectedDivId;if(getElemById("flightAdvertisers")){this.smartDisplay(2)}}else{if(name=="dropoffCity"){document.carsForm.AJAXCheck1.value="1";document.carsForm.cityId1.value=selectedDivId}else{if(name=="innerCity"){document.profileChangeCityForm.AJAXCheck.value="1";document.profileChangeCityForm.cityId.value=selectedDivId;if(getElemById("hotelAdvertisers")){this.smartDisplay(1,"innerCity")}}}}}}}};StateSuggestions.prototype.getAJAXCheck=function(name){if(name=="City"){return document.hotelsForm.AJAXCheck.value}else{if(name=="pickupCity"){return document.carsForm.AJAXCheck.value}else{if(name=="DepartureCity"){return document.flightsForm.AJAXCheck.value}else{if(name=="ArrivalCity"){return document.flightsForm.AJAXCheck1.value}else{if(name=="dropoffCity"){return document.carsForm.AJAXCheck1.value}else{if(name=="innerCity"){return document.profileChangeCityForm.AJAXCheck.value}}}}}}};StateSuggestions.prototype.resetAJAXCheck=function(name){if(name=="City"){document.hotelsForm.AJAXCheck.value="0"}else{if(name=="pickupCity"){document.carsForm.AJAXCheck.value="0"}else{if(name=="DepartureCity"){document.flightsForm.AJAXCheck.value="0"}else{if(name=="ArrivalCity"){document.flightsForm.AJAXCheck1.value="0"}else{if(name=="dropoffCity"){document.carsForm.AJAXCheck1.value="0"}else{if(name=="innerCity"){document.profileChangeCityForm.AJAXCheck.value="0"}}}}}}};StateSuggestions.prototype.smartDisplay=function(tab,extra){if(tab==2){if(document.flightsForm.cityId.value!=""&&document.flightsForm.cityId1.value!=""&&document.flightsForm.departureCity.value!="City or Airport"&&document.flightsForm.arrivalCity.value!="City or Airport"){var orig=document.flightsForm.departureCity.value;if(orig.indexOf("(")>0){orig=orig.substring(0,3)}else{orig=document.flightsForm.cityId.value}var dest=document.flightsForm.arrivalCity.value;if(dest.indexOf("(")>0){dest=dest.substring(0,3)}else{dest=document.flightsForm.cityId1.value}var url="/linkagentservlet?t=list&tab="+tab+"&wid=1&wpid=1&orig="+orig+"&dest="+dest;var req=createXmlHttpReqObject();req.onreadystatechange=function(){if(req.readyState==4){if(req.status==200){reqStatus=200;smart_display_widget.updateAdvertisersFlights(req.responseText)}else{if(req.status==204){return null}}}};req.open("GET",url,true);req.send(null)}}else{if(tab==1&&extra=="innerCity"){if(document.profileChangeCityForm.cityId.value!=""||document.profileChangeCityForm.innerCity.value!="City or Airport"){var cityId=document.profileChangeCityForm.cityId.value;var city=document.profileChangeCityForm.innerCity.value;var url;if(document.profileChangeCityForm.cityId.value!=""){url="/linkagentservlet?t=list&tab="+tab+"&wid=1&wpid=1&cityId="+cityId}else{var names=city.split(",");if(names.length==3){var cityName=names[0];var state=names[1];var country=names[2];url="/linkagentservlet?t=list&tab="+tab+"&wid=1&wpid=1&cityName="+encodeURI(cityName)+"&state="+state+"&country="+encodeURI(country)}else{var cityName=names[0];var country=names[1];url="/linkagentservlet?t=list&tab="+tab+"&wid=1&wpid=1&cityName="+encodeURI(cityName)+"&country="+encodeURI(country)}}var req=createXmlHttpReqObject();req.onreadystatechange=function(){if(req.readyState==4){if(req.status==200){reqStatus=200;smart_display_widget.updateAdvertisersProfileHotels(req.responseText)}else{if(req.status==204){return null}}}};req.open("GET",url,true);req.send(null)}}else{if(tab==1){if(document.hotelsForm.cityId.value!=""||document.hotelsForm.City.value!="City or Airport"){var cityId=document.hotelsForm.cityId.value;var city=document.hotelsForm.City.value;var url;if(document.hotelsForm.cityId.value!=""){url="/linkagentservlet?t=list&tab="+tab+"&wid=1&wpid=1&cityId="+cityId}else{var names=city.split(",");if(names.length==3){var cityName=names[0];var state=names[1];var country=names[2];url="/linkagentservlet?t=list&tab="+tab+"&wid=1&wpid=1&cityName="+encodeURI(cityName)+"&state="+state+"&country="+encodeURI(country)}else{var cityName=names[0];var country=names[1];url="/linkagentservlet?t=list&tab="+tab+"&wid=1&wpid=1&cityName="+encodeURI(cityName)+"&country="+encodeURI(country)}}var req=createXmlHttpReqObject();req.onreadystatechange=function(){if(req.readyState==4){if(req.status==200){reqStatus=200;smart_display_widget.updateAdvertisersHotels(req.responseText)}else{if(req.status==204){return null}}}};req.open("GET",url,true);req.send(null)}}}}};
