function logout() { displayAlert('Question', 'Sign out of Who\'s There?', new Array('Are you sure?', ((document.cookie.indexOf('rememberMe=')>=0) ? 'The Remember Me feature on this computer will be removed if you click OK.' : '')), new Array({ lbl:'OK', auto:30, defaultBtn:true, click:function() { markOffline(); location.href='http://www.whosthere.co.uk/home/authorise.asp?logout'; } }, { lbl:'Cancel', key:27 }), true); } //**********************************// //** **// //** Tooltip **// //** **// //**********************************// function tooltip(title, message) { $('tooltip').innerHTML = '
' + ((title!='') ? '

' + title + '

' : '') + '
' + message + '
'; $('tooltip').style.display = 'block'; } function killTT() { $('tooltip').innerHTML = ''; $('tooltip').style.display = 'none'; } function moveTooltip(e) { if ($('tooltip').style.display == 'block') { var e = (e) ? e : event; var sLeft, sTop, x, y, h, w, lEdge, bEdge; sLeft = (document.documentElement.scrollLeft) ? document.documentElement.scrollLeft : document.body.scrollLeft; sTop = (document.documentElement.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop; x = (e.pageX) ? e.pageX : e.clientX + sLeft; y = (e.pageY) ? e.pageY : e.clientY + sTop; h = $('tooltip').offsetHeight + 12; w = $('tooltip').offsetWidth + 12; lEdge = (document.documentElement.clientWidth) + sLeft; bEdge = (document.documentElement.clientHeight) + sTop; $('tooltip').style.left = ((x + w > lEdge) ? ((x > lEdge) ? lEdge-w+8 : x-w+8) : x+12) + 'px'; $('tooltip').style.top = ((y + h > bEdge) ? ((y > bEdge) ? bEdge-h+8 : y-h+8) : y+12) + 'px'; } } document.onmousemove = moveTooltip; //**********************************// //** **// //** Chat **// //** **// //**********************************// //Mark Online makeXMLRequest('/_code/_asp/chat/changeOnlineStatus.asp', 's=on', null, null); function markOffline() { makeXMLRequest('/_code/_asp/chat/changeOnlineStatus.asp', 's=off', null, null); } function getWhosOnline() { makeXMLRequest('/_code/_asp/chat/whosOnline.json.asp', '', function(r) { var whosOnline = eval('(' + r + ')'); if (whosOnline.memberCount == 0) { $('whosOnlineBtn').innerHTML = ' 0 Members Online'; $('whosOnlineBtn').onclick = null; $('whosOnlineBtn').className = ''; $('whosOnlineWindow').style.display = ''; } else { $('whosOnlineBtn').innerHTML = ' ' + whosOnline.memberCount + ' Member' + ((whosOnline.memberCount==1) ? '' : 's') + ' Online'; var winHTML = ''; for (i=0; i '; winHTML += '' + whosOnline.groups[i].groupName + ' (' + whosOnline.groups[i].members.length + ')'; winHTML += ''; } $('whosOnlineWindow').innerHTML = winHTML $('whosOnlineBtn').onclick = toggleWhosOnlineWindow; $('whosOnlineBtn').className = ($('whosOnlineBtn').className == 'whosOnlineBtnActive') ? 'whosOnlineBtnActive' : 'whosOnlineHoverBtn'; } }, null); } function toggleWhosOnlineWindow() { if ($('whosOnlineBtn').className == 'whosOnlineHoverBtn') { $('whosOnlineBtn').className = 'whosOnlineBtnActive'; $('whosOnlineWindow').style.display = 'block'; } else { $('whosOnlineBtn').className = 'whosOnlineHoverBtn'; $('whosOnlineWindow').style.display = ''; } } //**********************************// //** **// //** Alerts **// //** **// //**********************************// function displayAlert(type, title, message, buttons, blackout) { $('alert').className = 'alert' + type; $('alertTitle').innerHTML = title; for (var i=0; i0) ? $('alertMsg').innerHTML : '') + '

' + message[i] + '<'+'/p>'; } $('alert').style.top = '-' + $('alert').offsetHeight + 'px'; $('alert').style.paddingBottom = (buttons) ? '3em' : '1em'; alertKeys = new Array(); if (buttons) { autoCloseAlertButton = null; defaultAlertButton = null; $('alertButtons').innerHTML = ''; for (var i=0; i=0) { $('alertButtons').insertBefore(btn, $('alertButtons').firstChild); } else { $('alertButtons').appendChild(btn); } if (buttons[i].auto) { if (buttons[i].auto != 0) { autoCloseAlertButton = btn; btn.countdownValue = buttons[i].auto; btn.orgValue = btn.value } } if (buttons[i].defaultBtn) { defaultAlertButton = btn; } if (buttons[i].key) { alertKeys.push(registerKeys(buttons[i].key, ((buttons[i].click) ? buttons[i].click : closeAlert), true)); } } } if (blackout) { $('blackout').style.display = 'block'; } clearTimeout(displayAlertTimeout); clearTimeout(alertCountdownTimeout); registerResizableElement($('alert'), 'centre'); registerResizableElement($('blackout'), 'fullScreen'); displayAlertAnimate(); if (window.ie6HacksAlertScroll) { ie6HacksAlertScroll(); } } function closeAlert() { clearTimeout(displayAlertTimeout); clearTimeout(alertCountdownTimeout); $('blackout').style.display = 'none'; $('alert').style.top = (parseInt($('alert').style.top)-8) + 'px'; if (parseInt($('alert').style.top) > -$('alert').offsetHeight) { setTimeout(closeAlert, 10); } else { $('alert').style.top = '-1000em'; deregisterResizableElement($('alert')); deregisterResizableElement($('blackout')); } for (var i=0; i= 0) { alertCountdownTimeout = setTimeout(closeAlertCountdown, 1000); } else { autoCloseAlertButton.click(); } } var autoCloseAlertButton = null; var defaultAlertButton = null; var displayAlertTimeout, alertCountdownTimeout; var mousedownOnButton = null; var alertKeys; //**********************************// //** **// //** Window Resizing **// //** **// //**********************************// function resizeElements() { if (resizableElements.length > 0) { var h = 600; var w = 800; var bdy = document.getElementsByTagName('body')[0]; //for IE6 :-( if (typeof(window.innerWidth) == 'number') { h = window.innerHeight; w = window.innerWidth; } else if (document.documentElement && (document.documentElement.clientHeight)) { h = document.documentElement.clientHeight; w = document.documentElement.clientWidth; } else if (document.body && (document.body.clientHeight)) { h = document.body.clientHeight; w = document.body.clientWidth; } for (var i=0; i 0) { if (!e) var e = window.event; if (e.keyCode) key = e.keyCode; else if (e.which) key = e.which; var keyFound = false; var blackout = (!($('blackout').style.display == '' || $('blackout').style.display == 'none')); for (var i=keyActions.length-1; i>=0; i--) { if (keyActions[i].key == key && !keyFound && ((blackout && keyActions[i].overBlackout) || !blackout)) { keyFound = true; keyActions[i].action(); } } } } function registerKeys(keyCode, action, overBlackout) { var uid = new Date().valueOf(); keyActions.push({ 'key': keyCode, 'action': action, 'overBlackout':overBlackout, 'uid':uid }); return uid } function deregisterKeys(uid) { for (var i=0; i