var SquidooComments=function(){return{show_on_close_el:null,current_form:null,initial_type:"visitor",fb_available:false,captcha_loaded:false,debug:false,log:function(a){if(this.debug&&window&&window.console){window.console.log(a)}},setFocus:function(a){var d=a.parents("li:eq(0)");if(d.length==0){d=a.parents("div.module:eq(0)");if(d.length==0){return}}var b=d.offset();var c=b.top-0;a.focus();jQuery("html,body").animate({scrollTop:c},250)},display_tabs:function(f){var c=jQuery("li.gb_li_visitor",this.current_form);var e=jQuery("li.gb_li_squidoo",this.current_form);var d=jQuery("li.gb_li_facebook",this.current_form);var b=jQuery("li.gb_li_twitter",this.current_form);var a=jQuery("div.gb_email_check",this.current_form);if(f.visitor){c.show()}else{c.hide()}if(f.squidoo){e.show()}else{e.hide()}if(f.facebook){d.show()}else{d.hide()}if(f.twitter){b.show()}else{b.hide()}if(f.email_notify){a.show()}else{a.hide()}},new_form:function(g,b,d,c,f){if(this.current_form){this.close()}var e=jQuery("#primary_comment_input").clone().removeAttr("id").appendTo(d);jQuery("input[name='comment_lmi']",e).val(g);jQuery("input[name='blurb_type']",e).val(b);var a=jQuery("textarea",e);if(a){setTimeout(function(){SquidooComments.setFocus(a)},100)}e.show();this.switch_type(this.initial_type);this.show_on_close_el=c;this.current_form=e;this.display_tabs(f)},reply_form:function(e,a,c,b,d){pageTracker._trackEvent("Guestbook","Reply");this.new_form(e,a,b,null,d);jQuery("input[name='comment_parent_id']",this.current_form).val(c)},close:function(){if(this.current_form){this.current_form.parent().empty();this.current_form=null;if(this.show_on_close_el){this.show_on_close_el.show();this.show_on_close_el=null}}},save:function(){var c=true;this.hide_error();var b=jQuery.trim(jQuery("textarea",this.current_form).val());if(b==""){c=false;message="Your comment cannot be blank. Please enter a comment and try again."}if(c){var a=jQuery("form",this.current_form);var d=a.serialize();pageTracker._trackEvent("Guestbook","Submit");jQuery.post("/utility/post_blurb",d,function(e){SquidooComments.post_save(e)})}else{this.show_error(message)}return false},show_error:function(a){jQuery("#comment_error_message",this.current_form).html(a).show();setTimeout(function(){SquidooComments.hide_error()},5000)},hide_error:function(){this.log("here");jQuery("#comment_error_message",this.current_form).fadeOut(2500)},load_more:function(f,h,a,b,d,g,c){var e={lmi:h,blurb_type:a,per_page:b,page:d,show_photos:g?"true":"false",strip_html:c?"true":"false"};pageTracker._trackEvent("Guestbook","LoadMore");jQuery.post("/utility/more_blurbs",e,function(i){if(i!="error"){jQuery(f).parent().replaceWith(i)}})},cancel:function(){pageTracker._trackEvent("Guestbook","Cancel");this.close()},switch_fb:function(){var a=Facebook_SDK_Helper.getUid();this.log("switch_fb");this.log(a);this.log("calling init");Facebook_SDK_Helper.subscribe(function(){SquidooComments.log("logged in facebook");SquidooComments.fb_available=true;SquidooComments.switch_type("facebook")},function(){SquidooComments.switch_type(SquidooComments.initial_type)});Facebook_SDK_Helper.login()},switch_type:function(b){this.log("switch_type");var a=false;if(b=="facebook"){if(!this.fb_available){return this.switch_fb()}}this.log("setting type: "+b);this.log(this.current_form);jQuery("input[name='comment_type']",this.current_form).val(b);jQuery("#gb_type_"+b).attr("checked","checked");jQuery("ul.gb_select li",this.current_form).removeClass("gb_selected");jQuery("ul.gb_select li.gb_li_"+b,this.current_form).addClass("gb_selected");jQuery("div.gb_type_elements div",this.current_form).hide();jQuery("div.gb_type_elements div.gb_elements_"+b,this.current_form).show();if((b=="facebook")||(b=="twitter")){jQuery("div.gb_captcha",this.current_form).hide()}else{jQuery("div.gb_captcha",this.current_form).show();if(!this.captcha_loaded){jQuery.get("/utility/load_captcha/new",function(c){jQuery("div.gb_captcha").html(c);SquidooComments.captcha_loaded=true})}}jQuery("#gb_type_"+b).attr("checked","checked");this.initial_type=b;return true},set_initial_type:function(a){this.log("set_initial_type: "+a);this.initial_type=a;jQuery("#gb_type_"+a).attr("checked","checked")},set_fb_available:function(a){this.fb_available=a},post_save:function(b){var a;var c=JSON.parse(b);this.captcha_loaded=false;if(this.current_form){a=this.current_form.parent()}if(c.status=="success"){if(c.post_type=="facebook"){if(c.fb_data){var f=c.fb_data;var e=null;if(f.lens_image!=""){e=[{type:"image",href:f.module_url,src:f.lens_image}]}FB.ui({method:"stream.publish",message:f.comment_body,attachment:{name:f.module_title,caption:"{*actor*} just commented on "+f.module_title,description:f.module_abstract,href:f.module_url,media:e},action_links:[{text:"Join Discussion",href:f.module_url},{text:"View Lens",href:f.lens_url}],user_message_prompt:"Invite your friends to join the discussion:"},function(g){if(g&&g.post_id){SquidooComments.log("Post was published.")}else{SquidooComments.log("Post was not published.")}})}}this.close();var d=jQuery('<div class="gb_notice">'+c.message+"</div>");a.append(d);setTimeout(function(){d.hide()},5000)}else{this.show_error(c.message)}},xableFollowerEmail:function(b){var c=b.attr("checked");var a=jQuery("div.gb_follower_email_div",this.current_form);if(c){a.show()}else{a.hide()}},dummy:function(){}}}();