// Load me in a new window if caught in a frame
function frameCheck ()
{
	if (self != top)
		top.location.href = self.location.href;
}


function debugOutput (debugMode)
{
	if (debugMode == 1)
		alert ("Debugging(message):\n"
		       + "Window width = " + getWindowWidth ()
		       + "; Window height = " + getWindowHeight ()
		       + "\nScreen width = " + getScreenWidth ()
		       + "; Screen height = " + getScreenHeight ()
		       + "\nStylesheetName = " + getStylesheetName ()
		       + "\nOS = " + getOSName ()
		       + "\nUserAgent = " + navigator.userAgent
		       + "\nE-mail = " + mkEmAdr (0)
		      );
}


function decodeString (text)
{
	var decoded = '';

	for (i = 0; i < text.length; i++)
		decoded += String.fromCharCode ((text.charCodeAt (i) - 5));
	return decoded;
}


function mkEmAdr (aID)
{
	var emadr = '';
	var unme = '(((';

	switch (aID)
	{
		case 0:
			unme += '|zgrfxyzw';
			unme = decodeString (unme);
			unme = unme.replace (/u/gi, String.fromCharCode (101));
			break;
		case 1:
			unme += 'FMk}fsikw&Rzkqqkw';
			unme = decodeString (unme);
			unme = unme.replace (/f/gi, String.fromCharCode (0x65));
			unme = unme.replace (/H/gi, String.fromCharCode (108));
			break;
	}
	emadr += String.fromCharCode (0x40);
	emadr += String.fromCharCode (0x45, 118, 0x64);
	emadr += String.fromCharCode (67, 0x64, 0x6d, 112);
	emadr += '!';
	emadr = emadr.replace (/d/gi, String.fromCharCode (0x6f));
	emadr += String.fromCharCode (100, 0x65);
	emadr = unme.concat (emadr);
	emadr = emadr.replace (/!/gi, String.fromCharCode (46));
	emadr = emadr.replace (/###/, String.fromCharCode (0x6D, 97, 105, 0x6C, 0x74, 0x6f, 58));
	return emadr;
}


function getWindowWidth ()
{
	if (window.innerWidth)
		return window.innerWidth;
	else
		return document.body.offsetWidth;
}


function getWindowHeight ()
{
	if (window.innerHeight)
		return window.innerHeight;
	else
		return document.body.offsetHeight;
}


function getScreenWidth ()
{
	return screen.width;
}


function getScreenHeight ()
{
	return screen.height;
}


function getOSName ()
{
	var uagent = navigator.userAgent;

	if (uagent.indexOf ("Mac") >= 0)
		return "Macintosh";
	else if (uagent.indexOf ("Win") >= 0)
		return "Windows";
	else if (uagent.indexOf ("Linux") >= 0)
		return "Linux";
	else
		return "Unknown";
}


function getStylesheetName ()
{
	var uagent  = navigator.userAgent;
	var os = "_";
	var isIE    = (uagent.indexOf ("MSIE") >= 0) ? true : false;
	var isOpera = (uagent.indexOf ("Opera") >= 0) ? true : false;
	var isGecko = (uagent.indexOf ("Gecko") >= 0) ? true : false;

	switch (getOSName ())
	{
		case "Windows":
			os = os + "win";
			break;
		case "Macintosh":
			os = os + "mac";
			break;
		case "Linux":
			os = os + "linux";
			break;
		default:
			os = os + "other";
			break;
	}

	if (isIE && !isOpera)
	{
		cssfile = "ie";
	}
	else if (isGecko)
	{
		cssfile = "mozilla";
	}
	else if (isOpera)
	{
		cssfile = "opera";
	}
	else if (document.layers)
	{
		cssfile = "nn";
	}
	cssfile += (os + ".css");
	return cssfile;
	/*document.write ("<link rel=\"stylesheet\" type=\"text/css\" href=\"" + cssfile + "\">");*/
}


