<!-- 
//*************************************************************************
//								incLibrary.js
//	Library routines for the web site.					Nick 09/14/04
//*************************************************************************
//	Changes:
//	Changed libPopUp to set a focus, center popup on screen, and to accept
//	an argument that indicates whether to show a title bar or not. The 
//	setting of the focus will prevent popups from being hidden behind the 
//	window, when a previous popup wasn't closed (call 4313).
//														Nick	11/06/06
//	Removed window.onload function, because it isn't needed in .NET.
//														Nick	05/23/07
//	Changed libValidateBC() to validate for american express, which is
//	now a valid bankcard type for e-conolight and lampa lamps.
//														Nick	10/26/07
//*************************************************************************

var libForceFocus = true;	// Determines if validate routines should force
							// focus when something is invalid.  The Default 
							// is to force the focus.
var libMessage = "";		// Message used to describe the problem with the
							// validation routine.
var libShowAlert = true;	// Determines if we should show an alert dialog
							// box when something is invalid.  The Default
							// is to show the alert.
var libTrimFirst = true;	// Determines if validate routines should trim
							// the textbox field before doing the validation.


// ******************************************************
//	Procedure Name:	libIsNumeric
//	Purpose:		Determine if a string field is numeric or not
//	Arguments:		String field to test
//	Return Value:	True if numeric
//					False if not numeric
//	Created:		07/02/04	Eric H	
// ******************************************************
function libIsNumeric(strText)
{
	var Char = "";						// Character of digit being tested
	var DecimalUsed = false;			// True after 1st decimal is found
	var IsNumber = true;				// Return value of function
	var ValidChars = "-0123456789.";	// Valid numeric digits

	for (i = 0; i < strText.length; i++) 
	{ 
		Char = strText.charAt(i); 
		
		// Check for a non-numeric digit.  Allow (-) and (.)
		if (ValidChars.indexOf(Char) == -1) 
		{
			return false;
		}

		// Make sure (-) is only in the 1st digit place
		if (Char=="-" && i > 0) 
		{
			return false;
		}

		// Make sure (.) is only used once
		if (Char=="." && DecimalUsed==true) 
		{
			return false;
		}

		// If this is a decimal, then set a flag to indicate that it was used
		if (Char==".") 
		{
			DecimalUsed==true;
		}
	}
	return true;
}


// ******************************************************
//	Procedure Name:	libKeyUpAdvance
//	Purpose:		Advance from 1 field to the next.
//	Arguments:		Control coming from
//					Control going to
//					Event that this was called from
//	Return Value:	None
//	Created:		07/02/04	Eric H	
// ******************************************************
function libKeyUpAdvance(txtField1, txtField2,Event) 
{
	// Don't bother advancing if user just pressed tab or shift-tab.
	// This should only advance if user is filling in data into the field.
	if (Event.keyCode == 9 || Event.keyCode == 16)
	{
		return;
	}
	
	// If the field is full then make move to next field
	if (txtField1.value.length == txtField1.maxLength)
	{
		libSetFocus(txtField2);	
	}
}


// ******************************************************
//	Procedure Name:	libLeft
//	Purpose:		Find the Left of a string
//	Arguments:		String to find Left of
//                  Length of substring
//	Return Value:	SubString
//	Created:		07/02/04	Eric H	
// ******************************************************
function libLeft(strString,intLength) 
{
	if (intLength<1)
	{
		TheSubString="";
		return TheSubString;
	}
	
	TheSubString = strString.substr(0,intLength);
	return TheSubString;
}


// ******************************************************
//	Procedure Name:	libMid
//	Purpose:		Find the Mid of a string
//	Arguments:		String to find Mid of
//                  Start location
//                  Length of substring
//	Return Value:	SubString
//	Created:		07/02/04	Eric H	
// ******************************************************
function libMid(strString,intStart,intLength) 
{
	if (intStart<1)
	{
		TheSubString="";
		return TheSubString;
	}

	if (intLength<1)
	{
		TheSubString="";
		return TheSubString;
	}
	
	TheSubString = strString.substr(intStart-1,intLength);
	return TheSubString;
}

//******************************************************
//	Procedure Name:	libPopUp
//	Purpose:		Opens a URL in a new window
//	Arguments:		URL to open
//					Width of new window
//					Height of new window
//	Return Value:	--
//	Created:		Nathan	07/07/04
//******************************************************
//	Changes:
//	Changed to accept another parameter, which determines
//	whether the popup should have a toolbar. Also changed
//	to always center the popup in the middle of the screen, and
//	changed to set a focus. This will prevent popups from being
//	hidden behind the window, when a previous popup wasn't
//	closed.	Also changed to have a unique name for every
//	popup, using a random number.		Nick	11/06/06
//*******************************************************

function libPopUp(Address,Width,Height,ToolBar) 
{
	var Left;			//Left of screen
	var RandomNumber	//Random number
	var ScreenX;		//Width of screen
	var ScreenY;		//Height of screen
	var Top;			//Top property
	
	//If the ToolBar argument wasn't passed in, then default to no ToolBar
	if (!ToolBar)
	{
		ToolBar = false;
	}
	
	//Setup the string for the ToolBar 
	if (ToolBar == true) 
	{
		ToolBar = "yes"
	}
	else
	{
		ToolBar = "no"
	}
	
	//Get the size of the screen
	if(navigator.appName == "Microsoft Internet Explorer") 
	{
		ScreenY = document.body.offsetHeight;
		ScreenX = window.screen.availWidth;
	}
	else 
	{
		ScreenY = window.outerHeight
		ScreenX = window.outerWidth
	}
	
	//Get the top and left properties
	Left = (ScreenX - Width) / 2;
	Top = (ScreenY - Height) / 2;
	
	//If this isn't IE, then subtract the offsets
	if(navigator.appName != "Microsoft Internet Explorer") 
	{
		Left = (Left - pageXOffset);
		Top = (Top - pageYOffset);
	}
	
	//Get a random number, which will be added to the window's name
	//in order to make it unique.
	RandomNumber = "" + Math.random();
    RandomNumber = RandomNumber.replace("0.","");
	
	//Create the new window.
	var NewWindow = window.open(Address,'PopUp' + RandomNumber,'toolbar=' + ToolBar + ',location=no,directories=no,status=no,menubar=no,resizable=yes,copyhistory=no,scrollbars=yes,width=' + Width + ',height=' + Height + ',left=' + Left + ',top=' + Top);
	
	//Set the focus.
	if (NewWindow.focus)
	{
		NewWindow.focus();
	}	
	
	return false;
}


// ******************************************************
//	Procedure Name:	libRight
//	Purpose:		Find the Right of a string
//	Arguments:		String to find Right of
//                  Length of substring
//	Return Value:	SubString
//	Created:		07/02/04	Eric H	
// ******************************************************
function libRight(strString,intLength) 
{
	if (intLength<1)
	{
		TheSubString="";
		return TheSubString;
	}
	
	TheSubString = strString.substr(strString.length-intLength,intLength);
	return TheSubString;
}


// ******************************************************
//	Procedure Name:	libReturnFromValidate
//	Purpose:		Show alert and set focus.  Called from
//					Validate routines.
//	Arguments:		Text field to set focus to
//	Return Value:	None
//	Created:		07/02/04	Eric H	
// ******************************************************
function libReturnFromValidate(txtField) 
{
	// Display a message describing the validation problem.
	if (libShowAlert==true)
	{
		alert(libMessage)
	}

	// Set focus to the invalid text field
	if (libForceFocus==true)
	{
		libSetFocus(txtField)
	}
}


// ******************************************************
//	Procedure Name:	libSetFocus
//	Purpose:		Set focus to a control on a form
//	Arguments:		Control to set focus to
//	Return Value:	True if successful
//					False if unsuccessful
//	Created:		07/02/04	Eric H	
// ******************************************************
function libSetFocus(Control) 
{
	// try and catch are keywords to attempt code 
	try
	{
		// Attempt to set focus
		Control.focus();
		Control.select();
		return true;
	}
	catch(error)
	{
		// do nothing
		return false;
	}
}


// ******************************************************
//	Procedure Name:	libTrim
//	Purpose:		Trim trailing spaces
//	Arguments:		String to trim
//	Return Value:	Trimmed string value
//	Created:		07/02/04	Eric H	
// ******************************************************
function libTrim(strString) 
{
  // Remove leading spaces and carriage returns
  while ((strString.substring(0,1) == ' ') || (strString.substring(0,1) == '\n') || (strString.substring(0,1) == '\r'))
  {
    strString = strString.substring(1,strString.length);
  }

  // Remove trailing spaces and carriage returns
  while ((strString.substring(strString.length-1,strString.length) == ' ') || (strString.substring(strString.length-1,strString.length) == '\n') || (strString.substring(strString.length-1,strString.length) == '\r'))
  {
    strString = strString.substring(0,strString.length-1);
  }
  return strString;
}

// ******************************************************
//	Procedure Name:	libValidateBC(BCNumber, BCType, ExpirationMonth, ExpirationYear) 
//	Purpose:		validate bank card information
//	Arguments:		IsNewNumber - Indicates whether the number should be validated or not
//								BCNumber - bank card number
//								ExpirationMonth - expiration month of bank card
//								ExpirationYear - expiration Year of bank card
//	Return Value:	 "BCNumber" if BCNumber failed validation
//								 "BCMonth" if BCMonth failed validation
//								 "BCYear" if BCYear failed validation
//								true if validation passed
//	Created:		Nick 07/26/05
//
// ******************************************************
//	Changes:
//	Changed to validate for american express, which is now 
//	a valid bankcard type for e-conolight and lampa lamps.
//										Nick	10/26/07
// ******************************************************
function libValidateBC(IsNewNumber, BCNumber, ExpirationMonth, ExpirationYear) 
{
	var TestBCNumber = "";
	var Char;
	var Today = new Date(); // get today's date
	var ThisYear = Today.getYear();
	var ThisMonth = 1 + Today.getMonth();
	var ExpirationYear =2000 + parseInt(ExpirationYear, 10);
	var ExpirationMonth = parseInt(ExpirationMonth, 10);
	var ThisMonth = 1 + Today.getMonth();
	
	//----------------------------------------------------------
    // Test BC Number if user entered a new number 
    //----------------------------------------------------------
    
    if (IsNewNumber == true)
    {    
		//check which card type
		if (BCNumber.substr(0, 1) == 4)
		{
			BCType = "V";
		}
		else if (BCNumber.substr(0, 1) == 5)
		{
			BCType = "MC";
		}
		else if (BCNumber.substr(0, 1) == 3)
		{
			BCType = "AX";
		}
		else
		{
			alert("Only Visa, MasterCard, and American Express are accepted.");
			return "BCNumber";
		}
	
		TestBCNumber="";
	
		// Erase all non-numeric digits in case a space or (-) was used.
		for (i=0; i<BCNumber.length; i++)
		{
			Char = BCNumber.substr(i,1)   
		  
			if ((Char >= "0") && (Char <= "9"))
			{
				TestBCNumber = TestBCNumber + Char
			}
		}
				
	
			// Make sure the length of the bc number is ok
			if(BCType == "V" && TestBCNumber.length !=16 && TestBCNumber.length != 13)
			{
				alert("Visa bank card numbers must be 13 or 16 digits.");
				return "BCNumber";
			}
			else if (BCType == "MC" && TestBCNumber.length !=16)
			{
				alert("MasterCard bank card numbers must be 16 digits.");
				return "BCNumber";
			}
			else if (BCType == "AX" && TestBCNumber.length !=15)
			{
				alert("American Express bank card numbers must be 15 digits.");
				return "BCNumber";
			}
			// else continue with validation
    
			SumTotal = 0;

			// Use the check digit algorithm
			for (i=TestBCNumber.length-1;i>=0;i--)
			{
			    // Determine the character (digit) we are checking
			  Char = TestBCNumber.substr(i,1)
			    Digit = parseInt(Char)
			    
			    // Length - Position will give the place of the digit.
			    // If the place is odd, multiply the number by 2.
			    if (((TestBCNumber.length -i-1) % 2) > 0) 
			    {
			        Digit = Digit * 2
			    }

			    // If the number is > 9 then subtract 9 from the number.
			    // This is an easier way to sum the individual digits.
			    if (Digit > 9)
			    {
			        Digit = Digit - 9
			    }
			    
			    // Add the number to the Sum
			    SumTotal = SumTotal + Digit

			}

    
			// If the sum is not divisible by 10, it is invalid.
			if ((SumTotal % 10) > 0) 
			{
			    alert("Invalid credit card number.");
				 return "BCNumber";
			}
		}
		
		
	//----------------------------------------------------------
    //						Test Expiration Date
    //----------------------------------------------------------
     
	// Make sure an expire month is selected
	if (isNaN(ExpirationMonth) == true)
	{
	    alert("Select the Expiration Month.");
	   // libSetFocus(document.frmPaymentInfo.cboBCExpireMonth);
	    return "BCMonth";
	}
	
	// Make sure an expire Year is selected
	else if (isNaN(ExpirationYear) == true)
	{
	    alert("Select the Expiration Year.");
	    //libSetFocus(document.frmPaymentInfo.cboBCExpireYear);
	    return "BCYear";
	}
	
	else if (ThisYear == ExpirationYear && ExpirationMonth < ThisMonth)
	{
		alert("Invalid Expiration Date.");
	   // libSetFocus(document.frmPaymentInfo.cboBCExpireMonth);
	    return "BCMonth";
	}
    return true;
}

// ******************************************************
//	Procedure Name:	libValidateEmail
//	Purpose:		Validate an Email text form field
//	Arguments:		Form Field to validate
//					Text required - true/false
//					Field name to display in alert message box
//	Return Value:	True if passes validation
//					False if it doesn't pass validation
//					Also sets libMessage if it fails validation
//	Created:		07/02/04	Eric H	
// ******************************************************
function libValidateEmail(txtField,Required,FieldName) 
{
	var Str = txtField.value;
	var Filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
	var FieldValue;

	// Make sure the text box is a valid object
	if (typeof txtField == "undefined")
	{
		return false;		
	}
 
	// Trim First
	if (libTrimFirst==true)
	{
		txtField.value = libTrim(txtField.value);
	}	

	FieldValue = txtField.value

	// Default field name if it wasn't passed
	if (typeof FieldName == "undefined")
	{
		FieldName = "E-mail Address";
	}
	
	// Check Required
	if ((Required==true)&&(FieldValue.length == 0))
	{
		libMessage="The " + FieldName + " field is Required.";
		libReturnFromValidate(txtField);
		return false;		
	}	

	// If this field wasn't required and its blank, then end validation here.
	if (FieldValue=="")
	{
		return true;
	}

	// Test the e-mail address against the filter
	if (Filter.test(Str) == false)
	{
		libMessage="The " + FieldName + " field is Invalid.";
		libReturnFromValidate(txtField);
		return false;		
	}

	return true;
}


// ******************************************************
//	Procedure Name:	libValidateNumeric
//	Purpose:		Validate a numeric text form field
//	Arguments:		Form Field to validate
//					Required - true/false
//					Minimum Value of text (-99 if none)
//					Maximum Value of text (-99 if none)
//					Decimal Places allowed (0 if none)
//					Field name to display in alert message box
//	Return Value:	True if passes validation
//					False if it doesn't pass validation
//					Also sets libMessage if it fails validation
//	Created:		07/02/04	Eric H	
// ******************************************************
function libValidateNumeric(txtField, Required, MinValue, MaxValue, DecimalPlaces, FieldName) 
{
	var FieldValue="";
	
	// Make sure the text box is a valid object
	if (typeof txtField == "undefined")
	{
		return false;		
	}

	// Trim First
	if (libTrimFirst==true)
	{
		txtField.value = libTrim(txtField.value);
	}	
	FieldValue = txtField.value

	// Default field name if it wasn't passed
	if (typeof FieldName == "undefined")
	{
		FieldName = "Numeric";
	}

	// Check Required
	if ((Required==true)&&(FieldValue==""))
	{
		libMessage="The " + FieldName + " field is Required.";
		libReturnFromValidate(txtField);
		return false;		
	}	
	
	// If this field wasn't required and its blank, then end validation here.
	if (FieldValue=="")
	{
		return true;
	}

	// Check for all numeric digits.
	if (libIsNumeric(FieldValue)==false)
	{
		libMessage="The " + FieldName + " field is not a valid number.";
		libReturnFromValidate(txtField);
		return false;		
	}	

	// Check for the number of decimal places
	DecimalLocation = FieldValue.indexOf(".") + 1
	ActualDecimalPlaces = FieldValue.length-DecimalLocation
	if ((DecimalPlaces>0)&&(ActualDecimalPlaces>DecimalPlaces))
	{
		libMessage="The " + FieldName + " field contains too many decimal places.";
		libReturnFromValidate(txtField);
		return false;		
	}	

	// Check for no decimal places
	if ((DecimalPlaces == 0)&&(DecimalLocation > 0))
	{
		libMessage="The " + FieldName + " field should not have a decimal.";
		libReturnFromValidate(txtField);
		return false;		
	}	


	// Check Max Value
	if ((MaxValue!=-99)&&(FieldValue > MaxValue))
	{
		libMessage="The " + FieldName + " field value is too large.";
		libReturnFromValidate(txtField);
		return false;		
	}	

	// Check Min Value.  
	// Only check if something was entered.
	if (FieldValue.length > 0)
	{
		if ((MinValue!=-99)&&(FieldValue < MinValue))
		{
			libMessage="The " + FieldName + " field value is not large enough.";
			libReturnFromValidate(txtField);
			return false;		
		}	
	}

}


// ******************************************************
//	Procedure Name:	libValidatePhone
//	Purpose:		Validate a phone number form text field
//	Arguments:		Form Field to validate
//					Text required - true/false
//					Field name to display in alert message box
//	Return Value:	True if passes validation
//					False if it doesn't pass validation
//					Also sets libMessage if it fails validation
//	Created:		07/02/04	Eric H	
// ******************************************************
function libValidatePhone(txtField1, txtField2, txtField3, Required, FieldName) 
{
	var FieldValue1;
	var FieldValue2;
	var FieldValue3;
	
	// Make sure the text box is a valid object
	if ((typeof txtField1 == "undefined")||
	    (typeof txtField2 == "undefined")||
	    (typeof txtField3 == "undefined"))
	{
		return false;		
	}

	txtField1.value = libTrim(txtField1.value);
	txtField2.value = libTrim(txtField2.value);
	txtField3.value = libTrim(txtField3.value);

	FieldValue1 = txtField1.value
	FieldValue2 = txtField2.value
	FieldValue3 = txtField3.value

	// Default field name if it wasn't passed
	if (typeof FieldName == "undefined")
	{
		FieldName = "Phone Number";
	}

	// If this field wasn't required and its blank, then end validation here.
	if (Required==false&&FieldValue1==""&&FieldValue2==""&&FieldValue3=="")
	{
		return true;
	}

	// -----------------------------
	// Check area code
	// -----------------------------

	// Check Required
	if ((Required==true)&&(FieldValue1.value==""))
	{
		libMessage="The " + FieldName + " Area Code field is Required.";
		libReturnFromValidate(txtField1);
		return false;		
	}	

	// Make sure area code is numeric
	if (libValidateNumeric(txtField1,Required,0,999,0,FieldName) == false)
	{
		return false;
	}

	// Make sure area code has all digits filled in
	if (FieldValue1.length != 3)
	{
		libMessage="The " + FieldName + " Field is Invalid.";
		libReturnFromValidate(txtField1);
		return false;		
	}

	// -----------------------------
	// Check Exchange code
	// -----------------------------

	// Check Required
	if ((Required==true)&&(FieldValue2.value==""))
	{
		libMessage="The " + FieldName + " field is Required.";
		libReturnFromValidate(txtField2);
		return false;		
	}	

	// Make sure area code is numeric
	if (libValidateNumeric(txtField2,Required,0,999,0,FieldName) == false)
	{
		return false;
	}

	// Make sure code has all digits filled in
	if (FieldValue2.length != 3)
	{
		libMessage="The " + FieldName + " Field is Invalid.";
		libReturnFromValidate(txtField2);
		return false;		
	}

	// -----------------------------
	// Check Last 4 Digits of phone number
	// -----------------------------

	// Check Required
	if ((Required==true)&&(FieldValue3.value==""))
	{
		libMessage="The " + FieldName + " Field is Required.";
		libReturnFromValidate(txtField3);
		return false;		
	}	

	// Make sure area code is numeric
	if (libValidateNumeric(txtField3,Required,0,9999,0,FieldName) == false)
	{
		return false;
	}

	// Make sure area code has all digits filled in
	if (FieldValue3.length != 4)
	{
		libMessage="The " + FieldName + " Field is Invalid.";
		libReturnFromValidate(txtField3);
		return false;		
	}

}

// ******************************************************
//	Procedure Name:	libValidateState
//	Purpose:		Validate a State Code form field
//	Arguments:		Form Field to validate
//					Text required - true/false
//					Field name to display in alert message box
//	Return Value:	True if passes validation
//					False if it doesn't pass validation
//					Also sets libMessage if it fails validation
//	Created:		08/12/04	Eric H	
// ******************************************************
function libValidateState(txtField,Required,FieldName) 
{
	// Does not include Alaska or Hawaii
	var States = "AL AZ AR CA CO CT DC DE FL GA " +
 				 "ID IL IN IA KS KY LA ME MD MA " +
				 "MI MN MS MO MT NE NV NH NJ NM " +
				 "NY NC ND OH OK OR PA RI SC SD " +
				 "TN TX UT VT VA WA WV WI WY";

	// Make sure the text box is a valid object
	if (typeof txtField == "undefined")
	{
		return false;		
	}

	// Trim First
	if (libTrimFirst==true)
	{
		txtField.value = libTrim(txtField.value);
	}	

	var FieldValue = txtField.value;

	// Default field name if it wasn't passed
	if (typeof FieldName == "undefined")
	{
		FieldName = "State Code";
	}
	
	// Check Required
	if ((Required==true)&&(FieldValue.length == 0))
	{
		libMessage="The " + FieldName + " field is Required.";
		libReturnFromValidate(txtField);
		return false;		
	}	

	// If this field wasn't required and its blank, then end validation here.
	if (FieldValue=="")
	{
		return true;
	}

	// Make sure the length is 2
	if (FieldValue.length != 2)
	{
		libMessage="The " + FieldName + " field is invalid.";
		libReturnFromValidate(txtField);
		return false;		
	}	

	// Make sure State code is valid 
	if (States.indexOf(FieldValue)< 0 || FieldValue.indexOf(" ")>=0)
	{
		libMessage="The " + FieldName + " field is invalid.";
		libReturnFromValidate(txtField);
		return false;		
	}

	return true;
}


//***************************************************************************
//	Procedure Name:	libValidatePassword
//	Purpose:		Validate password against security criteria
//	Arguments:		Password - password to be checked
//					Password2 - re-typed password
//	Return Value:	Blank if valid.  Message if invalid.
//	Created:		Nathan	01/13/05
//***************************************************************************
//	Changes:
//***************************************************************************
function libValidatePassword(Password, Password2)
	{
		var Alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
		var AlphaFound = false;
		var Character;
		var Numeric = "0123456789";
		var NumericFound = false;
		var x;

		//Make sure the password and retyped password are the same
		if (Password != Password2)
		{
			return "Passwords Do Not Match:  Please ensure that your passwords match.";
		}

		//Make sure password is entered
		if (Password.length == 0)
		{
			return "Invalid Password:  Please enter your password.";
		}

		//Make sure password is at least 7 characters long
		if (Password.length < 7)
		{
			return "Invalid Password:  Please enter a password that is at least seven characters long.";
		}

		//Make sure password is no more than 20 characters long
		if (Password.length > 20)
		{
			return "Invalid Password:  Please enter a password that is no more than twenty characters long.";
		}

		//Look for at least one alpha and one numeric character in the password
		for (x = 0; x < Password.length; x++)
		{
			Character = Password.charAt(x).toUpperCase();
				
			if (Alpha.indexOf(Character) > -1) AlphaFound = true;

			if (Numeric.indexOf(Character) > -1) NumericFound = true;
				
			if (AlphaFound == true && NumericFound == true) break;
		}

		//Make sure password contains at least one alpha and one numeric character
		if (AlphaFound == false || NumericFound == false)
		{
			return "Invalid Password:  Please enter a password that contains at least one letter and one number.";
		}

		return true;
	}
	
// ******************************************************
//	Procedure Name:	libValidateText
//	Purpose:		Validate a text form field
//	Arguments:		Form Field to validate
//					Text required - true/false
//					Minimum length of text (0 if none)
//					Maximum length of text (0 if none)
//					Field name to display in alert message box
//	Return Value:	True if passes validation
//					False if it doesn't pass validation
//					Also sets libMessage if it fails validation
//	Created:		07/02/04	Eric H	
// ******************************************************
function libValidateText(txtField,Required,MinLength,MaxLength,FieldName) 
{

	// Make sure the text box is a valid object
	if (typeof txtField == "undefined")
	{
		return false;		
	}

	// Trim First
	if (libTrimFirst==true)
	{
		txtField.value = libTrim(txtField.value);
	}	

	FieldValue = txtField.value

	// Default field name if it wasn't passed
	if (typeof FieldName == "undefined")
	{
		FieldName = "Text";
	}
	
	// Check Required
	if ((Required==true)&&(FieldValue.length == 0))
	{
		libMessage="Invalid " + FieldName + ":  Please enter " + FieldName + ".";
		libReturnFromValidate(txtField);
		return false;		
	}	

	// If this field wasn't required and its blank, then end validation here.
	if (FieldValue=="")
	{
		return true;
	}

	// Check Max Length
	if ((MaxLength>0)&&(FieldValue.length > MaxLength))
	{
		libMessage="Invalid " + FieldName + ":  Please enter a value that is no more than " + MaxLength + " characters long.";
		libReturnFromValidate(txtField);
		return false;		
	}	

	// Check Min Length
	if ((MinLength>0)&&(FieldValue.length < MinLength)&&(FieldValue.length > 0))
	{
		libMessage="Invalid " + FieldName + ":  Please enter a value that is at least " + MinLength + " characters long.";
		libReturnFromValidate(txtField);
		return false;		
	}	

}


// ******************************************************
//	Procedure Name:	libValidateZip
//	Purpose:		Validate a Zip Code form field
//	Arguments:		Form Field to validate
//					Text required - true/false
//					Field name to display in alert message box
//	Return Value:	True if passes validation
//					False if it doesn't pass validation
//					Also sets libMessage if it fails validation
//	Created:		07/02/04	Eric H	
// ******************************************************
function libValidateZip(txtField,Required,FieldName) 
{
	// Make sure the text box is a valid object
	if (typeof txtField == "undefined")
	{
		return false;		
	}

	// Trim First
	if (libTrimFirst==true)
	{
		txtField.value = libTrim(txtField.value);
	}	

	FieldValue = txtField.value

	// Default field name if it wasn't passed
	if (typeof FieldName == "undefined")
	{
		FieldName = "Zip Code";
	}
	
	// Check Required
	if ((Required==true)&&(FieldValue.length == 0))
	{
		libMessage="Invalid " + FieldName + ":  Please enter " + FieldName + ".";
		libReturnFromValidate(txtField);
		return false;		
	}	

	// If this field wasn't required and its blank, then end validation here.
	if (FieldValue=="")
	{
		return true;
	}

	// Make sure the length is 5
	if (FieldValue.length != 5)
	{
		libMessage="Invalid " + FieldName + ":  Please enter a 5 digit number.";
		libReturnFromValidate(txtField);
		return false;		
	}	

	// Make sure Zip code is numeric
	if (libIsNumeric(FieldValue)==false)
	{
		libMessage="Invalid " + FieldName + ":  Please enter numbers only.";
		libReturnFromValidate(txtField);
		return false;		
	}

	// Make sure Zip code doesn't contain a (.) or (-)
	if ((FieldValue.indexOf(".")>=0)||(FieldValue.indexOf("-")>=0))
	{
		libMessage="Invalid " + FieldName + ":  Please enter numbers only.";
		libReturnFromValidate(txtField);
		return false;		
	}

	// Zip code must be 00100 - 99999
	if ((FieldValue<00100)||(FieldValue>99999))
	{
		libMessage="Invalid " + FieldName + ":  Please enter a valid " + FieldName + ".";
		libReturnFromValidate(txtField);
		return false;		
	}
	
	return true;
}

-->

