GuideSelector.SERVICE_NAME="/services/Guides";if(window.WIDGET_MODE){GuideSelector.SERVICE_NAME+=".php"}function GuideSelector(C,A,E,B,G,D){this.valueField=C;this.textField=A;this.optionArea=E;this.serverParam=B;this.selectionCallback=G;this.invalidationCallback=D;this.validGuide=(this.valueField&&this.valueField.value!="");this.guideQuery=new YAHOO.widget.DS_XHR(GuideSelector.SERVICE_NAME,["results","name","regionName","countryName","id","lat","lng","zoom"]);this.guideQuery.responseType=YAHOO.widget.DS_XHR.TYPE_JSON;this.guideQuery.scriptQueryParam="name";this.prepareQuery();this.selector=new YAHOO.widget.AutoComplete(A,E,this.guideQuery);this.selector.useShadow=true;this.selector.maxResultsDisplayed=20;this.selector.minQueryLength=2;var F=this;this.selector.formatResult=function(H,I){return F.getFullName(H)};this.selector.doBeforeExpandContainer=function(H,I,L,K){var J=YAHOO.util.Dom.getXY(H);J[1]+=YAHOO.util.Dom.get(H).offsetHeight;YAHOO.util.Dom.setXY(I,J);return true};YAHOO.util.Event.addListener(this.textField,"blur",this.validateEntry,this,true);this.selector.guideSelector=this;this.selector.textboxKeyEvent.subscribe(function(K,J){var H=J[0];var I=H.guideSelector;I.markEntryInvalid()});this.selector.itemSelectEvent.subscribe(function(K,J){var H=J[0];var I=H.guideSelector;I.id=J[2][3];I.lat=J[2][4];I.lng=J[2][5];I.zoom=J[2][6];I.fullName=I.getFullName(J[2]);if(I.valueField){I.valueField.value=I.id}I.markEntryValid(I.id)})}GuideSelector.prototype.getFullName=function(A){var B=A[0];return B};GuideSelector.prototype.validateEntry=function(){var A=this;setTimeout(function(){if(!A.validGuide){A.checkNameMatch()}},500)};GuideSelector.prototype.markEntryValid=function(A){this.validGuide=true;this.textField.style.backgroundColor="#fff";if(this.selectionCallback){this.selectionCallback(A)}};GuideSelector.prototype.markEntryInvalid=function(A){this.validGuide=false;this.textField.style.backgroundColor="#fab327";if(this.invalidationCallback){this.invalidationCallback()}};GuideSelector.prototype.updateParent=function(A){this.parentId=A;this.prepareQuery()};GuideSelector.prototype.prepareQuery=function(){var A="event=getSimilarNames";if(this.serverParam){A+="&"+this.serverParam}else{A+="&max=20"}if(this.parentId){A+="&parent="+this.parentId}else{A+="&getParentNames=true"}this.guideQuery.scriptQueryAppend=A};GuideSelector.prototype.checkNameMatch=function(){var B=this.guideQuery.scriptQueryAppend+"&name="+encode(this.textField.value);var A=this;YAHOO.util.Connect.asyncRequest("GET",GuideSelector.SERVICE_NAME+"?"+B,{success:A.checkMatch,failure:function(C){},scope:A})};GuideSelector.prototype.checkMatch=function(A){};ListingSelector.SERVICE_NAME="/services/Listings";if(window.WIDGET_MODE){GuideSelector.SERVICE_NAME+=".php"}function ListingSelector(C,A,F,B,H,E){try{this.valueField=C;this.textField=A;this.optionArea=F;this.selectionCallback=H;this.invalidationCallback=E;this.findDistant=false;this.validListing=false;if(this.valueField&&this.valueField.value!=""){this.validListing=true}this.listingQuery=new YAHOO.widget.DS_XHR(ListingSelector.SERVICE_NAME,["results","name","id","lat","lng","listingType","guideName"]);this.listingQuery.responseType=YAHOO.widget.DS_XHR.TYPE_JSON;this.listingQuery.scriptQueryParam="name";this.setServerParam(B);this.selector=new YAHOO.widget.AutoComplete(A,F,this.listingQuery);this.selector.useShadow=true;this.selector.maxResultsDisplayed=20;this.selector.autoHighlight=false;var G=this;this.selector.formatResult=function(I,J){var K=I[0];if(G.findDistant){K+=", "+I[5]}return K};this.selector.doBeforeExpandContainer=function(I,J,M,L){var K=YAHOO.util.Dom.getXY(I);K[1]+=YAHOO.util.Dom.get(I).offsetHeight;YAHOO.util.Dom.setXY(J,K);return true};this.selector.listingSelector=this;this.selector.textboxKeyEvent.subscribe(function(L,K){var I=K[0];var J=I.listingSelector;J.markEntryInvalid()});this.selector.itemSelectEvent.subscribe(function(L,K){var I=K[0];var J=I.listingSelector;J.name=K[2][0];J.id=K[2][1];J.lat=K[2][2];J.lng=K[2][3];J.listingType=K[2][4];if(J.valueField){J.valueField.value=J.id}J.markEntryValid()})}catch(D){alert(D)}}ListingSelector.prototype.setServerParam=function(A){this.serverParam=A;this.buildQuery()};ListingSelector.prototype.validateEntry=function(){var A=this;setTimeout(function(){if(!A.validListing){A.checkNameMatch()}},500)};ListingSelector.prototype.markEntryValid=function(){this.validListing=true;this.textField.style.backgroundColor="#fff";if(this.selectionCallback){this.selectionCallback()}};ListingSelector.prototype.markEntryInvalid=function(A){this.validListing=false;this.textField.style.backgroundColor="#fab327";if(this.invalidationCallback){this.invalidationCallback()}};ListingSelector.prototype.buildQuery=function(){var A="event=getSimilarNames&isNameQuery=true&skipPhotos=true&max=20";if(this.serverParam){A+="&"+this.serverParam}if(this.locationParams){A+="&"+this.locationParams}if(this.findDistant){A+="&findDistant=true"}this.listingQuery.scriptQueryAppend=A};ListingSelector.prototype.checkNameMatch=function(){var B=this.listingQuery.scriptQueryAppend+"&name="+encode(this.textField.value);var A=this;YAHOO.util.Connect.asyncRequest("GET",ListingSelector.SERVICE_NAME+"?"+B,{success:A.checkMatch,failure:function(C){},scope:A})};ListingSelector.prototype.checkMatch=function(A){var C=this.textField.value.toLowerCase();var D=JSON.parse(A.responseText);var E=D.results;for(var B=0;B<E.length;B++){var F=E[B];if(F.name.toLowerCase()==C){this.textField.value=F.name;if(this.valueField){this.valueField.value=F.id}this.markEntryValid();break}}};ListingSelector.prototype.setFindDistant=function(){this.findDistant=true};ListingSelector.prototype.updateLocation=function(A,C,B){if(A){this.locationParams="guide="+A}else{if(C&&B){this.locationParams="lat="+encode(C)+"&lng="+encode(B)}else{this.locationParams=null}}this.buildQuery()};var tagQuery=new YAHOO.widget.DS_XHR("/services/Tags",["results","name","id"]);tagQuery.responseType=YAHOO.widget.DS_XHR.TYPE_JSON;tagQuery.scriptQueryParam="name";function TagSelector(A,D,C,B){this.tagField=A;this.optionalTagArea=C;this.entityType=B;this.selector=new YAHOO.widget.AutoComplete(A,D,tagQuery);this.selector.useShadow=true;this.selector.delimChar=",";this.selector.queryDelay=0.3;this.selector.maxResultsDisplayed=20;this.selector.tagSelector=this;this.selectedTags=new Array();this.selector.formatResult=function(E,F){return E[0]};this.selector.doBeforeExpandContainer=function(E,F,I,H){var G=YAHOO.util.Dom.getXY(E);G[1]+=YAHOO.util.Dom.get(E).offsetHeight;YAHOO.util.Dom.setXY(F,G);return true};this.selector.itemSelectEvent.subscribe(function(H,G){var E=G[0];var F=E.tagSelector;if(F.autoSubmit){F.autoSubmit();return }if(F.isSingleSelect){return }F.lastTagCount++;if(F.optionalTagArea){F.loadOptionalRelatedTags()}});this.selector.dataReturnEvent.subscribe(function(H,G){var E=G[0];var F=E.tagSelector;F.resultCount=G[2].length;if(F.matchCallback){F.matchCallback(F.resultCount)}});if(this.entityType!=11){this.updateListingType()}YAHOO.util.Event.addListener(this.tagField,"keypress",this.checkTagsKeyed,this,true);this.lastTagCount=this.tagField.value.split(/,/).length}TagSelector.prototype.setSingleSelect=function(A){this.isSingleSelect=A;if(this.isSingleSelect){this.selector.delimChar=""}};TagSelector.prototype.useShortlist=function(){tagQuery.scriptQueryAppend+="&shortlist=true"};TagSelector.prototype.setAutoSubmit=function(A){this.autoSubmit=A};TagSelector.prototype.setMatchCallback=function(A){this.matchCallback=A};TagSelector.prototype.checkTagsKeyed=function(){if(this.isSingleSelect){return }var A=this.tagField.value;A=A.replace(/\n/,",");A=A.replace(/, *,/,",");this.tagField.value=A;var B=this.tagField.value.split(/,/).length;if(B!=this.lastTagCount){this.lastTagCount=B;if(this.optionalTagArea){this.loadOptionalRelatedTags()}}};TagSelector.prototype.updateListingType=function(B){this.listingType=B;var A="event=getTagsWithSimilarName&entityType="+this.entityType;if(B){A+="&listingType="+B
}tagQuery.scriptQueryAppend=A};TagSelector.prototype.loadOptionalRelatedTags=function(){var B=this;var A="/services/Tags?event=getRelatedTags&entityType="+this.entityType+"&listingType="+this.listingType+"&tags="+this.tagField.value;YAHOO.util.Connect.asyncRequest("GET",A,{success:B.renderOptionalRelatedTags,failure:function(C){},scope:B})};TagSelector.prototype.renderOptionalRelatedTags=function(B){var G=", "+this.tagField.value.toLowerCase()+", ";var E=JSON.parse(B.responseText);var L=new Array();for(var D=0;D<E.length;D++){var M=E[D];var K=RegExp(", "+M.name+", ");if(G.indexOf(", "+M.name.toLowerCase()+", ")>=0){continue}for(var C=0;C<L.length;C++){if(L[C].name==M.name){break}}if(C==L.length){L.push(M)}}var H=this.tagField.value;L.sort(function(O,N){if(O.mainName!=N.mainName){return H.indexOf(O.mainName)-H.indexOf(N.mainName)}else{if(O.name<N.name){return -1}else{if(O.name>N.name){return 1}else{return 0}}}});var F="<div style='font-weight:bold'>Related Tags:</div><div>";var I=null;for(var D=0;D<L.length;D++){var M=L[D];if(I!=null&&I!=M.mainName){F+="<div style='width:100px;height:1px;background-color:#000;margin:5px 0px;'></div>"}F+="<input type='checkbox' name='tag"+encode(M.name)+"' value='"+encode(M.name)+"' class='radioCheck'>"+M.name+"<BR>";I=M.mainName}F+="</div>";var A=document.getElementById(this.optionalTagArea);A.innerHTML=F;if(L.length==0){A.style.display="none"}else{A.style.display="";var J=YAHOO.util.Dom.getXY(this.tagField);J[0]+=this.tagField.offsetWidth+20;YAHOO.util.Dom.setXY(A,J);for(var D=0;D<L.length;D++){YAHOO.util.Event.addListener(A.childNodes[D+1],"click",this.selectRelatedTag,this,true)}}};TagSelector.prototype.selectRelatedTag=function(A){var C=YAHOO.util.Event.getTarget(A);if(!C.checked){return }var D=C.name.substring(3);var B=decode(C.value);if(!this.tagField.value.match(/, *$/)){this.tagField.value+=", "}this.tagField.value+=B+", ";this.loadOptionalRelatedTags();this.tagField.focus()};TagSelector.prototype.toggleTag=function(B){var C=this.tagField.value;var A=(C.indexOf(B)<0);if(A){tagSelector.addTag(B)}else{tagSelector.removeTag(B)}return A};TagSelector.prototype.addTag=function(B){var A=this.tagField.value;if(A.length>0){if(!this.tagField.value.match(/, *$/)){A+=", "}}A+=B;this.tagField.value=A+", ";this.tagField.focus();this.loadOptionalRelatedTags()};TagSelector.prototype.removeTag=function(B){var A=this.tagField.value;A=A.replace(B,"");A=A.replace(/,\s*,/,",");A=A.replace(/^,\s*/,"");A=A.replace(/,\s*$/,"");this.tagField.value=A;this.tagField.focus();this.loadOptionalRelatedTags()};var COMMENT_SERVICE="/services/Comments";var SOCIAL_SERVICE="/services/Social";var working=false;function flagItem(C,B,A){establishActiveUser(function(){if(working){return }working=true;var D="event=saveFlag&item="+C+"&type="+B;YAHOO.util.Connect.asyncRequest("POST",SOCIAL_SERVICE,{success:function(E){var F=JSON.parse(E.responseText);if(F.result&&F.result=="OK"){A.innerHTML="Flagged!";A.style.backgroundImage="none"}working=false},failure:function(E){}},D)})}function voteThumbsUp(D,C,B,A){establishActiveUser(function(){if(working){return }working=true;var E="event=voteThumbsUp&item="+D+"&type="+C+"&vote="+A;E+="&"+getSessionParams();YAHOO.util.Connect.asyncRequest("POST",SOCIAL_SERVICE,{success:function(F){var G=JSON.parse(F.responseText);if(G.result&&G.result=="OK"){B.parentNode.innerHTML="Voted!"}else{if(G.error){var H=G.error.replace(/-/," ");showPrompt("Voting Failed",H)}}working=false},failure:function(F){}},E)})}function addComment(D,B,A,F){var C=document.getElementById("commentText"+D)||document.getElementById("commentText");var E=C.value;if(!E||E.length<3){showPrompt("Please type something longer");return }A.disabled=true;saveComment(D,B,E,function(H){var G=JSON.parse(H.responseText);var J=$("commentCount");if(J){J.innerHTML=parseInt(J.innerHTML)+1;J.parentNode.style.display=""}var I=document.createElement("DIV");$("commentArea").appendChild(I);I.innerHTML=G.html;displaySuccessBox(D);A.disabled=false;if(F){F(G.html)}})}function saveComment(B,A,C,D){establishActiveUser(function(){if(working){return }working=true;var E="event=addComment&text="+encode(C)+"&type="+A+"&item="+B;E+="&forGecko=true";E+="&"+getSessionParams();YAHOO.util.Connect.asyncRequest("POST",COMMENT_SERVICE,{success:function(F){if(D){D(F)}working=false},failure:function(F){}},E)},"Please login to comment")}function deleteComment(C,A,B,D){establishActiveUser(function(){if(working){return }working=true;var E="event=deleteComment&type="+A+"&item="+C;E+="&"+getSessionParams();YAHOO.util.Connect.asyncRequest("POST",COMMENT_SERVICE,{success:function(F){if(F.responseText.indexOf("OK")>=0){var G=$("commentCount");if(G){G.innerHTML=parseInt(G.innerHTML)-1}B=YAHOO.util.Dom.getAncestorByClassName(B,"comment");if(B){B.style.display="none"}}working=false},failure:function(F){}},E)})}var rtes=[];var tempRte;var iconText=new Array("Random note","I like!...","Muchos appreciation","Keep'em coming","Great writing","I like your thinking","You helped a brother out","You cracked me up","Holy street cred!","You're hardcore","Scary stuff","What the...?");var iconBody=new Array("","You very good for make information.  Tzequi!","Danke. Thank-you. Merci. Gracias. Arigato!","Just keep writing, just keep writing, I`ll keep reading. :)","Your writing is a work of art.","I find myself strangely attracted to your brain.","If it weren`t for you I would have fallen into a pit of snakes and died a slow horrible death.  Instead I got all my travel expenses paid for, found the love of my life and lived happily ever after.","You so funny when you say stuff.","Thugs and gang leaders from around the world wish they were you right now.","Holy moly you`re one tough cookie!","How`d you keep it together?  I would`ve peed myself silly if I`d been in your boots!","?...");var iconImages=new Array("compliment_random.png","compliment_like.png","compliment_appreciation.png","compliment_coming.png","compliment_great.png","compliment_thinking.png","compliment_helped.png","compliment_crackup.png","compliment_street.png","compliment_hardcore.png","compliment_scary.png","compliment_whatthe.png");function isNewText(B){if(B=="<br>"){return false}for(var A=0;A<iconBody.length;A++){if(iconBody[A]==B){return false}}return true}function displayComplimentBox(D){var C=document.getElementById("rte"+D);document.getElementById("box"+D).style.display="";tempRte=new WYSIWYG_Editor("tempRte",C,"","http://ui.geckogo.com/ui/editor",392,100);tempRte.setModeToggle(hasUserPriv());tempRte.setAllowAnchors(hasUserPriv());rtes[D]=tempRte;rtes[D].display();var B="<form name='form"+D+"'>";for(var A=0;A<iconText.length;A++){if(A%2==0){B+="<div>"}B+="<div class='compliment-box'><input type='radio' class='compliment-radio' name='icons' value='"+A+"' onclick='if(!isNewText(rtes["+D+"].getContent().toString())) { rtes["+D+'].setContent("'+iconBody[A]+"\") }'><img src='http://ui.geckogo.com/ui/media/"+iconImages[A]+"'><span class='compliment-text'>"+iconText[A]+"</span></div>";if((A+1)%2==0||A==iconText.length-1){B+="</div>"}}B+="</form>";document.getElementById("icons"+D).innerHTML=B}function closeComplimentBox(A){document.getElementById("box"+A).style.display="none"}var reviewId=null;function sendItemCompliment(H){reviewId=H;if(!loggedIn){establishActiveUser(complimentCallback);return }var F=null;var B=document.forms;var D=0;for(var C=0;!F&&C<B.length;C++){if(B[C].name.indexOf(H+"")>0){F=B[C]}}for(var C=0;C<F.icons.length;C++){if(F.icons[C].checked){D=F.icons[C].value}}var E=document.getElementById("box"+H);var A=rtes[H].getContent();while(A.indexOf("<br>")==0){A=A.replace("<br>","")}for(var C=A.toString().length-4;C>0;C-=4){if(A.substring(C,C+4)=="<br>"){A=A.substring(0,C)}else{break}}A=encode(A)||"";var G="event=addCompliment&relatedId="+H+"&text="+A+"&type="+D;YAHOO.util.Connect.asyncRequest("POST","/services/Compliments",{success:function(I){var J=I.responseText;if(J=="OK"){E.innerHTML="<b>Thank you, your compliment is posted!</b>";setTimeout("location.reload(true);",3000)}else{alert(J)
}},failure:function(I){reportAjaxFailure()}},G)}function complimentCallback(A){if(A!="cancel"){loggedIn=true;sendItemCompliment(reviewId)}}function toggleCompliments(B){var A=document.getElementById("comments"+B);A.style.display=(A.style.display=="none")?"":"none"}function toggleInputBox(B){var A=document.getElementById("input"+B);A.style.display=(A.style.display=="none")?"":"none"}function displaySuccessBox(A){inputElem=document.getElementById("input"+A)||document.getElementById("inputBox");inputElem.style.display="none";succElem=document.getElementById("success"+A)||document.getElementById("successBox");succElem.style.display="";setTimeout("succElem.style.display='none';",4000)}function toggleCommentBox(D){var B=document.getElementById("comments"+D);var C=(B.style.display=="none")?"":"none";B.style.display=C;var A=document.getElementById("link"+D);if(A){A.style.display=C}}var profileUrl="/profile/";var addTipUrl="";var dBox;addOnload(init);var controls1,controls2;function init(){registerEnter(document.form.search,doSearch)}function showMore(A){var B=A.parentNode.previousSibling.previousSibling;B.style.display=""}function hideMore(A){var B=A.parentNode.parentNode;B.style.display="none"}function doSearch(){var B=document.form.search.value;if(B){var A=window.location.pathname;if(document.form.searchScope[0].checked){if(A.match(/(\/.+?)\//)){A=RegExp.$1}window.location=A+"?search="+encode(B);return }var C=document.getElementById("searchTerms");if(C&&C.innerText){B+=" "+C.innerText}window.location=A+"?search="+encode(B)}}function removeSearchTerm(){window.location=window.location.pathname}var bookingPage="tips";YAHOO.util.Event.onAvailable("bookingWidgetLodging",function(){new BookingWidget("bookingWidgetLodging",bookingCityName,bookingPage+"-side","calendar-travelers")});YAHOO.util.Event.onAvailable("bookingWidgetCombo",function(){var A="";if(!window.destAirport){destAirport=""}if(originAirports){A=originAirports.split(/,/)[0]}new BookingWidget("bookingWidgetCombo",bookingCityName,bookingPage+"-sideCombo","combo",A,destAirport)});YAHOO.util.Event.onContentReady("sideDealArea",function(){new BookingDeals("sideDealArea",bookingCityName,bookingGuideId,bookingPage+"-side","combined")});function BookingWidget(F,E,D,A,C,B){this.guideName=E;this.baseName=D.replace(/-/,"");this.originAirport=C;this.destAirport=B;$(F).innerHTML=this.getBookingView(A);this.setup(A)}BookingWidget.prototype.setup=function(A){this.setupBookingView(A);var B=this;YAHOO.util.Event.addListener($(this.baseName+"CheckRateButton"),"click",function(){B.checkRates(A)});if(A=="calendar-travelers"){this.urls={hotel:"http://rd.bookingbuddy.com/?r=bbs_geckogo_ros_v1_320250-h_006"}}else{if(A=="combo"){this.urls={air:"http://rd.bookingbuddy.com/?r=bbs_geckogo_ros_v2_320250-a_006",hotel:"http://rd.bookingbuddy.com/?r=bbs_geckogo_ros_v2_320250-h_006",car:"http://rd.bookingbuddy.com/?r=bbs_geckogo_ros_v2_320250-c_006",vacation:"http://rd.bookingbuddy.com/?r=bbs_geckogo_ros_v2_320250-v_006"}}else{this.urls={hotel:"http://rd.bookingbuddy.com/?r=bbs_geckogo_ros_300250-h_006"}}}};BookingWidget.prototype.setupBookingView=function(B){var H=this;var F=document.forms[this.baseName];if(B=="calendar-travelers"){this.dateField1=F[this.baseName+"Date1"];this.dateField2=F[this.baseName+"Date2"];var D=new Date();var E=D.getFullYear()%2000;D.setDate(D.getDate()+7);this.dateField1.value=(D.getMonth()+1)+"/"+D.getDate()+"/"+E;D.setDate(D.getDate()+7);this.dateField2.value=(D.getMonth()+1)+"/"+D.getDate()+"/"+E}else{if(B=="combo"){this.dateField1=F[this.baseName+"Date1"];this.dateField2=F[this.baseName+"Date2"];var D=new Date();var E=D.getFullYear()%2000;D.setDate(D.getDate()+7);this.dateField1.value=(D.getMonth()+1)+"/"+D.getDate()+"/"+E;D.setDate(D.getDate()+7);this.dateField2.value=(D.getMonth()+1)+"/"+D.getDate()+"/"+E;this.cityQuery=new YAHOO.util.XHRDataSource("/booking-buddy/ajax/");this.cityQuery.responseType=YAHOO.util.XHRDataSource.TYPE_JSON;this.cityQuery.responseSchema={resultsList:"items",fields:["value"]};this.cityQuery.doBeforeParseData=function(K,L,I){var J={items:L};return J};this.fromField=F[this.baseName+"From"];var G=document.createElement("DIV");this.fromField.parentNode.appendChild(G);G.className="autocomplete-results";this.acFrom=new YAHOO.widget.AutoComplete(this.fromField,G,this.cityQuery);this.acFrom.useShadow=true;this.acFrom.generateRequest=this.acRequestBuilder;this.acFrom.queryQuestionMark=false;this.toField=F[this.baseName+"To"];var A=document.createElement("DIV");this.toField.parentNode.appendChild(A);A.className="autocomplete-results";this.acTo=new YAHOO.widget.AutoComplete(this.toField,A,this.cityQuery);this.acTo.useShadow=true;this.acTo.generateRequest=this.acRequestBuilder;this.acTo.queryQuestionMark=false;var C=$(this.baseName+"Type").getElementsByTagName("INPUT");YAHOO.util.Event.addListener(C,"click",function(J){H.type=this.value;var I=(this.value=="air"||this.value=="vacation");$(H.baseName+"AirControls").style.display=(I)?"":"none"});this.fromField.value=this.originAirport;this.toField.value=(this.destAirport)?this.destAirport:this.guideName}else{this.monthField1=F[this.baseName+"Month1"];this.monthField2=F[this.baseName+"Month2"];this.dayField1=F[this.baseName+"Day1"];this.dayField2=F[this.baseName+"Day2"];this.travelerField=F[this.baseName+"Travelers"];this.renderMonths(this.monthField1);this.renderMonths(this.monthField2);this.renderDays(this.dayField1);this.renderDays(this.dayField2);var D=new Date();D.setDate(D.getDate()+7);this.monthField1.selectedIndex=D.getMonth();this.dayField1.selectedIndex=D.getDate();D.setDate(D.getDate()+7);this.monthField2.selectedIndex=D.getMonth();this.dayField2.selectedIndex=D.getDate()}}};BookingWidget.prototype.acRequestBuilder=function(C){var B={input:C,types:["airport"],limit:15};var A="?service=LocationSuggest.suggest&args=";A+=encodeParam(JSON.stringify(B));return A};BookingWidget.prototype.renderMonths=function(A){for(var B=0;B<SHORT_MONTHS.length;B++){var C=document.createElement("OPTION");C.innerHTML=SHORT_MONTHS[B];C.value=B+1;A.appendChild(C)}};BookingWidget.prototype.renderDays=function(A){for(var B=1;B<=31;B++){var C=document.createElement("OPTION");C.innerHTML=B;C.value=B;A.appendChild(C)}};BookingWidget.prototype.checkRates=function(C){var E=new Date();if(C=="combo"){fromDate=getDate(this.dateField1.value);toDate=getDate(this.dateField2.value)}else{if(C=="calendar-travelers"){fromDate=getDate(this.dateField1.value);toDate=getDate(this.dateField2.value)}else{fromDate=this.monthField1.value+"-"+this.dayField1.value+"-"+E.getFullYear();toDate=this.monthField2.value+"-"+this.dayField2.value+"-"+E.getFullYear()}}var H=this.guideName;var G="hotel";if(C=="combo"){H=this.toField.value;if(this.type){G=this.type}else{G="vacation"}}var A="1";var B=(this.travelerField)?this.travelerField.value:"1";var D=this.urls[G];D+="&num_travelers="+B;D+="&search_mode="+G;var F=(G=="air"||G=="vacation");if(C=="combo"&&F){D+="&search_type=roundtrip";D+="&departure_city="+this.fromField.value;D+="&arrival_city="+encodeParam(H);D+="&departure_date="+encodeParam(fromDate);D+="&return_date="+encodeParam(toDate)}else{if(C=="combo"&&G=="car"){D+="&pickup_city="+encodeParam(H);D+="&pickup_date="+encodeParam(fromDate);D+="&dropoff_date="+encodeParam(toDate)}else{D+="&arrival_city="+encodeParam(H);D+="&arrival_date="+encodeParam(fromDate);D+="&departure_date="+encodeParam(toDate);D+="&num_rooms="+A}}D+="&placement="+this.baseName;logAction("booking-widget",this.baseName,true,H+","+fromDate+","+toDate);openNewWindow(D)};function getDate(B){var C=B.split(/\//);var D=C[0];D=(D.length==2)?D:"0"+D;var A="20"+C[2];return D+"/"+C[1]+"/"+A}function encodeParam(A){A=A.replace(/%20/g," ");A=encode(A);A=A.replace(/-/g,"%2F");return A}BookingWidget.prototype.getBookingView=function(A){var B="";if(A=="calendar-travelers"){B+="<div><h2>Find Great Deals on Hotels in "+this.guideName+"</h2></div>";B+='<div class="check-controls"><form name="'+this.baseName+'">';B+='<div class="date-selector">Check-in:<br>';
B+='<input type="text" size="10" name="'+this.baseName+'Date1">';B+="<a href=\"javascript:openCalendar('"+this.baseName+'Date1\')">&nbsp;<img style="vertical-align:-4px" src="http://ui.geckogo.com/ui/media/calendar.png"></a>';B+='</div><div class="date-selector">Check-out:<br>';B+='<input type="text" size="10" name="'+this.baseName+'Date2">';B+="<a href=\"javascript:openCalendar('"+this.baseName+'Date2\')">&nbsp;<img style="vertical-align:-4px" src="http://ui.geckogo.com/ui/media/calendar.png"></a>';B+="</div>";B+='<div class="traveler-selector">Adults:<br>';B+='<select name="'+this.baseName+'Travelers"><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option></select>';B+="</div>";B+='<div class="find-hotels" id="'+this.baseName+'CheckRateButton">Search</div>';B+="</form></div>";B+='<div class="clear-empty"></div>'}else{if(A=="combo"){B+="<div><h2>Find Great Travel Deals in "+this.guideName+'</h2></div><form name="'+this.baseName+'">';B+='<div class="check-radios" id="'+this.baseName+'Type"><input type="radio" name="checkCombo" value="air"><span>Flights</span> <input type="radio" name="checkCombo" checked value="vacation"><span>Flights+Hotels</span> <input type="radio" name="checkCombo" value="hotel"><span>Hotels</span> <input type="radio" name="checkCombo" value="car"><span>Cars</span></div>';B+='<div class="check-controls-air" id="'+this.baseName+'AirControls">';B+='<div class="place-selector">From:<br>';B+='<input type="text" size="20" name="'+this.baseName+'From">';B+='</div><div class="place-selector">To:<br>';B+='<input type="text" size="20" name="'+this.baseName+'To">';B+="</div>";B+='</div><div class="check-controls">';B+='<div class="date-selector">From:<br>';B+='<input type="text" size="10" name="'+this.baseName+'Date1">';B+="<a href=\"javascript:openCalendar('"+this.baseName+'Date1\')">&nbsp;<img style="vertical-align:-4px" src="http://ui.geckogo.com/ui/media/calendar.png"></a>';B+='</div><div class="date-selector">To:<br>';B+='<input type="text" size="10" name="'+this.baseName+'Date2">';B+="<a href=\"javascript:openCalendar('"+this.baseName+'Date2\')">&nbsp;<img style="vertical-align:-4px" src="http://ui.geckogo.com/ui/media/calendar.png"></a>';B+="</div>";B+='<div class="traveler-selector">Adults:<br>';B+='<select name="'+this.baseName+'Travelers"><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option></select>';B+="</div>";B+='<div class="find-hotels" id="'+this.baseName+'CheckRateButton">Search</div>';B+="</div></form>";B+='<div class="clear-empty"></div>'}else{B+="<div>Planning to visit "+this.guideName+"?  Find the best rates for your stay:</div>";B+='<div class="check-controls"><form name="'+this.baseName+'">';B+='<div class="date-selector">';B+='<select name="'+this.baseName+'Month1" id="month1"></select>';B+='<select name="'+this.baseName+'Day1" id="day1"></select>';B+='</div> <div class="date-to"> to </div>';B+='<div class="date-selector">';B+='<select name="'+this.baseName+'Month2" id="month2"></select>';B+='<select name="'+this.baseName+'Day2" id="day2"></select>';B+='</div> <div class="find-hotels" id="'+this.baseName+'CheckRateButton">Find hotels</div>';B+="</form></div>";B+='<div class="clear-empty"></div>'}}return B};var calElem;function openCalendar(A){if(!calElem){calElem=document.createElement("div");document.body.appendChild(calElem);calElem.style.position="absolute";calElem.style.zIndex="1000"}calElem.style.display="";var B=A.replace(/Date\d/,"");var C=document.forms[B];var E=YAHOO.util.Dom.getXY(C[A]);E[1]+=5;YAHOO.util.Dom.setXY(calElem,E);var D=new YAHOO.widget.Calendar("cal",calElem,{title:"Select a date:",close:true,navigator:true});D.render();D.selectEvent.subscribe(function(G,H){var I=H[0].toString().split(",");var F=I[0].substring(2);I=I[1]+"/"+I[2]+"/"+F;D.hide();C[A].value=I})}function BookingDeals(E,D,C,B,A){this.guideName=D;this.guideId=C;this.baseName=B;this.elem=$(E);this.elem.innerHTML=this.getBookingView(A);this.setupBookingView(A)}BookingDeals.prototype.getBookingView=function(A){var D="";if(A=="tabbed"){D+="<div class='deal-container'>";D+="<div class='deal-header'>";D+="<div class='name'>Deals for "+this.guideName+" right now</div>";D+="</div>";D+="<div class='clear_fix labels' id='deal-tabs'>";for(var E in tabs){D+="<div id='"+E+"-label' class='deal-label"+(E=="car"?" last":"")+"'><a href='#' onclick='return false' class='tab-"+E+"'>"+tabs[E]+"</a></div>";tabs[E]=""}D+="</div>";D+="<div class='deal-body'>";for(var E in tabs){D+="<div id='"+E+"-body' "+(E==lastBookingBuddyType?"":"style='display:none'")+">Please wait while we get the deals...</div>"}D+="</div>";D+="</div>";D+="<div class='booking-provider'><span>Deals by <a href='http://www.bookingbuddy.com/'>BookingBuddy</a></span><br><span class='small'>*taxes, fees not included</span></div>"}else{var C=new Date();var B=SHORT_MONTHS[C.getMonth()]+" "+C.getDate();D+="<div class='deal-container'>";D+="<div class='deal-header'>";D+="<div class='name'>Best Deals for "+this.guideName+", "+B+"</div>";D+="</div>";D+="<div class='deal-body' id='dealBody'>";D+="</div>";D+="</div>";D+="<div class='booking-provider'><span>Deals by <a href='http://www.bookingbuddy.com/'>BookingBuddy</a></span><span class='small'>*taxes, fees not included</span></div>"}return D};BookingDeals.prototype.setupBookingView=function(A){var C=this;if(A=="tabbed"){this.getDeals($(lastBookingBuddyType+"-body"),lastBookingBuddyType,true);$(lastBookingBuddyType+"-label").className+=" selected";var D=$("deal-tabs");var B=D.getElementsByTagName("A");YAHOO.util.Event.addListener(B,"click",function(F){var E=this.className.replace(/tab-/,"");C.toggle(E)})}else{this.getDeals($("dealBody"),"Hotel",true)}};function encodeParam(A){A=A.replace(/%20/g," ");A=encode(A);A=A.replace(/-/g,"%2F");return A}var lastBookingBuddyType="Hotel";var tabs={};tabs.Hotel="HOTELS";tabs.Package="VACATION";tabs.Flight="AIRFARE";tabs.Cruise="CRUISE";tabs.Car="CAR";BookingDeals.prototype.getDeals=function(F,A,E){var D=this;var C="event=bookingBuddyDeals&limit=10&radius=25&guide="+this.guideId+"&type="+A;var B=window.deals[C];if(B){D.renderDeals(F,B,A,E)}else{YAHOO.util.Connect.asyncRequest("GET","/services/Guides?"+C,{success:function(G){var J=JSON.parse(G.responseText);var K=[];if(J.length){for(var H=0;H<J.length;H++){var I=J[H];if(I&&I.DealListing&&(!I.DealListing.ErrorInfo||!I.DealListing.ErrorInfo.ErrorText)){K=K.concat(I.DealListing.DealList.Deal)}}K.shuffle();if(K.length>7){K=K.slice(0,7)}}else{if(J&&J.DealListing&&(!J.DealListing.ErrorInfo||!J.DealListing.ErrorInfo.ErrorText)){K=J.DealListing.DealList.Deal;if(!K.length){K=[K]}}}window.deals[C]=K;D.renderDeals(F,K,A,E)},failure:function(G){}})}};window.deals={};BookingDeals.prototype.renderDeals=function(J,F,C,I){if(F.length==0){tabs[C]="No deals were found at this time.";if(I){this.elem.style.display="none"}else{J.innerHTML=tabs[C]}return }var G="";for(var E=0;E<F.length;E++){var D=F[E];var K=D.Title;var A=D.URL;A+="&placement="+this.baseName;A="/go.html?u="+encode(A)+"&t=booking-deals&m="+this.baseName;var H=D.Price;var B=D.SourceAdvertiserName;G+="<div class='clear_fix deal'>";G+="<div class='price'><a href='"+A+"'>"+H+"</a></div>";G+="<div class='details'>";G+="<div class='title'><a href='"+A+"'>"+K+"</a></div>";G+="<div class='source'><a href='"+A+"'>"+B+"</a></div>";G+="</div>";G+="</div>"}J.innerHTML=G;tabs[C]=G};BookingDeals.prototype.toggle=function(A){if(A==lastBookingBuddyType){return }$(lastBookingBuddyType+"-label").className="deal-label"+(lastBookingBuddyType=="car"?" last":"");$(A+"-label").className+=(A=="car"?" last":"")+" selected";$(lastBookingBuddyType+"-body").style.display="none";$(A+"-body").style.display="";lastBookingBuddyType=A;if(tabs[A]!=""){$(A+"-body").innerHTML=tabs[A]}else{this.getDeals($(lastBookingBuddyType+"-body"),lastBookingBuddyType,false)}};
