function cloak(divID) {
  var item = document.getElementById(divID);

  if (item) {
    item.className=(item.className=='content-cloak')?'content':'content-cloak';
  }
}

//***************************************************************************

function squirrelmail_loginpage_onload() {
}

//***************************************************************************

function GetXmlHttpObject()
{
	if (window.XMLHttpRequest)
	  {
	  // code for IE7+, Firefox, Chrome, Opera, Safari
	  return new XMLHttpRequest();
	  }
	if (window.ActiveXObject)
	  {
	  // code for IE6, IE5
	  return new ActiveXObject("Microsoft.XMLHTTP");
	  }
	return null;
}

//***************************************************************************

function showTerranovaPlaying()
{
	xmlhttp=GetXmlHttpObject();
	myRand=parseInt(Math.random()*98939291)
	
	if (xmlhttp==null)
	  {
	  alert ("Your Browser doesn't support AJAX  - Please Upgrade by visiting www.microsoft.com/ie or www.mozilla.com!");
	  alert ("Song Information on the Sidebar will not update automatically");
	  return;
	  }
	  
	var url="/playingdata.php";
	url=url+"?mode=now&session="+myRand;
	xmlhttp.onreadystatechange=showTerranovaNowPlaying;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
	
	xmlhttp2=GetXmlHttpObject();

	var url="/playingdata.php";
	url=url+"?mode=last&session="+myRand;
	xmlhttp2.onreadystatechange=showTerranovaLastPlaying;
	xmlhttp2.open("GET",url,true);
	xmlhttp2.send(null);
	
	setTimeout(showTerranovaPlaying,30000);
}

//***************************************************************************

function showTerranovaNowPlaying()
{
	if (xmlhttp.readyState==4)
	  {
	  document.getElementById("nowPlaying").innerHTML=xmlhttp.responseText;
	  }
}

//***************************************************************************

function showTerranovaLastPlaying()
{
	if (xmlhttp.readyState==4)
	  {
	  document.getElementById("lastPlaying").innerHTML=xmlhttp2.responseText;
	  }
}

//***************************************************************************

function showHint(str)
{
	if (str.length==0)
	  {
	  document.getElementById("txtStatus").innerHTML="";
	  return;
	  }
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
	  {
	  alert ("Your browser does not support XMLHTTP!");
	  return;
	  }
	var url="gethint.asp";
	url=url+"?q="+str;
	url=url+"&sid="+Math.random();
	xmlhttp.onreadystatechange=stateChanged;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}

//***************************************************************************

function stateChanged()
{
	if (xmlhttp.readyState==4)
	  {
	  document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
	  }
}

//***************************************************************************

function textCounter(textarea, counterID, maxLen) { 
	cnt = document.getElementById(counterID); 
	if (textarea.value.length > maxLen) 
	{
		textarea.value = textarea.value.substring(0,maxLen);
	}
	
	cnt.innerHTML = maxLen - textarea.value.length;
}

//***************************************************************************

isString = function(obj) { return (typeof obj == 'string'); }
isBoolean = function(obj) { return (typeof obj == 'boolean'); }
isUndefined = function(obj) { return (typeof obj == 'undefined'); }
isNull = function(obj) { return (obj == null); }
isValid = function(obj) { return (!isNull(obj) && !isUndefined(obj)); }

//***************************************************************************

ReloadURL = function(url, context)
{
	context = context || window;
	url = url || GetUrl(context);

	if (context.location.href.toString() != url)
		context.location = url;
	else
		context.location.reload(true);
}

//***************************************************************************

ID = function(id, context)
{
	if (isValid(id) && isString(id))
		return (context || document).getElementById(id);
	else
		return null;
}

//***************************************************************************

toObject = function(obj, def)
{
	return ID(obj) || def || obj || null;
}

//***************************************************************************

GetEventObject = function(e) 
{ 
	return (e ? e : window.event); 
}

//***************************************************************************

GetEventCtrlKey = function(e) 
{ 
	e = GetEventObject(e); 
	return e.ctrlKey; 
}

//***************************************************************************

GetEventShiftKey = function(e) 
{ 
	e = GetEventObject(e); 
	return e.shiftKey; 
}

//***************************************************************************

GetEventKeyCode = function(e) 
{ 
	e = GetEventObject(e); 
	return e.keyCode; 
}

//***************************************************************************

AddEvent = function(elm, evType, fn, useCapture)
{
	elm = toObject(elm);
	if (isValid(elm))
	{
		if (elm.addEventListener)
		{
			elm.addEventListener(evType, fn, useCapture);
			return true;
		}
		else if (elm.attachEvent)
		{
			var r = elm.attachEvent('on' + evType, fn);
			return r;
		}
		else
		{
			elm['on' + evType] = fn;
		}
	}
}


//***************************************************************************

OnKeyDown = function(e)
{

	if ((GetEventCtrlKey(e)) && (GetEventShiftKey(e)) && (GetEventKeyCode(e) == 112))
	{
		ReloadURL("http://www.fdnetwork.com.au");
		return false;
	}

	if ((GetEventCtrlKey(e)) && (GetEventShiftKey(e)) && (GetEventKeyCode(e) == 113))
	{
		ReloadURL("http://www.terranovaradio.com");
		return false;
	}

	if ((GetEventCtrlKey(e)) && (GetEventShiftKey(e)) && (GetEventKeyCode(e) == 114))
	{
		ReloadURL("http://webmail.fdnetwork.com.au");
		return false;
	}

	if ((GetEventCtrlKey(e)) && (GetEventShiftKey(e)) && (GetEventKeyCode(e) == 120))
	{
		ReloadURL("http://www.terranovaradio.com/controlpanel/");
		return false;
	}
	if ((GetEventCtrlKey(e)) && (GetEventShiftKey(e)) && (GetEventKeyCode(e) == 121))
	{
		ReloadURL("http://admin.fdnetwork.com.au");
		return false;
	}
}

//***************************************************************************

AddEvent(document, 'keydown', OnKeyDown);

//***************************************************************************

