<!--

//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

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;
}

//================================================================================//
// Functions to ensure that ASAP availablity status is corrected for other when either 
// START or EXPIRY date ASAP option is altered
//================================================================================//
// This function matches the current radio option selections for both start and expiry dates
function matchAvailability( objCheckbox ) {
	var blnCheckboxValue = objCheckbox.value;
	if ( objCheckbox.name == 'AvailabilityStatus_Expiry') {
		if (blnCheckboxValue=='ASAP') {
			// Adjust Start date option appropriately
			objCheckbox.form.AvailabilityStatus_Start[0].checked = true;
			clearSpecifiedDates( objCheckbox.form);
		} else if (blnCheckboxValue=='ONGOING') {
			// Adjust Start date option appropriately
			objCheckbox.form.AvailabilityStatus_Start[1].checked = true;
			clearSpecifiedDates( objCheckbox.form); 
		} else {
			objCheckbox.form.AvailabilityStatus_Start[2].checked = true;	
		}
	}
	if ( objCheckbox.name == 'AvailabilityStatus_Start') {
		// Adjust Expiry date option appropriately
		if (blnCheckboxValue=='ASAP') {
			objCheckbox.form.AvailabilityStatus_Expiry[0].checked = true;
			clearSpecifiedDates( objCheckbox.form);
		} else if (blnCheckboxValue=='ONGOING') {
			objCheckbox.form.AvailabilityStatus_Expiry[1].checked = true;
			clearSpecifiedDates( objCheckbox.form);
		} else {
			objCheckbox.form.AvailabilityStatus_Expiry[2].checked = true;				
		}
	}
	return true;
}

// This function selects both of the "Specify Date" options (called when a date dropdown is changed)
// (this does not explicitly ensure that the selectedIndex was > 0 but it is implied)
function checkSpecifiedOptions ( objForm ) {
	objForm.AvailabilityStatus_Start[2].checked = true;	
	objForm.AvailabilityStatus_Expiry[2].checked = true;
	return true;
}

// Clear any previously specified dates for start or expiry date (called when ASAP is checked)
function clearSpecifiedDates( objForm ) {
	// clear the dropdowns and unmark them (this helps when validation highlights dates and then user selects ASAP/ONGOING
	markField(objForm._14_select_Starting_Month,'#FFFFFF','14','hidden');
	markField(objForm._15_select_Starting_Day,'#FFFFFF','15','hidden');
	markField(objForm._16_select_Starting_Year,'#FFFFFF','16','hidden');
	objForm._14_select_Starting_Month.selectedIndex = 0;
	objForm._15_select_Starting_Day.selectedIndex = 0;
	objForm._16_select_Starting_Year.selectedIndex = 0;
	markField(objForm._17_select_Month_Of_Application_Deadline,'#FFFFFF','17','hidden');
	markField(objForm._18_select_Day_Of_Application_Deadline,'#FFFFFF','18','hidden');
	markField(objForm._19_select_Year_Of_Application_Deadline,'#FFFFFF','19','hidden');
	objForm._17_select_Month_Of_Application_Deadline.selectedIndex = 0;
	objForm._18_select_Day_Of_Application_Deadline.selectedIndex = 0;
	objForm._19_select_Year_Of_Application_Deadline.selectedIndex = 0;
	return true;
}

// Returns true if this job is available ASAP 
function jobAvailableASAPorONGOING( objForm ) {
	return ((objForm.AvailabilityStatus_Start[0].checked) || (objForm.AvailabilityStatus_Start[1].checked));
}

// Sets the dropdowns to become mandatory
function setDateDropdownsMandatory( objForm ) {
	renameDropdowns( objForm , true );
	return true;
}
// Sets the dropdowns to become non-mandatory
function setDateDropdownsNonMandatory( objForm ) {
	renameDropdowns( objForm , false );
	return true;
}

// Renames all 6 date dropdowns to change their mandatory requirement mandatory=true when parameter=true
function renameDropdowns( objForm , blnMandatory ) {
	if (blnMandatory) {
		objForm._14_select_Starting_Month.name = '_14_select_Starting_Month';
		objForm._15_select_Starting_Day.name = '_15_select_Starting_Day';
		objForm._16_select_Starting_Year.name = '_16_select_Starting_Year';
		objForm._17_select_Month_Of_Application_Deadline.name = '_17_select_Month_Of_Application_Deadline';
		objForm._18_select_Day_Of_Application_Deadline.name = '_18_select_Day_Of_Application_Deadline';
		objForm._19_select_Year_Of_Application_Deadline.name = '_19_select_Year_Of_Application_Deadline';
	} else {
		objForm._14_select_Starting_Month.name = '_14_Starting_Month';
		objForm._15_select_Starting_Day.name = '_15_Starting_Day';
		objForm._16_select_Starting_Year.name = '_16_Starting_Year';
		objForm._17_select_Month_Of_Application_Deadline.name = '_17_Month_Of_Application_Deadline';
		objForm._18_select_Day_Of_Application_Deadline.name = '_18_Day_Of_Application_Deadline';
		objForm._19_select_Year_Of_Application_Deadline.name = '_19_Year_Of_Application_Deadline';	
	}
	return true;
}


//================================================================================//


// Function to check a radio button on the current form if the current dropdown has a selectedIndex
function checkSpecifyNewDate( objForm , intSelectedIndex , strRadioFieldName  ) {
	if (intSelectedIndex > 0) {
		// if specifying a new expiry date, validate that date
		var objCurrentField = null;
		for (var temp=0;temp<objForm.elements.length; temp++) {
			objCurrentField = objForm.elements[temp];
			if (objCurrentField.name == strRadioFieldName) {	
				// keep current ? check if first box with that name is CHECKED.
				if (objCurrentField.value=='True') {
					objCurrentField.checked = true;
				}
			}
		}
	}
	return true;
}


function checkDateOrder(intEarlierYear, intEarlierMonth, intEarlierDay, strEarlierName, intLaterYear, intLaterMonth, intLaterDay, strLaterName) {
	//Checks to see if one date is before another and returns an error if this is the case
	var boolError = false;

	if (intLaterYear < intEarlierYear) {
		boolError = true;
	} else if ((intLaterYear == intEarlierYear) && (intLaterMonth <= intEarlierMonth)) {
		if ( (intLaterMonth < intEarlierMonth) || ((intLaterMonth == intEarlierMonth) && (intLaterDay <= intEarlierDay)) ) {
			boolError = true;
		}
	}
	if (boolError == true) {
		return '     -  ' + strLaterName + ' date cannot be earlier than ' + strEarlierName + ' date.\n';
	} else {
		return '';
	}
}

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 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 is used to display the Job search form layer (from the Toolbox menu)
function displayJobSearchForm() {
	var strSearchJobForm;
	strSearchJobForm = '<FORM ACTION=\'JobListing.asp\' NAME=\'SearchJobs\' METHOD=\'POST\'><span class="bodyText">To search the jobs database, please use the form below to enter any keywords and press <em>Search Now &gt;&gt;</em>:</span><BR><BR>KEYWORDS<BR><INPUT TYPE=\'text\' NAME=\'searchJobsString\' SIZE=\'25\' onFocus=\'javascript:this.select();return true;\'><BR><INPUT CLASS=adminButton TYPE=\'Button\' NAME=\'MySubmit\' VALUE=\'Search Now &gt;&gt;\' onClick=javascript:lyrCurrentPopup.getFirstFormOnLayer().submit();>&nbsp;<INPUT CLASS=adminButton TYPE=\'button\' NAME=\'myClose\' VALUE=\'Close Window\' onClick=\'javascript:cClick();lyrToolBox.show();\'></FORM>';

	overlayPopup(strSearchJobForm, CAPTION, 'SEARCH JOBS . . .', AUTOSTATUS, WIDTH, 400, STICKY, SNAPY, 10, FIXX,200, FIXY, 100, TEXTCOLOR, '#222222', CLOSETEXT, '<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0><TR><TD><A HREF=\'javascript: cClick();\'><img src=../images/admin/toolbox/x.jpg alt=Close border=0></A></TD></TR></TABLE>', CLOSECOLOR, '#d1d2e1', FGCOLOR, '#d1d2e1');
	
	var tempForm = lyrCurrentPopup.getFirstFormOnLayer();
	tempForm.searchJobsString.value = 'keywords';
	tempForm.searchJobsString.focus();
	tempForm.searchJobsString.select();						

	return true;	
}


// This function is used to display the Resume search form layer (from the Toolbox menu)
function displayResumeSearchForm( strSearchType ) {
	var strSearchResumeForm;
	
	switch (strSearchType) {
	case 'ID':
		strSearchResumeForm = '<BLOCKQUOTE><BR><FORM ACTION=\'ResumeSearch.asp?formAction=SearchResults\' NAME=\'SearchResumes\' METHOD=\'POST\'><INPUT TYPE="hidden" NAME="searchType" VALUE="Simple">Find a Resume by entering an Applicant\'s ID:<BR><BR>APPLICANT ID<BR><INPUT TYPE=\'text\' NAME=\'ApplicantID\' SIZE=\'4\' onFocus=\'javascript:this.select();return true;\'>&nbsp;<INPUT CLASS=adminButton TYPE=\'Button\' NAME=\'MySubmit\' VALUE=\'GO &gt;&gt;\' onClick=javascript:lyrCurrentPopup.getFirstFormOnLayer().searchType.value=\'ID\';lyrCurrentPopup.getFirstFormOnLayer().submit();></FORM></BLOCKQUOTE>';

		overlayPopup(strSearchResumeForm, CAPTION, 'SEARCH RESUMES . . .', AUTOSTATUS, WIDTH, 400, STICKY, SNAPY, 10, FIXX,200, FIXY, 100, TEXTCOLOR, '#222222', CLOSETEXT, '<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0><TR><TD><A HREF=\'javascript: cClick();\'><img src=../images/admin/toolbox/x.jpg alt=Close border=0></A></TD></TR></TABLE>', CLOSECOLOR, '#d1d2e1', FGCOLOR, '#d1d2e1');
		
		var tempForm = lyrCurrentPopup.getFirstFormOnLayer();
		tempForm.ApplicantID.value = '0';
		tempForm.ApplicantID.focus();
		tempForm.ApplicantID.select();						
		break;
	case 'Keywords':
		strSearchResumeForm = '<BLOCKQUOTE><BR><FORM ACTION=\'ResumeSearch.asp?formAction=SearchResults\' NAME=\'SearchResumes\' METHOD=\'POST\'><INPUT TYPE="hidden" NAME="searchType" VALUE="Simple">Find Resumes by searching for keywords:<BR><BR>KEYWORDS<BR><INPUT TYPE=\'text\' NAME=\'Keyword\' SIZE=\'25\' onFocus=\'javascript:this.select();return true;\'>&nbsp;<INPUT CLASS=adminButton TYPE=\'Button\' NAME=\'MySubmit\' VALUE=\'GO &gt;&gt;\' onClick=javascript:lyrCurrentPopup.getFirstFormOnLayer().searchType.value=\'Simple\';lyrCurrentPopup.getFirstFormOnLayer().submit();></FORM></BLOCKQUOTE>';

		overlayPopup(strSearchResumeForm, CAPTION, 'SEARCH RESUMES . . .', AUTOSTATUS, WIDTH, 400, STICKY, SNAPY, 10, FIXX,200, FIXY, 100, TEXTCOLOR, '#222222', CLOSETEXT, '<TABLE CELLSPACING=0 CELLPADDING=0 BGCOLOR=#EEEEEE BORDER=0><TR><TD><A HREF=\'javascript: cClick();\'><img src=../images/admin/toolbox/x.jpg alt=Close border=0></A></TD></TR></TABLE>', CLOSECOLOR, '#d1d2e1', FGCOLOR, '#d1d2e1');
		
		var tempForm = lyrCurrentPopup.getFirstFormOnLayer();
		tempForm.Keyword.value = 'keywords';
		tempForm.Keyword.focus();
		tempForm.Keyword.select();						
		break;
	}
	return true;	
}



// 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|').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].focus();
						if ( String('text').indexOf( frmCurrentForm.elements[x].type.toString() ) > -1 )
							frmCurrentForm.elements[x].select();
						break;
					}
				}
			}
		}
	}
	return true;
}

//this script puts an input number into currency format and returns it as a string
function formatCurrencywiggitywhack(numInput) {

	var intIntegerPart = Math.floor(numInput);					// eg. if numInput = 1234.236, intIntegerPart = 1234
	var intDecimalPart = Math.round((numInput % 1)*100);		// eg. if numInput = 1234.236, intMod = 24
	alert(intIntegerPart);
	var strDecimalPart = intDecimalPart.toString();

	if (intDecimalPart == 0) {					// ie. there was originally no decimal values in number
		strDecimalPart = '00';
	} else if (strDecimalPart.length == 1) {	// ie. there was originally one decimal place value, eg. 1234.1
		strDecimalPart = strDecimalPart + '0';	// ie. to make it 1234.10
	}

	return '$' + intIntegerPart.toString() + '.' + strDecimalPart;
}

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">');
	else if (browserIsNN6)
	   document.write('<LINK rel="stylesheet" type="text/css" href="' + strRootPath + 'Common/Styles/' + strAdminOrPublic + '_nn6.css">');
	else if (browserIsNN4)
	   document.write('<LINK rel="stylesheet" type="text/css" href="' + strRootPath + 'Common/Styles/' + strAdminOrPublic + '_nn.css">');
	document.write('<LINK rel="stylesheet" type="text/css" href="' + strRootPath + 'Common/Styles/'+strAdminOrPublic + 	'stylesheet.css">');
	return true;
}

// 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=no,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, strUniqueName)
{
	var strWindowName = "popupWindow";
	if (typeof strUniqueName != "undefined"){
		strWindowName = strUniqueName;
	}
	popup = window.open(url,strWindowName,'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;
		}
}



// 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) {
	var emailAddressEntered = objAddressField.value;
	if ((emailAddressEntered.indexOf('@') < 1) || (emailAddressEntered.lastIndexOf('.') < (emailAddressEntered.indexOf('@') + 2)) || (emailAddressEntered.indexOf('\'') > -1)) {
		alert('Please enter a valid email address');
		objAddressField.focus();
		objAddressField.select();
		return false;
	} else {
		return true;
	}
}

// DIVISIONS FUNCTION
// This function populates the ManageJobs form with both a hidden value (clientID) and a corresponding text field value (clientuniqueid)
function returnIDToJobsForm(idToReturn, UniqueIDToReturn) {
	myFormField = opener.frmCurrentForm["_26_Organization_ID"];
	myFormField.value = idToReturn;
	myFormField = opener.frmCurrentForm["_25_mandatory_Unique_Organization_ID"];
	myFormField.value = UniqueIDToReturn;
	opener.focus();
	self.close();
}


// MATCHING FUNCTION
// This function populates the ManageJobs form with both a hidden value (clientID) and a corresponding text field value (clientuniqueid)
function returnIDToMatchForm(UniqueIDToReturn) {
	myFormField = opener.frmCurrentForm["JobUniqueID"];
	myFormField.value = UniqueIDToReturn;
	opener.focus();
	self.close();
}

//this script verifies a numeric entry in a quantity field
function verifyNumeric(inputText) {
	var flg = 0;
	var str='';
	var spc='';
	var arw='';

	var boolMustBePositiveNumber;
	if (arguments[1]) { boolMustBePositiveNumber = (arguments[1].toString() == 'positive'); }
	var strNameOfField;
	if (arguments[2]) { strNameOfField = (arguments[2].toString());}

	for (var i=0; i < inputText.length; i++) {
		cmp='0123456789.';
		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 false;
	} else {
		if (boolMustBePositiveNumber && (Math.abs(inputText) <= 0))
		{
			alert('Sorry, this value ' + strNameOfField + ' must be a positive number ( greater than zero ).');
			return false;
		} else {
			return true;
		}
	}
}



//this script verifies a numeric entry in a quantity field
function isFieldNumeric(inputText) {
	var flg = 0;
	var str='';
	var spc='';
	var arw='';

	var boolMustBePositiveNumber;
	boolMustBePositiveNumber = (arguments[1].toString() == 'positive');
	var strNameOfField;
	strNameOfField = (arguments[2].toString());

	for (var i=0; i < inputText.length; i++) {
		cmp='0123456789.';
		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 'The quantity ' + strNameOfField + ' must be number. You have entered ' + flg + ' unacceptable characters (' + str + ').';
	} else {
		if (boolMustBePositiveNumber && (Math.abs(inputText) <= 0))
		{
			//alert('Sorry, this value ' + strNameOfField + ' must be a positive number ( greater than zero ).');
			return 'The value ' + strNameOfField + ' must be a positive number ( greater than zero ).';
		} else {
			return 'valid';
		}
	}
}

//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';
	}
}

//===============================================================================
// This function sets the two form variables which are critical to the functionality of all pages
//===============================================================================
function setFormVariables(strCurrentForm, isPopupWindow) {

	// if the page has a form, then setup the currentForm variable
	if (strCurrentForm !='') {
		if (isPopupWindow)
			frmCurrentForm = eval('document.' + strCurrentForm);	
		else
			frmCurrentForm = eval('lyrPageContents.layer.document.' + strCurrentForm);	
	}

	//alert(frmCurrentForm.name);
	// and there is always a toolbox in a main window, not in a popup though
	if (! isPopupWindow)
		frmToolBox = lyrToolBox.layer.document.toolbarLinks;

	//if there is a popup form requiring post-pageload preparation, call it
	if (typeof preparePopupForm != 'undefined') {preparePopupForm();}
}


//===============================================================================
// 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
	lyrToolBox = new LayerObject('ToolBox');

	// Open/Close Image layers for the site menu
	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)
	if (!(lyrToolBox.visible))
	{
		lyrPageContents.hide();
		lyrToolBox.show();
		lyrToolBoxControl.hide();
		lyrToolBoxControlClose.show();
	}
	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();\'>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); }

// 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;
}

//-->