var rte;var interestListingId;var interestReviewRating;function InterestSlideshow(G,E,C,F,B,A,D){this.area=document.getElementById(G);this.addedArea=document.getElementById(C);this.noInterestArea=document.getElementById(E);this.interestItems=[];this.isLargePhoto=B;this.controlClicked=A;this.noResultCallback=D;this.params=F;interestSlideshow=this}InterestSlideshow.prototype.render=function(){this.refreshFeed(this.params)};InterestSlideshow.prototype.setImproveRecs=function(A){this.improveRecsFunx=A};InterestSlideshow.prototype.setGuide=function(A){this.guide=A};InterestSlideshow.prototype.refreshFeed=function(A){this.params=A;this.load()};InterestSlideshow.prototype.load=function(){var B="event=getInterests&getText=true";if(this.isLargePhoto){B+="&mostPopular=true"}B+="&mode=bigPic";if(this.params){B+="&"+this.params}if(this.guide){B+="&guide="+this.guide}B+="&noise="+Math.round(10000*Math.random());var A=this;YAHOO.util.Connect.asyncRequest("GET","/services/Listings?"+B,{success:function(D){try{var C=JSON.parse(D.responseText).results;this.interestItems=[];for(var E=0;E<C.length;E++){if(C[E].image){this.interestItems.push(C[E])}}if(this.isLargePhoto){this.interestItems.sort(function(H,G){return 0.5-Math.random()})}this.position=0;this.renderSlide(this.position)}catch(F){alert(F)}},failure:function(C){},scope:A})};InterestSlideshow.prototype.clearFeed=function(){this.interestItems.length=0;this.position=0;this.renderSlide(this.position)};InterestSlideshow.prototype.renderSlide=function(D){if(D>=0&&D<this.interestItems.length){var A=this.interestItems[D];var E;if(this.isLargePhoto){E=renderLargePhotoVersion(A,D,this.interestItems.length)}else{E=renderProfileVersion(this.interestItems[D])}this.area.innerHTML=E;if(this.noInterestArea){this.noInterestArea.style.display="none"}this.area.style.display="";var B=YAHOO.util.Dom.getElementsByClassName("pager-box","div",this.area);var G=this;for(var C=0;C<B.length;C++){var F=B[C];YAHOO.util.Event.addListener(F,"click",function(H){if(G.controlClicked){G.controlClicked()}});YAHOO.util.Event.addListener(F,"mouseover",function(H){var I=H.target;I.className=I.className+" over"});YAHOO.util.Event.addListener(F,"mouseout",function(H){var I=H.target;I.className=I.className.replace(/ over/,"")})}}else{if(this.noInterestArea){this.noInterestArea.style.display=""}this.area.style.display="none";if(this.noResultCallback){this.noResultCallback()}}};function navInterestIndex(A){interestSlideshow.goIndex(A)}function navInterestLeft(){interestSlideshow.goLeft()}function navInterestRight(){interestSlideshow.goRight()}InterestSlideshow.prototype.goLeft=function(){this.position--;this.renderSlide(this.position);if(window.location.href.match(/MyProfile/)){logAction("pic","flip-l")}else{logAction("hic","flip-l")}};InterestSlideshow.prototype.goRight=function(){this.position++;this.renderSlide(this.position);if(window.location.href.match(/MyProfile/)){logAction("pic","flip-r")}else{logAction("hic","flip-r")}};InterestSlideshow.prototype.goIndex=function(A){this.position=A;this.renderSlide(this.position);if(window.location.href.match(/MyProfile/)){logAction("pic","flip-p")}else{logAction("hic","flip-p")}};var loggedIn=isLoggedIn();var listingId;var userVote;function voteListingUp(A){interestSlideshow.voteListing(1,A)}function voteListingDown(A){interestSlideshow.voteListing(-1,A)}function voteCallback(A){if(A!="cancel"){loggedIn=true;interestSlideshow.voteListing(userVote,listingId)}}InterestSlideshow.prototype.voteListing=function(B,F,C){listingId=F;userVote=B;if(!loggedIn&&B>0){establishActiveUser(voteCallback);return }var A=C?2:0;var E="event=voteListing&vote="+B+"&id="+F+"&type="+A;var D=this;YAHOO.util.Connect.asyncRequest("POST","/services/Listings",{success:function(G){var H=getElementText("error",G.responseXML);if(H){}else{if(B>0){this.addedArea.style.display="";setTimeout("interestSlideshow.addedArea.style.display = 'none'",5000)}if(C){return }this.interestItems.splice(this.position,1);if(this.position+1<this.interestItems.length){this.position=(this.position==0)?-1:this.position-1;navInterestRight()}else{if(this.interestItems.length>0){this.position=1;navInterestLeft()}else{this.area.innerHTML="No more attractions to display."}}}},failure:function(G){},scope:D},E)};InterestSlideshow.prototype.setNavHandler=function(A){window.navTo=A};renderLargePhotoVersion=function(A,C,F){var E="";E+="<div class='interest-image'><img src='"+A.image+"' width='320' height='320'></div>";E+="<div class='interest-box-controls'>";if(C>0){E+="   <div class='pager-box' onclick='navInterestLeft()'>&lt;</div>"}else{E+="<div class='pager-box'></div>"}var H=5*Math.floor(C/5);for(var B=H;B<Math.min(H+5,F);B++){var D=(B==C)?"selected":"";E+="   <div class='pager-box "+D+"' onclick='navInterestIndex("+B+")'>"+(B+1)+"</div>"}if(C<F-1){E+="   <div class='pager-box' onclick='navInterestRight()'>&gt;</div>"}else{E+="<div class='pager-box'></div>"}E+="<div class='photo-upload-box' onclick='uploadPhoto()'></div>";E+="</div>";E+="<div class='interest-box-info-bg'></div>";E+="<div class='interest-box-info clear_fix' onclick='interestSlideshowClicked(\""+A.url+"\")'><div class='interest-name-info'>";E+="   <div class='interest-name'>"+A.name+"</div>";E+="   <div class='interest-guide-name'>"+A.guideName+"</div>";E+="</div><div class='interest-rating-info'>";E+="   <div>"+new StarRating(A.rating,5,"stars/rating-star",14,14).getHtml(true)+"</div>";var G=(A.reviewCount==1)?"1 review":A.reviewCount+" reviews";E+="   <div>"+G+"</div>";E+="</div></div>";return E};function interestSlideshowClicked(A){if(window.navTo){window.navTo(A)}else{window.location=A}}renderOldVersion=function(B){var D="<div style='height:84px;'><div class='name'><a class='bold' href='"+B.url+"'>"+B.name+"</a></div>";var G=B.id;if(B.reviewCount>0){var A=new StarRating(B.rating,5,"rating-star-s",14,14).getHtml();D+="<div class='review'><div class='star-rating'>"+A+"</div> ("+B.reviewCount+" reviews)</div>"}if(B.guideName){D+="<div style='color:#888888' class='italic bold'>"+B.guideName+"</div>"}if(B.text){D+="<div>"+prepareText(B.text,75)+" <a href='"+B.url+"'>(More info)</a></div>"}D+="</div>";var F="<div style='margin-top:5px; position:relative; right:2px'><a class='fake-link' onclick='voteListingUp("+G+")'><img src='http://ui.geckogo.com/ui/media/spacer.gif' class='imglisting_vote_up' alt='vote up'></a><a class='fake-link' style='margin-left:10px;' onclick='voteListingDown("+G+")'><img src='http://ui.geckogo.com/ui/media/spacer.gif' class='imglisting_vote_down' alt='vote down'></a></div>";var E="";E+="<table cellpadding='5px'><tr>";E+="<td class='top-align' style='width:60px'>";var C=(B.image)?B.image:"ui/media/types/qt/no-attraction.png";E+="<a href='"+B.url+"'><img src='"+C+"' width='60' height='60'></a>";E+="</td><td class='top-align'><div style='position:relative; bottom:4px; margin-left:-2px'>"+D+F+"</div></td>";E+="</tr></table>";return E};function renderProfileVersion(B){closeInterestReview();var C=(B.image)?B.image:"ui/media/types/qt/no-attraction.png";var D="";var F=B.id;D+="<div class='clear_fix profile-interests'>";D+="<div class='image'><a href='"+B.url+"'><img src='"+C+"' width='180' height='180'></a></div>";D+="<div class='info'>";D+="<div class='name'><a href='"+B.url+"' name='interestSlideshowTop'>"+B.name+"</a></div>";if(B.guideName){D+="<div class='guide'>"+B.guideName+"</div>"}if(B.reviewCount>0){var A=new StarRating(B.rating,5,"stars/rating-star-s",14,14).getHtml();D+="<div class='review'><span class='star-rating'>"+A+"</span>&nbsp;("+B.reviewCount+" reviews)</div>"}else{D+="<div class='review'>&nbsp;</div>"}var E=B.text?prepareText(B.text,160)+"&nbsp;<a href='"+B.url+"'>(More info)</a>":"&nbsp;";D+="<div class='desc'>"+E+"</div>";D+="<div class='controls clear_fix'>";D+="<div class='interested'><a class='fake-link' onclick='voteListingUp("+F+"); return false;'>I'm interested</a></div>";D+="<div class='been'><a class='fake-link' onclick='openInterestReview("+F+"); return false;'>I've been</div>";D+="<div class='not'><a class='fake-link' onclick='voteListingDown("+F+"); return false;'>Not interested</a></div>";D+="</div>";D+="<div class='link'><a href='#' onclick='improveRecs();return false'>Improve your recommendations</a></div>";D+="</div>";D+="</div>";return D}function improveRecs(){if(interestSlideshow.improveRecsFunx){interestSlideshow.improveRecsFunx()}}function closeInterestReview(){document.getElementById("interestReview").style.display="none"}var loadReviewHandler={success:function(B){var A=JSON.parse(B.responseText);renderReviewEditor(A.rating,A.text)},failure:function(A){}};function openInterestReview(B){interestListingId=B;var A="event=getReview&listing="+B;YAHOO.util.Connect.asyncRequest("POST","/services/Reviews",loadReviewHandler,A);window.location.hash="interestSlideshowTop"}function renderReviewEditor(C,E){interestSlideshow.voteListing(-1,interestListingId,true);var B="<div class='review-header'>Write a review</div><div id='interestReviewRating' class='star-rating-input'></div><div id='interestReviewArea'></div>";B+="<div style='padding:5px; text-align:right'><form name='editorForm'><a class='main-button' href='#' onclick='saveInterestReview(this);return false'><span>Save</span></a><a class='main-button' href='javascript:navInterestRight()'><span>Cancel</span></a></form></div>";var D=document.getElementById("interestReview");D.innerHTML=B;D.style.display="";var A=document.getElementById("interestReviewArea");rte=new WYSIWYG_Editor("rte",A,E,"http://ui.geckogo.com/ui/editor",451,200);rte.setModeToggle(hasUserPriv());rte.setAllowAnchors(hasUserPriv());rte.display();interestReviewRating=new StarRating(C,5,"stars/rating-star",20,19);interestReviewRating.renderSelector(document.getElementById("interestReviewRating"))}function saveInterestReview(A){var B=interestReviewRating.getRating();if(!B||B==0){alert("Please rate your review");return }var D=rte.getContent();if(D.length<40){alert("Please type something longer");rte.focus();return }startSpinner(A);var E=interestListingId;var C="event=saveReview&listing="+E+"&text="+encode(D);C+="&rating="+B;YAHOO.util.Connect.asyncRequest("POST","/services/Reviews",saveReviewHandler,C)}var saveReviewHandler={success:function(A){var B=JSON.parse(A.responseText);if(B.status=="OK"){endSpinner();closeInterestReview();document.getElementById("interestReviewAdded").style.display="";setTimeout("document.getElementById('interestReviewAdded').style.display = 'none'",5000);window.location.hash="interestBox";navInterestRight()}else{endSpinner()}},failure:function(A){endSpinner()}};
