 /**

-- checkMaxInput --

inputArea = text area to be checked
iMaxLen = maximum number of characters allowed in text area
remLen = text field which shows character remaining

Updates number of remaining characters for text area 
fields and prohibits entry greater than iMaxLen

*/

	function checkMaxInput(inputArea, iMaxLen, remLen) {

	if (inputArea.value.length > iMaxLen) 

		{ 

		// IF TOO LONG IT WILL TRUNCATE TEXT 
		inputArea.value = inputArea.value.substring(0, iMaxLen);
		remLen.value = iMaxLen - inputArea.value.length;
		inputArea.focus();
		alert("Maximum limit of " + iMaxLen +" characters for this field is reached, Excess characters removed"); 
		inputArea.focus();

		// IF LESS THAN MAXLENGTH UPDATE THE CHARACTER COUNTER 
		}
	
		else 
		remLen.value = iMaxLen - inputArea.value.length;
	
	}

/**

-- addBulletin1Validator --

Checks addBulletin1.asp Form

*/

	function addBulletin1Validator(form){

	// form is the form data

		// Title is required
		if(notEmpty(form.bulletinTitle.value)==false){
			alert("A Bulletin Title is required");
			form.bulletinTitle.focus();
			return false;
		}

		/*
		// Check formatting on Start Date
		if ((notEmpty(form.bulletinStartDate.value)==true) && (validateDate(form.bulletinStartDate.value)==false)){
			alert("The Start Date must be correctly formatted");
			form.bulletinStartDate.focus();
			return false;
		}
		*/

		// form.submit.value = "Please Wait......";

	}


/**
-- addBulletinDraftValidator --
Checks addBulletin2.asp Form (if draft)
*/

	function addBulletinDraftValidator(form){ // form is the form object

		var newsIndex = 0
		var eventIndex = 1
		var documentIndex = 2 

		//--------- FIX FORMATTING

		if ((notEmpty(form.bulletinStartDisplay.value)==true) && (validateDate(form.bulletinStartDisplay.value)==false)){
			alert("The Start Diplay Date must be correctly formatted");
			form.bulletinStartDisplay.focus();
			return false;
		}

		if ((notEmpty(form.bulletinEndDisplay.value)==true) && (validateDate(form.bulletinEndDisplay.value)==false)){
			alert("The End Display Date must be correctly formatted");
			form.bulletinEndDisplay.focus();
			return false;
		}

		// format end display
		if(notEmpty(form.bulletinEndDisplay.value)==true){
			form.bulletinEndDisplay.value = formatDate(form.bulletinEndDisplay.value);
		}


		// format start display
		if(notEmpty(form.bulletinStartDisplay.value)==true){
			form.bulletinStartDisplay.value = formatDate(form.bulletinStartDisplay.value)
		}

		// IF ITEM IS A DOCUMENT AND A DOC IS BEING UPLOADED	
		if((form.bulletinTypeID[documentIndex].checked == true) && (notEmpty(form.FILE1.value) == true)){
		
			// only return checkDoc if false to prevent early return of true value
			var checkDoc = checkDocument(form);
			if(checkDoc == false) return checkDoc;
		};

		
	};

/**
-- checkDocument --
checks document data
*/

	function checkDocument(form){

		
			// !!! document title is required		
			if(notEmpty(form.bulletinDocumentTitle.value) == false){
				alert("A Document Title is required");
				form.bulletinDocumentTitle.focus();
				return false;
			}
			
			var tempFileName = form.FILE1.value
		   	if (tempFileName.indexOf('/') > -1){
		        	var myFileName = tempFileName.substring(tempFileName.lastIndexOf('/')+1,tempFileName.length);
		    	} else {
		       		var myFileName = tempFileName.substring(tempFileName.lastIndexOf('\\')+1,tempFileName.length);
			}
	
			myFileName = myFileName.split(".");
			
			// new code added to grab ext and name (even if there are multiple .'s in the filename)
			
			var fileNameLength = myFileName.length - 1;
			myFileExt = myFileName[fileNameLength];	
			
			// error if filename has more than 1 dot.
			if(fileNameLength > 1){
				alert("An 'Upload Document' filename can only have one period or 'dot' in its name (just before the file extension). Please rename the file then use the 'Browse' button again to locate the newly named file.");
				form.FILE1.focus();
				return false;
			}
			
			var tempCounter = 0;
			var tempFile = ""
			while(tempCounter < (myFileName.length-1)){
				var tempAdd = myFileName[tempCounter];
				tempFile += tempAdd;
				if((tempCounter + 1) != (myFileName.length-1)) tempFile += "."
				tempCounter++;
			}
			myFileName = tempFile;
			
			//alert("myFileName = " + myFileName + " / myFileExt = " + myFileExt);
		
			// !!! document filename must have an extension
			if(myFileExt == undefined || myFileExt.length == 0 || myFileExt == ""){
				alert("An Uploaded Document must have a file extension.");
				form.FILE1.focus();
				return false;
			};


			// !! document filename cannot contain ()!/\:*?!"<>| characters
			var badCharString = "@()!/\[]:;=,^*?!''<>|";
			var badCharArray = badCharString.split("");
			
			var bCounter = 0;
			var containsBadChar = false;

			while(bCounter < badCharArray.length){
				var badChar = badCharArray[bCounter];
				if(myFileName.indexOf(badChar) != -1) containsBadChar = true;
				if(myFileExt.indexOf(badChar) != -1) containsBadChar = true;
				bCounter++;
			};

			if(containsBadChar == true){
				alert("A filename cannot contain the following characters: " + badCharString + " Please rename the file then use the 'Browse' button again to locate the newly named file.");
				form.FILE1.focus();
				return false;
			}


			// !!! document filename must be no more than 30characters
			if(myFileName.length > 30){
				alert("An Uploaded Document File Name may be no longer than 30 characters");
				form.FILE1.focus();
				return false;
			};


			if(form.bulletinDocumentPDF.checked == true){
	
				// !!! check document extension against list
				var xx = 0;
				var isMatch = false;
				while(xx < fileTypeArray.length){
					//alert("file type " + xx + " / " + fileTypeArray[xx].ext + " / " + myFileExt);	
					if(fileTypeArray[xx].ext == myFileExt) isMatch = true;			
					xx++;
				};
	
				if(isMatch == false && form.bulletinDocumentPDF.checked == true){
					alert("At this time " + myFileExt.toUpperCase() + " documents cannot be converted to PDF");
					form.bulletinDocumentTitle.focus();
					return false;
				};

			}	

	}

/**
-- checkPDFConvert --
checks to make sure a proper file is being uploaded when clicking on convert to pdf
*/

	function checkPDFConvert(form){

		// !!! document title is required		
		if(notEmpty(form.FILE1.value) == false){
			alert("An Uploaded File is required");
			form.FILE1.focus();
			return false;
		}
		
		return checkDocument(form);
		
	};

/**
-- checkPDFConvertModify --
checks to make sure a proper file is being uploaded when clicking on convert to pdf - used on modify page
*/


	function checkPDFConvertModify(form){
		
		// !!! document title is required		
		if(notEmpty(form.bulletinDocumentTitle.value) == false){
			alert("A Document Title is required");
			form.bulletinDocumentTitle.focus();
			return false;
		}	

		if(notEmpty(form.FILE1.value) == true){  // run usual check if we're uploading a new file

			return checkDocument(form);

		} else { // check current document

			// response.write curDocName
			var myFileName = curDocName.split(".");
			//var myFileExt = myFileName[1];	
			//var myFileName = myFileName[0];

			// new code added to grab ext and name (even if there are multiple .'s in the filename)
			
			var fileNameLength = myFileName.length - 1;
			myFileExt = myFileName[fileNameLength];	
			
			var tempCounter = 0;
			var tempFile = ""
			while(tempCounter < (myFileName.length-1)){
				var tempAdd = myFileName[tempCounter];
				tempFile += tempAdd;
				if((tempCounter + 1) != (myFileName.length-1)) tempFile += "."
				tempCounter++;
			}
			myFileName = tempFile;

			//alert(myFileExt);

			// !!! check document extension against list
			var xx = 0;
			var isMatch = false;
			while(xx < fileTypeArray.length){
				//alert("file type " + xx + " / " + fileTypeArray[xx].ext + " / " + myFileExt);	
				if(fileTypeArray[xx].ext == myFileExt) isMatch = true;			
				xx++;
			};
	
			if(isMatch == false && form.bulletinDocumentPDF.checked == true){
				alert("At this time " + myFileExt.toUpperCase() + " documents cannot be converted to PDF");
				form.bulletinDocumentTitle.focus();
				return false;
			};

		};
		

	};


/**

-- addBulletin2Validator --

Checks addBulletin2.asp Form

*/

	function addBulletin2Validator(form){ // form is the form object
		
		var newsIndex = 0
		var eventIndex = 1
		var documentIndex = 2 
		
		var newEndDate = convertToDate(form.bulletinEndDate.value);
		var newStartDate = convertToDate(form.bulletinStartDate.value);	
		

		// Bulletin Type must be selected
	
		// loop through all bulletinTypeIDs
		// also flag individual types as on or off
		var bulletinTypeSelected = 0; 		
		for (x=0; x < form.bulletinTypeID.length; x++){
  			if(form.bulletinTypeID[x].checked){
				bulletinTypeSelected = 1;
			}
 		}
		
		if (bulletinTypeSelected==0){
			alert("At least one Bulletin Type is required");
			form.bulletinTypeID[0].focus();
			return false;
		}


		// Title is required
			if(notEmpty(form.bulletinTitle.value)==false){
			alert("A Bulletin Title is required");
			form.bulletinTitle.focus();
			return false;
		}
		
		// Description is required
			if(notEmpty(form.bulletinDetails.value)==false){
			alert("A Bulletin Description is required");
			form.bulletinDetails.focus();
			return false;
		}

		// Check formatting on URL
			if ((notEmpty(form.bulletinURL.value)==true) && (validateURL(form.bulletinURL.value)==false)){
			alert("The Bulletin Hyperlink must be correctly formatted and begin with http://");
			form.bulletinURL.focus();
			return false;
		}


		// Start Date is required
		if (notEmpty(form.bulletinStartDisplay.value)==false){
			alert("The Display Start Date is required");
			form.bulletinStartDisplay.focus();
			return false;
		}

		

		//--------- FIX FORMATTING

		if ((notEmpty(form.bulletinStartDisplay.value)==true) && (validateDate(form.bulletinStartDisplay.value)==false)){
			alert("The Start Diplay Date must be correctly formatted");
			form.bulletinStartDisplay.focus();
			return false;
		}

		if ((notEmpty(form.bulletinEndDisplay.value)==true) && (validateDate(form.bulletinEndDisplay.value)==false)){
			alert("The End Display Date must be correctly formatted");
			form.bulletinEndDisplay.focus();
			return false;
		}

		// format end display
		if(notEmpty(form.bulletinEndDisplay.value)==true){
			form.bulletinEndDisplay.value = formatDate(form.bulletinEndDisplay.value);
		}


		// format start display
		if(notEmpty(form.bulletinStartDisplay.value)==true){
			form.bulletinStartDisplay.value = formatDate(form.bulletinStartDisplay.value)
		}

		//--------------------------------

		// Check formatting on Start Date
			if ((notEmpty(form.bulletinStartDisplay.value)==true) && (validateDate(form.bulletinStartDisplay.value)==false)){
			alert("The Display Start Date must be correctly formatted");
			form.bulletinStartDisplay.focus();
			return false;
		}

		// End Date is required - if the item is not marked as an event, or the event does not have any date entered

		// IF ITEM IS AN EVENT		
		if(form.bulletinTypeID[eventIndex].checked==true){

			// location is required			
			//if(notEmpty(form.bulletinLocation.value)==false){
			//	alert("A Location is required for Events");
			//	form.bulletinLocation.focus();
			//	return false;
			//}

			var bulletinDateType = '';


			// return event date type
			for (i=0; i < form.bulletinDateType.length; i++) {
  				if (form.bulletinDateType[i].checked) {
  				    bulletinDateType = form.bulletinDateType[i].value;
  				}
			}

			if(bulletinDateType=='single'){

				// If single date, check data in fields

				//--------- FIX FORMATTING

				// format start date
				if(notEmpty(form.bulletinStartDate.value)==true){
					form.bulletinStartDate.value = formatDate(form.bulletinStartDate.value)
				}


				// format end date
				if(notEmpty(form.bulletinEndDate.value)==true){
					form.bulletinEndDate.value = formatDate(form.bulletinEndDate.value)
				}

				//--------------------------------

				// Check for startDate
				if(notEmpty(form.bulletinStartDate.value)==false){
					alert("A Start Date is required");
					form.bulletinStartDate.focus();
					return false;
				}

				// Check formatting on Start Date
				if ((notEmpty(form.bulletinStartDate.value)==true) && (validateDate(form.bulletinStartDate.value)==false)){
					alert("The Start Date must be correctly formatted");
					form.bulletinStartDate.focus();
					return false;
				}	

				// Check formatting on End Date
				if ((notEmpty(form.bulletinEndDate.value)==true) && (validateDate(form.bulletinEndDate.value)==false)){
					alert("The End Date must be correctly formatted");
					form.bulletinEndDate.focus();
					return false;
				}


				// End Date cannot occur before Start Date
				if ((((notEmpty(form.bulletinEndDate.value)==true) && (validateDate(form.bulletinEndDate.value)==true)) && ((notEmpty(form.bulletinStartDate.value)==true) && (validateDate(form.bulletinStartDate.value)==true))) && (newEndDate < newStartDate)) {
					alert("The End Date cannot occur before the Start Date");
					form.bulletinEndDate.focus();
					return false;
				}

				// Check formatting on Start Time
				if ((notEmpty(form.bulletinStartTime.value)==true) && (validateTime(form.bulletinStartTime.value)==false)){
					alert("The Start Time must be correctly formatted");
					form.bulletinStartTime.focus();
					return false;
				}
			
				// Check formatting on End Time
				if ((notEmpty(form.bulletinEndTime.value)==true) && (validateTime(form.bulletinEndTime.value)==false)){
					alert("The End Time must be correctly formatted");
					form.bulletinEndTime.focus();
					return false;
				}

			}else{

				// If reoccuring date, check for at least 1 entry in select list.

				// Check Select List
				if(form.bulletinDates.length<=1){
					alert("At least one reoccurring date must be provided");
					form.bulletinDates.focus();
					return false;
				}

			}

		}

		// IF ITEM IS A DOCUMENT	
		if(form.bulletinTypeID[documentIndex].checked==true){

			// document is required		
			if(notEmpty(form.FILE1.value)==false){
				alert("A Document is required");
				form.FILE1.focus();
				return false;
			}
			
			// only return checkDoc if false to prevent early return of true value
			var checkDoc = checkDocument(form);
			if(checkDoc == false) return checkDoc;

		}

		// IF ITEM IS SMART URL
		
		/**
		if(form.bulletinTypeID[3].checked==true){

			// Keywords are required		
			if(notEmpty(form.bulletinKeywords.value)==false){
				alert("SmartURL Keywords are required");
				form.bulletinKeywords.focus();
				return false;
			}


		}
		*/		

		// At LEAST 1 Folder is required
		// loop through all bulletinTypeIDs

		var bulletinFolderSelected = 0; 

		if(form.bulletinFolder.length == undefined){

			if(form.bulletinFolder.checked==true){

				bulletinFolderSelected += 1;

			}else{

				alert("At least one Folder selection is required");
				form.bulletinFolder.focus();
				return false;	

			}	

		} else {

			for (x=0; x < form.bulletinFolder.length; x++){
  				if(form.bulletinFolder[x].checked==true) bulletinFolderSelected += 1;
 			}
	
			if (bulletinFolderSelected==0){
				alert("At least one Folder selection is required");
				form.bulletinFolder[0].focus();
				return false;
			}
		}

		// if bulletin is public we should make an alert

		// form.submit.value = "Please Wait......";
		
	}


/**

-- modifyBulletinValidator --

Checks modifyBulletin.asp Form

*/

	function modifyBulletinValidator(form){ // form is the form object
		
		var newsIndex = 0
		var eventIndex = 1
		var documentIndex = 2 

		var newEndDate = convertToDate(form.bulletinEndDate.value);
		var newStartDate = convertToDate(form.bulletinStartDate.value);	

		// Bulletin Type must be selected
	
		// loop through all bulletinTypeIDs
		// also flag individual types as on or off
		var bulletinTypeSelected = 0; 		
		for (x=0; x < form.bulletinTypeID.length; x++){
  			if(form.bulletinTypeID[x].checked){
				bulletinTypeSelected = 1;
			}
 		}
		
		if (bulletinTypeSelected==0){
			alert("At least one Bulletin Type is required");
			form.bulletinTypeID[0].focus();
			return false;
		}


		// Title is required
			if(notEmpty(form.bulletinTitle.value)==false){
			alert("A Bulletin Title is required");
			form.bulletinTitle.focus();
			return false;
		}
		
		// Description is required
			if(notEmpty(form.bulletinDetails.value)==false){
			alert("A Bulletin Description is required");
			form.bulletinDetails.focus();
			return false;
		}

		// Check formatting on URL
			if ((notEmpty(form.bulletinURL.value)==true) && (validateURL(form.bulletinURL.value)==false)){
			alert("The Bulletin Hyperlink must be correctly formatted and begin with http://");
			form.bulletinURL.focus();
			return false;
		}

		// Start Date is required
			if (notEmpty(form.bulletinStartDisplay.value)==false){
			alert("The Display Start Date is required");
			form.bulletinStartDisplay.focus();
			return false;
		}


		//--------- FIX FORMATTING

		if ((notEmpty(form.bulletinStartDisplay.value)==true) && (validateDate(form.bulletinStartDisplay.value)==false)){
			alert("The Start Diplay Date must be correctly formatted");
			form.bulletinStartDisplay.focus();
			return false;
		}

		if ((notEmpty(form.bulletinEndDisplay.value)==true) && (validateDate(form.bulletinEndDisplay.value)==false)){
			alert("The End Display Date must be correctly formatted");
			form.bulletinEndDisplay.focus();
			return false;
		}

		// format end display
		if(notEmpty(form.bulletinEndDisplay.value)==true){
			form.bulletinEndDisplay.value = formatDate(form.bulletinEndDisplay.value);
		}


		// format start display
		if(notEmpty(form.bulletinStartDisplay.value)==true){
			form.bulletinStartDisplay.value = formatDate(form.bulletinStartDisplay.value)
		}

		//--------------------------------

		// Check formatting on Start Date
			if ((notEmpty(form.bulletinStartDisplay.value)==true) && (validateDate(form.bulletinStartDisplay.value)==false)){
			alert("The Display Start Date must be correctly formatted");
			form.bulletinStartDisplay.focus();
			return false;
		}

		// End Date is required - if the item is not marked as an event, or the event does not have any date entered

		// IF ITEM IS AN EVENT		
		if(form.bulletinTypeID[eventIndex].checked==true){

			// location is required			
			//if(notEmpty(form.bulletinLocation.value)==false){
			//	alert("A Location is required for Events");
			//	form.bulletinLocation.focus();
			//	return false;
			//}

			var bulletinDateType = '';

			// return event date type
			for (i=0; i < form.bulletinDateType.length; i++) {
  				if (form.bulletinDateType[i].checked) {
  				    bulletinDateType = form.bulletinDateType[i].value;
  				}
			}

			if(bulletinDateType=='single'){

				//--------- FIX FORMATTING

				// format start date
				if(notEmpty(form.bulletinStartDate.value)==true){
					form.bulletinStartDate.value = formatDate(form.bulletinStartDate.value)
				}


				// format end date
				if(notEmpty(form.bulletinEndDate.value)==true){
					form.bulletinEndDate.value = formatDate(form.bulletinEndDate.value)
				}

				//--------------------------------

				// If single date, check data in fields

				// Check for startDate
				if(notEmpty(form.bulletinStartDate.value)==false){
					alert("A Start Date is required");
					form.bulletinStartDate.focus();
					return false;
				}

				// Check formatting on Start Date
				if ((notEmpty(form.bulletinStartDate.value)==true) && (validateDate(form.bulletinStartDate.value)==false)){
					alert("The Start Date must be correctly formatted");
					form.bulletinStartDate.focus();
					return false;
				}	

				// Check formatting on End Date
				if ((notEmpty(form.bulletinEndDate.value)==true) && (validateDate(form.bulletinEndDate.value)==false)){
					alert("The End Date must be correctly formatted");
					form.bulletinEndDate.focus();
					return false;
				}	
		
				// End Date cannot occur before Start Date
				if ((((notEmpty(form.bulletinEndDate.value)==true) && (validateDate(form.bulletinEndDate.value)==true)) && ((notEmpty(form.bulletinStartDate.value)==true) && (validateDate(form.bulletinStartDate.value)==true))) && (newEndDate < newStartDate)) {
					alert("The End Date cannot occur before the Start Date");
					form.bulletinEndDate.focus();
					return false;
				}

				// Check formatting on Start Time
				if ((notEmpty(form.bulletinStartTime.value)==true) && (validateTime(form.bulletinStartTime.value)==false)){
					alert("The Start Time must be correctly formatted");
					form.bulletinStartTime.focus();
					return false;
				}
			
				// Check formatting on End Time
				if ((notEmpty(form.bulletinEndTime.value)==true) && (validateTime(form.bulletinEndTime.value)==false)){
					alert("The End Time must be correctly formatted");
					form.bulletinEndTime.focus();
					return false;
				}

			}else{

				// If reoccuring date, check for at least 1 entry in select list.

				// Check Select List
				if(form.bulletinDates.length<=1){
					alert("At least one reoccurring date must be provided");
					form.bulletinDates.focus();
					return false;
				}

			}

		}

		// IF ITEM IS A DOCUMENT	
		if(form.bulletinTypeID[documentIndex].checked==true){


			if((form.bulletinTypeID[documentIndex].checked == true)){


				// !!! document title is required		
				if(notEmpty(form.bulletinDocumentTitle.value) == false){
					alert("A Document Title is required");
					form.bulletinDocumentTitle.focus();
					return false;
				}

			
				if (notEmpty(form.FILE1.value) == true){

					// only return checkDoc if false to prevent early return of true value
					var checkDoc = checkDocument(form);
					if(checkDoc == false) return checkDoc;
				
				}
				

			}


		}

		// IF ITEM IS SMART URL
		/*
		if(form.bulletinTypeID[3].checked==true){

			// Keywords are required		
			if(notEmpty(form.bulletinKeywords.value)==false){
				alert("SmartURL Keywords are required");
				form.bulletinKeywords.focus();
			return false;
			}


		}
		*/

		// At LEAST 1 Folder is required
		// loop through all bulletinTypeIDs

		var bulletinFolderSelected = 0; 
		if(form.bulletinFolder.length == undefined){

			if(form.bulletinFolder.checked==true){

				bulletinFolderSelected += 1;

			}else{

				alert("At least one Folder selection is required");
				form.bulletinFolder.focus();
				return false;	

			}	

		} else {

			for (x=0; x < form.bulletinFolder.length; x++){
  				if(form.bulletinFolder[x].checked==true) bulletinFolderSelected += 1;
 			}
	
			if (bulletinFolderSelected==0){
				alert("At least one Folder selection is required");
				form.bulletinFolder[0].focus();
				return false;
			}
		}


		// if bulletin is public we should make an alert

		// form.submit.value = "Please Wait......";
		
	}

/**

-- addUserValidator --

Checks addUser.asp Form

*/

	function addUserValidator(form){

	// form is the form data

		// username is required
			if(notEmpty(form.accountName.value)==false){
			alert("A username is required");
			form.accountName.focus();
			return false;
		}

		// password & confirmation password are required
			if(notEmpty(form.accountPassword.value)==false){
			alert("Both a password and confirmation password are required");
			form.accountPassword.focus();
			return false;
		}

		// confirmation password is required
			if(notEmpty(form.accountPasswordC.value)==false){
			alert("Please confirm the password you have entered");
			form.accountPasswordC.focus();
			return false;
		}

		// password and confirmation password must match
			if(((notEmpty(form.accountPassword.value)==true)&&(notEmpty(form.accountPasswordC.value)==true)) && (form.accountPassword.value != form.accountPasswordC.value)){
			alert("Password and confirmation do not match");
			form.accountPassword.focus();
			return false;
		}
			
		// Check for First Name
			if(notEmpty(form.contactFname.value)==false){
			alert("A First Name is required");
			form.contactFname.focus();
			return false;
		}

		// Check for Last Name
			if(notEmpty(form.contactLname.value)==false){
			alert("A Last Name is required");
			form.contactLname.focus();
			return false;
		}

		// Phone Number Formatting
			if(notEmpty(form.contactInfoPhone.value)==true){
				if(validateUSPhone(form.contactInfoPhone.value)==true){
					form.contactInfoPhone.value = formatPhone(form.contactInfoPhone.value);
				} else {
					alert("Phone Number entered is not valid");
					form.contactInfoPhone.focus();
					return false;
				}
		}

		// Fax Number Formatting
			if(notEmpty(form.contactInfoFax.value)==true){
				if(validateUSPhone(form.contactInfoFax.value)==true){
					form.contactInfoFax.value = formatPhone(form.contactInfoFax.value);
				} else {
					alert("Fax Number entered is not valid");
					form.contactInfoFax.focus();
					return false;
				}
		}

		// Email Formatting
			if((notEmpty(form.contactInfoEmail.value)==true) && (validateEMail(form.contactInfoEmail.value)==false)){
			alert("Email entered is not valid");
			form.contactInfoEmail.focus();
			return false;
		}

		// URL Formatting

		form.submit.value = "Please Wait......";

	}



/**

-- modifyUserValidator --

Checks modifyUser.asp Form

*/

	function modifyUserValidator(form){

	// form is the form data

		// Check for First Name
			if(notEmpty(form.contactFname.value)==false){
			alert("A First Name is required");
			form.contactFname.focus();
			return false;
		}

		// Check for Last Name
			if(notEmpty(form.contactLname.value)==false){
			alert("A Last Name is required");
			form.contactLname.focus();
			return false;
		}

		// Phone Number Formatting
			if(notEmpty(form.contactInfoPhone.value)==true){
				if(validateUSPhone(form.contactInfoPhone.value)==true){
					form.contactInfoPhone.value = formatPhone(form.contactInfoPhone.value);
				} else {
					alert("Phone Number entered is not valid");
					form.contactInfoPhone.focus();
					return false;
				}
		}

		// Fax Number Formatting
			if(notEmpty(form.contactInfoFax.value)==true){
				if(validateUSPhone(form.contactInfoFax.value)==true){
					form.contactInfoFax.value = formatPhone(form.contactInfoFax.value);
				} else {
					alert("Fax Number entered is not valid");
					form.contactInfoFax.focus();
					return false;
				}
		}

		// Email Formatting
			if((notEmpty(form.contactInfoEmail.value)==true) && (validateEMail(form.contactInfoEmail.value)==false)){
			alert("Email entered is not valid");
			form.contactInfoEmail.focus();
			return false;
		}

		// URL Formatting
		
		form.submit.value = "Please Wait......";

	}

/**

-- addGroupValidator --

Checks addGroup.asp Form

*/

	function addGroupValidator(form){

	// form is the form data

		// Group Name is required
			if(notEmpty(form.groupName.value)==false){
			alert("A Group Name is required");
			form.groupName.focus();
			return false;
		}

		selectAllOptions(form.groupUsers);

		form.submit.value = "Please Wait......";

	}

/**

-- addFolderValidator --

Checks addFolder.asp Form

*/

	function addFolderValidator(form){

	// form is the form data

		// Folder Name is required
			if(notEmpty(form.folderName.value)==false){
			alert("A Folder Name is required");
			form.folderName.focus();
			return false;
		}

		// Folder Type is required
			if(((form.folderType.options[form.folderType.options.selectedIndex].text)=="-- select --")||((form.folderType.options[form.folderType.options.selectedIndex].value)=="")){
			alert("Folder Type must be selected");
			form.folderType.focus();
			return false;
		}	

		// Check for required fields
		// Hidden reqFieldsList field contains required field data
		
		var currentType = form.folderType.options[form.folderType.options.selectedIndex].text;
		var reqFieldsList = (currentType+"Req");
		
		// loop through and check required fields

		if(form[reqFieldsList]){

		var reqFieldsArray = form[reqFieldsList].value.split(",");

			for(i = 1; i < reqFieldsArray.length; i++) {
				
				var reqFieldInfo = reqFieldsArray[i].split(":");	
				var formFieldTitle=(reqFieldInfo[0]);
				var formFieldName=(currentType+reqFieldInfo[0]);
				var formFieldType=(reqFieldInfo[1]);
	
				// if field is text
				if(formFieldType=="text"){			
					
					if(notEmpty(form[formFieldName].value)==false){
						alert(currentType+" "+formFieldTitle+" is required");
						form[formFieldName].focus();
						return false;
					}
	
				}
	
				// if field is a date
				if(formFieldType=="date"){
	
					// Check for Date
					if(notEmpty(form[formFieldName].value)==false){
						alert("A "+currentType+" "+formFieldTitle+" Date is required");
						form[formFieldName].focus();
						return false;
						}
	
		
					// Check formatting on Date
					if((notEmpty(form[formFieldName].value)==true) && (validateDate(form[formFieldName].value)==false)){
						alert("A correctly formated "+currentType+" "+formFieldTitle+" Date is required");
						form[formFieldName].focus();
						return false;
						}
	
				}
	
				// if field is a list
				if(formFieldType=="list"){
	
					if(((form[formFieldName].options[form[formFieldName].options.selectedIndex].text)=="-- select --")||((form[formFieldName].options[form[formFieldName].options.selectedIndex].value)=="")){
						alert(currentType+" "+formFieldTitle+" must be selected");
						form[formFieldName].focus();
						return false;
					}		

				}	
				
			}

		}
			
		// select all folder users
		selectAllOptions(form.folderUsers);

		form.submit.value = "Please Wait......";

	}

/**

-- addFolderTypeValidator --

Checks addFolderType.asp Form

*/

	function addFolderTypeValidator(form){

	// form is the form data

		if((form.formAction.value)=='submit'){
	
			// Folder Type Name is required
				if(notEmpty(form.folderType.value)==false){
				alert("A Folder Type Name is required");
				form.folderType.focus();
				return false;
			}
			
			// Loop through all attributes

			var attributeNames = "" //Will hold list of && delimited attribute names

			var formTotalAttributes = form.numberOfAttributes.value;

			//alert("formTotalAttributes: "+formTotalAttributes)

			for(i = 1; i <= formTotalAttributes; i++) {
			
				//alert("i: "+i);
				
				var attributeName = "attributeName" + i;
				var attributeType = "attributeType" + i;
				var attributeData = "attributeData" + i;

				if(notEmpty(form[attributeName].value)==true){
					
					// check for spaces
					if(returnStringCount(" ",form[attributeName].value)!=0){
						alert("Attribute Names cannot contain spaces");
						form[attributeName].focus();
						return false;
					}	

					// check for attribute type
					if(((form[attributeType].options[form[attributeType].options.selectedIndex].text)=="-- select --")||((form[attributeType].options[form[attributeType].options.selectedIndex].value)=="")){
						alert("Attribute Type must be selected");
						form[attributeType].focus();
						return false;
					}	

					// check for attribute data (if attribute type is a list)
					if(((form[attributeType].options[form[attributeType].options.selectedIndex].value)=="list")&&(notEmpty(form[attributeData].value)==false)){
						alert("Comma delimited option must be added for attributes with 'list' type specifications");
						form[attributeData].focus();
						return false;
					}

					// split array of attributeNames
					var attributeNamesArray = attributeNames.split("$$");

					// check for duplicate attributeNames
					for(x = 0; x <= attributeNamesArray.length; x++) {
						if(attributeNamesArray[x]){
							if(form[attributeName].value==attributeNamesArray[x]){
								alert("Duplicate attribute names are not allowed");
								form[attributeName].focus();
								return false;
							}
						}
					}
					
					// append field title to attribute names
					attributeNames = attributeNames + "$$" + form[attributeName].value;

				} 
			
			}

			return false;

			form.submitButton.value = "Please Wait......";
		
		}
	
	}



/**

-- checkMakePublic --

Sends alert if makePublic has been checked

*/

function checkMakePublic(checkStatus){
	if(checkStatus==true){
		// if makepublic is being checked
		alert("This Bulletin will be publicly available.");
		return false;
		}
	}


/**

-- checkFolderTypeAttribLimit--

checks to make sure the user doesn't more attributes filled in than they are choosing to show.

totalAttributesShown = attributes currently on view

*/

function checkFolderTypeAttribLimit(theForm, totalAttributesShown){

	var formTotalAttributes = theForm.numberOfAttributes.value;
	var totalAttributesUsed = 0

	// loop through all current fields
	for(i = 1; i <= totalAttributesShown; i++) {
		
		var nameField = "attributeName" + i;
		var typeField = "attributeType" + i;
		var dataField = "attributeData" + i;
		var reqField = "attributeReq" + i; 

		if((theForm[nameField].value=='')&&(theForm[typeField].selectedIndex==0)&&(theForm[dataField].value=='')&&(theForm[reqField][1].checked=true)){
			//Do Nothing
			}else{
			// add number of fields to list if selected
			totalAttributesUsed = totalAttributesUsed + 1;
			}
	
	}

	// if number of fields in list is great then the new number, then error occurs.
	if(formTotalAttributes<totalAttributesUsed){
	
		alert("you must clear attributes");
	
		}else{
        
	       	theForm.formAction.value='refresh';
        	theForm.submit();
	}
	
	}

/**

-- addUserValidator --

Checks addUser.asp Form

*/

	function addUserValidator(form){

	// form is the form data

		// username is required
			if(notEmpty(form.accountName.value)==false){
			alert("A username is required");
			form.accountName.focus();
			return false;
		}

		// password & confirmation password are required
			if(notEmpty(form.accountPassword.value)==false){
			alert("Both a password and confirmation password are required");
			form.accountPassword.focus();
			return false;
		}

		// confirmation password is required
			if(notEmpty(form.accountPasswordC.value)==false){
			alert("Please confirm the password you have entered");
			form.accountPasswordC.focus();
			return false;
		}

		// password and confirmation password must match
			if(((notEmpty(form.accountPassword.value)==true)&&(notEmpty(form.accountPasswordC.value)==true)) && (form.accountPassword.value != form.accountPasswordC.value)){
			alert("Password and confirmation do not match");
			form.accountPassword.focus();
			return false;
		}
			
		// Check for First Name
			if(notEmpty(form.contactFname.value)==false){
			alert("A First Name is required");
			form.contactFname.focus();
			return false;
		}

		// Check for Last Name
			if(notEmpty(form.contactLname.value)==false){
			alert("A Last Name is required");
			form.contactLname.focus();
			return false;
		}

		// Phone Number Formatting
			if(notEmpty(form.contactInfoPhone.value)==true){
				if(validateUSPhone(form.contactInfoPhone.value)==true){
					form.contactInfoPhone.value = formatPhone(form.contactInfoPhone.value);
				} else {
					alert("Phone Number entered is not valid");
					form.contactInfoPhone.focus();
					return false;
				}
		}

		// Fax Number Formatting
			if(notEmpty(form.contactInfoFax.value)==true){
				if(validateUSPhone(form.contactInfoFax.value)==true){
					form.contactInfoFax.value = formatPhone(form.contactInfoFax.value);
				} else {
					alert("Fax Number entered is not valid");
					form.contactInfoFax.focus();
					return false;
				}
		}

		// Email Formatting
			if((notEmpty(form.contactInfoEmail.value)==true) && (validateEMail(form.contactInfoEmail.value)==false)){
			alert("Email entered is not valid");
			form.contactInfoEmail.focus();
			return false;
		}

		// URL Formatting

		form.submit.value = "Please Wait......";

	}



/**

-- addFileTypeValidator --

Checks addFiletype.asp Form

*/

	function addFileTypeValidator(form){

	// form is the form data

		// Check for File Type Name
		if(notEmpty(form.fileTypeName.value)==false){
			alert("A File Type Name is required");
			form.fileTypeName.focus();
			return false;
		}

		// Check for File Type Extension
		if(notEmpty(form.fileTypeExt.value)==false){
			alert("A File Type Extension is required");
			form.fileTypeExt.focus();
			return false;
		}

		// Check for File Type Mime
		//if(notEmpty(form.fileTypeMime.value)==false){
		//	alert("A File Type Mime is required");
		//	form.fileTypeMime.focus();
		//	return false;
		//}

		// Check for File Type Icon
		if(notEmpty(form.FILE1.value)==false){
			alert("A File Type Icon is required");
			form.FILE1.focus();
			return false;
		}

		form.submit.value = "Please Wait......";

	}


/**

-- modifyFileTypeValidator --

Checks modifyFiletype.asp Form

*/

	function modifyFileTypeValidator(form){

	// form is the form data

		// Check for File Type Name
		if(notEmpty(form.fileTypeName.value)==false){
			alert("A File Type Name is required");
			form.fileTypeName.focus();
			return false;
		}

		// Check for File Type Extension
		if(notEmpty(form.fileTypeExt.value)==false){
			alert("A File Type Extension is required");
			form.fileTypeExt.focus();
			return false;
		}

		form.submit.value = "Please Wait......";

	}


/**

-- modifyPasswordValidator --

Checks modifyMyPassword.asp Form

*/

	function modifyMyPasswordValidator(form){

	// form is the form data

		// Password is Required
		if(notEmpty(form.password.value)==false){
			alert("Your password is required");
			form.password.focus();
			return false;
		}

		// New Password is Required
		if(notEmpty(form.newpassword1.value)==false){
			alert("Your new password is required");
			form.newpassword1.focus();
			return false;
		}


		// New Password Confirmation is Required
		if(notEmpty(form.newpassword2.value)==false){
			alert("Your new password confirmation is required");
			form.newpassword2.focus();
			return false;
		}


		// New Password must Match Confirmation
		if(form.newpassword1.value != form.newpassword2.value){
			alert("Your new password and confirmation do not match");
			form.newpassword1.focus();
			return false;
		}


		form.submit.value = "Please Wait......";

	}


/**

-- modifyPasswordValidator --

Checks modifyPassword.asp Form

*/

	function modifyPasswordValidator(form){

	// form is the form data

		// New Password is Required
		if(notEmpty(form.newpassword1.value)==false){
			alert("Your new password is required");
			form.newpassword1.focus();
			return false;
		}


		// New Password Confirmation is Required
		if(notEmpty(form.newpassword2.value)==false){
			alert("Your new password confirmation is required");
			form.newpassword2.focus();
			return false;
		}


		// New Password must Match Confirmation
		if(form.newpassword1.value != form.newpassword2.value){
			alert("Your new password and confirmation do not match");
			form.newpassword1.focus();
			return false;
		}


		form.submit.value = "Please Wait......";

	}


/**

-- generate calendar validator --

Checks masterCalendar1x.Form

*/

	function generateCalendarValidator(form){

	// form is the form data

		// Check formatting on Start Date
		if ((notEmpty(form.startDate.value)==true) && (validateDate(form.startDate.value)==false)){
			alert("The Start Date must be correctly formatted");
			form.startDate.focus();
			return false;
		}

		// Check formatting on End Date
		if ((notEmpty(form.endDate.value)==true) && (validateDate(form.endDate.value)==false)){
			alert("The End Date must be correctly formatted");
			form.endDate.focus();
			return false;
		}

	}
