$(function(){var a;function b(e,d){$("#X",d).val(e.x);$("#Y",d).val(e.y);$("#W",d).val(e.w);$("#H",d).val(e.h)}$(".photoPopup").click(function(c){$("#setCover").val("0");if($(this).attr("id")=="SetCoverButton"||$(this).attr("id")=="SetCoverButton2"){$("#setCover").val("1")}$("#redirect").val("0");if($(this).attr("id")=="redirectToPics"){$("#redirect").val("1")}if(DTD.IsAuthenticated){tb_show("Photo Upload","#TB_inline?height=225&width=600&inlineId=PhotoUploadContainer","",function(){var g=$(".cloned"),f=$("#imageUploadForm",g),d=$("#imageCropForm",g),e={url:DTD.TempUploadRoute,success:function(j){if(j.IsSuccessful){$(f).hide();$(d).show();var i=$("#tempFileUploadImage",g),h=[];i.attr("src",j.Path);$(i).load(function(){h.push($(this).width(),$(this).height());initSelectionValues=[((h[0]/10)),((h[0]/10)*9),((h[1]/10)),((h[1]/10)*9)];$("#imageUploadFileName",g).val(j.FileName);$("#imageUploadMimeType",g).val(j.MimeType);$("#planId",g).val(DTD.PlanId);a=$.Jcrop($("#tempFileUploadImage",g),{onSelect:b,aspectRatio:244/176,setSelect:[initSelectionValues[0],initSelectionValues[2],initSelectionValues[1],initSelectionValues[3]],trueSize:[h[0],h[1]],boxWidth:244,boxHeight:176})});$(d).submit(function(k){var l=a.tellSelect();if(l.w>0||l.h>0){b(l,g);$(this).find("input[type=image]").attr("disabled","disabled");$.post(DTD.PlanImageCropRoute,$(this).serialize(),function(m){if(m.IsSuccessful){if(!!m.Information){window.location=m.Information}else{window.location.reload()}}else{if(m.Information=="unauthenticated"){Membership.showLogin("Login in to continue...")}}},"json")}else{$("#crop-error",g).show();a.setSelect([initSelectionValues[0],initSelectionValues[2],initSelectionValues[1],initSelectionValues[3]])}k.preventDefault();return false})}else{alert(j.ErrorMessage)}},type:"post",dataType:"json"};$("#TB_blankClose",g).click(tb_remove);$(f).ajaxForm(e)})}else{Membership.showLogin()}c.preventDefault();return false})});function followerCount(b,a){$.get(DTD.FollowerCountRoute,{planId:DTD.PlanId,followAction:a},function(c){$(b).text(c.count)},"json")}function shareitCount(b,a){$.post(DTD.FollowerPlanRoute,{id:DTD.PlanId,followAction:a,follow:true},function(c){if(c.IsSuccessful){followerCount("#followCommunicateCount",3)}},"json")}$(function(){$("#likeLink").click(function(a){if(DTD.IsAuthenticated){$.post(DTD.FollowerPlanRoute,{id:DTD.PlanId,followAction:1,follow:true},function(d){if(d.Information=="unauthenticated"){Membership.showLogin()}if(d.IsSuccessful){followerCount("#followLikeCount",1);if(!$("#likeLink").hasClass("btn02b")){$("#likeLink").addClass("btn02b");pageTracker._trackPageview(document.location.pathname+document.location.search+" / like plan");var c=Math.random()+"",b=c*10000000000000;$("body").append('<iframe src="http://fls.doubleclick.net/activityi;src=1701343;type=planb126;cat=users618;ord=1;num='+b+'?" width="1" height="1" frameborder="0"></iframe>')}else{$(".tooltip01").show().click(function(){$(".tooltip01").hide()}).html("No Big deal but you already <strong>Liked</strong> my plan.").css({left:a.pageX-70,top:a.pageY+10})}}},"json")}else{$(".tooltip01").show().click(function(){$(".tooltip01").hide()}).html("I'd love your support but you need to <a href='/Membership/Register?TB_iframe=true&height=300&width=600' class='thickbox' title='Welcome to PlanBig'>signup</a> or <a href='/Login?TB_iframe=true&height=300&width=600' class='thickbox' title='Welcome back'>login</a>.").css({left:a.pageX-70,top:a.pageY+10})}return false});$("#subscribeLink").live("click",function(b){var a=$(this);if(DTD.IsAuthenticated){$.post(DTD.FollowerPlanRoute,{id:DTD.PlanId,followAction:2,follow:true},function(e){if(e.Information=="unauthenticated"){Membership.showLogin()}if(e.IsSuccessful){followerCount("#followSubscribeCount",2);$(a).attr("id","unsubscribeLink").find(".ico").text("Unwatch");pageTracker._trackPageview(document.location.pathname+document.location.search+" / watch plan");var d=Math.random()+"",c=d*10000000000000;$("body").append('<iframe src="http://fls.doubleclick.net/activityi;src=1701343;type=;cat=users290;ord=1;num='+c+'?" width="1" height="1" frameborder="0"></iframe>')}},"json")}else{$(".tooltip01").show().click(function(){$(".tooltip01").hide()}).html("You'll need to <a href='/Membership/Register?TB_iframe=true&height=300&width=600' class='thickbox' title='Welcome to PlanBig'>signup</a> or <a href='/Login?TB_iframe=true&height=300&width=600' class='thickbox' title='Welcome back'>login</a> so we know who to send updates to.").css({left:b.pageX-70,top:b.pageY+10})}return false});$("#unsubscribeLink").live("click",function(b){var a=$(this);$.post(DTD.FollowerPlanRoute,{id:DTD.PlanId,followAction:2,follow:false},function(c){if(c.Information=="unauthenticated"){Membership.showLogin()}if(c.IsSuccessful){followerCount("#followSubscribeCount",2);$(a).attr("id","subscribeLink").find(".ico").text("Watch");pageTracker._trackPageview(document.location.pathname+document.location.search+" / unwatch plan")}},"json");return false});followerCount("#followLikeCount",1);followerCount("#followSubscribeCount",2);followerCount("#followCommunicateCount",3);followerCount("#followHelpedCount",4)});