//ff525f1374fbf58f860343618d1430be
var Details=new Class({Implements:[Options,Events],options:{},rating:[],starclass:[],review_forms:[],initialize:function(B){this.setOptions(B);if(snooth.options.user.id>0){if($("delete_wm_notes")!=null){$("delete_wm_notes").addEvent("click",function(C){if(confirm("Really delete winemaker's notes?")){window.location=snooth.options.site_url+"/delete-content/wine/notes/"+this.options.wine_data.id}new Event(C).stop()}.bind(this))}this.options.reviews.each(function(D,C){this.setup_review_display.attempt([D],this)},this)}this.setup_review.attempt([0],this);if($("groups-help")!=null){$("groups-help").removeEvents("click");$("groups-help").addEvent("click",function(){show_bubble("group-help")})}$$("#no-prices","#no-prices-link").each(function(C){C.removeEvents("click");C.addEvent("click",function(E){var D=(snooth.options.user.id>0)?1:0;show_bubble("out-of-stock",null,null,null,{wine_id:this.options.wine_data.id,active:D,user_id:snooth.options.user.id});new Event(E).stop()}.bind(this))}.bind(this));$$(".icon-vote").each(function(D){var C=D.getProperty("id").split("-");D.removeEvents("click");D.addEvent("click",function(E){if(!D.hasClass("icon-voted")&&this.options.reviews.contains(C[1].toInt())==false){this.vote(1,C[1],C[2])}new Event(E).stop()}.bind(this))}.bind(this));if($("claim-btn")){$("claim-btn").removeEvents("click");$("claim-btn").addEvent("click",function(C){new Event(C).stop();show_bubble("claim",null,null,null,{claimed:this.options.claimed,winery_code:this.options.winery_code,winery_name:this.options.winery_name})}.bind(this))}if($("image-viewer")){$$("#image-viewer, #image-viewer-text").each(function(C){C.addEvent("click",function(D){new Event(D).stop();window.open($("image-viewer").getProperty("href"),"wine_image","scrollbars=yes,resizable=yes,height=600,width=900")}.bind(this))}.bind(this))}if($("wine-image-upload-link")){$$("#wine-image-upload-link, #wine-image-upload-text").each(function(C){C.addEvent("click",function(D){new Event(D).stop();if(snooth.options.user.id>0){show_bubble("wine-image-upload",null,null,null,{wine_id:this.options.wine_data.id,wine_color:this.options.wine_data.color})}else{show_bubble("log-in",null,null,null,{rpng:9})}}.bind(this))}.bind(this))}var A=Cookie.read("inline_notification");if(A!=null){inline_notification(A,$("wine-top"),"after");Cookie.dispose("inline_notification",{domain:snooth.options.cdom,path:"/"})}this.initwiki();this.initrecipe();snooth.post_load("FusionCharts")},initwiki:function(){var A=$("wiki-edit");if(A==null){return }A.removeEvents("click");if(snooth.options.user.id==0){A.addEvent("click",function(){show_bubble("log-in")})}else{A.addEvent("click",function(){snooth.post_load("owwiki")})}},initrecipe:function(){var A=0;var C=$("recipe-pairing-"+A);while(C){var B=$("recipe-pairing-"+A+"-global-id").value;if($("recipe-pairing-"+A+"-vote")){$("recipe-pairing-"+A+"-up").click(this.recipe_pairing_vote.bind(this,[B,1,A]));$("recipe-pairing-"+A+"-down").click(this.recipe_pairing_vote.bind(this,[B,0,A]))}A+=1;C=$("recipe-pairing-"+A)}},init_ws:function(){snooth.post_load("sharing")},setup_review_display:function(A){$("edit-link-"+A).addEvent("click",function(B){this.edit_review.attempt([A],this);new Event(B).stop()}.bind(this));$("tweet-"+A).addEvent("click",function(B){__pl_trid=A;snooth.post_load("twitter");new Event(B).stop()}.bind(this));$("html-export-"+A).addEvent("click",function(B){show_bubble("html-export",null,null,null,{review_text:$("html-export-cont-"+A).innerHTML});new Event(B).stop()})},setup_review:function(A){$("review-form-"+A).removeEvents("submit");$("review-form-"+A).addEvent("submit",function(B){this.write_review.attempt([A],this);new Event(B).stop()}.bind(this));$("review-submit-"+A).removeEvents("click");$("review-submit-"+A).addEvent("click",function(B){this.write_review.attempt([A],this)}.bind(this));if($("review-cancel-"+A)!=null){$("review-cancel-"+A).addEvent("click",function(B){$("wine-review-form-"+A).addClass("hide");$("wine-review-box-"+A).removeClass("hide")}.bind(this))}$("review-text-"+A).addEvent("focus",function(){if(this.value==snooth.options.default_review_text){this.value=""}});$("review-text-"+A).autoresize();$("review-tags-"+A).addEvent("focus",function(){if(this.value==snooth.options.default_tag_text){this.value=""}});this.starclass[A]=$("wine-rating-"+A).getProperty("class").replace("star-rating ","");$$("#wine-rating-"+A+" li a").each(function(B){B.removeEvents("click");B.addEvent("click",function(C){$("wine-rating-"+A).removeClass(this.starclass[A]);this.rating[A]=B.get("text").toFloat();this.starclass[A]="starset"+(this.rating[A]*32);$("wine-rating-"+A).addClass(this.starclass[A]);new Event(C).stop()}.bind(this))}.bind(this));if($("wine-rating-"+A+"-0")!=null){$("wine-rating-"+A+"-0").removeEvents("click");$("wine-rating-"+A+"-0").addEvent("click",function(B){$("wine-rating-"+A).removeClass(this.starclass[A]);this.rating[A]=0;this.starclass[A]="starset0";$("wine-rating-"+A).addClass(this.starclass[A]);new Event(B).stop()}.bind(this))}$("review-help-"+A).addEvent("click",function(B){show_bubble("writing-review");new Event(B).stop()}.bind(this))},write_review:function(D){var A=$("review-text-"+D).value;var C=$("review-tags-"+D).value;var B=($("is-private-"+D).checked==1)?1:0;if(snooth.options.user.id==0){snooth.removeEvents("login-callback");snooth.addEvent("login-callback",this.write_review.bind(this,[D]));snooth.si_show()}else{var E=new Date();if(D==0&&(A==snooth.options.default_review_text||A=="")&&(C==snooth.options.default_tag_text||C=="")&&(this.rating[D]==null||this.rating[D]==0)){alert("Please add a rating/review.")}else{$("review-submit-"+D).removeEvents("click");new Request({url:snooth.options.site_url+"/rate/"+E.getTime()+"/",onComplete:function(G){if(D==0){Cookie.write("inline_notification","Thanks for your review",{duration:5,domain:snooth.options.cdom,path:"/"});var F=window.location.href.split("#");window.location.href=F[0]}else{$("wine-review-form-"+D).addClass("hide");$("wine-review-box-"+D).set("html",G);$("wine-review-box-"+D).removeClass("hide");this.setup_review_display(D);this.setup_review(D)}}.bind(this)}).post({edit:D,review:A,tags:C,wine_id:this.options.wine_data.id,rating:this.rating[D],rprivate:B,page:snooth.options.page,full_review:1})}}},edit_review:function(A){if(A==0){$("wine-review-form-"+A).removeClass("hide");$("wine-review-box-"+A).addClass("hide")}else{details.load_review_form.attempt([A],details)}},load_review_form:function(A){if(this.review_forms[A]==null){new Request.HTML({url:snooth.options.site_url+"/rate/",update:"wine-review-form-"+A,onComplete:function(){this.setup_review.attempt([A],this);this.review_forms[A]=1;$("wine-review-form-"+A).removeClass("hide");$("wine-review-box-"+A).addClass("hide")}.bind(this)}).post({edit:A,wine_id:this.options.wine_data.id,form_only:1})}else{$("wine-review-form-"+A).removeClass("hide");$("wine-review-box-"+A).addClass("hide")}},write_winery_notes:function(B,C){var A=snooth.options.site_url+"/rate/";new Request({url:A,onComplete:function(){hide_bubble("winery_notes_bubble");var D=window.location.href.split("#");window.location.href=D[0]}}).post({notes:B,wine_id:C})},vote:function(E,A,B){var D=new Date();var C=snooth.options.site_url+"/vote/"+E+"/"+A+"/"+B+"/"+D.getTime()+"/";new Request({url:C,onComplete:function(F){if(snooth.options.page=="details"){$("vote-header-"+A).set("text","Thanks!");$("num-votes-"+A).set("text",parseInt($("num-votes-"+A).get("text"))+1);$("v-"+A+"-1").addClass("icon-voted")}}}).post()},recipe_pairing_vote:function(C,B,A){new Request.JSON({url:snooth.options.site_url+"/recipe-pairing-vote/",onComplete:function(D){if(!D){show_generic_bubble("Sorry!","We were unable to count your vote. If you already voted on this pairing you may not vote again for 24 hours")}else{if(D.error){show_generic_bubble("Sorry!",D.error)}else{show_generic_bubble("Thanks!","Your vote has been counted and will be tallied within 24 hours");$("recipe-pairing-"+A+"-vote").set("html","<br /><em>Thanks!</em>")}}}}).post({global_id:C,wine_id:this.options.wine_data.id,positive:B})}});