var ScrollToTop=ScrollToTop||{id:"ScrollToTop",control:$("#"+this.id),setup:function(){var a="<a id='"+ScrollToTop.id+"' href='#' class='Button WhiteButton Offscreen Indicator'></strong><span></span></a>";$("body").append(a);var b=$(window).height()/2;$(window).scroll(function(){(window.innerWidth?window.pageYOffset:document.documentElement.scrollTop)>=b?$("#ScrollToTop").removeClass("Offscreen"):$("#ScrollToTop").addClass("Offscreen")});$("#ScrollToTop").click(function(){$("html, body").animate({scrollTop:"0px"},
400);return!1})}},Modal=Modal||{setup:function(){$(document).keydown(function(a){if(27==a.keyCode){var b=$(".ModalContainer:visible").attr("id");b?Modal.close(b):$("#zoomScroll").length&&window.History.back();a.preventDefault()}})},show:function(a){"EmailModal"==a&&(document.getElementById("MessageRecipientName").value="",document.getElementById("MessageRecipientEmail").value="",document.getElementById("MessageBody").value="",document.getElementById("output").innerHTML="");var b=$("#"+a),a=$(".modal:first",
b);$("body").hasClass("noscrollf")||$("body").addClass("noscroll");b.show();var c=a.outerHeight()-50;a.css("margin-bottom","-"+c/2+"px");setTimeout(function(){b.addClass("visible");b.css("-webkit-transform","none")},1);return!1},close:function(a){var b=$("#"+a);0===$("#zoomScroll").length&&$("body").removeClass("noscroll");b.removeClass("visible");setTimeout(function(){b.hide();b.css("-webkit-transform","translateZ(0)")},251);return!1}},RepinDialog=RepinDialog||{setup:function(){var a=$("#Repin"),
b=$("form",a),c=$(".Buttons .Button",a),e=$("strong",c),d=$(".DescriptionTextarea",a),g=$(".mainerror",a);BoardPicker.setup("#Repin .BoardPicker",function(b){$("#repin_board",a).val(b)},function(b){$("#repin_board",a).val(b)});AddDialog.shareCheckboxes("Repin");c.click(function(){if(""==d.val()||"Describe your pin."==d.val())return g.html("Please enter a description.").slideDown(),!1;$("#Repin #repin_details").val(d.val());Tagging.loadTags(d,"#Repin #repin_comment_replies","#Repin #repin_tags","#Repin #repin_currency_holder");
b.submit();return!1});a.click(function(){alert("sfd");trackGAEvent("repin_submit","clicked","dialogue");if(c.hasClass("disabled"))return!1;c.addClass("disabled");e.html("Pinning...");$.ajax({type:"POST",url:$(this).attr("action"),dataType:"json",data:$(this).serialize(),success:function(b){if("success"==b.status){trackGAEvent("repin_submit","success","dialogue");var d=$(".PostSuccess",a);$(".BoardLink",d).attr("href",b.board_url).text(b.board_name);$(".PinLink",d).attr("href",b.repin_url);d.show();
setTimeout(function(){a.addClass("super")},1);setTimeout(function(){RepinDialog.reset()},2500);0<$("#CloseupRight").length&&$("#PinRepins").append('<a href="'+b.repin_user_url+'" class="CommenterImage" title="Rewished by <a href=\'#\'>'+b.repin_user_name+"</a> to <a href='#'>"+b.board_name+'</a>"><img src="'+b.repin_user_image+'" alt="Thumbnail of" /></a>')}else c.removeClass("disabled"),e.html("Pin It")},error:function(){c.removeAttr("disabled").html("Pin It")}});return!1})},grid:function(){$(".repin_link").live("click",
function(){trackGAEvent("repin_button","clicked","board_layout");pinID=$(this).parents(".pin").attr("data-id");RepinDialog.show(pinID);return!1})},show:function(a){var b=$("#Repin");$.getJSON("/pin/"+a+"/repindata/",{},function(c){$(".DescriptionTextarea",b).val(c.details).parent("li").addClass("val");var e='<img src="'+c.imgurl+'" />';c.video&&(e='<img src="'+media_url+'images/VideoIndicator.png" alt="Video Icon" class="video" />'+e);c.buyable&&$(".ImagePicker .price",b).html("$"+c.buyable);$(".Images",
b).html(e);$("#repin_pin_id",b).val(a);$("#repin_tags",b).val(c.tags.join(","));$("#repin_comment_replies",b).val(c.reply_usernames.join(","));$("form",b).attr("action","/pin/"+a+"/repin/");Tagging.initTextarea("#Repin .DescriptionTextarea");Tagging.priceTag("#Repin .DescriptionTextarea","#Repin .Images");Modal.show("Repin")})},reset:function(){document.getElementById("Header").style.zIndex=7;var a=$("#Repin");Modal.close("Repin");a.removeClass("visible").removeClass("super");$(".PostSuccess",a).hide();
$("form",a).attr("action","");$(".DescriptionTextarea",a).val("");$(".ImagePicker .Images",a).html("");$(".price",a).removeClass("visible").html("");$(".mainerror",a).html("");$(".Buttons .RedButton",a).removeClass("disabled");$(".Buttons .RedButton strong",a).html("Pin It");$("#repin_pin_id",a).val("")},append:function(){var a=$("#Repin");$("#PostSuccess").show();setTimeout(function(){a.addClass("super")},1);setTimeout(function(){RepinDialog.reset()},2500)}},BoardPicker=function(){return{setup:function(a,
b,c){var a=$(a),e=$(".BoardListOverlay",a.parent()),d=$(".BoardList",a),g=$(".CurrentBoard",a),j=$("ul",d);a.click(function(){d.show();e.show()});e.click(function(){d.hide();e.hide()});$("li",j).live("click",function(){g.text($(this).text());e.hide();d.hide();b&&b($(this).attr("data"));return!1});var a=$(".CreateBoard",d),h=$("input",a),f=$(".Button",a);$("strong",f);var i=$(".CreateBoardStatus",a);h.defaultValue("Create New Board");f.click(function(){if("disabled"==f.attr("disabled"))return!1;if("Create New Board"==
h.val())return i.html("Enter a board name").css("color","red").show(),!1;i.html("").hide();f.addClass("disabled").attr("disabled","disabled");$.post("/board/create/",{name:h.val(),pass_category:!0},function(a){a&&"success"==a.status?(j.append("<li data='"+a.id+"'><span>"+a.name+"</span></li>"),d.hide(),g.text(a.name),h.val("").blur(),f.removeClass("disabled").removeAttr("disabled"),c&&c(a.id)):(i.html(a.message).css("color","red").show(),f.removeClass("disabled").removeAttr("disabled"))},"json");
return!1})}}}();