<!--

//Created By:	 				Reid Guest
//Last Modified By:			Reid Guest
//Created On:					August 25, 2000
//Modified: 						August 25, 2000
//Purpose:						To provide standard functions essential to most OnTheFly modules


// VARIABLES

// This variable is the one-and-only variable to use for non-unique popup windows
var popup;

// This variable is used to revert the document's title (in title bar) back to original title when the hash of the location is altered
var strCurrentTitle = document.title;

// install the global error-handler
window.onerror = errorHandler;

//FUNCTIONS

//for navigating to a URL specified in a drop-down
function go( objDrop ) {
	var strURL = '';
	if (objDrop[objDrop.selectedIndex].value != '') {
		strURL = objDrop[objDrop.selectedIndex].value;
		document.location = strURL;
	}
	return true;
}

function isImageFile( s ) {
	var blnIsValid = false;
	if (s.length > 0) {
		var ext = s.substring( s.lastIndexOf('.') + 1 , s.length ).toLowerCase();
		var strFileTypes = '|gif|jpg|jpeg|';
		if (strFileTypes.indexOf( '|' + ext + '|') > -1)
			blnIsValid = true;
	}
	return blnIsValid;
}

//modified by Jon October 23, 2001 to pass in the second parameter 
// modified by REID November 14,2001 to validate the extension of the file (as an optional parameter)
function CheckFileType(d){
	var file_name = d.value.toLowerCase();
	// Optional second argument affects validation routine
	var extensionString = (arguments.length >= 2) ? arguments[1].toString() : '';
	var blnExtensionCheck = (extensionString.length > 0);
	var file_extensions_permitted = extensionString.toLowerCase();
	// NOTE: When not checking extensions, the fourth slot will never be used as a message
	var msg = ['Please select a valid file to upload.',
		'Uploading exectuable files is considered malicious behavior and will not be permitted. Please select a valid file and then try submitting your file again.',
		'Please ensure that the file has no single or double quotes ( \' or " ) in the filename.',
		'You may not upload a file with that extension.\nThe following extensions are permitted : ' + file_extensions_permitted]
	var start_position = file_name.lastIndexOf(".");
	if (start_position < 0) { alert( msg[0] );return false; }
	var end_position = file_name.length;
	var file_extension = file_name.substring(start_position + 1, end_position );
	if (file_extension == 'exe') { alert( msg[1] );return false; }
	if ( (file_name.indexOf('\'') > -1) || (file_name.indexOf('"') > -1) ) { alert( msg[2] );return false; }
	if (blnExtensionCheck)
		if (file_extensions_permitted.indexOf(file_extension) < 0) { alert( msg[3] );return false; }
	return true;
}

function CountWords (objField) {
	var fullStr = String(objField.value);
	var charCount = fullStr.length;
	var rExp = /[^A-Za-z0-9]/gi;
	var spacesStr = fullStr.replace(rExp, " ");
	var cleanedStr = spacesStr + " ";
	do {
		var old_str = cleanedStr;
		cleanedStr = cleanedStr.replace("  ", " ");
	} while (old_str != cleanedStr);
	var splitString = cleanedStr.split(" ");
	var wordCount = splitString.length -1;
	if (fullStr.length <1) {wordCount = 0;}
	// Netscape's word count is one under the correct count
	if ( (fullStr.length > 0) && (browserIsNN4) ) {
		wordCount++;
	}
	return wordCount;
}

//this script verifies a numeric entry in a quantity field
function isFieldAlphanumeric(inputText) {
	var flg = 0;
	var str='';
	var spc='';
	var arw='';
	var bLowerCase = false;
	var strLowerCase = '';
	var strNameOfField;
	var cmp='0123456789abcdefghijklmnopqrstuvwxyz';
	strNameOfField = (arguments[1].toString());
	if (typeof arguments[2] != 'undefined')
		bLowerCase = (arguments[2]);
	else
		bLowerCase = false;
	if (bLowerCase==true)
		strLowerCase = ' and lower-case';
	else
		cmp += 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
	for (var i=0; i < inputText.length; i++) {
		tst=inputText.substring(i,i+1);
		if (cmp.indexOf(tst) < 0) {
			flg++;
			str += tst;
			spc += tst;
			arw += '^';
		} else {
			arw += '_';
		}
	}
	if (flg != 0) {
		if (spc.indexOf(' ') > -1) {
			str += ' and a space';
		}
		//alert('Sorry, the quantity ' + strNameOfField + ' must be number. You have entered ' + flg + ' unacceptable characters (' + str + ').');
		return strNameOfField + ' must be alphanumeric' + strLowerCase + '. You have entered ' + flg + ' unacceptable characters (' + str + ').';
	} else {
		return 'valid';
	}
}

function errorHandler()
{
 // handle the error here
//alert('There has been an error in this application.\nThis message should only be seen in testing/development phases.\n\nPlease comment out this line if this site is live (see templates).');
 // stop the event from bubbling up to the default window.onerror handler
   return true;
}

function checkDate(myMonthStr, myDayStr, myYearStr) {
	 
	//var myDateStr = myDayStr + ' ' + myMonthStr + ' ' + myYearStr;

	/* Using form values, create a new date object
	which looks like "Wed Jan 1 00:00:00 EST 1975". */
	var myDate = new Date( myYearStr, myMonthStr, myDayStr );

	// Convert the date to a string so we can parse it.
	var myDate_string = myDate.toGMTString();

	/* Split the string at every space and put the values into an array so,
	using the previous example, the first element in the array is "Wed", the
	second element is "Jan", the third element is "1", etc. */
	var myDate_array = myDate_string.split( ' ' );

	/* If we entered "Feb 31, 1975" in the form, the "new Date()" function
	converts the value to "Mar 3, 1975". Therefore, we compare the month
	in the array with the month we entered into the form. If they match,
	then the date is valid, otherwise, the date is NOT valid. */
	myMonthStr = getMonthAbbreviation(myMonthStr);

	if ( myDate_array[2] != myMonthStr ) {
	  return false;
	} else {
	  return true;
	}
}

//This function closes the popup window and restores focus to the opener window
function closePopup() {
	self.close();
	opener.focus();
	return true;
}

function jsDisplay( strCaption , strMessage , strStatus , bShowOK ) {
	// defaults, in case of old browser (non ie/nn browsers as well)
	var intCurrentWindowWidth2 = 640, height = 480; 
	if (document.layers) {
		intCurrentWindowWidth2 = window.innerWidth;
	}
	else if (document.all) {
		intCurrentWindowWidth2 = document.body.clientWidth;
	}
	var intMessageWindowWidth2 = 400;
	var intXCenter2 = ((intCurrentWindowWidth2 - intMessageWindowWidth2) / 2)

	// popup please wait dialog
	var strErrorMessage2 = strMessage;
	strErrorMessage2 = strErrorMessage2.replace(/\n/g,'<BR>');
	if (bShowOK)
		strErrorMessage2 = strErrorMessage2 + '<TABLE BGCOLOR=#EEEEEE ALIGN=CENTER CELLPADDING=0 CELLSPACING=0><TR><TD><A HREF=\'javascript: void(0);\' onClick=\'javascript:cClick();lyrEmptyPage.hide();lyrPageContents.show();lyrFormattingTools.show();sendToFirstBadField();\'><IMG BORDER=0 SRC=\'../Images/OK_button.gif\'></A></TD></TR></TABLE>';

	lyrPageContents.hide();
	lyrEmptyPage.setInnerHTML('<HTML><BODY><TABLE WIDTH=630 HEIGHT=2000 BGCOLOR=#FFFFFF><TR><TD BGCOLOR=#FFFFFF>&nbsp;</TD></TR></TABLE></BODY></HTML>');
	lyrFormattingTools.hide();
	lyrEmptyPage.show();

	var waitForClick2 = overlayPopup(strErrorMessage2,CAPTION, strCaption, STICKY, STATUS, strStatus, FIXX, intXCenter2, FIXY, 100, WIDTH, intMessageWindowWidth2, HEIGHT, 60, ABOVE, CLOSETEXT, '', CLOSECOLOR, '#FFFFFF');
	scrollTo(0,79);
}

function getMonthAbbreviation(intMonth) {
	var strMonthAbbreviation = '';
	arrMonths = new Array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
	strMonthAbbreviation = arrMonths[intMonth];
	return strMonthAbbreviation;
}

//function to count number of text rows entered in a textarea
function countRows(strText) {
	var intLineCount;
	var intTempIndex = 0;

	// if there is text, then we have one line
	intLineCount = (strText.length > 0) ? 1: 0;

	// loop through text, removing  any double-carriage-returns until there are no more
	do
	{
		intTempIndex =  strText.indexOf('\r\n');
		if (intTempIndex > 0)
		{
			strText = strText.substring(intTempIndex + 1);
			intLineCount ++;
		}
	}
	while (intTempIndex > 0);
	return intLineCount;
}

function isEmpty(objInputField) {
	if (objInputField.value == '')
	{
		return true;
	} else {
		return false;
	}
}

// This function links to a given anchor (ie. <A NAME="strAnchorName"> ....) in the current document, then corrects the document's title
function linkToAnchor(strAnchorName) {
	document.location.hash = strAnchorName;
	document.title = strCurrentTitle;
}


//function to remove double-line-breaks (empty lines) from a textarea (while trimming external breaks)
function removeEmptyLines(strText) {
	var tempText = stripSpaces(getAcceptableText(String(strText))); 
	var intTempIndex = 0;

	do
	{
		intTempIndex =  tempText.indexOf('\r\n\r\n');
		if (intTempIndex > -1)
		{
			// remove double lines (from the text to be returned from the function
			tempText = tempText.replace('\r\n\r\n','\r\n');
		}
	}
	while (intTempIndex > 0);

	return tempText;
}

function focusOnFirstField() {
	//if there is a form, focus on it's first editable field
	if (typeof frmCurrentForm != 'undefined')
	{
		//Focus and select the first element on the form that is a textual input field
		for (var x=0; x<frmCurrentForm.elements.length;x++) {
			if ( String('|hidden|button|checkbox|radio|textarea|reset|submit|select-one|').indexOf( '|' + frmCurrentForm.elements[x].type.toString() + '|' ) == -1 ) {
				// Do not focus on the records/page dropdown
				if (frmCurrentForm.elements[x].name!='RecordsPerPage') {
					if ((frmCurrentForm.elements[x].focus) && (frmCurrentForm.elements[x].name != 'WordCount')){ 
						frmCurrentForm.elements[x].focus();
						self.scrollTo(0,0);
						if ( String('text').indexOf( frmCurrentForm.elements[x].type.toString() ) > -1 )
							frmCurrentForm.elements[x].select();
						break;
					}

				}
			}
		}
	}
	return true;
}



function formatCurrency(num) {
	num = Math.abs(num);
	if (isNaN(num)) {
		num = "0";
	}
	cents = Math.floor((num*100+0.5)%100); 
	num = Math.floor(num).toString();
	if (cents < 10) {
		cents = "0" + cents; 
	}
	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++) {
		num = num.substring(0,num.length-(4*i+3))+num.substring(num.length-(4*i+3)); 
	}

	return (num + '.' + cents); 
}

// Function to include a style sheet based on the browser and version of the user
function includeStyleSheet( strAdminOrPublic , strRootPath ) {
	if ((browserIsIE4) || (browserIsIE3)) {
	   document.write('<LINK rel="stylesheet" type="text/css" href="' + strRootPath + 'Common/Styles/' + strAdminOrPublic + '_ie4.css">');
	   if (strAdminOrPublic.toLowerCase()=='admin') { document.write('<LINK rel="stylesheet" type="text/css" href="' + strRootPath + 'Common/Styles/' + strAdminOrPublic + '_gui_ie4.css">'); }
	} else if (browserIsNN6) {
	   document.write('<LINK rel="stylesheet" type="text/css" href="' + strRootPath + 'Common/Styles/' + strAdminOrPublic + '_nn6.css">');
	   if (strAdminOrPublic.toLowerCase()=='admin') { document.write('<LINK rel="stylesheet" type="text/css" href="' + strRootPath + 'Common/Styles/' + strAdminOrPublic + '_gui_nn6.css">'); }
	} else if (browserIsNN4) {
	   document.write('<LINK rel="stylesheet" type="text/css" href="' + strRootPath + 'Common/Styles/' + strAdminOrPublic + '_nn.css">');
		// Include minor-version-dependent stylesheets for netscape 4 (these rules override default nn stylesheet rules)
	   if (strAdminOrPublic.toLowerCase()=='public') {
		   var strMinorVer = parseFloat(navigator.appVersion).toString();
			switch (strMinorVer) {
			case '4.74':
				document.write('<LINK rel="stylesheet" type="text/css" href="' + strRootPath + 'Common/Styles/' + strAdminOrPublic + '_nn_474.css">');
				break;
			case '4.7':
				document.write('<LINK rel="stylesheet" type="text/css" href="' + strRootPath + 'Common/Styles/' + strAdminOrPublic + '_nn_47.css">');
				break;
			case '4.08':
				alert('Netscape 4.08 Alert:\n\nThe home page of this site is not yet optimized for your version of the netscape browser.\n\nWe strongly recommend upgrading to version 4.7 as we are not yet optimizing this page for your current version');
				document.write('<LINK rel="stylesheet" type="text/css" href="' + strRootPath + 'Common/Styles/' + strAdminOrPublic + '_nn_408.css">');
				break;
			default:
				// The 4.7 stylesheet will be used for all other minor versions of NS4
				document.write('<LINK rel="stylesheet" type="text/css" href="' + strRootPath + 'Common/Styles/' + strAdminOrPublic + '_nn_47.css">');
				break;
			}
	   }
	   if (strAdminOrPublic.toLowerCase()=='admin') { document.write('<LINK rel="stylesheet" type="text/css" href="' + strRootPath + 'Common/Styles/' + strAdminOrPublic + '_gui_nn.css">'); }
	}
	return true;
}

function includeMenuScripts( isMenu ) {
	if (isMenu)
	document.write("<SCRIPT LANGUAGE='JavaScript1.2' SRC='hierArrays.js' TYPE='text/javascript'><\/SCRIPT>");
	if (isMenu)
	document.write("<SCRIPT LANGUAGE='JavaScript1.2' SRC='hierMenus.js' TYPE='text/javascript'><\/SCRIPT>");
}

// The variable through which a popup can be tested for/accessed from any page
var popup

function popupWindow(url, windowsWidth, windowsHeight)
{

	popup = window.open(url,'popupWindow','resizable=yes,scrollbars=yes,width=' + windowsWidth + ',height=' + windowsHeight + ',top=50,left=200');
	// delay to halt IE4 errors
	setTimeout('popup.focus();',250);

	return popup.name;
}

function popupWindowDetails(url, toolBar, windowsLocation, directories, status, menuBar, scrollBars, resizable, windowsWidth, windowsHeight, windowsTop, windowsLeft)
{
	popup = window.open(url,'popupWindow','toolbar=' + toolBar + ',location=' + windowsLocation + ',directories=' + directories + ',status=' + status + ',menubar=' + menuBar + ',scrollbars=' + scrollBars + ',resizable=' + resizable + ',width=' + windowsWidth + ',height=' + windowsHeight + ',top=' + windowsTop + ',left=' + windowsLeft + '');
	// delay to halt IE4 errors
	setTimeout('popup.focus();',250);

	return popup.name;
}



//Created By:	 				Reid Guest
//Last Modified By:			Reid Guest
//Created On:					July 18, 2000
//Modified: 						August 16, 2000
//Purpose:						To preload images on a page so they can be used with minimal load time OnTheFly
//									ie. to load images which are only shown on selecting a certain drop-down item or used to swap graphics onMouseOver
//Parameters:					A listing of 'virtualpath/filename' parameters


function preloadImages()
{
	for (i=0, j=arguments.length; i<j; i++)
	{
		preloadImage = new Image();
		preloadImage.src = arguments[i];	 
	}
}

// this function is used to change the text on a submit button for a bilingual back-end
function setSubmitButtonText(objButton, objCheckBox) {
		//backup original value of submit button to replace when equiv checkbox is cleared
		if (typeof strOriginalSubmitButtonValue == 'undefined') {
			strOriginalSubmitButtonValue = objButton.value.toString().replace(' EQUIVALENT','');;
		}

		// if the checkbox is checked, then insert 'EQUIVALENT' into the button text
		if (objCheckBox.checked) {		
			// Insert ' EQUIVALENT' into the button text
			objButton.value=strOriginalSubmitButtonValue.replace(' >>',' EQUIVALENT >>');
		} else {
			// Remove ' EQUIVALENT' from the button text
			objButton.value=strOriginalSubmitButtonValue;
		}
}

// this function is used to change the text on a submit button for eBulletin Descriptors
// this is specific to NRCAN-EBulletin
function setSubmitButtonTextEB(objButton, objCheckBox, mode) {
		//backup original value of submit button to replace when equiv checkbox is cleared
		if (typeof strOriginalSubmitButtonValue == 'undefined') {
			strOriginalSubmitButtonValue = objButton.value.toString();
		}

		// if the checkbox is checked, then insert 'EQUIVALENT' into the button text
		if (objCheckBox.checked) {		
			// Insert ' EQUIVALENT' into the button text
			if (mode == 1) {
				objButton.value=strOriginalSubmitButtonValue.replace('PROCEED','ADD EQUIVALENT');
			} else if (mode == 2) {
				objButton.value=strOriginalSubmitButtonValue.replace('PROCEED','UPDATE EQUIVALENT');
			}
			
		} else {
			// Remove ' EQUIVALENT' from the button text
			objButton.value='PROCEED >>';
		}
}

// this function is used to change the text on a submit button for eBulletin Article Management
// this is specific to NRCAN-EBulletin
function setSubmitButtonTextCM(objButton, objCheckBox) {
		//backup original value of submit button to replace when equiv checkbox is cleared
		if (typeof strOriginalSubmitButtonValue == 'undefined') {
			strOriginalSubmitButtonValue = objButton.value.toString();
		}

		// if the checkbox is checked, then insert 'EQUIVALENT' into the button text
		if (objCheckBox.checked) {		
			// Insert ' EQUIVALENT' into the button text
			objButton.value=strOriginalSubmitButtonValue.replace('ARTICLE','EQUIVALENT');
		} else {
			// Remove ' EQUIVALENT' from the button text
			objButton.value=strOriginalSubmitButtonValue.replace('EQUIVALENT','ARTICLE');
		}
}
// this function is used to change the text on a submit button for eBulletin Article Management
// this is specific to NRCAN-EBulletin
function setSubmitButtonTextMP(objButton, objCheckBox) {
		//backup original value of submit button to replace when equiv checkbox is cleared
		if (typeof strOriginalSubmitButtonValue == 'undefined') {
			strOriginalSubmitButtonValue = objButton.value.toString();
		}

		// if the checkbox is checked, then insert 'EQUIVALENT' into the button text
		if (objCheckBox.checked) {		
			// Insert ' EQUIVALENT' into the button text
			objButton.value=strOriginalSubmitButtonValue.replace('SECTIONS','EQUIVALENT');
		} else {
			// Remove ' EQUIVALENT' from the button text
			objButton.value=strOriginalSubmitButtonValue.replace('EQUIVALENT','SECTIONS');
		}
}

// this function is used to change the text on a submit button for eBulletin Article Management
// this is specific to NRCAN-EBulletin
function setSubmitButtonTextMPS(objButton, objCheckBox) {
		//backup original value of submit button to replace when equiv checkbox is cleared
		if (typeof strOriginalSubmitButtonValue == 'undefined') {
			strOriginalSubmitButtonValue = objButton.value.toString();
		}

		// if the checkbox is checked, then insert 'EQUIVALENT' into the button text
		if (objCheckBox.checked) {		
			// Insert ' EQUIVALENT' into the button text
			objButton.value=strOriginalSubmitButtonValue.replace('ANOTHER SECTION','EQUIVALENT');
		} else {
			// Remove ' EQUIVALENT' from the button text
			objButton.value=strOriginalSubmitButtonValue.replace('EQUIVALENT','ANOTHER SECTION');
		}
}

// Equivalent to vbscript's Trim() function	
function stripSpaces(strText) {
	x = strText;
	while (x.substring(0,1) == ' ') x = x.substring(1);
	while (x.substring(x.length-1,x.length) == ' ') x = x.substring(0,x.length-1);
	return x;
}

// This function removes all line-breaks and other characters not found in the acceptable characters string
function getAcceptableText(strText) {
	x = strText;
	strAcceptables = '1234567890qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM';
	while (strAcceptables.indexOf(x.substring(0,1)) == -1) x = x.substring(1);
	while (strAcceptables.indexOf(x.substring(x.length-1,x.length)) == -1) x = x.substring(0,x.length-1);
	return x;
}

// validates an email address
function isEmailAddress(objAddressField, strLanguage) {
	if ( typeof(strLanguage) == 'undefined'){
		strLanguage = 'English';
	}
	var emailAddressEntered = objAddressField.value;
	if ((emailAddressEntered.indexOf('@') < 1) || (emailAddressEntered.lastIndexOf('.') < (emailAddressEntered.indexOf('@') + 2)) || (emailAddressEntered.indexOf('\'') > -1) || (emailAddressEntered.indexOf('"') > -1) ) {
		if (strLanguage =='English')
		{
			alert('Please enter a valid email address');
		}else{
			alert('Veuillez insérer votre adresse de courriel');
		}
		
		objAddressField.focus();
		objAddressField.select();
		return false;
	} else {
		return true;
	}
}




//this script verifies a numeric entry in the Quantity field on the shopping cart forms
function verifyNumeric(inputText) {
	var noAlert = false;
	var allowCurrency = false;
	if (typeof arguments[1] != 'undefined')
		noAlert = (arguments[1] == true);
	if (typeof arguments[2] != 'undefined')
		allowCurrency = (arguments[2] == true);
	var flg = 0;
	var str='';
	var spc='';
	var arw='';
	for (var i=0; i < inputText.length; i++) {
		cmp='0123456789';
		if (allowCurrency==true)
			cmp+='.'; // Allow decimals to be in the value entered
		tst=inputText.substring(i,i+1);
		if (cmp.indexOf(tst) < 0) {
			flg++;
			str += tst;
			spc += tst;
			arw += '^';
		} else {
			arw += '_';
		}
	}
	if (flg != 0) {
		if (spc.indexOf(' ') > -1) {
			str += ' and a space';
		}
		if (!(noAlert))
			alert('Sorry, the quantity must be number. You have entered ' + flg + ' unacceptable characters (' + str + ').');
		return false;
	} else {
		return true;
	}
}


//===============================================================================
// This function sets the two form variables which are critical to the functionality of all pages
//===============================================================================
function setFormVariables(strCurrentForm, isPopupWindow) {
	// Optional 3rd parameter specifies if the popup window has page layers (for validation)
	var layersUsed = (String(arguments[2]) == 'true') ? true : false;
	// if the page has a form, then setup the currentForm variable
	if (strCurrentForm !='') {
		if (isPopupWindow && (! layersUsed)) {
			frmCurrentForm = eval('document.' + strCurrentForm);	
		} else {
			if (lyrPageContents.layerExists)
				frmCurrentForm = eval('lyrPageContents.layer.document.' + strCurrentForm);	
		}
	}
	// and there is always a toolbox in a main window, not in a popup though
	if ((! isPopupWindow) && (typeof lyrToolBox != 'undefined')) // and only if the toolbox laer exists
		frmToolBox = lyrToolBox.layer.document.toolbarLinks;

	//if there is a popup form requiring post-pageload preparation, call it
	if (typeof preparePopupForm != 'undefined') {preparePopupForm();}
}


//===============================================================================
// public layer creation methods
// Main layer where module-specific HTML is placed (all forms, etc...)
//===============================================================================
pageLoaded = false;
frmCurrentForm = null; // allow reference to these variables prior to the page onLoad event
objMyForm = null;
function InitializePublicLayers() {
	lyrLeftNav = new LayerObject('leftNav');
	lyrPageContents = new LayerObject('pageContents');
	frmCurrentForm = null;
	objMyForm = null;
}

//===============================================================================
// This function assigns layer objects to the required public layer variables 
//===============================================================================
function setFormVariables_Public(strCurrentForm, isPopupWindow) {
	// Optional 3rd parameter specifies if the popup window has page layers (for validation)
	var layersUsed = (String(arguments[2]) == 'true') ? true : false;
	// if the page has a form, then setup the currentForm variable
	if (strCurrentForm !='') {
		if (isPopupWindow && (! layersUsed)) {
			frmCurrentForm = eval('document.' + strCurrentForm);	
		}
		else {
			if (lyrPageContents.layerExists) {
				if (browserIsNN6) {
					frmCurrentForm = document.getElementById(strCurrentForm);
				} else {				
					frmCurrentForm = eval('lyrPageContents.layer.document.' + strCurrentForm);		
				}
			} else {
				alert( '\'PageContents\' layer could not be created');
			}
		}
	}
}

//===============================================================================
// This function assigns layer objects to the required layer variables (see template's BODY onLoad event for call)
// NOTE:
//	To get at the style for the layer, IE is lyrToolBoxControl.style.attributename whereas NN is lyrToolBoxControl.left;
//===============================================================================
function initializeLayers() {
	// Assign layers to objects
	// IMPORTANT: ALL LAYERS IN ANY MODULE IN THE SITE <<MUST>> BE DECLARED HERE

	// Menu for site
	lyrPleaseWait = new LayerObject('PleaseWait');
	lyrToolBox = new LayerObject('ToolBox');

	// Open/Close Image layers for the site menu
	lyrLoadingLayer = new LayerObject('LoadingLayer');
	lyrToolBoxControl = new LayerObject('ToolBoxControl');
	lyrToolBoxControlClose = new LayerObject('ToolBoxControlClose');

	// Main layer where module-specific HTML is placed (all forms, etc...)
	lyrPageContents = new LayerObject('PageContents');

	// Empty page for covering screen with nothing when necessary
	lyrEmptyPage = new LayerObject('EmptyPage');

	// Preview pane for CM pages
	lyrPreviewPage = new LayerObject('PreviewPage');
	
	// Newsletter status bar (also needed to be declared earlier in page load on SendNewsletter.asp)
	lyrStatusBar = new LayerObject('statusBar');

	// CM page-formatting buttons
	lyrFormattingTools = new LayerObject('FormattingTools');

	// Popup mousovers/clicks (descriptions, menus)
	lyrCurrentPopup = new LayerObject('overlayPopupStyle');
	initializeWindowControlLayers()
}

function initializeWindowControlLayers() {
	// window actions layers in the popup windows
	lyrBottomWindowControls = new LayerObject('bottomWindowControlsBar');
	lyrTopWindowControls = new LayerObject('topWindowControlsBar');
}

function logoutUser( strLogoutURL ) {
	frmToolBox.action=strLogoutURL;
	frmToolBox.FormAction.value='Logout';
	frmToolBox.target='openerWindow';
	frmToolBox.submit();
	self.close();
	return true;
}

function showPasswordPopup() {
	// hide the page and show the toolbox if necessary (not necessary when called from toolbox)
	var strGetPassword;
	strGetPassword = '<BLOCKQUOTE><BR><FORM ACTION=\'SendPassword.asp\' NAME=\'sendPassword\' METHOD=\'POST\' TARGET=\'popupWindow\'><INPUT TYPE=\'hidden\' NAME=\'formAction\' VALUE=\'SendPassword\'>Upon pressing <I>Send &gt;&gt;</I>, the username/password combination for your account will be sent to you by email.<BR><BR>YOUR EMAIL ADDRESS<BR><INPUT TYPE=\'text\' NAME=\'emailAddress\' SIZE=\'25\' onFocus=\'javascript:this.select();return true;\'><BR><BR><INPUT CLASS=buttons TYPE=\'Button\' NAME=\'MySubmit\' VALUE=\'SEND &gt;&gt;\' onClick=\'javascript: sendMail(this.form, &quot;Email Address&quot;,this.form.emailAddress);\'>&nbsp;<INPUT CLASS=buttons TYPE=\'button\' NAME=\'myClose\' VALUE=\'CLOSE\' onClick=\'javascript:cClick();lyrToolBoxControlClose.hide();lyrToolBoxControl.show();lyrToolBox.hide();lyrPageContents.setLeft(0);lyrPageContents.show();\'></FORM></BLOCKQUOTE>';

	overlayPopup(strGetPassword, CAPTION, 'FORGOT PASSWORD . . .', AUTOSTATUS, WIDTH, 200, STICKY, SNAPY, 10, FIXX,200, FIXY, 100, FGCOLOR, '#EEEEEE', TEXTCOLOR, '#222222', CLOSETEXT, '<TABLE CELLSPACING=0 CELLPADDING=0 BGCOLOR=#EEEEEE BORDER=0><TR><TD><FONT SIZE=1><A HREF=\'javascript:void()\' onClick=\'javascript:cClick();lyrToolBox.hide();lyrPageContents.setLeft(0);lyrPageContents.show();\'>X</A></FONT></TD></TR></TABLE>');

	var tempForm = lyrCurrentPopup.getFirstFormOnLayer();
	tempForm.emailAddress.value = 'you@yourhost.com';
	tempForm.emailAddress.focus();
	tempForm.emailAddress.select();	
}

var strCMIamgePath = '';
function setCMImagePath( strPath ){ strCMIamgePath = strPath;return true;}
function getCMImagePath(){ return(strCMIamgePath); }

// Update up to 3 RichEdit boxes (to activate initial FONT attribue presets)
function	initializeRichEditControls() {
	// NOTE: cannot use eval and typeof to determine existence of "n" controls
	if (typeof setFont_RichEdit_1 != 'undefined') {
		setFont_RichEdit_1('FontName');		
		setFont_RichEdit_1('FontSize');		
		setFont_RichEdit_1('FontColor');		
	}
	if (typeof setFont_RichEdit_2 != 'undefined') {
		setFont_RichEdit_2('FontName');		
		setFont_RichEdit_2('FontSize');		
		setFont_RichEdit_2('FontColor');		
	}
	if (typeof setFont_RichEdit_3 != 'undefined') {
		setFont_RichEdit_3('FontName');		
		setFont_RichEdit_3('FontSize');		
		setFont_RichEdit_3('FontColor');		
	}
}

// Maximize the current browser window
function maximizeWin() {
	if (window.screen) {
		var newWidth = (browserIsIE4) ? (screen.availWidth) : (screen.availWidth - 8);
		var newHeight = (browserIsIE4) ? (screen.availHeight) : (screen.availHeight - 125);
		window.moveTo(0, 0);
		window.resizeTo(newWidth, newHeight);
	}
	return true;
}


//-->
