﻿
Type.registerNamespace("PlainJoeStudios.MediaSocial.WebServer.Controls");PlainJoeStudios.MediaSocial.WebServer.Controls.LiveHelpButtonMonitor=function(params){this.Construct(params);};PlainJoeStudios.MediaSocial.WebServer.Controls.LiveHelpButtonMonitor.prototype={HelpPopupWindowOptions:"width=580,height=402,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0",HelpPopupWindowName:"livehelp",_JqButtonId:null,_JqButton:null,_jqLink:null,_AccountId:0,_IsLiveHelpOnline:false,_ImageUrlBase:null,_ImageUrlOnlineNormal:null,_ImageUrlOnlineHover:null,_ImageUrlOfflineNormal:null,_ImageUrlOfflineHover:null,_LiveHelpOnlineUrl:null,_LiveHelpOfflineUrl:null,_Button_On_Mouse_Over:null,_Button_On_Mouse_Out:null,_bLockPopupSize:false,Construct:function(params){var This=this;if(!params["JqButtonId"]||!params["ImageUrlBase"]||!params["AccountId"]){return;}
This._JqButtonId=params["JqButtonId"];This._JqButton=$("#"+This._JqButtonId);this._jqLink=this._JqButton.parent();This._ImageUrlBase=params["ImageUrlBase"];This._ImageUrlOnlineNormal=This._ImageUrlBase+"normal_on.png";This._ImageUrlOnlineHover=This._ImageUrlBase+"over_on.png";This._ImageUrlOfflineNormal=This._ImageUrlBase+"normal_off.png";This._ImageUrlOfflineHover=This._ImageUrlBase+"over_off.png";This._AccountId=params["AccountId"];This._LiveHelpOnlineUrl=params["LiveHelpUrl"];This._LiveHelpOfflineUrl=params["LiveHelpUrl"];this._bLockPopupSize=params["LockPopupSize"];This.SetupButton();var oBus=$PJP.GetControl("ChannelBus");oBus.attachListener(oBus.LISTENER_TYPE_LIVE_HELP_STATUS,function(oData){This._processLiveHelpStatusPacket(oData);});},SetupButton:function(){var This=this;if(This._Button_On_Mouse_Over!=null){This._JqButton.unbind('mouseover',This._Button_On_Mouse_Over);This._Button_On_Mouse_Over=null;}
if(This._Button_On_Mouse_Out!=null){This._JqButton.unbind('mouseout',This._Button_On_Mouse_Out);This._Button_On_Mouse_Out=null;}
This._JqButton.parent().unbind('click');if(This._IsLiveHelpOnline==true){This._Button_On_Mouse_Over=function(){This._JqButton.attr("src",This._ImageUrlOnlineHover);};This._Button_On_Mouse_Out=function(){This._JqButton.attr("src",This._ImageUrlOnlineNormal);};}
else{This._Button_On_Mouse_Over=function(){This._JqButton.attr("src",This._ImageUrlOfflineHover);};This._Button_On_Mouse_Out=function(){This._JqButton.attr("src",This._ImageUrlOfflineNormal);};}
if(This._JqButton.attr("src")==="/null.null"||This._JqButton.attr("src")===This._ImageUrlOfflineNormal||This._JqButton.attr("src")===This._ImageUrlOnlineNormal){This._Button_On_Mouse_Out();}
else{This._Button_On_Mouse_Over();}
This._JqButton.mouseover(This._Button_On_Mouse_Over);This._JqButton.mouseout(This._Button_On_Mouse_Out);if(!this._bLockPopupSize){if(this._IsLiveHelpOnline){this._jqLink.attr("href",this._LiveHelpOnlineUrl);}
else{this._jqLink.attr("href",this._LiveHelpOfflineUrl);}
this._jqLink.attr("target","_blank");}
else{this._jqLink.attr("href","javascript:;");this._jqLink.removeAttr("target");This._JqButton.parent().click(function(){This._buttonOnMouseClick()});}},_buttonOnMouseClick:function(){var This=this;var strUrlToOpen;if(This._IsLiveHelpOnline==true){strUrlToOpen=this._LiveHelpOnlineUrl;}
else{strUrlToOpen=this._LiveHelpOfflineUrl;}
var openedWindow=window.open(strUrlToOpen,this.HelpPopupWindowName,this.HelpPopupWindowOptions,false);WindowManager.CheckForPopupBlock(openedWindow);},_processLiveHelpStatusPacket:function(oPacket){if(this._IsLiveHelpOnline!==oPacket){this._IsLiveHelpOnline=oPacket;this.SetupButton();}}};