// Variables
var OVER = 0;
var OUT = 1;
	
// Loads a page in a new window (800x600 centered) with all normal options activated
function fLoadPage(url)
{
	var h, w, t, l;
	if (eval(window.screen.height) >= 600 && eval(window.screen.width) >= 820)
	{
		h = 600;
		w = 820;
		t = (eval(window.screen.height) - h) / 2;
		l = (eval(window.screen.width) - w) / 2;
	}
	else
	{
		h = eval(window.screen.height);
		w = eval(window.screen.width);
		t = 0;
		l = 0;
	}
		
	var random_num = Math.round(Math.random()*10000)
	var newWin;
	newWin = window.open(url,"Document" + random_num,"channelmode=no,left=" + l + ",top=" + t + ",height=" + h + ",width=" + w + ",SCROLLBARS=1,RESIZABLE=1,MENUBAR=1,TOOLBAR=1,LOCATION=1,DIRECTORIES=1,STATUS=1");
}
		
// Standard Resize Window Function
function fResizeWindow(WINDOW_WIDTH,WINDOW_HEIGHT)
{
	if (WINDOW_HEIGHT > window.screen.height - 50) WINDOW_HEIGHT = (window.screen.height - 50);
	window.resizeTo(WINDOW_WIDTH,WINDOW_HEIGHT);
	window.moveTo((window.screen.width/2) - (WINDOW_WIDTH/2),(window.screen.height/2) - (WINDOW_HEIGHT/2));
}
	
// Loads a new Pop Up with no scroll bars, address bar, menu bar, status bar etc.
function WinOpen(path, height, width)
{
	// align pop up to center of screen
	var ltop = (window.screen.height/2) - (height/2)
	var lleft = (window.screen.width/2) - (width/2)

	var newWin;
	newWin = window.open(path,"","channelmode=no,left=" + lleft + ",top=" + ltop + ",height=" + height + ",width=" + width + ",SCROLLBARS=0,RESIZABLE=1,MENUBAR=0,TOOLBAR=0,LOCATION=0,DIRECTORIES=0,STATUS=0");
}

// Wait
function fWait(delay)
{
	string="pauseforalert();";
	setTimeout(string,delay);
}
	
function pauseforalert()
{
	location.href = location.href;
}
	
// Styleize Input Borders
function fBorder(objform)
{
	for (var i=0; i<objform.elements.length; i++)
	{
		if (objform.elements(i).type == "text" || objform.elements(i).type == "textarea")
		{
			if (objform.elements(i).type == "text")
			{
				objform.elements(i).style.border = "solid Lightslategray 1px";
			}
		}
	}
}

// Eliminates all leading, trailing and double spaces
function fTrim(str)
{
	var i;
	// Eliminates double spaces
	for(i=0;i<20;i++)
	{
		str = str.replace("  "," ");
	}
		
	// Chop off leading spaces
	while (str.length > 0)
	{
		if (str.charAt(0) == " ")
		{
			str = str.substr(1);
		}
		else
		{
			break;
		}
	}

	// Chop off trailing spaces
	while (str.length > 0)
	{
		i = str.length - 1;
		if (str.charAt(i) == " ")
		{
			str = str.substr(0, str.length - 1);
		}
		else
		{
			break;
		}
	}
		
	return str;
}
