var MyBBS=function(n){function tt(n){n=n||0,r>0&&!y?r=0:n>0&&(r=n)}function d(n){n=n||0,f==""||k?n!=""&&(f=n):f=""}function nt(n){n=n||0,u>0&&!w?u=0:n>0&&(u=n)}function g(n,i){typeof n=="undefined"&&(n=!0),i=i||function(){return!0},typeof t.UserUtilities.CheckLoginStatus=="function"?t.UserUtilities.CheckLoginStatus(function(t){t=t||{UserLoggedInSuccessfully:!1,UserGreeting:"",IsBroker:!1,OnBrokerLoginSuccessfulRedirectUrl:"",ReportedAbuseQuestionIDs:[],ReportedAbuseAnswerIDs:[],SavedSearches:[]};var r=!!t.UserLoggedInSuccessfully;r&&o({UserLoggedInSuccessfully:!0,UserGreeting:t.UserGreeting||"",IsBroker:!!t.IsBroker},n),i()},function(){i()}):i()}function a(){var n=$("#txtUserName"),u=$("#txtPassword"),r=!1,f=!1;n.val().length==0?r=!0:n.val()==n.attr("defaultValue")&&(r=!0),u.val().length==0&&(f=!0),r&&f?(alert("Please enter your User Name and Password"),n.focus()):r?(alert("Please enter your User Name"),n.focus()):f?(alert("Please enter your Password"),u.focus()):($("#divDisableMyBBSLogin").show(),h?i.Users&&typeof Users.Login=="function"&&Users.Login(n.val(),u.val(),e):t.LinuxLogIn(n.val(),u.val()))}function o(n,u){var e,f;n=n||{UserLoggedInSuccessfully:!1,UserGreeting:"",IsBroker:!1,OnBrokerLoginSuccessfulRedirectUrl:"",ReportedAbuseQuestionIDs:[],ReportedAbuseAnswerIDs:[],SavedSearches:[],WatchedListingListNumbers:[]},t.IsUserLoggedIn=!!n.UserLoggedInSuccessfully,e=!!n.IsBroker,typeof u=="undefined"&&(u=!0),userGreeting=n.UserGreeting||"",$("#myBBSTopNav").addClass("loggedIn"),userGreeting.length>0&&$("#lblMyBBSGreeting").html(userGreeting),$("#txtUserName").val("").blur(),$("#txtPassword").val(""),$("#loginPopupOverlay").removeClass("loginFailed"),$("#divDisableMyBBSLogin").hide(),e&&(f=$("#hlMyBBSMenu"),f&&f.parent("li").removeClass("mybbsUser").addClass("brokerworksUser")),(n.WatchedListingListNumbers||[]).length>0&&i.Listings&&typeof Listings.OnLoginSuccessful=="function"&&Listings.OnLoginSuccessful([],n.WatchedListingListNumbers),$("#bbs_page_overlay").unbind("click"),u&&$(document).trigger("OnMyBBSLoginSuccessful",[r,{IsBroker:e,OnBrokerLoginSuccessfulRedirectUrl:n.OnBrokerLoginSuccessfulRedirectUrl||""}])}function s(){$("#loginPopupOverlay").removeClass("loginFailed").addClass("loginFailed"),$("#txtPassword").val(""),$("#divDisableMyBBSLogin").hide()}var t={UserUtilities:{}},i=this,ot=i.Utilities||{},h=n.IsDotNet||!1,et=n.CookieDomain||".bizbuysell.com",r=n.RegistrationType||0,y=!1,b=n.RegistrationTypeQueryStringKey||"m_rt",f=n.OnRegistrationSuccessfulRedirectUrl||"",k=!1,p=n.OnRegistrationSuccessfulRedirectUrlQueryStringKey||"returnurl",u=n.PurchasedProductID||0,w=!1,l=n.PurchasedProductIDQueryStringKey||"m_ppid",rt=n.ToggleSignInPopupOptions||{},e=n.LoginType||0,it=!!n.IsUserLoggedIn,c=!1,ft=!!n.RedirectBrokerOnSuccessfulLogin,v="Already a BizBuySell Member?",ut="Log In to Continue";return t.IsUserLoggedIn=it,r>0&&(y=!0),f!=""&&(k=!0),u>0&&(w=!0),t.LinuxLogOut=function(){typeof t.UserUtilities.Logout=="function"&&t.UserUtilities.Logout(function(n){n=!!n,n&&(top.location="http://www.bizbuysell.com/")})},t.LinuxLogIn=function(n,r){typeof t.UserUtilities.Login=="function"&&t.UserUtilities.Login(n,r,e,function(n){n=n||{UserLoggedInSuccessfully:!1,UserGreeting:"",IsBroker:!1,OnBrokerLoginSuccessfulRedirectUrl:"",ReportedAbuseQuestionIDs:[],ReportedAbuseAnswerIDs:[],SavedSearches:[]};var r=!!n.UserLoggedInSuccessfully;r?(o(n),$("#loginPopupOverlay.loginFailed").removeClass("loginFailed"),t.ToggleSignInPopup(),i.Listings&&typeof Listings.OnLoginSuccessful=="function"&&Listings.OnLoginSuccessful(n.SavedSearches)):s()},function(){s()})},t.ToggleSignInPopup=function(n){var s,r,u,t;n=n||{};var e=n.ExistingEmailAddress||"",o=n.CustomLoginHeading||"",h=n.CustomLoginSubHeading||"",f=n.CustomExistingLoginSubHeading||"",c=!!n.HideHeading,l=!!n.HideBBSRegisterSection;o!=""?(v=$("#myBBSLoginHeading").html(),$("#myBBSLoginHeading").html(o)):$("#myBBSLoginHeading").html(v),f!=""?(ut=$("#loginPopupOverlay .loginOverlayHeader p.header_subHeading").html(),$("#loginPopupOverlay .loginOverlayHeader p.header_subHeading").html(f)):$("#loginPopupOverlay .loginOverlayHeader p.header_subHeading").html(f),h!=""?$("#myBBSLoginSubHeading").html(h).show():$("#myBBSLoginSubHeading").html("").hide(),c&&$("#myBBSLoginHeading").hide(),l&&$("#newToBBS").hide(),$("body").toggleClass("signIn").toggleClass("showOverlay"),s=$("body").hasClass("signIn"),$.browser.msie&&$.browser.version<7&&(r=$("body").height(),u=$(i).height(),r>u?$("#bbs_page_overlay").height(r):$("#bbs_page_overlay").height(u),$("select").toggle()),e!=""&&($("#txtUserName").val(e),$("#alreadyRegistered").show(),$("#newToBBS").hide(),$("#txtPassword").focus(),t=$(".myBBSLoginForgotPassword a"),t&&t.attr("href",function(){return this.href+(this.href.indexOf("?")>=0?"&":"?")+"rl_email="+encodeURIComponent(e)})),tt(n.RegistrationType||0),d(n.OnRegistrationSuccessfulRedirectUrl||""),nt(n.PurchasedProductID||0),s&&$(document).scrollTop(0)},t.OnLoginSuccessful=function(n){n=n||{UserLoggedInSuccessfully:!1,UserGreeting:"",IsBroker:!1,OnBrokerLoginSuccessfulRedirectUrl:"",ReportedAbuseQuestionIDs:[],ReportedAbuseAnswerIDs:[],SavedSearches:[],WatchedListingListNumbers:[]};var u=!!n.IsBroker,r=n.OnBrokerLoginSuccessfulRedirectUrl||"";u&&ft&&r!=""&&$(document).bind("OnMyBBSLoginSuccessful",function(){i.location=r}),o(n),t.ToggleSignInPopup(),$("#loginPopupOverlay.loginFailed").removeClass("loginFailed")},t.OnLoginFailed=function(){s()},t.ResetNotificationCheckbox=function(n,t){t=!!t,n&&n.attr("checked",t)},t.SetLoginType=function(n){c||(e=n,c=!0)},t.HideLoggedOutPromo=function(){},t.HideLoggedInPromo=function(){},jQuery&&$(function(){$("#hlMyBBSMenu, .myBBS-topNavPrimary ul").hover(function(){$(".myBBS-topNavPrimary ul").stop().show(0)}),$(".myBBS-topNavPrimary").mouseleave(function(){$(".myBBS-topNavPrimary ul").delay(500).hide(0)}),$("#hlMyBBSSignOut").click(function(){h?i.Users&&typeof Users.Logout=="function"&&Users.Logout():MyBBS.LinuxLogOut()}),$("#hlMyBBSSignIn").click(function(){MyBBS.ToggleSignInPopup(rt),$("#bbs_page_overlay").click(function(){MyBBS.ToggleSignInPopup(),$("body").removeClass("showOverlayOverride"),$("#loginPopupOverlay").removeClass("loginFailed"),$("#txtUserName").val(""),$(this).unbind("click")})}),$("#hlCancel").click(function(){MyBBS.ToggleSignInPopup(),$("body").removeClass("showOverlayOverride"),$("#loginPopupOverlay").removeClass("loginFailed"),$("#txtUserName").val(""),$("#bbs_page_overlay").unbind("click")}),$("#hlLogin").click(a),$("#txtUserName").focus(function(){var n=$(this);n.hasClass("watermark")&&n.val("").toggleClass("watermark")}),$("#txtUserName").blur(function(){var n=$(this);n.val().length>0||n.val(n.attr("defaultValue")).toggleClass("watermark")}),$("#txtUserName, #txtPassword").keypress(function(n){var t=n.keyCode||n.which||0;if(t==13)return a(),!1}),$("#hlJoinMyBBS, #hlMyBBSRegistration").click(function(){var t=$(this),n=t.attr("href");n!=""&&(r>0&&n.indexOf(b)<0&&(n+=(n.indexOf("?")>=0?"&":"?")+b+"="+r),f!=""&&n.indexOf(p)<0&&(n+=(n.indexOf("?")>=0?"&":"?")+p+"="+encodeURIComponent(f)),u>0&&n.indexOf(l)<0&&(n+=(n.indexOf("?")>=0?"&":"?")+l+"="+u),t.attr("href",n))}),h?$("#myBBSTopNav").show().css("visibility","visible"):g(!1,function(){$("#myBBSTopNav").show().css("visibility","visible")})}),i.BizBuySellWebSite&&BizBuySellWebSite.users&&BizBuySellWebSite.users.Services&&BizBuySellWebSite.users.Services.Users&&(t.UserUtilities=BizBuySellWebSite.users.Services.Users),t}(window.MyBBSInitValues||{})
