//# o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o
//
// modified: 2010-08-10, 3:56 pm
//
//# o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o


function UpdateManageChargeCodes() {
	var DF = document.Employee;
	if( DF.manage_charge_codes.checked == true ) {
		if( DF.time_access.value == "employee" ) {
			alert( "Only administrators and supervisors can manage charge codes" );
			DF.manage_charge_codes.checked = false;
		}
	}
}


//# - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #


function ToggleCB( CB ) {
	var MYCB = eval( "document." + CB );
	if( MYCB.checked == true ) {
		MYCB.checked = false;
	} else {
		MYCB.checked = true;
	}
}


//# - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #


function CheckCookie() {
	var AllCookies = document.cookie;
	var pos = AllCookies.indexOf( "user=customer" );
	if( pos == -1 ) {
		location="/supportlogin.html";
	}
}


//# - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #


function CheckAdmin() {
	var AllCookies = document.cookie;
	var pos = AllCookies.indexOf( "user=admin" );
	if( pos == -1 ) {
		location="/supportlogin.html";
	}
}


//# - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #


function CheckAdminOrCustomer() {
	var AllCookies = document.cookie;
	var pos = AllCookies.indexOf( "user=admin" );
	if( pos == -1 ) {
		pos = AllCookies.indexOf( "user=customer" );
		if( pos == -1 ) {
			location = "/supportlogin.html";
		}
	}
}


//# - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #


function CheckAccess( NecessaryAccessLevel ) {
	var UserCookie = document.cookie;
	var CookieFields = /calianemployee=\d{4}(\d{2})/;
	if( UserCookie.match( CookieFields ) ) {
		var AccessLevel = UserCookie.match( CookieFields )[1];
		var alertmsg = ( AccessLevel + " : " + NecessaryAccessLevel );
		if( AccessLevel < NecessaryAccessLevel ) {
			location="/notallowed.html";
		}
	} else {
		location="/notallowed.html";
	}
}


//# - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #


function CheckSupportAccess( NecessaryAccessLevel ) {
	var UserCookie = document.cookie;
	var CookieFields = /caliansupportuser=(\d{2})/;
	if( UserCookie.match( CookieFields ) ) {
		var AccessLevel = UserCookie.match( CookieFields )[1];
		if( AccessLevel < NecessaryAccessLevel ) {
			location="/notallowed.html";
		}
	} else {
		location="/notallowed.html";
	}
}


//# - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #
//
//
//function SetCookie() {
//	document.cookie = "user=customer; path=/;";
//}
//
//
//# - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #


function RemoveCookie() {
	document.cookie = "user=; path=/; expires=Sunday, 12-Dec-71 05:06:00;";
	document.cookie = "caliansupportuser=00n.obody; path=/; expires=Sunday, 12-Dec-71 05:06:00;";
}


//# - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #


function RemoveEmployeeCookie() {
	document.cookie = "calianemployee=;path=/;expires=Sunday, 12-Dec-71 13:06:00 GMT";
}


//# - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #


function MoveTo( NewURL , Delay ) {
	setTimeout( "location='" + NewURL + "'" , Delay );
}


//# - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #


function ValidateSupportForm() {
	var EmptyElements = new Array();
	var fi = document.supportForm;
	if( ! fi.supportCustomer.value            ) { EmptyElements[EmptyElements.length] = "Customer";   }
	if( ! trim( fi.supportName.value        ) ) { EmptyElements[EmptyElements.length] = "Your Name";  }
	if( ! ValidEmail( fi.supportEmail.value ) ) { EmptyElements[EmptyElements.length] = "Your Email"; }
	if( ! trim( fi.supportPhone.value       ) ) { EmptyElements[EmptyElements.length] = "Your Phone"; }
	if( fi.supportProgram ) {
		if( fi.supportProgram.value == "null" ) { EmptyElements[EmptyElements.length] = "Program"; }
	}
	if( ! trim( fi.supportTitle.value       ) ) { EmptyElements[EmptyElements.length] = "Title"; }
	if( fi.supportComponent.value == "null" ) {
		EmptyElements[EmptyElements.length] = "Application";
	} else if( ( fi.supportComponent.value == "Specify" ) & ( fi.supportOthercomponent.value == "" ) ) {
		EmptyElements[EmptyElements.length] = "Application";
	}
	if( ! trim( fi.supportIssue.value       ) ) { EmptyElements[EmptyElements.length] = "Issue"; }
	if( EmptyElements.length > 0 ) {
		var AlertString = "______________________________________________          \n\n";
		AlertString    += "This request cannot be considered complete\n";
		AlertString    += "without the following information:\n\n\n";
		for( i = 0 ; i < EmptyElements.length ; i++ ) {
			AlertString += "        " + EmptyElements[i] + "\n";
		}
		AlertString += "\n\n______________________________________________          \n\n";
		alert( AlertString );
		return false;
	} else {
		if( fi.supportUpload.value ) {
			alert( "\nIt will take a few moments for your chosen file to upload.\n\n" +
							"Please do not stop the process or reload the page while this is uploading.\n\n" );
		}
		return true;
	}
}


//# - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #


function ValidateLoginForm() {
	var Missing = new Array();
	if( document.forms[0].elements[0].value == "" ) {
		Missing[ Missing.length ] = "username"; }
	if( document.forms[0].elements[1].value == "" ) {
		Missing[ Missing.length ] = "password"; }
	if( Missing.length > 0 ) {
		var Message = "\n\nThe form cannot be submitted without the following field";
		if( Missing.length > 1 ) {
			Message += "s";
		}
		Message += ":      \n\n";
		for( i = 0 ; i < Missing.length ; i++ ) {
			Message += ( "- " + Missing[ i ] + "\n" );
		}
		Message += "\n";
		alert( Message );
		return false;
	} else {
		return true;
	}
}


//# - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #


function DisableOther() {
	document.supportForm.supportOthercomponent.readOnly = true;
	document.supportForm.supportOthercomponent.tabIndex = -1;
	document.supportForm.supportOthercomponent.value = "";
}


//# - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #


function EnableOther() {
	document.supportForm.supportOthercomponent.readOnly = false;
	document.supportForm.supportOthercomponent.focus();
}


//# - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #


function ComponentCheck() {
	if( document.supportForm.supportComponent.value == "Specify" ) {
		EnableOther();
	} else {
		DisableOther();
	}
}


//# - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #


function OtherClick() {
	if( document.supportForm.supportOthercomponent.readOnly ) {
		var Mesg = "\n        In order to specify an unlisted Component, you must        \n";
		Mesg += "        select \"Specify\" in the Application drop box.        \n\n";
		Mesg += "        Currently ";
		if( document.supportForm.supportComponent.value ) {
			Mesg += "\"" + document.supportForm.supportComponent.value + "\"";
		} else {
			Mesg += "nothing";
		}
		Mesg += " is selected.\n\n";
		alert( Mesg );
		document.supportForm.supportComponent.focus();
	}
}


// # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #


function ValidateArticleForm() {
	var Mesg = "";
	if( ! document.article.headline.value ) {
		Mesg += "      + HEADLINE field is empty          \n";
	}
	if( ! document.article.body.value ) {
		Mesg += "      + BODY field is empty          \n";
	}
	if( Mesg ) {
		alert( "\n\n    The form cannot be submitted:          \n\n" + Mesg + "\n\n" );
		return false;
	} else {
		return true;
	}
}


// # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #


function ConfirmDeleteArticle( ID ) {
	var DeleteMesg = "\n\n    You have chosen to delete this article.    \n\n";
	DeleteMesg += "    If you are sure of this, click \"OK\".    \n\n";
	if( confirm( DeleteMesg ) ) {
		{ window.location="/cgi-bin/e/cale-admin-newsletter-delete.cgi?id=" + ID };
	}
}


//# - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #


function ConfirmDeleteHandbook( ID ) {
	var DeleteMesg = "\n\n    You have chosen to delete this article.    \n\n";
	DeleteMesg += "    If you are sure of this, click \"OK\".    \n\n";
	if( confirm( DeleteMesg ) ) {
		{ window.location="/cgi-bin/e/cale-admin-handbook-delete.cgi?id=" + ID };
	}
}


// # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #
//  This is a "generic" function to check that the sortnos for a listing
//  of records are all unique.
//
//  To use this function in a generic manner, you must:
//   + create the form with all the selects as the first form elements,
//   + name the form "list",
//   + pass the number of items to sort.
//
//  See the listing of the "messages" function for an example.

function VFSort( NumItemsToSort ) {
	var UsedNumbers = "%";
	var Repeat = 0;
	var RepeatVal = "";
	for( var i = 0 ; i < ( NumItemsToSort ) ; i++ ) {
		var ThisEntry = "%" + document.list.elements[i].value + "%";
		if( UsedNumbers.match( ThisEntry ) ) {
			Repeat = 1;
			RepeatVal = document.list.elements[i].value;
			break;
		}
		UsedNumbers += document.list.elements[i].value + "%";
	}
	if( Repeat ) {
		alert( "\n      All the entries must have a unique order number.      \n\n      At least one order number (" + RepeatVal + ") is shared.      \n\n" );
		return false;
	} else {
		return true;
	}
}


//# - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #


function DeleteNewsletterImage( ImageFileName , ARTTYPE ) {
	var DeleteMesg = "\n\n    You have chosen to delete this image.    \n\n";
	DeleteMesg += "    If you are sure of this, click \"OK\".    \n\n";
	if( confirm( DeleteMesg ) ) {
		{ window.location="/cgi-bin/e/cale-admin-newsletter-image-delete.cgi?file=" + ImageFileName + "&type=" + ARTTYPE };
	}
}


//# - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #


function VFImage() {
	var Mesg = "";
	var Img = new Array();
	var Bad = new Array();
	var fi = document.images.elements;

	for( i = 0 ; i < ( fi.length - 1 ) ; i++ ) {
		if( fi[i].name.match( /^file:/ ) ) {
			if( fi[i].value != "" ) {
				if( fi[i].value.match( /\.jpe?g$/i ) ) {
					Img[Img.length] = fi[i].value;
				} else {
					Bad[Bad.length] = ( i + 1 );
				}
			}
		}
	}

	if( Img.length == 0 ) {
		Mesg += "    No (valid) images were chosen    \n    to upload.    \n\n";
	}
	if( Bad.length > 0 ) {
		Mesg += "    Make sure all the files above    \n";
		Mesg += "    are image files.    \n\n";
		Mesg += "\n";
	}
	if( Mesg != "" ) {
		Mesg = ( "    ---------------------------------------------    \n\n    The form cannot be submitted.    \n\n" ) + Mesg;
		Mesg += ( "    Only images can be uploaded, and    \n    only files with an extension of    \n    .jpg or .jpeg.         \n\n" );
		Mesg += ( "    ---------------------------------------------    \n\n" );
		alert( Mesg );
		return false;
	} else {
		return true;
	}
}


//# - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #
//# - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #
// New 2004-01-26, 5:39 pm
//# - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #


var oldMenu;
var popTimer;
var PageWidth = 634;
var WaitTime = 600;
var isNav, isIE;
if( parseInt( navigator.appVersion ) >= 4 ) {
	if( navigator.appName == "Netscape" ) {
		isNav = true;
	} else {
		isIE = true;
	}
}


function WindowWidth() {
	if( isNav ) {
		return( window.innerWidth );
	} else {
		return( document.body.clientWidth );
	}
}


function WindowHeight() {
	if( isNav ) {
		return( window.innerHeight );
	} else {
		return ( document.body.clientHeight );
	}
}


function menu_action(src, showMenu) {
	if (showMenu == true) {
		window.clearTimeout(popTimer);
		if( oldMenu != null ) {
			close_menu();
		}
		src.origColor=src.style.backgroundColor;
//		src.style.backgroundColor="333377";
		var menu = src.firstChild.nextSibling;
		menu.style.visibility = "visible";

		if( WindowWidth() > PageWidth ) {
			menu.style.left = ( ( ( WindowWidth() - PageWidth ) / 2 ) - 16 + src.offsetLeft );
		} else {
			menu.style.left = ( src.offsetLeft - 16 );
		}
		menu.style.top = (src.offsetTop + src.offsetHeight);
	} else {
		// Set up our timer for closing this menu
		oldMenu = src;
		popTimer = window.setTimeout('close_menu()', WaitTime);
	}
}


function highlight_menu(e, highlight) {
	var src = get_src(e);
	e.cancelBubble = true;
	if ((src.tagName == "TD") || (src.nodeName == "#text")) {
		if (highlight == true) {
			window.clearTimeout(popTimer);
			src.origColor=src.style.backgroundColor;
			src.style.backgroundColor="#333366";
	 } else {
			popTimer = window.setTimeout('close_menu()', WaitTime);
			src.style.backgroundColor=src.origColor;
		}
	}
}


function close_menu() {
	oldMenu.style.backgroundColor= oldMenu.origColor;
	oldMenu.firstChild.nextSibling.style.visibility = "hidden";
	oldMenu = null;
}


//# - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #


function get_src(event_obj) {
	var src;
	// Fork for Netscape event handling
	if (navigator.appName == "Netscape")
		src = event_obj.target;
	else
		src = event_obj.srcElement;
	return src;
}


//# - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #


function PopUp( URL , Name , X , Y , Xoff , Yoff ) {
	if( ! Xoff ) { Xoff = 25; }
	if( ! Yoff ) { Yoff = 25; }
	var newWindow = window.open( URL , Name , "screenX=" + Xoff + ",left=" + Xoff + ",screenY=" + Yoff + ",top=" + Yoff + ",width=" + X + ",height=" + Y + ",scrollbars=yes,resizable=yes,toolbar=yes,status=yes,titlebar=yes,location=yes" , false );
	newWindow.focus();
}


//# - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #


function VFcontact() {
	var Mesg = "";
	if( trim( document.contact.name.value ) == "" ) {
		Mesg += "    + Name is empty          \n";
	}
	if( ( trim( document.contact.email.value ) != "" ) & ( ! ValidEmail( document.contact.email.value ) ) ) {
		Mesg += "    + Email address is not valid          \n";
	}
	if( trim( document.contact.message.value ) == "" ) {
		Mesg += "    + Message is empty          \n";
	}
	if( Mesg != "" ) {
		alert( "\n    Please make sure to correct the following:          \n\n" + Mesg + "\n" );
		return false;
	} else {
		alert( "\n    Thank you for contacting us! If you've requested information, you will hear from someone shortly.          \n\n" );
		return true;
	}
}


//# - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #


function trim( myStr ) {
	myStr = myStr.replace( /^\s+/ , "" );
	myStr = myStr.replace( /\s+$/ , "" );
	myStr = myStr.replace( /\s{2,}/g , " " );
	return myStr;
}


//# - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #


function ValidEmail( Email ) {
	Email = trim( Email );
	if( ( ! Email ) | ( ! Email.match( /^[\w\.\-_]+@[^\.][\w\.\-_]+$/ ) ) | ( ! Email.match( /\.[a-zA-Z]{2,}$/ ) ) ) {
		return false;
	} else {
		return true;
	}
}


//# - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #


function ValidateSupportUpdateForm() {
	var Mesg = "";
	var fi = document.supportForm;
	if( ! trim( fi.name.value ) )        { Mesg += "        + Name is empty          \n";             }
	if( ! ValidEmail( fi.email.value ) ) { Mesg += "        + Email is empty or invalid          \n"; }
	if( ! trim( fi.phone.value ) )       { Mesg += "        + Phone is empty          \n";            }
	if( ! trim( fi.text.value ) )        { Mesg += "        + Update text is empty          \n";      }

//	if( fi.resolution ) {
//alert( "yep" );
		if( fi.user.value.toLowerCase() == "mesa" ) {
			if( fi.resolved.checked == true ) {
				if( fi.resolution.selectedIndex == 0 ) {
					Mesg += "        + You are attempting to close the ticket without assigning a Resolution Code          \n";
				}
			}
			if( ! trim( fi.title.value ) ) { Mesg += "        + Title is empty          \n"; }
		}
//		return false;
//	} else {
//		alert( "nope" );
//	}
//	return false;

	if( Mesg != "" ) {
		alert( "\n      The form cannot be submitted:          \n\n" + Mesg + "\n" );
		return false;
	} else {
		if( trim( fi.upload.value ) ) {
			alert( "\nIt will take a few moments for your chosen file to upload.\n\n" +
							"Please do not stop the process or reload the page while this is uploading.\n\n" );
		}
		return true;
	}
}


//# - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #


function PrimeSupportUN() {
	var myCookie = document.cookie;
	var Pos = myCookie.indexOf( "calsup=" );
	if( Pos != -1 ) {
		var start = Pos + 7;
		var end = myCookie.indexOf( ";" , start );
		if( end == -1 ) end = myCookie.length;
		var value = myCookie.substring( start , end );
		document.login.username.value=value;
		document.login.password.focus();
	}
}


//# - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #


function PrimeEmployeeUN() {
	var myCookie = document.cookie;
	var Pos = myCookie.indexOf( "calemp=" );
	if( Pos != -1 ) {
		var start = Pos + 7;
		var end = myCookie.indexOf( ";" , start );
		if( end == -1 ) end = myCookie.length;
		var value = myCookie.substring( start , end );
		document.login.username.value=value;
		document.login.password.focus();
	}
}


//# - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #


function ShowPriorityMeaning() {
	var PriorityWindow = window.open( '/calian-priority-defs.html' , 'priorities' , "resizeable,height=500,width=600" , false );
	PriorityWindow.focus();
}


//# - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #


function PrimeUN() {
	var myCookie = document.cookie;
	var Pos = myCookie.indexOf( "calsupcontact=" );
	if( Pos != -1 ) {
		var start = Pos + 14;
		var end = myCookie.indexOf( ";" , start );
		if( end == -1 ) end = myCookie.length;
		var value = myCookie.substring( start , end );
		var namestart = value.indexOf( "[name]" );
		var emailstart = value.indexOf( "[email]" );
		var phonestart = value.indexOf( "[phone]" );
		var Name = value.substring( namestart + 6 , emailstart )
		var Email = value.substring( emailstart + 7 , phonestart )
		var Phone = value.substring( phonestart + 7 , end )
		document.supportForm.supportName.value = Name;
		document.supportForm.supportEmail.value = Email;
		document.supportForm.supportPhone.value = Phone;
		document.supportForm.supportPriority.focus();
	} else {
		document.supportForm.supportName.focus();
	}
}


//# - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #


function OnHold() {
	alert( "\n\n      This part of the web site is undergoing rennovations.          \n      It should be operational by 2004-02-20.          \n      Apologies for the inconvenience.          \n\n" );
	return false;
}


//# - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #


function PrimeEmployeeDates( DOB , DOH ) {
	var DatePattern = /^(\d{4})(\d{2})(\d{2})$/;
	var DOByr = DOB.match( DatePattern )[1];
	var DOBmo = DOB.match( DatePattern )[2];
	var DOBdy = DOB.match( DatePattern )[3];
	var DOHyr = DOH.match( DatePattern )[1];
	var DOHmo = DOH.match( DatePattern )[2];
	var DOHdy = DOH.match( DatePattern )[3];

	document.Employee.dob_month.selectedIndex = ( DOBmo - 1 );
	document.Employee.dob_day.selectedIndex   = ( DOBdy   - 1 );
	document.Employee.dob_year.value = DOByr;

	if( document.Employee.doh_month ) {
		document.Employee.doh_month.selectedIndex = ( DOHmo - 1 );
		document.Employee.doh_day.selectedIndex   = ( DOHdy - 1 );
		document.Employee.doh_year.value = DOHyr;
	}
}


//# - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #


function ValidateEmployeeForm() {
	var doby = ( document.Employee.dob_year.value );
	var dobm = ( document.Employee.dob_month.selectedIndex );
	var dobd = ( document.Employee.dob_day.selectedIndex + 1 );
	var dobdate = new Date( parseFloat( doby ) , parseFloat( dobm ) , parseFloat( dobd ) , 0 , 0 , 0 , 0 );

	var dohy;
	var dohm;
	var dohd;
	var dohdate;
	var ValidDOH = 1;

	var Mesg = "";
	var ValidDOB = 1;

	if( document.Employee.empno ) {
		if( ! document.Employee.empno.value.match( /^\d{4}$/ ) ) {
			Mesg += "    - Employee number is not valid.    \n"
		}
	}

	if( ! document.Employee.fname.value ) {
		Mesg += "    - First name is empty.    \n";
	}

	if( ! document.Employee.sname.value ) {
		Mesg += "    - Last name is empty.    \n";
	}

	if( parseFloat( dobd ) != dobdate.getDate() ) {
		ValidDOB = 0;
	}

	if( parseFloat( dobm ) != dobdate.getMonth() ) {
		ValidDOB = 0;
	}

	if( ValidDOB < 1 ) {
		Mesg += "    Date of birth is not valid. Please check a calendar.    \n\n";
	}

	if( document.Employee.doh_year ) {

		dohy = ( document.Employee.doh_year.value );
		dohm = ( document.Employee.doh_month.selectedIndex );
		dohd = ( document.Employee.doh_day.selectedIndex + 1 );
		dohdate = new Date( parseFloat( dohy ) , parseFloat( dohm ) , parseFloat( dohd ) , 0 , 0 , 0 , 0 );

		if( parseFloat( dohd ) != dohdate.getDate() ) {
			ValidDOH = 0;
		}

		if( parseFloat( dohm ) != dohdate.getMonth() ) {
			ValidDOH = 0;
		}

		if( ValidDOH < 1 ) {
			Mesg += "    Date of hire is not valid. Please check a calendar.    \n\n";
		}
	}

	if( Mesg ) {
		Mesg = "  The form cannot be submitted for the following reason(s):    \n\n" + Mesg + "\n";
		alert( Mesg );
		return false;
	} else {
		return true;
	}
}


//# - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #


function ConfirmDeleteEmployee( ID ) {
	var DeleteMesg = "\n\n    You have chosen to delete this employee record.    \n\n";
	DeleteMesg += "    If you are sure of this, click \"OK\".    \n\n";
	if( confirm( DeleteMesg ) ) {
		window.location="/cgi-bin/e/cale-admin-employee-delete.cgi?id=" + ID;
	}
}


//# - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #


function HL( Row ) {
	document.getElementById( Row ).bgColor='ffff66';
}


function UHL( Row ) {
	document.getElementById( Row ).bgColor='ffffff';
}


//# - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #


function ZeroPad( thisString , Length ) {
	thisString = thisString.toString();
	if( Length > thisString.length ) {
		var RetStr = thisString;
		for( var i = thisString.length ; i < Length ; i++ ) {
			RetStr = "0" + RetStr;
		}
		return RetStr;
	} else {
		return thisString;
	}
}


//# - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #


function VFSupportSummary() {
	var FromDate = document.summary.fromYear.value + ZeroPad( document.summary.fromMonth.value , 2 ) + ZeroPad( document.summary.fromDay.value , 2 );
	var ToDate   = document.summary.toYear.value   + ZeroPad( document.summary.toMonth.value   , 2 ) + ZeroPad( document.summary.toDay.value   , 2 );
	var Mesg = "";
	if( ToDate < FromDate ) {
		Mesg += "    + Activity From date cannot be later than Activity To date      \n";
	}
	if( Mesg ) {
		alert( "\n    The form cannot be submitted:      \n\n" + Mesg + "\n" );
		return false;
	} else {
		return true;
	}
}


//# - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #


function Benefits( Type ) {
	document.benefits.type.value = Type;
	document.benefits.submit();
}


//# - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #


function VFSupportForm() {
	var Mesg = "";
	var BadEmailAddrs = new Array;
	var EmailAddrs = document.customer.cc.value.replace( /;/g , "," );
	EmailAddrs = EmailAddrs.replace( /[,;]\s+/g , "," );
	EmailAddrs = EmailAddrs.replace( /\s+[,;]/g , "," );
	EmailAddrs = EmailAddrs.replace( /^,/ , "" );
	EmailAddrs = EmailAddrs.replace( /,$/ , "" );
	EmailAddrs = EmailAddrs.replace( /\s+/g , "" );
	var EmailArray = EmailAddrs.split( "," );
	if( EmailAddrs == "" ) {
		return true;
	}
	for( var i = 0 ; i < EmailArray.length ; i++ ) {
		if( ! ValidEmail( EmailArray[ i ] ) ) {
			BadEmailAddrs[ BadEmailAddrs.length ] = EmailArray[ i ];
		}
	}
	if( BadEmailAddrs.length > 0 ) {
		if( Mesg ) {
			Mesg += "\n";
		}
		Mesg += "    + The following email addresses in the list are not valid:      \n";
		for( var i = 0 ; i < BadEmailAddrs.length ; i++ ) {
			Mesg += "\n      < " + BadEmailAddrs[ i ] + " >      ";
		}
	}
	if( Mesg ) {
		alert( "\n  The form cannot be submitted yet:        \n\n" + Mesg + "\n" );
		return false;
	} else {
		return true;
	}
}


//# - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #


function ValidateDepartmentForm() {
	var Mesg = "";
	var SuperVisors = "";
	var Employees = "";
	var SupListObj = document.Department.supervisor;
	var EmpListObj = document.Department.employees;
	for( var i = 0 ; i < SupListObj.length ; i++ ) {
		if( SupListObj[i].selected ) {
			SuperVisors += SupListObj[i].value + "_";
		}
	}
	for( var i = 0 ; i < EmpListObj.length ; i++ ) {
		if( EmpListObj[i].selected ) {
			if( EmpListObj[i].value != "null" ) {
				Employees += EmpListObj[i].value + "_";
			}
		}
	}
	if( ! trim( document.Department.name.value ) ) {
		Mesg += "    + NAME is empty          \n";
	}
	if( ! trim( SuperVisors ) ) {
		Mesg += "\n    + NO SUPERVISOR(s) specified. If you need a supervisor that does not appear          \n";
		Mesg += "      in this list, you need to go to MANAGE EMPLOYEE RECORDS, and edit the\n";
		Mesg += "      employee who is the supervisor, changing their setting for \"time recording          \n";
		Mesg += "      role\" to \"supervisor\".\n";
	}
	if( ! trim( Employees ) ) {
		Mesg += "\n    + NO EMPLOYEE(s) specified.          \n";
	}
	if( Mesg ) {
		alert( Mesg );
		return false;
	} else {
		var ID = document.Department.id.value;
		if( ID ) {
			ID = "&id=" + ID;
		}
		window.location="/cgi-bin/e/cale-admin-department-insert.cgi?n=" + document.Department.name.value + "&s=" + SuperVisors + "&e=" + Employees + ID;
	}
}


//# - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #


function DeleteDepartment( ID ) {
	var DeleteMesg = "\n\n    You have chosen to delete this department.    \n\n";
	DeleteMesg += "    If you are sure of this, click \"OK\".    \n\n";
	if( confirm( DeleteMesg ) ) {
		{ window.location="/cgi-bin/e/cale-admin-department-delete.cgi?id=" + ID };
	}
}


//# - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #


function ToggleRadio( RADIONAME , POSITION ) {
	eval( "document." + RADIONAME + "[" + POSITION + "].checked=true" );
}


//# - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #


function Pare( STR , SIDE , COUNT ) {
	if( COUNT > STR.length ) {
		return "";
	} else {
		if( SIDE == "left" ) {
			eval( "STR = STR.replace( /^(.){" + COUNT + "}(.*?)$/ , \"$2\" );" );
		} else {
			eval( "STR = STR.replace( /(.*?)(.){" + COUNT + "}$/ , \"$1\" );" );
		}
	}
	return STR;
}


//# - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #


function VFLogin() {
	var DF = document.login;
	var MESG = "";
	if( ! trim( DF.username.value ) ) { MESG += "    + USERNAME is empty          \n"; }
	if( ! trim( DF.password.value ) ) { MESG += "    + PASSWORD is empty          \n"; }
	if( MESG ) {
		alert( "\n  The form cannot be submitted yet:          \n\n" + MESG + "\n" );
		return false;
	} else {
		DF.thing.value = "desmond";
		return true;
	}
}


//# - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #
//# - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #

