<!-- // start hiding code
/*
// File Name:		common.js
// Purpose:	This is a file of javascript code of common client side functions.  
// Modification History
// 08/06/1999 000 MEB Created file.
// 02/29/2000 001 MEB Split out all the sections into separate files.
// 05/19/2000 002 MEB Added dhtml browser sniffer function.
// 08/10/2000 003 MEB Added swap, shownon and hidenon DHTML functions.
// 10/24/2000 004 LAC Remarked out line in ProgramError function to avoid errors.
// 11/27/2000 005 MEB Added isReadyCP function.
// 03/27/2001 006 MEB Fixed missing return value on CheckPath.
*/

// 05/19/2000 MEB Added dhtml browser sniffer function.
/////////////////////////////////////////////////////
//                                                 //
//  SECTION 5: BROWSER SNIFFER & DOMS              //
//  ---------------------------------------------  //
//  Document Object switch routine use to          //
//  maintain cross-browser compatibility.          //
//                                                 //
/////////////////////////////////////////////////////

function Is() {
    var agent = navigator.userAgent.toLowerCase();
    this.major = parseInt(navigator.appVersion);
    this.minor = parseFloat(navigator.appVersion);
    this.ns  = ((agent.indexOf('mozilla')!=-1) && ((agent.indexOf('spoofer')==-1) && (agent.indexOf('compatible') == -1)));
    this.ns2 = (this.ns && (this.major == 2));
    this.ns3 = (this.ns && (this.major == 3));
    this.ns4b = (this.ns && (this.minor < 4.04));
    this.ns4 = (this.ns && (this.major >= 4));
    this.ie   = (agent.indexOf("msie") != -1);
    this.ie3  = (this.ie && (this.major == 2));
    this.ie4  = (this.ie && (this.major >= 4));
    this.op3 = (agent.indexOf("opera") != -1);
    this.win   = (agent.indexOf("win")!=-1);
    this.mac   = (agent.indexOf("mac")!=-1);
    this.unix  = (agent.indexOf("x11")!=-1);
}

var is = new Is();

function onerror() {
    document.location.href = "javascript:";
}

// DOCUMENT OBJECT SWITCH (Used for building cross_browser functions)

if(is.ns4) {
    doc = "document";
    sty = "";
    htm = ".document"
} else if(is.ie4) {
    doc = "document.all";
    sty = ".style";
    htm = ""
}

function changeContent(what,text) {
    if (is.ie4)
        what.innerHTML = text;
    else if (is.ns4) {
        what.document.open();
        what.document.write(text);
        what.document.close();
    }
}

// 08/10/2000 MEB Added swap, shownon and hidenon DHTML functions.
ns4 = (document.layers)? true:false
ie4 = (document.all)? true:false

// swap fields
function swap(hideobj,showobj) {
        hidenon(hideobj)
        shownon(showobj)
}

// Show/Hide functions for non-pointer layer/objects
function shownon(showobj) {
        if (ns4) document.layers[showobj].visibility = "show"
        else if (ie4) document.all[showobj].style.visibility = "visible"
}

function hidenon(hideobj) {
        if (ns4) document.layers[hideobj].visibility = "hide"
        else if (ie4) document.all[hideobj].style.visibility = "hidden"
}

// ********* General purpose Function Scripts  *****************
// DEFINE VARIABLES
// whitespace characters
var whitespace = " \t\n\r";

// Check whether string s is empty.
function isEmpty(s) {
	return ((s == null) || (s.length == 0))
}

/****************************************************************/
// Returns true if string s is empty or 
// whitespace characters only.
function isWhitespace (s) {
	var i;
	// Is s empty?
    if (isEmpty(s)) return true;

    // Search through string's characters one by one
    // until we find a non-whitespace character.
    // When we do, return false; if we don't, return true.
    for (i = 0; i < s.length; i++) {
		// Check that current character isn't whitespace.
		var c = s.charAt(i);
		if (whitespace.indexOf(c) == -1) return false;
    }
    // All characters are whitespace.
    return true;
}

// This function will check to make sure that paths are entered
// in correctly
function CheckFileName(elm) {
	nPeriodPos=""
	strvalid = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_^$~!#%&-{}@`'()."
	strtest= elm.value;
	for (var i = 0; i < strtest.length; i++) {
		cInChar=strtest.charAt(i);
//		alert("Current Character - "+cInChar);
		nsearch = strvalid.indexOf(cInChar);
//		alert("Index of character in valid string - "+nsearch);
//		alert("Invalid character - "+(nsearch == -1));
		if (nsearch == -1) {
			alert("The "+cInChar+" is not allowed");
			elm.focus();
			elm.select();
			return false;
		}
	}
	
	if (strtest.length!=0) {
		nPeriodPos=strtest.indexOf(".");
		if (nPeriodPos<strtest.length-4) {
			alert("File extensions can't be more than 3 characters long")
			elm.focus();
			elm.select();
			return false;
		}
		if (nPeriodPos==strtest.length-1) {
			alert("File names can't contain periods.")
			elm.focus();
			elm.select();
			return false;
		}
	}
}

// This function will check to make sure that paths are entered
// in correctly
function CheckPath(elm) {
	strvalid = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_^$~!#%&-{}@`'()\\:"
	strtest= elm.value;
	for (var i = 0; i < strtest.length; i++) {
		cInChar=strtest.charAt(i);
//		alert("Current Character - "+cInChar);
		nsearch = strvalid.indexOf(cInChar);
//		alert("Index of character in valid string - "+nsearch);
//		alert("Invalid character - "+(nsearch == -1));
		if (nsearch == -1) {
			alert("The "+cInChar+" is not allowed");
			elm.focus();
			elm.select();
			return false;
		}
	}

	if (strtest.substring(strtest.length-1,strtest.length) != "\\") {
		if (strtest.length!=0) {
			elm.value=strtest+"\\";
		}
	}
// 03/27/2001 006 MEB Fixed missing return value on CheckPath.
	return true;
}

/****************************************************************/
// isEmail (STRING s [, BOOLEAN emptyOK])
// 
// Email address must be of form a@b.c ... in other words:
// * there must be at least one character before the @
// * there must be at least one character before and after the .
// * the characters @ and . are both required
// * there can't be a semi-colon (;) in the string
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.
function isEmail (s) {
	//alert("Checking email");
	if (isEmpty(s)) {
		if (isEmail.arguments.length == 1) {
			return defaultEmptyOK;
		} else {
			return (isEmail.arguments[1] == true);
		}
	}
    // is s whitespace?
    if (isWhitespace(s)) return false;
    // there must be >= 1 character before @, so we
    // start looking at character position 1 
    // (i.e. second character)
    var i = 1;
    var sLength = s.length;

    // look for ;
    if (s.indexOf(";",0)>-1) {
		return false;
    }

    // look for @
    while ((i < sLength) && (s.charAt(i) != "@")) {
		i++
    }

    if ((i >= sLength) || (s.charAt(i) != "@")) {
		return false;
	} else {
		i += 2;
	}

    // look for .
    while ((i < sLength) && (s.charAt(i) != ".")) { 
		i++
    }

    // there must be at least one character after the .
    if ((i >= sLength - 1) || (s.charAt(i) != ".")) {
		return false;
	} else {
		return true;
	}
}

/****************************************************************/
// Checks to see if a required field is blank.  If it is, a warning
// message is displayed...
function ForceEntry(objField, FieldName) {
	var strField = new String(objField.value);
	if (isWhitespace(strField)) {
		alert("You need to enter information for " + FieldName);
		objField.focus();
		objField.select();
		return false;
	}
	return true;
}
		
/****************************************************************/
// Returns true if the string passed in is a valid number
//  (no alpha characters), else it displays an error message
function ForceNumber(objField, FieldName) {
	var strField = new String(objField.value);
	if (isWhitespace(strField)) return true;
	var i = 0;
	for (i = 0; i < strField.length; i++) {
		if (strField.charAt(i) < '0' || strField.charAt(i) > '9') {
			alert(FieldName + " must be a valid numeric entry.  Please do not use commas or dollar signs or any non-numeric symbols.");
			objField.focus();
			return false;
		}
	}
	return true;
}

/****************************************************************/
// Returns true if the string passed in is a valid money
//  (no alpha characters except a decimal place), 
//   else it displays an error message
function ForceMoney(objField, FieldName) {
	var strField = new String(objField.value);
	if (isWhitespace(strField)) return true;
	var i = 0;
	for (i = 0; i < strField.length; i++) {
		if ((strField.charAt(i) < '0' || strField.charAt(i) > '9') && (strField.charAt(i) != '.')) {
			alert(FieldName + " must be a valid numeric entry.  Please do not use commas or dollar signs or any non-numeric symbols.");
			objField.focus();
			return false;
		}
	}
	return true;
}

/****************************************************************/
// Right trims the string...  Useful for SQL datatypes of CHAR
function RTrim(strTrim) {
	var str = new String(strTrim);
	var i = 0;
	var c = "";
	var endpos = 0
	for (i = str.length; i >= 0 && endpos == 0; i = i - 1) {
		c = str.charAt(i);
		if (whitespace.indexOf(c) == -1) endpos = i;
	}
	return str.substring(0,endpos+1);
}

// Check for Apostrophy, Carriage Return or double Quotes in strings
function StringCheck(elm) {
	var ctmp;
	ctmp = elm.value;
	while (ctmp.indexOf("\"") != "-1") {
		ctmp = ctmp.substring(0,ctmp.indexOf("\""))+"``"+ctmp.substring(ctmp.indexOf("\"")+1,ctmp.length);
	}
	while (ctmp.indexOf("\r") != "-1") {
		ctmp = ctmp.substring(0,ctmp.indexOf("\r"))+"<br>"+ctmp.substring(ctmp.indexOf("\r")+2,ctmp.length);
	}
	while (ctmp.indexOf("\'") != "-1") {
		ctmp = ctmp.substring(0,ctmp.indexOf("\'"))+"`"+ctmp.substring(ctmp.indexOf("\'")+1,ctmp.length);
	}
	elm.value = ctmp;
}

// This function checks for the length of a string
function isStringLength(elm,len) {
var elmstr = elm.value + "";
	if ((elmstr.length)!= (len)) {
		return false;
	}
	return true;
}

// Check for null and for empty
function isFilled(elm) {
	if (elm.value == "" || elm.value == null) return false;
	else return true;
}

// Check for numeric integer
function isInt(elm) {
	var elmstr = elm.value + "";
	if (elmstr == "") return false;
	for (var i = 0; i < elmstr.length; i++) {
		if ((elmstr.charAt(i) < "0") ||
		    (elmstr.charAt(i) > "9")) {
		return false;
		}
	}
	return true;
}

// Check for 10 digit phone number in the format NNNxNNNxNNNN
// Where 'x' can be - or .
function isPhone(elm) {
	var elmstr = elm.value + "";
	if (elmstr.length != 12) return false;
	for (var i = 0; i < elmstr.length; i++) {
		if ((i < 3 && i > -1) ||
		    (i > 3 && i < 7) ||
		    (i > 7 && i < 12)) {
		    if (elmstr.charAt(i) < "0" ||
			elmstr.charAt(i) > "9") return false;
		}
		else if (elmstr.charAt(i) != "-" && elmstr.charAt(i) != ".") return false;
	}
	return true;
}

// Check a string for valid URL formatting.
// Valid formatting is a string that begins with
// 'http://' and has something.something after it.
function isURL(strIn) {
	var strRequest = strIn.substring(0,6)
	if (strRequest != "http:/") {	// a double forward slash gets converted to a single forward slash.
		alert("URL doesn't start with http://");
		return false;
	}
	intPeriod = strIn.indexOf(".",8);
//	alert('intPeriod '+intPeriod);
	if (intPeriod < 8 ) {
		return false;
	} else {
//		alert("length "+strIn.length);
		if (intPeriod+1 == strIn.length) {
			alert("A URL must have a top level domain name such as .com")
			return false;
		}
	}
	return true;
}

// This function compares two elements to see if they have the same value
function IsSame(oldelm,elm) {
	var previousstr = oldelm.value + "";
	var currentstr = elm.value + "";
	if (previousstr.toUpperCase() == currentstr.toUpperCase()) {
		return true;
	}
	return false;
}

/****************************************************************/
// This function determines if the string passed in is a valid
// US zip code.  It accepts either ##### or #####-####.  If the
// string is valid, it returns true, else false.
function isZipcode(strZip) {
	var s = new String(strZip);
	if (s.length != 5 && s.length != 10)
		// inappropriate length
		return false;
	var i;
	for (var i=0; i < s.length; i++) {
		if ((s.charAt(i) < '0' || s.charAt(s) > '9') && s.charAt(i) != '-') {
			return false;
		}
	}
	return true;
}

/****************************************************************/
// This function ensures that a field is less than or equal to the
// Length passed in.  You must call this function with the element
// name in your form (for example: "ForceLength(document.forms[0].txtElement)"
// as opposed to "ForceLength(document.forms[0].txtElement.value)"
// If the field's value is too large, an error message is displayed
// and false is returned, else true is returned.
function ForceLength(objField, nLength, strWarning) {
	var strField = new String(objField.value);
	if (strField.length > nLength) {
		alert(strWarning);
		return false;
	} else {
		return true;
	}
}

/****************************************************************/
// Displays an alert box with an error message from the passed in string
// Sets focus on the field and selects the bad value.
function PromptErrorMsg(Field,strError) {
	alert("You have entered an invalid value for " + strError + ".");
	//Field.focus();	LAC
	Field.select();
}

// Displays an alert box with an error message from the passed in string
function PromptErrorMsgString(strError) {
	alert("You have entered an invalid value for " + strError + ".");
}

// These are navigation gif functions.
function MM_preloadImages() { //v2.0
  if (document.images) {
    var imgFiles = MM_preloadImages.arguments;
    if (document.preloadArray==null) document.preloadArray = new Array();
    var i = document.preloadArray.length;
    with (document) for (var j=0; j<imgFiles.length; j++) if (imgFiles[j].charAt(0)!="#"){
      preloadArray[i] = new Image;
      preloadArray[i++].src = imgFiles[j];
  } }
}

function MM_swapImgRestore() { //v2.0
  if (document.MM_swapImgData != null) 
    for (var i=0; i<(document.MM_swapImgData.length-1); i+=2) 
      document.MM_swapImgData[i].src = document.MM_swapImgData[i+1];
}

function MM_swapImage() { //v2.0
  var i,j=0,objStr,obj,swapArray=new Array,oldArray=document.MM_swapImgData;
  for (i=0; i < (MM_swapImage.arguments.length-2); i+=3) {
    objStr = MM_swapImage.arguments[(navigator.appName == 'Netscape')?i:i+1];
    if ((objStr.indexOf('document.layers[')==0 && document.layers==null) ||
        (objStr.indexOf('document.all[')   ==0 && document.all   ==null))
      objStr = 'document'+objStr.substring(objStr.lastIndexOf('.'),objStr.length);
    obj = eval(objStr);
    if (obj != null) {
      swapArray[j++] = obj;
      swapArray[j++] = (oldArray==null || oldArray[j-1]!=obj)?obj.src:oldArray[j];
      obj.src = MM_swapImage.arguments[i+2];
  } }
  document.MM_swapImgData = swapArray; //used for restore
}

function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

// 11/27/2000 005 MEB Added isReadyCP function.
// This function checks to make sure the password information is valid
// before submitting the password change.
function isReadyCP(form) {
	if (document.form1.pwdPassword.value=="" || document.form1.pwdPassword.value==null) {
		alert("You must have your existing password to change your password.");
		return false;
	}
	if (document.form1.pwdNewPassword.value=="" || document.form1.pwdPassword.value==null) {
		alert("You must have a new password to change your password.");
		return false;
	}
	if (document.form1.pwdNewPassword.value!=document.form1.pwdCPassword.value) {
		alert("The passwords you entered do not match. Please try again.");
		return false;
	}
	return true;
} // end function isReadyCP(form)

// stop hiding code
//-->
