/* detail.js */

var DETAIL={last_img:3,first_img:1,photoAnim:false,total_strip_width:0,comment_form_validated:false,commentMessage:[],replyMessage:[],commentId:0,show_error:function(A){$$("#lightbox .error_msg")[0].innerHTML=A;Element.show($$("#lightbox .error_row")[0]);},reload_captcha:function(C,B,A,D){C=$(C);C.src=VIVASTREET.captcha(B,A);if(D){D.value="";}C.hide();setTimeout(C.show.bind(C),10);},hide_form:function(A){var A=$(A);A.disable();A.getElementsByClassName("field").each(Element.hide);},process:function(c){var res=eval("("+c.responseText.strip()+")");
switch(res.code){case"error":break;case"comment_error":if(VIVASTREET.isLogged()){VIVASTREET.resetCaptcha("comment","captcha_image_comment","captcha",true);}else{VIVASTREET.resetCaptcha("register","captcha_image_comment","captcha",true);}Lightbox.updateLogMessage(__("add_comment_error"),"error");setTimeout(function(){Lightbox.hideLogger();Lightbox.unhide("add_comment");},2000);break;case"comment_added":Lightbox.hideLogger();Lightbox.close("add_comment");Lightbox.showNotification(__("add_comment_success"),2000);
break;case"classified_flagged":Lightbox.hideLogger();Lightbox.close("flag_classified");Lightbox.showNotification(__("flag_classified_success"),2000);$("moderation_links").hide();break;case"reply_sent":$$("#replyForm tr:not([id=error_row])").each(function(e){if(e.readAttribute("class")){e.hide();}});if(!VIVASTREET.isLogged()){$("send_reply_register").show();}break;}},validateRegister:function(A){var B=true;if(A.elements["mail_posting"].value.length<6){UTILS.showError($("mail_posting").up(1),true);
B=false;}else{UTILS.showError($("mail_posting").up(1),false);}if("login"!==DETAIL.authType&&A.elements["mail_posting"].value!==A.elements["mail_posting_confirm"].value){UTILS.showError($("mail_posting").up(1),true);UTILS.showError($("mail_posting_confirm").up(1),true);B=false;}if(A.elements["pass_posting"].value.length<3){UTILS.showError($("pass_posting").up(1),true);B=false;}else{UTILS.showError($("pass_posting").up(1),false);}if("login"!==DETAIL.authType&&A.elements["pseudo_posting"].value.length<3){UTILS.showError($("pseudo_posting").up(1),true);
B=false;}else{UTILS.showError($(A.elements["pseudo_posting"]).up(1),false);}if(A.elements["captcha"].value.length<5){UTILS.showError($("captcha").up(1),true);B=false;}else{UTILS.showError($("captcha").up(1),false);}if(!B){$("add_comment_error").show();return false;}VIVASTREET.authorize({action:DETAIL.authType?"force-"+DETAIL.authType:"register",email:A.elements["mail_posting"].value,password:A.elements["pass_posting"].value,username:A.elements["pseudo_posting"].value,captcha:A.elements["captcha"].value,checkDupe:true,onComplete:function(C){DETAIL.registerResponseHandler(C);
}.bind(DETAIL)});return true;},registerResponseHandler:function(C){var A=C.responseText.evalJSON();var B="";for(i=0;i<A.length;i++){B=A[i];switch(B.code){case"blocked_user":case"incorrect_email_password":case"invalid_email":case"register_failed":case"invalid_captcha":case"duplicate_email":LIGHTBOX.updateLog("add_comment_log","comment","notify",__("add_comment_validate")+" "+__("add_comment_failed"),false,true);LIGHTBOX.log("add_comment_log","register","error",B.message,true,true);if(VIVASTREET.isLogged()){VIVASTREET.resetCaptcha("comment","captcha_image_comment","captcha",true);
}else{VIVASTREET.resetCaptcha("register","captcha_image_comment","captcha",true);}$("add_comment_error").show();DETAIL.peExecuter.stop();if(B.code=="duplicate_email"){UTILS.showError($("mail_posting").up(1),true);UTILS.showError($("pass_posting").up(1),true);}else{if(B.code="invalid_captcha"){UTILS.showError($("captcha").up(1),true);}else{if(B.code="invalid_email"){UTILS.showError($("mail_posting").up(1),true);}else{if(B.code="incorrect_email_password"){UTILS.showError($("mail_posting").up(1),true);
UTILS.showError($("pass_posting").up(1),true);}}}}break;case"register_successful":break;case"login_successful":$$("input[name=logged_in]").each(function(D){D.value="1";});Cookie.set(VIVASTREET._cookie_name,C.responseText.gsub(/\s+/,""),30,VIVASTREET._gpc_domain);VIVASTREET.login();$("comment_logged_in_as").innerHTML=VIVASTREET.username.bold();$("logged_in_comment").value="1";$$(".comment_login").each(function(D){D.hide();});$$(".comment_logged").each(function(D){D.show();});$("reset_captcha_link").onclick=function(){VIVASTREET.resetCaptcha("comment","captcha_image_comment","captcha",true);
return false;};DETAIL.comment_form_validated=true;break;}}},setCommentAuth:function(A){$$(".comment_register").each(Element["register"==A?"show":"hide"]);Element["register"!==A?"show":"hide"]("forgot_password_link");this.authType=A;$("vs-comment-"+A).addClassName("active").blur();$("vs-comment-"+("register"==A?"login":"register")).removeClassName("active");},deleteComment:function(){if(this.commentId==0){return false;}LIGHTBOX.updateLog("delete_comment_log","comment","ajax-loader",__("delete_comment_deleting"),false,true);
new Ajax.Request(VIVASTREET._ajax_dir+"classified_comments.php",{method:"get",parameters:{classified_id:VIVASTREET._classified_id,comment_id:this.commentId},onComplete:DETAIL.deleteCommentProcess});},deleteCommentProcess:function(c){var response=eval("("+c.responseText.strip()+")");if(response.status=="success"){LIGHTBOX.updateLog("delete_comment_log","comment","done",__("delete_comment_success"),false,true);}else{LIGHTBOX.updateLog("delete_comment_log","comment","done",__("delete_comment_failed"),false,true);
}$("delete_comment_finished_buttons").show();},validateComment:function(A){Lightbox.hide("add_comment");Lightbox.showLogger();Lightbox.addLogMessage(__("add_comment_sending"),"loading");DETAIL.comment_form_validated=false;this.form=$(A);var B=[{"message":{action:"min",value:3,message:DETAIL.commentMessage["message_too_short"]}},{"message":{action:"max",value:500,message:DETAIL.commentMessage["message_too_long"]}},{"captcha":{action:"min",value:5,message:DETAIL.commentMessage["captcha_too_short"]}}];
Lightbox.updateLogMessage(__("add_comment_validate"),"loading");if(VIVASTREET.isLogged()){if(!UTILS.validate(A,B,function(C){Lightbox.updateLogMessage(C.message,"error");setTimeout(function(){Lightbox.hideLogger();Lightbox.unhide("add_comment");},2000);})){return false;}else{DETAIL.comment_form_validated=true;}DETAIL.submitCommentForm(A);}else{form_submitted=false;Lightbox.updateLogMessage(__("register_login_msg_holder"),"loading");if(!DETAIL.validateRegister(A)){Lightbox.updateLogMessage(__("postform_login_error"),"error");
setTimeout(function(){Lightbox.hideLogger();Lightbox.unhide("add_comment");},2000);return false;}DETAIL.peExecuter=new PeriodicalExecuter(function(C){if(!UTILS.validate(A,B,function(D){Lightbox.addLogMessage(D.message,"error");})){DETAIL.peExecuter.stop();setTimeout(function(){Lightbox.hideLogger();Lightbox.unhide("add_comment");if(VIVASTREET.isLogged()){VIVASTREET.resetCaptcha("comment","captcha_image_comment","captcha",true);}else{VIVASTREET.resetCaptcha("register","captcha_image_comment","captcha",true);
}},2000);return false;}else{DETAIL.comment_form_validated=DETAIL.comment_form_validated&&true;}if(DETAIL.comment_form_validated&&!form_submitted){form_submitted=true;DETAIL.submitCommentForm(A);C.stop();}else{if(form_submitted==true){C.stop();}}},0.8);}},submitCommentForm:function(A){if(!DETAIL.comment_form_validated){return false;}Lightbox.addLogMessage(__("add_comment_sending"),"loading");var B=DETAIL.formToObj(A);new Ajax.Request(A.action,{method:A.method,parameters:B,onSuccess:DETAIL.process});
},formatCommentForm:function(A){$("comment_ad_id").value=A;$("password_image").hide();if(VIVASTREET.isLogged()){VIVASTREET.resetCaptcha("comment","captcha_image_comment","captcha",true);$("reset_captcha_link").onclick=function(){VIVASTREET.resetCaptcha("comment","captcha_image_comment","captcha",true);return false;};DETAIL.setCommentAuth("login");$("logged_in_comment").value="1";$("comment_logged_in_as").innerHTML=VIVASTREET.username.bold();$$(".comment_login").each(function(B){B.hide();});$$(".comment_logged").each(function(B){B.show();
});}else{VIVASTREET.resetCaptcha("register","captcha_image_comment","captcha",true);$("reset_captcha_link").onclick=function(){VIVASTREET.resetCaptcha("register","captcha_image_comment","captcha",true);return false;};$("logged_in_comment").value="0";$$(".comment_login").each(function(B){B.show();});$$(".comment_logged").each(function(B){B.hide();});}},requestPassword:function(A){A=$(A);if(A.elements["mail_posting"].value.length<=0){UTILS.showError($("mail_posting").up(1),true);return false;}$("password_image").style.display="inline";
VIVASTREET.forgotPassword(A.elements["mail_posting"].value,function(B){if(B.code=="error"){UTILS.showError($("mail_posting").up(1),true);}else{$("forgot_password_link").innerHTML=B.message;$("pass_posting").value="";}$("password_image").style.display="none";});},validateFlag:function(A){this.form=$(A);var C=[{"message":{action:"min",value:3,message:"Your message is too short."}},{"message":{action:"max",value:2000,message:"Your message is too long."}},{"captcha":{action:"min",value:5,message:"Please enter the security text."}}];
if(!UTILS.validate(A,C)){return false;}var B=DETAIL.formToObj(A);Lightbox.hide("flag_classified");Lightbox.showLogger();Lightbox.addLogMessage(__("flag_classified_pending"),"loading");new Ajax.Request(A.action,{method:A.method,parameters:B,onSuccess:this.process.bind(this)});},validateReply:function(A){this.form=$(A);$("email_form_submit_button").disable();$("email_form_submit_button").removeClassName("vs-input-button-green");$("email_form_submit_button").addClassName("vs-input-button-grey");Lightbox.showLogger();
Lightbox.addLogMessage(__("send_reply_validation"),"loading");var B=[{"posting_user_email":{action:"min",value:3,message:__("postform_register_mail_posting")}},{"posting_user_email":{action:"email",message:__("postform_register_mail_posting")}},{"message":{action:"min",value:3,message:"message too short"}},{"message":{action:"max",value:1000,message:"message too long"}},{"message":{action:"default",value:$("message").readAttribute("title"),message:"message too short"}},{"captcha":{action:"min",value:5,message:__("postform_login_captcha")}}];
if(!UTILS.validate(A,B)){setTimeout(function(){Lightbox.hideLogger();$("email_form_submit_button").enable();$("email_form_submit_button").removeClassName("vs-input-button-grey");$("email_form_submit_button").addClassName("vs-input-button-green");},2000);return false;}Lightbox.updateLogMessage(__("send_reply_validation"),"success");Lightbox.addLogMessage(__("send_reply_sending"),"loading");document.replyForm.submit();},replySuccessHandler:function(c){try{var response=eval("("+c.responseText.strip()+")");
}catch(error){if(window.console){console.log("Could not parse JSON array!");}Lightbox.updateLogMessage(__("send_reply_error"),"error");setTimeout(Lightbox.hideLogger.bind(Lightbox),2000);return false;}if(response.status=="success"){setTimeout(function(){document.location="?status=success";},2000);Lightbox.updateLogMessage(response.message,"success");}else{Lightbox.updateLogMessage(response.message,"error");setTimeout(Lightbox.hideLogger.bind(Lightbox),2000);VIVASTREET.resetCaptcha("vivamail","captcha_image_vivamail","captcha",true);
UTILS.showError($("captcha").up(1),true);}},formToObj:function(B){var C=[];for(var A=0;A<B.elements.length;A++){if("checkbox"==B.elements[A].type.toLowerCase()&&false==B.elements[A].checked){continue;}C.push(encodeURIComponent(B.elements[A].name)+"="+encodeURIComponent(B.elements[A].value));}return(C.join("&"));},printAd:function(){parent.window.print();},initPhotoStrip:function(){if($("photo_strip_container")){var A=0;var B=0;$$("#photo_strip img").each(function(C){if(A<4){B+=C.width;A++;}DETAIL.total_strip_width+=C.width;
});if(B-4>617){B=621;}$("photo_strip_container").style.width=(B-4)+"px";}},prevImg:function(A){if(DETAIL.first_img-1>0&&DETAIL.photoAnim==false){if($("photo_strip").style.marginLeft&&$("photo_strip").style.marginLeft.length>0){marginLeft=parseInt($("photo_strip").style.marginLeft.substring(0,$("photo_strip").style.marginLeft.length-2));}else{marginLeft=0;}end=marginLeft+$("photo_"+(DETAIL.first_img-1)).width+5;if(end>0){end=0;}new Slider($("photo_strip"),marginLeft,end,"marginLeft",{duration:450,onStart:function(){DETAIL.photoAnim=true;
},onComplete:function(){DETAIL.photoAnim=false;}}).slide();DETAIL.last_img--;DETAIL.first_img--;if(DETAIL.first_img<=1){$("photo_strip_left").addClassName("photo-strip-arrow-left-disabled");}if(DETAIL.last_img<A){$("photo_strip_right").removeClassName("photo-strip-arrow-right-disabled");}}},nextImg:function(A){if(DETAIL.last_img+1<=A&&DETAIL.photoAnim==false){if($("photo_strip").style.marginLeft&&$("photo_strip").style.marginLeft.length>0){marginLeft=parseInt($("photo_strip").style.marginLeft.substring(0,$("photo_strip").style.marginLeft.length-2));
}else{marginLeft=0;}end=marginLeft-$("photo_"+DETAIL.first_img).width-5;if(end<-1*(DETAIL.total_strip_width-parseInt($("photo_strip_container").style.width))){end=-1*(DETAIL.total_strip_width-parseInt($("photo_strip_container").style.width));}new Slider($("photo_strip"),marginLeft,end,"marginLeft",{duration:450,onStart:function(){DETAIL.photoAnim=true;},onComplete:function(){DETAIL.photoAnim=false;}}).slide();DETAIL.last_img++;DETAIL.first_img++;if(DETAIL.first_img>1){$("photo_strip_left").removeClassName("photo-strip-arrow-left-disabled");
}if(DETAIL.last_img>=A){$("photo_strip_right").addClassName("photo-strip-arrow-right-disabled");}}},selectImg:function(A){if($(A)){$(A).blur();$$(".photo_thumb_selected").each(function(B){B.removeClassName("photo_thumb_selected");B.addClassName("photo_thumb");});$("current_photo").src=$(A).src.sub("/small/","/large/");$(A).removeClassName("photo_thumb");$(A).addClassName("photo_thumb_selected");}},observeExit:function(){$("post_free_ad").onclick=function(){return false;};Event.observe(document.body,"click",function(C){var B=Event.element(C);
if("post_free_ad"==B.up(3).getAttribute("id")||"post_free_ad"==B.getAttribute("id")||"logolink"==B.getAttribute("id")||"logo"==B.getAttribute("id")||"vs-detail-ad-right"!=B.up(3).getAttribute("id")&&"detail_menu_ad"!=B.up(2).getAttribute("id")&&("INPUT"==B.tagName||"A"==B.tagName)&&"publish"!=B.getAttribute("id")&&"modify"!=B.getAttribute("id")&&"cancel"!=B.getAttribute("id")&&"review_incomplete_continue"!=B.getAttribute("id")){if(B.getAttribute("id")=="review_incomplete_close"){LIGHTBOX.close("review_incomplete_exit");
return true;}if(B.getAttribute("id")=="lbCloseLinkA"){LIGHTBOX.close("review_incomplete_exit");return true;}var A=B.getAttribute("href");if(B.tagName=="IMG"){A=B.up().getAttribute("href");}Event.stop(C);LIGHTBOX.open({id:"review_incomplete_exit",content:"review_incomplete_exit.php?destination="+A,loading:{header:"Confirm",message:"Loading information..."}});}});},changePlan:function(C){var B=$$("table.vs-payment-form");if(0==B.length){return ;}var A=$$("table.vs-payment-form input","table.vs-payment-form select");
if(0<C.value){B[0].removeClassName("vs-trans-35");for(i=0;i<A.length;i++){Form.Element.enable(A[i]);}}else{if(0==C.value){B[0].addClassName("vs-trans-35");for(i=0;i<A.length;i++){Form.Element.disable(A[i]);}}}},getSelectedPaymentElement:function(){var B=false;for(var A=0;A<document.forms["process"].elements.length;A++){B=$(document.forms["process"].elements[A]);if(B.hasClassName("vs-payment-card-type")&&B.checked==true){return B;}}return false;},changePaymentType:function(B,A){if(A){B.checked=true;
}B=$(B);if(B.value=="paypal"){$("vs_add_card_form").hide();DETAIL.changeCard($("vs-card-paypal"));$$(".vs-stored-payment").each(function(C){C.removeClassName("active");});$("vs-card-paypal").up(1).addClassName("active");}else{if(B.value=="newcard"){$("vs_add_card_form").show();DETAIL.changeCard(DETAIL.getSelectedPaymentElement());$$(".vs-stored-payment").each(function(C){C.removeClassName("active");});$("vs_payment_type_newcard").up(1).addClassName("active");}else{if(null!==$("vs_add_card_form")){$("vs_add_card_form").hide();
$$(".vs-stored-payment").each(function(C){C.removeClassName("active");});$("stored_payment_"+B.value).addClassName("active");$$(".vs-payment-paypal").each(function(C){C.style.display="none";});$$(".vs-payment-ccform").each(function(C){C.style.display="none";});$$(".vs-payment-todito").each(function(C){C.style.display="none";});$$(".vs-payment-saved").each(function(C){C.style.display="";});}}}},changeCard:function(A){if(A.checked&&A.checked==false){return false;}if("paypal"==A.value){$$("tr.vs-payment-ccform").each(function(B){B.style.display="none";
});$$("tr.vs-payment-todito").each(function(B){B.style.display="none";});$$("tr.vs-payment-paypal").each(function(B){B.style.display="";});}else{if("todito"==A.value){$$("tr.vs-payment-ccform").each(function(B){B.style.display="none";});$$("tr.vs-payment-paypal").each(function(B){B.style.display="none";});$$("tr.vs-payment-todito").each(function(B){B.style.display="";});}else{$$("tr.vs-payment-paypal").each(function(B){B.style.display="none";});$$("tr.vs-payment-todito").each(function(B){B.style.display="none";
});$$("tr.vs-payment-ccform").each(function(B){B.style.display="";});}}$$("tr.vs-card-switchsolo").each(function(B){if("switchsolo"==A.value){B.style.display="";}else{B.style.display="none";}});},publishAd:function(){var A=document.createElement("input");A.setAttribute("type","hidden");A.setAttribute("name","publish");A.setAttribute("value","1");document.getElementById("process").appendChild(A);$("process").submit();},httpLinks:function(){var A=$$("#ad_detail div.description")[0];},processSendToFriend:function(){var A=$("frmSendToFriend");
UTILS.clearErrors("send_to_friend");var B=[{"friend_email":{action:"min",value:3,message:__("invalid_recipient_email")}},{"friend_email":{action:"email",message:__("invalid_recipient_email")}},{"message":{action:"min",value:3,message:__("message_too_short")}},{"message":{action:"max",value:1000,message:__("message_too_long")}},{"captcha":{action:"min",value:5,message:__("invalid_captcha")}}];if(VIVASTREET.isLogged()==false){B.push({"from_email":{action:"min",value:3,message:__("enter_from_email")}});
B.push({"from_email":{action:"email",message:__("invalid_from_email")}});}if(!UTILS.validate(A,B)){return false;}Lightbox.hide("send_to_friend");Lightbox.showLogger();Lightbox.addLogMessage(__("send_to_friend_sending"),"loading");$("reply_submit").observe("load",this.sendToFriendHandler.bind(this));$("frmSendToFriend").submit();},sendToFriendHandler:function(A){if(A.status=="error"){Lightbox.updateLogMessage(__("send_to_friend_error"),"error");Lightbox.addLogMessage(A.error_message,"error");Lightbox.hideLogger();
Lightbox.unhide("send_to_friend");if(A.error_code=="vivamail_invalid_captcha"){UTILS.showError($("captcha").up(1),true);}DETAIL.reload_captcha($("send_to_friend_captcha"),"vivamail","small",$("captcha"));}else{Lightbox.hideLogger();Lightbox.close("send_to_friend");Lightbox.showNotification(__("send_to_friend_success"),3000);}},Gallery:{init:function(){if("undefined"!=document.location.hash&&document.location.hash!=""){var A=document.location.hash.substr(1);this.switchPhoto(A);}},switchPhoto:function(A){if(this._index!=undefined){$("gallery_viewer_thumb_"+this._index).removeClassName("active");
}this._index=A;if($("gallery_viewer_thumb_"+this._index).hasClassName("vs-partners")){$("gallery_viewer_image").src=$("gallery_viewer_thumb_"+this._index).src;}else{$("gallery_viewer_image").src=this._imagePath+this._index+".jpg";}$("gallery_viewer_thumb_"+this._index).addClassName("active");},nextPhoto:function(){var A=(this._index==this._imageTotal?this._index=1:this._index+1);this.switchPhoto(A);},previousPhoto:function(){var A=(this._index==1?this._index=this._imageTotal:this._index-1);this.switchPhoto(A);
}},openContactWindow:function(url,code,type,custom_call){var width=660;var height=550;pageTracker._trackPageview("/click/"+pageTracker._tag+"/contact/"+type);window.open(url,code,"width="+width+",height="+height);if(custom_call){eval(custom_call);}return false;}};function detailAdTabs(){var A=$$("#detail_menu_ad a");A.each(function(B){if(B.id!="print_link"&&B.id!="add_comment_link"){B.onclick=function(){$$("#detail_menu_ad li").each(function(C){if(C.hasClassName("active")){C.removeClassName("active");
}});B.up(1).addClassName("active");if(B.href.endsWith("#comments")){getComments(1);}else{$("ad_comments").hide();}B.blur();};}});if(location.hash.length>4){hash=location.hash.sub("#","");$$("#detail_menu_ad a").each(function(B){if(B.href.endsWith(hash)&&!B.up(1).hasClassName("active")){B.up(1).addClassName("active");if(B.href.endsWith("#comments")){getComments(1);}}else{if(!B.href.endsWith(hash)){B.up(1).removeClassName("active");}}});}}function detailAuthCheck(){if(VIVASTREET.isLogged()){$$("input[name=logged_in]").each(function(A){A.value="1";
});$("posting_user_email").value=VIVASTREET.username;$("add_comment_form").show();}}function getComments(B){var A=VIVASTREET._ajax_dir+"classified_comments.php";new Ajax.Updater("ad_comments",A,{method:"post",parameters:"classified_id="+VIVASTREET._classified_id+"&country="+VIVASTREET.country_geo.code+"&a=get_comments&page="+B,onComplete:function(){if(null!=$("total_comments")){$("num_of_comments").innerHTML="("+$("total_comments").innerHTML+")";}$("ad_comments").show();}});}function changeAuthTab(A){A.siblings().each(function(B){B.removeClassName("selected");
});A.addClassName("selected");A.blur();}function formatMailForm(A){$("posting_user_email_recipient").innerHTML=A;VIVASTREET.resetCaptcha("vivamail","captcha_image_vivamail","captcha");if(VIVASTREET.isLogged()){$("logged_in_reply").value="1";$("posting_user_email").value=VIVASTREET.email;$("posting_user_email_input").hide();$("posting_user_email_div").innerHTML=VIVASTREET.username;$("posting_user_email_div").show();}else{if($("copy_message")){$("copy_message").disabled=false;$("copy_message_li").show();
}}}function formatFlagForm(B,A){$("add_flag").selectedIndex=B;$("flag_ad_id").value=A;VIVASTREET.resetCaptcha("flag","captcha_image_flag","captcha_flag");$("add_flag").style.visibility="visible";}function formatSendToFriendForm(A){if(VIVASTREET.isLogged()){$("trSendToFriendFromEmail").hide();$("strongUsernameContainer").innerHTML=VIVASTREET.username;}else{$("trSendToFriendFromUsername").hide();}VIVASTREET.resetCaptcha("vivamail","send_to_friend_captcha","captcha",true);}FastInit.addOnLoad(function(){setroll("vs-similar-ads-header","vs-similar-ads-list");
$$("#vivastreet.detail tr.vs-summary-sponsor").each(function(A){A.onclick=function(B){window.open(A.readAttribute("rel"));return false;};A.onmouseover=function(B){A.addClassName("vs-ad-hover");};A.onmouseout=function(B){A.removeClassName("vs-ad-hover");};});if(null!==$("message")){$("message").setStyle({color:"#888888"});$("message").onclick=function(){$("message").innerHTML="";$("message").setStyle({color:"#000000"});$("message").onclick=function(){};};}});var Slider=Class.create();Slider.prototype={initialize:function(C,E,A,D,B){if(typeof (B)=="undefined"){B={};
}this.start=E;this.end=A;this.change=(A-E);this.duration=B.duration||400;this.time=this.timeChange=0;this.el=$(C);this.property=D;this.onStart=B.onStart||function(F,G){if(G.end>G.start){F.style.display="block";}};this.onComplete=B.onComplete||function(F,G){if(G.end<G.start){F.style.display="none";}};},linear:function(){return this.change*this.timeChange/this.duration+this.start;},sineInOut:function(){return -this.change/2*(Math.cos(Math.PI*this.timeChange/this.duration)-1)+this.start;},slide:function(){if(this.el.style[this.property]!=(this.end)+"px"){this.el.style[this.property]=(this.start)+"px";
}setTimeout(this.onStart.bind(this,this.el,{start:this.start,end:this.end}),10);this.time=new Date().getTime();new PeriodicalExecuter(this.setStyle.bind(this),0.02);},setStyle:function(A){var B=new Date().getTime();if(B<this.time+this.duration&&this.el.style[this.property]!=(this.end)+"px"){this.timeChange=B-this.time;this.el.style[this.property]=(this.sineInOut())+"px";}else{this.el.style[this.property]=(this.end)+"px";setTimeout(this.onComplete.bind(this,this.el,{start:this.start,end:this.end}),10);
A.stop();}}};

/* search.js */

function highlightWord(B,C){if(B.hasChildNodes){var A;for(A=0;A<B.childNodes.length;A++){highlightWord(B.childNodes[A],C);}}if(B.nodeType==3){tempNodeVal=B.nodeValue.toLowerCase();tempWordVal=C.toLowerCase();if(tempNodeVal.indexOf(tempWordVal)!=-1){pn=B.parentNode;checkn=pn;while(checkn.nodeType!=9&&checkn.nodeName.toLowerCase()!="body"){if(checkn.className.match(/\bnosearchhi\b/)){return ;}checkn=checkn.parentNode;}if(pn.className!="searchword"){nv=B.nodeValue;ni=tempNodeVal.indexOf(tempWordVal);
before=document.createTextNode(nv.substr(0,ni));docWordVal=nv.substr(ni,C.length);after=document.createTextNode(nv.substr(ni+C.length));hiwordtext=document.createTextNode(docWordVal);hiword=document.createElement("font");hiword.className="searchword";hiword.appendChild(hiwordtext);pn.insertBefore(before,B);pn.insertBefore(hiword,B);pn.insertBefore(after,B);pn.removeChild(B);}}}}var Url={encode:function(A){return escape(this._utf8_encode(A));},decode:function(A){return this._utf8_decode(unescape(A));
},_utf8_encode:function(B){B=B.replace(/\r\n/g,"\n");var A="";for(var D=0;D<B.length;D++){var C=B.charCodeAt(D);if(C<128){A+=String.fromCharCode(C);}else{if((C>127)&&(C<2048)){A+=String.fromCharCode((C>>6)|192);A+=String.fromCharCode((C&63)|128);}else{A+=String.fromCharCode((C>>12)|224);A+=String.fromCharCode(((C>>6)&63)|128);A+=String.fromCharCode((C&63)|128);}}}return A;},_utf8_decode:function(A){var B="";var C=0;var D=c1=c2=0;while(C<A.length){D=A.charCodeAt(C);if(D<128){B+=String.fromCharCode(D);
C++;}else{if((D>191)&&(D<224)){c2=A.charCodeAt(C+1);B+=String.fromCharCode(((D&31)<<6)|(c2&63));C+=2;}else{c2=A.charCodeAt(C+1);c3=A.charCodeAt(C+2);B+=String.fromCharCode(((D&15)<<12)|((c2&63)<<6)|(c3&63));C+=3;}}}return B;}};function searchHighlight(){if(Cookie.get("vs-search-keywords")){var A=Cookie.get("vs-search-keywords");}else{if(window.query&&window.query.keywords&&(window.query.keywords.length>0)){var A=window.query.keywords;}else{return ;}}if(A.length<=1){return false;}A=A.replace("+"," ");
$$(".vs-search-word-container").each(function(B){highlightWord(B,A);});}FastInit.addOnLoad(function(){$$(".highlight").each(function(A){A.onmouseover=function(){this.addClassName("light_grey");};A.onmouseout=function(){this.removeClassName("light_grey");};Event.observe(A,"click",function(C){var B=Event.element(C);if(B.hasClassName("vs-fav-image")){return ;}if(A.down(1).href){location.href=A.down(1).href.toString();}else{if(A.down(2).href){location.href=A.down(2).href.toString();}else{if(A.down(3).href){location.href=A.down(3).href.toString();
}}}});});});var SEARCHFORM=new Object();SEARCHFORM={options:new Object(),links:new Object(),init:function(){$$("div.selectMultiple").each(function(B){var A=B.readAttribute("rel");var F=B.getElementsBySelector("input.text")[0];if(SEARCHFORM.options[A]){var C=SEARCHFORM.options[A];}else{return true;}if(SEARCHFORM.links[A]&&document.getElementsByName(SEARCHFORM.links[A]).length==1){var D=document.getElementsByName(SEARCHFORM.links[A])[0];}else{SEARCHFORM.drawOptions(B,C,false);return true;}if(D.selectedIndex>0&&D.options[D.selectedIndex].value.toLowerCase().gsub(/([\/\à\ \/\'])/,"-").gsub(/(-{1,})/,"-").gsub(/([^\S+])/,"-")!=""){var E=D.options[D.selectedIndex].value.toLowerCase().gsub(/([\/\à\ \/\'])/,"-").gsub(/(-{1,})/,"-").gsub(/([^\S+])/,"-");
if(C[E]){SEARCHFORM.drawOptions(B,C[E],false);}}else{SEARCHFORM.setToEmpty(B,VIVASTREET.captions["select_previous"]+" "+D.options[0].text);}});},drawOptions:function(J,A,G){var B=J.readAttribute("rel");var H=J.getElementsBySelector("ul")[0];var F="";var L;var K;var I;var C=0;if(!G){G=false;}for(var E in A){I=false;L=E;K=A[E];if(false==G&&window.query[B]){for(var D in window.query[B]){if(window.console&&typeof (window.query[B][D])=="string"){console.log("Trying ("+D+") "+Url.decode(window.query[B][D])+" : "+L);
}if(typeof (window.query[B][D])=="string"&&Url.decode(window.query[B][D]).gsub(/\+/," ")==L){I=true;break;}if(typeof (window.query[B][Url.decode(D)])=="string"&&window.query[B][Url.decode(D)].gsub(/\+/," ")==L){I=true;break;}}}F+='<li><label for="'+B+"_"+C+'"><input'+(I==true?' checked="checked"':"")+' style="border-width:0px;" type="checkbox" id="'+B+"_"+C+'" name="'+B+'[]" value="'+L+'" />'+K+"</label></li>";C++;}H.update(F);SEARCHFORM.selectMultiples(J);},resetMultipleSelect:function(B){$$("#ul_"+$(B).up().readAttribute("rel")+' input[type="checkbox"]').each(function(C){C.checked=false;
$(C.parentNode.parentNode).removeClassName("selected");});var A="value_"+$(B).up().readAttribute("rel");$(A).value=$(A).getAttribute("title");},selectMultiples:function(A){var B=function(E){setroll("rollover_"+E.readAttribute("rel"),"ul_"+E.readAttribute("rel"),false);var D=$("value_"+$(E).readAttribute("rel"));var C=false;if(D){D.value="";}$("ul_"+E.readAttribute("rel")).childElements().each(function(F){F.onmouseover=function(){this.addClassName("altrow");};F.onmouseout=function(){this.removeClassName("altrow");
};var G=F.down(1);if(G.checked&&D){D.value+=(D.value.length?", ":"")+G.value;$(G.parentNode.parentNode).addClassName("selected");C=true;}G.onclick=function(){if(this.checked){var H=$("value_"+$(this).up(3).readAttribute("rel"));H.value=H.value.gsub(H.readAttribute("title"),"");H.value+=(H.value.length?", ":"")+this.value;$(this.parentNode.parentNode).addClassName("selected");}else{var H=$("value_"+$(this).up(3).readAttribute("rel"));if(H.value.indexOf(", "+this.value)!=-1){H.value=H.value.gsub(", "+this.value,"");
}else{H.value=H.value.gsub(this.value,"");}if(H.value.substr(0,2)==", "){H.value=H.value.substr(2);}if(H.value==""){H.value=H.readAttribute("title");}$(this.parentNode.parentNode).removeClassName("selected");}};});if(C==false){SEARCHFORM.resetMultipleSelect($("ul_"+E.readAttribute("rel")));}};if(A){B(A);}else{$$("#search .selectMultiple").each(B);}},setToEmpty:function(A,B){var D=A.getElementsBySelector("ul")[0];var C=A.getElementsBySelector("input.text")[0];D.update("");C.value=B;unsetroll("rollover_"+A.readAttribute("rel"),"ul_"+A.readAttribute("rel"));
},showSection:function(G,C,F){var B=$(G);var A="";for(var E in SEARCHFORM.links){if(SEARCHFORM.links[E]==B.readAttribute("name")){A=E;break;}}if(""==A){return true;}var H=$("multi_"+A);var D=B.options[B.selectedIndex].value.toLowerCase().gsub(/([\/\à\ \/\'])/,"-").gsub(/(-{1,})/,"-").gsub(/([^\S+])/,"-");if(D==""){if(B.selectedIndex==0){SEARCHFORM.setToEmpty(H,VIVASTREET.captions["select_previous"]+" "+B.options[0].text);}else{SEARCHFORM.setToEmpty(H,VIVASTREET.captions["no_select_options"]);}}else{if(SEARCHFORM.options[A][D]){SEARCHFORM.drawOptions(H,SEARCHFORM.options[A][D],true);
SEARCHFORM.selectMultiples(H);}else{SEARCHFORM.setToEmpty(H,VIVASTREET.captions["no_select_options"]);}}return true;}};

