// Written By Yesi Jan 2004
function enterSuppression(evt)
{
	evt = (evt) ? evt : event;
	var charCode = (evt.charCode) ? evt.charCode : ((evt.which) ? evt.which : evt.keyCode);

	if (charCode  == 13 || charCode == 3)
	{
		//alert('You Hit Enter');
		return false;
	}
	else
	{
		return true;
	}
}

function maximixeSelf()
{
	self.moveTo(0,0);
	window.resizeTo(screen.width,screen.height);
}

function maximixeWin(windowToMaximize)
{
	windowToMaximize.moveTo(0,0);
	windowToMaximize.resizeTo(screen.width,screen.height);
}


function IsBrowserOnAMac()
{
	var onAMac = false;

	if (navigator.userAgent.indexOf("Mac") != -1)
	{
		onAMac = true;
	}

	return onAMac;
}

function IsBrowserNetscape()
{
	var isNetscape = false;

	if (navigator.appName.indexOf("Netscape") != -1)
	{
		isNetscape = true;
	}

	return isNetscape;
}

function IsBrowserCompatible()
{
	var campatible = false;

	var browser = new Object();
	// defaults
	browser.isNetscape = false;
	browser.isMicrosoft = false;
	browser.isSafari = false;
	browser.isOnAMac = false;
	browser.isOnAPC = false;

	// get browswer version
	browser.version = parseInt(navigator.appVersion);

	// find out which browser user is using
	if (IsBrowserNetscape)
	{
		browser.isNetscape = true;
	}
	else if (navigator.appName.indexOf("Microsoft") != 1)
	{
		browser.isMicrosoft = true;
	}
	else if (navigator.appName.indexOf("Safari") != 1)
	{
		browser.isSafari = true;
	}

	// deteriming OS
	if (IsBrowserOnAMac)
	{
		browser.isOnAMac = true;
	}
	else if (navigator.appName.indexOf("Microsoft") != 1)
	{
		browser.isOnAPC = true;
	}

	// criteria to determine whether or not browser is capable of continuing on
	//Work in progress

	return campatible;
}



function navigateTo(url_1, bool_ConditionHasBeenMet, url_2, promptMsg, bool_navToInPopUpWin, windowName, windowOptions)
{
	var urlToNavigateTo = ""

	if (bool_ConditionHasBeenMet)
	{
		urlToNavigateTo = url_2;
	}
	else
	{
		urlToNavigateTo = url_1;
	}

	if (bool_navToInPopUpWin)
	{
		popUpWin(urlToNavigateTo, windowName, windowOptions, promptMsg);
	}
	else
	{
		redirectPageTo(urlToNavigateTo, promptMsg);
	}
}

function redirectPageTo(urlToNavigateTo, promptMsg)
{
	var continueWithNavigation = true;

	// Confirm if a prompt message has been provided
	if (promptMsg)
	{
		continueWithNavigation = confirm(promptMsg);
	}

	if (continueWithNavigation)
	{
		document.location = urlToNavigateTo;
	}
}

function popUpWin(urlToNavigateTo, windowName, windowOptions, promptMsg)
{
	var windowHasBeenNamed = false;
	var continueWithNavigation = true;

	var fullScreeenWindow = false;

	if (windowName)
	{
		windowHasBeenNamed = true;
	}

	// Special Values provided into windowOptions
	if (!windowOptions)
	{
		windowOptions = "width=750,height=600,resizable=1,scrollbars=1";
	}
	else if (windowOptions == 'typicalWindow')
	{
		windowOptions = "width=750,height=600,resizable=1,scrollbars=1,location=1,menubar=1,status=1,toolbar=1";
	}
	else if (windowOptions == 'previewInews')
	{
		windowOptions = "width=750,height=600,resizable=1,scrollbars=1,location=1,menubar=1,status=1,";
		if (!windowHasBeenNamed)
		{
			windowName = 'lcd_previewInews';
			windowHasBeenNamed = true;
		}
	}
	else if (windowOptions == 'previewPdf')
	{
		windowOptions = "width=625,height=600,resizable=1,scrollbars=1";
		if (!windowHasBeenNamed)
		{
			windowName = 'lcd_previewPdf';
			windowHasBeenNamed = true;
		}
	}
	else if (windowOptions == 'previewDwg')
	{
		windowOptions = "width=700,height=600,resizable=1,scrollbars=1,menubar=1";
		if (!windowHasBeenNamed)
		{
			windowName = 'lcd_previewDwg';
			windowHasBeenNamed = true;
		}
	}
	else if (windowOptions == 'previewSld')
	{
		windowOptions = "width=700,height=600,resizable=1,scrollbars=1,menubar=1";
		if (!windowHasBeenNamed)
		{
			windowName = 'lcd_previewSld';
			windowHasBeenNamed = true;
		}
	}
	else if (windowOptions == 'previewImg')
	{
		windowOptions = "width=600,height=500,scrollbars=1,resizable=1,scrollbars=1,menubar=1";
		if (!windowHasBeenNamed)
		{
			windowName = 'lcd_previewImg';
			windowHasBeenNamed = true;
		}
	}
	else if (windowOptions == 'previewCloseup')
	{
		windowOptions = "width=900,height=600,scrollbars=1,resizable=1,scrollbar=1,menubar=1";
		if (!windowHasBeenNamed)
		{
			windowName = 'lcd_previewImg';
			windowHasBeenNamed = true;
		}
	}
	else if (windowOptions == 'previewMov')
	{
		windowOptions = "width=600,height=500,scrollbars=1,resizable=1,scrollbars=1,menubar=1";
		if (!windowHasBeenNamed)
		{
			windowName = 'lcd_previewMov';
			windowHasBeenNamed = true;
		}
	}
	else if (windowOptions == 'previewDoc')
	{
		windowOptions = "width=625,height=847,resizable=1,scrollbars=1,menubar=1";
		if (!windowHasBeenNamed)
		{
			windowName = 'lcd_previewDoc';
			windowHasBeenNamed = true;
		}
	}
	else if (windowOptions == 'previewZip')
	{
		windowOptions = "width=600,height=500,scrollbars=1,resizable=1,scrollbars=1,menubar=1";
		if (!windowHasBeenNamed)
		{
			windowName = 'lcd_previewZip';
			windowHasBeenNamed = true;
		}
	}
	else if (windowOptions == 'closeUp')
	{
		windowOptions = "width=800,height=700,scrollbars=1,resizable=1,location=1,menubar=1";
		if (!windowHasBeenNamed)
		{
			windowName = 'lcd_closeUp';
			windowHasBeenNamed = true;
		}
	}
	else if (windowOptions == 'previewCapturedPage')
	{
		windowOptions = "width=800,height=600,resizable=1,scrollbars=1,location=1,menubar=1";
		if (!windowHasBeenNamed)
		{
			windowName = 'lcd_previewCapturedPage';
			windowHasBeenNamed = true;
		}
	}
	else if (windowOptions == 'external')
	{
		windowOptions = "width=550,height=600,resizable=1,scrollbars=1,location=1,menubar=1,toolbar=1";
		if (!windowHasBeenNamed)
		{
			windowName = 'lcd_external';
			windowHasBeenNamed = true;
		}
	}
	else if (windowOptions == 'downloadFile')
	{
		windowOptions = "width=10,height=10";
		if (!windowHasBeenNamed)
		{
			windowName = 'lcd_downloadFile';
			windowHasBeenNamed = true;
		}
	}
	else if (windowOptions == 'previewInFullScreen')
	{
		windowOptions = "resizable=1,scrollbars=1";
		if (!windowHasBeenNamed)
		{
			windowName = 'lcd_previewDwg';
			windowHasBeenNamed = true;
		}

		fullScreeenWindow = true;
	}

	// Name window deault name if no noame has been provided
	if (!windowHasBeenNamed)
	{
		windowName = 'lcd_popUpWin';
		windowHasBeenNamed = true;
	}

	// Confirm if a prompt message has been provided
	if (promptMsg)
	{
		continueWithNavigation = confirm(promptMsg);
	}

	// If all conditions are ok then Pop up a window and bring focus to it
	if (continueWithNavigation)
	{
		var popedUpWindow = window.open(urlToNavigateTo, windowName, windowOptions);
		popedUpWindow.focus();

		if (fullScreeenWindow)
		{
			maximixeWin(popedUpWindow);
		}
	}
}


function imgSwap(imgObj, switchOn)
{
	var imgClass = "imgOff";

	if (imgObj)
	{
		if (switchOn)
		{
			imgClass = "imgOn";
		}

		imgObj.className = imgClass;
	}
}

function toggleDiv(divID, toggleIconID, ExpandSrc, CollpaseSrc)
{
	var divToExpand = document.getElementById(divID);
	var toggleIcon = document.getElementById(toggleIconID);
	var display = '';
	var toggleIconImg = false


	if ((toggleIcon) && (ExpandSrc) && (CollpaseSrc))
	{
		toggleIconImg = true
	}

	if (divToExpand)
	{
		if (divToExpand.style.display == 'none')
		{
			display = 'block';

			if (toggleIconImg)
			{
				toggleIcon.src = CollpaseSrc;
			}
		}
		else
		{
			display = 'none';

			if (toggleIconImg)
			{
				toggleIcon.src = ExpandSrc;
			}
		}

		divToExpand.style.display = display;
	}


}

var req;
function showstats (e,i,xoffset) {
 var o = document.getElementById(i);
 var y = 0;

 var maxX;
 var maxY;
 if (document.all&&!window.opera) {
   if (document.documentElement && document.documentElement.scrollTop) {
     maxX = document.documentElement.clientWidth + document.documentElement.scrollLeft - 80;
     maxY = document.documentElement.clientHeight + document.documentElement.scrollTop - 110;
     y = event.clientY + document.documentElement.scrollTop - 80;
     x = event.clientX + document.documentElement.scrollLeft - 110;
   } else {
     y = event.clientY + document.body.scrollTop - 110;
     x = event.clientX + document.body.scrollLeft - 80;
   }
 } else {
   maxX = window.innerWidth + document.documentElement.scrollLeft - 80;
   maxY = window.innerHeight + document.documentElement.scrollTop - 110;
   y = e.pageY - 110;
   x = e.pageX - 80;
 }
 o.style.position="absolute";
 o.style.display = "block";

 var divX = o.offsetWidth;
 var divY = o.offsetHeight;
 while (maxX > 110 && x + divX > (maxX -35) ) {
   x = x - (divX +30);
 }
 while (y + divY > (maxY -35)) {
   y = y - 1;
 }

 o.style.top = y + "px";
 o.style.left = x + "px";
}

function clearstats (i) {
 var o = document.getElementById(i);
 o.style.display = 'none';
}