var ua = window.navigator.userAgent;
var msie = ua.indexOf("MSIE");
var msieSP2 = (ua.indexOf("SV1") != -1);
var opera = ua.indexOf("Opera");
var mozilla = ua.indexOf("Mozilla");
var version = 0;
var isInternetExplorer = (msie >= 0);
var isOpera = (opera >= 0);
var isNetscape6 = !(isInternetExplorer || isOpera);
if (isInternetExplorer)
	version = parseInt(ua.slice(msie + 4));
else if (isOpera)
	version = parseInt(ua.slice(opera + 5));
else if (isNetscape6)
	{
	if (parseInt(ua.slice(8 + mozilla)) < 5) isNetscape6 = false;
	}

if ((isInternetExplorer) && (version < 5))
	eval('screenLeft = 0; screenTop = 0;');

var oPopup;
var oContentPopup;
if ((isInternetExplorer) && (version >= 6))
	{
	oPopup = window.createPopup();
	oContentPopup = window.createPopup();
	}

function onDoneIE(src)
	{
	oPopup.document.write(src);
	}

function onDoneContentIE(src)
	{
	oContentPopup.document.write(src);
	}

function BrowserIsOkay()
	{
	var isBrowserValid = true;
	if (isInternetExplorer) { if (version < 4) isBrowserValid = false; }
	else if (isOpera) { if (version < 5) isBrowserValid = false; }
	else if (!isNetscape6) isBrowserValid = false;

	if (!isBrowserValid) alert("The file you have requested cannot be displayed.\nIf you wish to view this file, please upgrade to a\nmore recent version of your browser.");
	return isBrowserValid;
	}

function ShowStatus(strMessage)
	{
	window.status = strMessage;
	return true;
	}

function PreloadImage(imgObj, imgSrc, strRolloverStatusMessage)
	{
	eval(imgObj + ' = new Image()');
	eval(imgObj + '.src = "' + imgSrc + '"');
	if (strRolloverStatusMessage != null) eval(imgObj + '.strRolloverStatusMessage = "' + strRolloverStatusMessage + '"');
	}

function ImageOver(strID)
	{
	var strStatusMessage;
	eval('document.images["' + strID + '"].src = ' + strID + '_H.src');
	eval('strStatusMessage = ' + strID + '_H.strRolloverStatusMessage');
	if (strStatusMessage != null)
		ShowStatus(strStatusMessage);
	else
		ShowStatus('');
	return true;
	}

function ImageOut(strID)
	{
	eval('document.images["' + strID + '"].src = ' + strID + '_N.src');
	ShowStatus('');
	return true;
	}

function ImageDown(strID)
	{
	var strStatusMessage;
	eval('document.images["' + strID + '"].src = ' + strID + '_P.src');
	eval('strStatusMessage = ' + strID + '_H.strRolloverStatusMessage');
	if (strStatusMessage != null)
		ShowStatus(strStatusMessage);
	else
		ShowStatus('');
	return true;
	}

function PopupComplete(strPopupURL, strNamedWindow, iWidth, iHeight, bToolbar, bStatus, bMenubar, bAddressbar, bScrollbars, bResizable)
	{
	var strSize = '';
	var strResizable = 'no';
	var strScrollbars = 'no';
	var strStatus = 'no';
	var strMenubar = 'no';
	var strAddressbar = 'no';
	var strToolbar = 'no';
	var x, y;
	if ((iWidth > 0) && (iHeight > 0))
		{
		x = (screen.availWidth - iWidth) / 2;
		if (x + iWidth > screen.availWidth)
			x = screen.availWidth - iWidth;
		if (x < 0)
			x = 0;
		y = (screen.availHeight - iHeight) / 2;
		if (y + iHeight > screen.availHeight)
			y = screen.availHeight - iHeight;
		if (y < 0)
			y = 0;
		strSize = 'width=' + iWidth + ',height=' + iHeight + ',left=' + x + ',top=' + y;
		}
	if (bResizable) strResizable = 'yes';
	if (bScrollbars) strScrollbars = 'yes';
	if (bStatus) strStatus = 'yes';
	if (bMenubar) strMenubar = 'yes';
	if (bAddressbar) strAddressbar = 'yes';
	if (bToolbar) strToolbar = 'yes';
	window.open(strPopupURL, strNamedWindow, strSize + ',resizable=' + strResizable + ',scrollbars=' + strScrollbars + ',status=' + strStatus + ',menubar=' + strMenubar + ',location=' + strAddressbar + ',toolbar=' + strToolbar)
	}

function PopupSized(strPopupURL, iWidth, iHeight)
	{
	PopupComplete(strPopupURL, '', iWidth, iHeight, false, false, false, false, true, true)
	}

function NewBrowserWindow(strPopupURL)
	{
	window.open(strPopupURL, '_blank');
	}

function ShowContent(strPopupURL, strWindowName, iWidth, iHeight, iPage)
	{
	var w, x, y;
	if ((isInternetExplorer) && (version >= 6))
		{
		x = (document.body.clientWidth - iWidth) / 2;
		y = (document.body.clientHeight - iHeight) / 2;
		}
	else
		{
		x = (screen.availWidth - iWidth) / 2;
		y = (screen.availHeight - iHeight) / 2;
		if (x + iWidth > screen.availWidth)
			x = screen.availWidth - iWidth;
		if (x < 0)
			x = 0;
		if (y + iHeight > screen.availHeight)
			y = screen.availHeight - iHeight;
		if (y < 0)
			y = 0;
		}
	iCurrentPage = iPage
	if ((isInternetExplorer) && (version >= 6))
		oContentPopup.show(x, y, iWidth, iHeight, document.body);
	else
		{
		w = window.open(strPopupURL,strWindowName,'left=' + x + ',top=' + y + ',width=' + iWidth + ',height=' + iHeight + ',resizable=yes,scrollbars=yes')
		w.focus();
		}
	}

function PopupNamedFixedSize(strPopupURL, strWindowName, iWidth, iHeight)
	{
	var w, x, y;
	if ((isInternetExplorer) && (version >= 6))
		{
		x = screenLeft + ((document.body.clientWidth - iWidth) / 2);
		y = screenTop + ((document.body.clientHeight - iHeight) / 2);
		}
	else
		{
		x = (screen.availWidth - iWidth) / 2;
		y = (screen.availHeight - iHeight) / 2;
		}
	if (x + iWidth > screen.availWidth)
		x = screen.availWidth - iWidth;
	if (x < 0)
		x = 0;
	if (y + iHeight > screen.availHeight)
		y = screen.availHeight - iHeight;
	if (y < 0)
		y = 0;
	if ((isInternetExplorer) && (version >= 6))
		{
		iWidth += 20;
		x = (document.body.clientWidth - iWidth) / 2;
		y = (document.body.clientHeight - iHeight) / 2;
		oPopup.show(x, y, iWidth, iHeight, document.body);
		}
	else
		{
		w = window.open(strPopupURL,strWindowName,'left=' + x + ',top=' + y + ',width=' + iWidth + ',height=' + iHeight + ',resizable=no,scrollbars=no')
		w.focus();
  		}
	}

function NextPagePreload()
	{
	var iUserImage;
	var strImage;
	for (iUserImage = 0; iUserImage < iTotalUserPreloadImages; iUserImage++)
		{
		strImage = eval('UserPreloadImage' + iUserImage);
		eval("PreloadImage('MAMPreload' + iUserImage, strImage, null)");
		}
	}

function MAMprint()
	{
	if ((isInternetExplorer) && (version < 5))
		alert('Sorry, your browser does not support this print method.\n\nPlease type Ctrl+P to print.');
	else
		window.print();
	}

function PreloadMAMImages()
	{
	PreloadImage("MAMTrans", "../Resources/trans.gif", null);
	PreloadImage("MAMLocBar", "../Resources/page_location_bar.png", null);
	PreloadImage("MAMButFirst_D", "../Resources/button_first_dummy.png", null);
	PreloadImage("MAMButFirst_H", "../Resources/button_first_hover.png", "First");
	PreloadImage("MAMButFirst_N", "../Resources/button_first_normal.png", null);
	PreloadImage("MAMButFirst_P", "../Resources/button_first_pressed.png", null);
	PreloadImage("MAMButLast_D", "../Resources/button_last_dummy.png", null);
	PreloadImage("MAMButLast_H", "../Resources/button_last_hover.png", "Last");
	PreloadImage("MAMButLast_N", "../Resources/button_last_normal.png", null);
	PreloadImage("MAMButLast_P", "../Resources/button_last_pressed.png", null);
	PreloadImage("MAMButPrevious_D", "../Resources/button_previous_dummy.png", null);
	PreloadImage("MAMButPrevious_H", "../Resources/button_previous_hover.png", "Previous");
	PreloadImage("MAMButPrevious_N", "../Resources/button_previous_normal.png", null);
	PreloadImage("MAMButPrevious_P", "../Resources/button_previous_pressed.png", null);
	PreloadImage("MAMButNext_D", "../Resources/button_next_dummy.png", null);
	PreloadImage("MAMButNext_H", "../Resources/button_next_hover.png", "Next");
	PreloadImage("MAMButNext_N", "../Resources/button_next_normal.png", null);
	PreloadImage("MAMButNext_P", "../Resources/button_next_pressed.png", null);
	PreloadImage("MAMButInfo_H", "../Resources/button_information_hover.png", "Information");
	PreloadImage("MAMButInfo_N", "../Resources/button_information_normal.png", null);
	PreloadImage("MAMButInfo_P", "../Resources/button_information_pressed.png", null);
	PreloadImage("MAMButClose_H", "../Resources/button_close_hover.png", "Close");
	PreloadImage("MAMButClose_N", "../Resources/button_close_normal.png", null);
	PreloadImage("MAMButClose_P", "../Resources/button_close_pressed.png", null);
	PreloadImage("MAMButContents_H", "../Resources/button_contents_hover.png", "Contents");
	PreloadImage("MAMButContents_N", "../Resources/button_contents_normal.png", null);
	PreloadImage("MAMButContents_P", "../Resources/button_contents_pressed.png", null);
	PreloadImage("MAMButPrint_H", "../Resources/button_print_hover.png", "Print");
	PreloadImage("MAMButPrint_N", "../Resources/button_print_normal.png", null);
	PreloadImage("MAMButPrint_P", "../Resources/button_print_pressed.png", null);
	}


