LI.define("FollowCompany");LI.FollowCompany=function(a,b){this.container=a;this.companyId=b.companyId||1337;this.followBtn=Y$("a.IN-follow",a,!0);this.counterRight=Y$(".IN-right",a,!0);this.startFollowingURL=b.startFollowingURL||null;this.companyURL=b.companyURL||"http://www.linkedin.com/company/"+this.companyId;this.attemptLogin=this.processing=!1;this.confirmationPopupUrl=b.confirmationPopupUrl;this.initListeners();YEvent.onDOMReady(this.updateFrameSize,null,this)};
LI.FollowCompany.prototype={updateFrameSize:function(){var a,b;a=0;this.counterRight?(a=YDom.getRegion(this.followBtn).width,b=YDom.getRegion(this.counterRight).width,a=a+b+2):(a=Y$(".IN-followcompany",this.container,!0),a=YDom.getRegion(a).width);YDom.get("body").style.width=a+"px"},initListeners:function(){var a=this.container;YEvent.on(this.container,"click",this.handleFollow,this,!0);YEvent.on(this.container,"mousedown",function(b){YDom.addClass(a,"down")});YEvent.on(this.container,"mouseout",
function(b){YDom.removeClass(a,"down")})},handleFollow:function(a){var b=this;if(YDom.hasClass(this.followBtn,"IN-signin")){this.attemptLogin=!0;try{window.self.parent.login=function(){YDom.removeClass(b.followBtn,"IN-signin");b.startFollowing()}}catch(c){}return!1}var f=Y$(".title-text",this.container,!0);YDom.hasClass(f,"follow")?(YEvent.preventDefault(a),this.startFollowing()):YDom.hasClass(f,"following")&&(YEvent.stopEvent(a),window.open(this.companyURL))},startFollowing:function(){function a(a){if(this.attemptLogin){this.attemptLogin=
!1;try{window.self.parent.getXD().login()}catch(b){}}var c=a.statusText;a=a.responseText;var d=this.container,e=Y$(".title-text",d,!0),g=Y$(".count",d,!0);this.processing=!1;"OK"===c&&(e.innerHTML=LI.i18n.get("followCompanyFollowing"),YDom.removeClass(e,"follow"),YDom.addClass(e,"following"),d.setAttribute("title",LI.i18n.get("followCompanyYouAreFollowing")),this.updateFrameSize(),g&&"BizFollow.error.alreadyFollowing"!==a.error_code&&(g.innerHTML=YDom.get("post-follow-count").value),this.confirmationPopupUrl&&
(this.confirmationPopup.location.replace(this.confirmationPopupUrl),this.confirmationPopup.focus()))}function b(){this.processing=!1;this.confirmationPopup&&(this.confirmationPopup.close(),this.confirmationPopup=null)}if(!this.processing){this.processing=!0;var c=this.startFollowingURL+"\x26ajax\x3d";this.confirmationPopupUrl&&(this.confirmationPopup=window.open("about:blank"),this.confirmationPopup.blur(),window.focus());LI.asyncRequest("GET",c,{success:a,failure:b,timeout:15E3,scope:this},null)}}};