var mainWindowState={};mainWindowState.ACTIVE=1;mainWindowState.CLOSED=2;mainWindowState.LOGGEDOUT=3;var assistantRefresh,refreshIntervalMilliSeconds=120,timeoutBeforeAssistantReloadMilliSeconds=0,trackAssistant,trackAssistantInterval=2500,titleSaved=document.title,inAssistantPopout=false,titleContentIntervalMilliSeconds=1e4,displayTitle=false,titleContentRefresh;function StartAssistant(){setTimeout(function(){ReloadAssistant();assistantRefresh=setInterval(function(){ReloadAssistant()},refreshIntervalMilliSeconds)},timeoutBeforeAssistantReloadMilliSeconds)}function hideItem(a){if(document.getElementById(a)&&document.getElementById(a).style.display=="block")document.getElementById(a).style.display="none"}function displayItem(a){document.getElementById(a).style.display="block";document.getElementById(a).style.height="auto"}function Reload(){window.location.reload()}function SetOpenerLocation(a){if(window.opener&&!window.opener.closed){window.opener.location.href=a;return false}else return true}function SetAssistant(a,c){var d=a?"Y":"N",b=new RequestPage("/User/ControlPanel/setassistant.asp?setassistant=Y&ota="+d);b.onreadystatechange=function(){if(b.readyState==4){ActionAssistant(a,c);clearTimeout(trackAssistant)}}}function ActionAssistant(a,b){if(a){OpenAssistant();Reload()}else CloseAssistant(b)}function OpenAssistant(){var a="/User/ControlPanel/assistantPopout.asp";assistantWindow=window.open("","assistant","status=yes,scrollbars=no,resizable=yes,width=250,height=100,screenX=10,screenY=10,top=10,left=10");if(!assistantWindow||assistantWindow.closed||!assistantWindow.assistantLoaded)assistantWindow=window.open(a,"assistant","status=yes,scrollbars=no,resizable=yes,width=250,height=100,screenX=10,screenY=10,top=10,left=10");trackAssistant=setInterval(function(){TrackAssistant()},trackAssistantInterval)}function OpenNotificationMessage(){setTimeout("window.open('/User/talk/PopupAlert.aspx','MessageReceived','status=no,scrollbars=no,resizable=no,width=400,height=140,screenX=400,screenY=300,top=450,left=450')",500)}function CloseAssistant(a){if(a){if(window.opener)if(window.opener.closed)OpenMainSite();else window.opener.location.reload();setTimeout(function(){self.close()},200)}else assistantWindow.close()}function TrackAssistant(){if(assistantWindow&&assistantWindow.closed){clearInterval(trackAssistant);SetAssistant(false,false);StartAssistant()}}function OpenMainSite(){window.open("/default.asp?setassistant=Y&ota=N","Gaydar","width=1000,height=700,toolbar=yes,menubar=yes,location=yes,resizable=yes,scrollbars=yes,status=yes")}function AssistantButtonSet(){if(inAssistantPopout)if(window.opener)if(window.opener.closed){$("#assistantLogout").show();$("#assistantClose").hide()}else{$("#assistantLogout").hide();$("#assistantClose").show()}}function ReloadAssistant(){AssistantButtonSet();$.getScript("/User/ControlPanel/assistantRefresh.asp?callback=PopulateAssistant&cb="+(new Date).getTime())}function updateMessageCount(){var c=getObject("messagesWaitingIcon"),a=getObject("messagesWaiting"),g="/Images/Icons/Assistant/",e=".png",f="Messages",d=a.innerHTML,b=d-1;if(0>=b){a.innerHTML="";$("#messagesWaiting").parent().hide();c.src=g+f+e}else if(b>0){a.innerHTML=b;$("#messagesWaiting").parent().show()}}function setAssistantPopoutButtons(a){if(a==mainWindowState.CLOSED){$("#assistantLogout").hide();$("#assistantClose").show()}else if(a==mainWindowState.ACTIVE){$("#assistantLogout").show();$("#assistantClose").hide()}else if(a==mainWindowState.LOGGEDOUT){$("#assistant").hide();$("#assistantLogout").hide();$("#assistantClose").hide();$("#assistantLoggedOutMessage").show();clearInterval(assistantRefresh);clearInterval(trackAssistantParent)}}function PopulateAssistant(a){if(true==a.sessionExpired){LogOutMainWindow(!inAssistantPopout,true);inAssistantPopout&&setAssistantPopoutButtons(mainWindowState.LOGGEDOUT)}else{var j=a.lastFriendId,f=a.friendsToUpdate,i=a.lastFavouriteId,e=a.favouritesToUpdate,d=a.numberFriendsOnline,c=a.numberFavouritesOnline,b=a.notifyFriendsFavourites,h="",g="";if(b&&(d>0||c>0)){friendFavouriteOnlineDisplay="NEW";(j>f||i>e)&&GetFriendsAndFavourites(friendFavouriteOnlineDisplay,a.username,f,e)}if(0==d){$("#numberFriendsOnline").parent().hide();ToggleIndicator("fr",false)}else{h=d;$("#numberFriendsOnline").parent().show();!b&&j>f&&ToggleIndicator("fr",true)}getObject("numberFriendsOnline").innerHTML=h;if(0==c){$("#numberFavouritesOnline").parent().hide();ToggleIndicator("fa",false)}else{g=c;$("#numberFavouritesOnline").parent().show();!b&&i>e&&ToggleIndicator("fa",true)}getObject("numberFavouritesOnline").innerHTML=g;if(a.messagesWaiting>0&&a.newMessageId>a.lastMessageId){"y"!=a.messageNotificationType&&"n"!=a.messageNotificationType&&playSoundNotification(a.messageNotificationType);true==a.messageNotification&&OpenMessagesWithIdReference(a.username,a.lastMessageId);false==a.messageNotification&&"n"==a.messageNotificationType&&OpenNotificationMessage()}if(0==a.messagesWaiting){getObject("messagesWaiting").innerHTML="";$("#messagesWaiting").parent().hide();ToggleIndicator("msg",false)}else{getObject("messagesWaiting").innerHTML=a.messagesWaiting;$("#messagesWaiting").parent().show();ToggleIndicator("msg",true)}}}function TitleContent(){if(displayTitle){document.title=titleSaved;displayTitle=false}else{currentMessageCount=getObject("messagesWaiting").innerHTML;if(""==currentMessageCount||0==currentMessageCount)document.title=titleSaved;else if(currentMessageCount==1)document.title="Gaydar - "+currentMessageCount+" "+QSoft.Lib.Translation.Get("106");else document.title="Gaydar - "+currentMessageCount+" "+QSoft.Lib.Translation.Get("107");displayTitle=true}}function ToggleIndicator(d,g){var f="/Images/Icons/Assistant/",e=".png",b=getObject("numberFriendsOnlineIcon"),a="Friends";if(d=="fa"){a="Favourites";b=getObject("numberFavouritesOnlineIcon")}else if(d=="msg"){a="Messages";b=getObject("messagesWaitingIcon")}var c=f+a+e;if(g)c=f+a+"_Glow"+e;b.src=c};
