function ValidatePage() {
// ===========================================================================

	// Name is alwqays required:
	if (!ValidateName())	{
		return false;
	}

	if (!ValidateAddress())	{
		return false;
	}
	
	// email is required	if enews requested	
		if (document.brochureForm.RequestEnewsletter.checked  
		&&  document.brochureForm.EMailAddress.value == "" )
		{
			alert("An eMail address is required when requesting the eNewsletter");
			brochureForm.EMailAddress.focus();
			return false;
		}	

		if (document.brochureForm.EMailAddress.value != "" ) {
			if (!ValidateEmailAddress(document.brochureForm.EMailAddress.value)) {
				alert("The entered eMail address is not valid.");
				brochureForm.EMailAddress.focus();			
				return false;
			}		
		}
	return true;
}			

function ValidateName(){
// ===========================================================================

var msg="";

	//alert("ValidateName");
	
    // Doing required edits in reverse order in order to properly set focus
		// Name is alwqays required:
		if (document.brochureForm.LastName.value == "" ) 	{
			msg="    Last Name \n" + msg;
			//alert("Last Name is required");
			document.brochureForm.LastName.focus();
		}
		if (document.brochureForm.FirstName.value == "" )	{
			msg="    First Name \n" + msg;
			//alert("First Name is required");
			document.brochureForm.FirstName.focus();
		}

    // If any required fields were omitted display message
    if (msg != "") {
        msg = "Required field(s) were left blank:\n" + msg;    
        alert(msg);
        return false;
    }
		return true;

}			

function ValidateAddress(){
// ===========================================================================
var msg="";
var strAnd="";

    // Doing required edits in reverse order in order to properly set focus

	if (document.brochureForm.PostalCode.value == "" ) 	{
		msg="    Postal Code \n" + msg;	
		document.brochureForm.PostalCode.focus();
	}	
	if (document.brochureForm.State.value == "OTHER") 	{
		msg="    State / Province \n" + msg;
		document.brochureForm.State.focus();
	}
	if (document.brochureForm.City.value == "" )	{
		msg="    City \n" + msg;
		document.brochureForm.City.focus();
	}

	if (document.brochureForm.Address.value == "" )	{
		msg="    Address \n" + msg;
		document.brochureForm.Address.focus();
	}

    if (msg != "") {
	msg="An incomplete address was entered. Please complete the following fields:\n" + msg		    
        alert(msg);
        return false;
    }

		return true

}			
// ===========================================================================
function StateSelected() {
// ===========================================================================
// State must be entered by picking from the list 
var choiceIndex, choice

    choiceIndex= document.brochureForm.State.selectedIndex
//    alert("-Selected Index = " + choiceIndex );
    if (choiceIndex ==0) {
			return false;
    } else {
      choiceValue =  document.brochureForm.State.options(choiceIndex).value
      //alert("Selected Index = " + choiceIndex +"\nChoice:"+choiceValue +":\ncategory = >" + document.brochureForm.State.value + "<")

			return true;
		}
}		
// ===========================================================================
function ValidateEmailAddress(field) {
// ===========================================================================
// check if the passed email address is syntactically correct


// Checking existense of "@" and ".". 
// Length of must >= 5 and the "." must 
// not directly precede or follow the "@"
	if ((field.indexOf("@") == -1) || 
		  (field.indexOf(",") > -1)  || 
		  (field.indexOf(" ") > -1)  || 
		  (field.charAt(0) == ".")   || 
		  (field.charAt(0) == "@")	 || 
		  (field.len < 6)						 || 
		  (field.indexOf(".") == -1) || 
		  (field.charAt(field.indexOf("@")+1) == ".") || 
		  (field.charAt(field.indexOf("@")-1) == ".")) 
		  { 
				return false;
      }

    return true;
}		
// ===========================================================================
function dataEntered(field) {
// ===========================================================================
// check if the passed field contains data

    if (field == "") return false;
    if (field.length > 0) {
        if (field.trim == " ") return false;
    }
    if (field.substring(0,1) == " ") return false;

    return true;
}				
