// -------------------------------------- Field validation subroutines ------------------------------------// Field validations - uploaded file names (Required since it also sets the file names in the document)function GNCheckFileName(fieldName, fieldDescription, formReload) {	if ( arguments[2] ) {	} else {		formReload = "" ;	}	errorMsg = '' ;	var frm = document.forms[0];	intAttachmentName = "GN" + fieldName ;	intAttachmentDetachName = "GN" + fieldName + "Detach" ;	intDateUploadName = fieldName ;	intDateUploadFieldName = replaceSubstring( intDateUploadName, "Attachment", "UploadDate");	if (is_ie5up || is_nav5up || is_opera7up || is_safari || is_konqueror3up ) {		AttachmentObj = document.getElementById(intAttachmentName) ;		AttachmentDetachObj = document.getElementById(intAttachmentDetachName) ;	} else if (is_ie4) {		AttachmentObj = document.all[intAttachmentName] ;		AttachmentDetachObj = document.all[intAttachmentDetachName] ;	}	var confirm_msgFN = "";	confirm_msgFN += "____________________________________________________\n\n";	confirm_msgFN += "The file name you have selected has spaces in the name.\n";	confirm_msgFN += "Some Browsers will not be able to reliably reference this\n";	confirm_msgFN += "image or attachment on the web. You should remove the\n";	confirm_msgFN += "spaces from the file name before uploading it.\n";	confirm_msgFN += "To continue with the current upload, Click \"OK\"\n";	confirm_msgFN += "Otherwise to replace it, Click \"Cancel\"\n";	confirm_msgFN += "_____________________________________________________\n";	var confirm_msgFN2 = "";	confirm_msgFN2 += "____________________________________________________\n\n";	confirm_msgFN2 += "The file name you have selected has invalid characters (*&?#@) in the name.\n";	confirm_msgFN2 += "Browsers will not be able to reference this image\n";	confirm_msgFN2 += "or attachment on the web. You must remove the\n";	confirm_msgFN2 += "invalid characters from the file name and upload it again.\n";	confirm_msgFN2 += "_____________________________________________________\n";	if ( AttachmentObj ) {		GNAttachmentLong = AttachmentObj.value ;		if ( GNAttachmentLong != "" ) {			if (is_Mac ) {				posLastSlash = GNAttachmentLong.lastIndexOf("/")			} else {				posLastSlash = GNAttachmentLong.lastIndexOf("\\")			}			GNAttachment = GNAttachmentLong.substring(posLastSlash+1, GNAttachmentLong.length)			var invalidFileNameExp1 = new RegExp("\\s") ;			var invalidFileNameExp2 = new RegExp("[\\*\\?#&@']") ;			FileNameTest1 = invalidFileNameExp1.test(GNAttachment) ;			if ( FileNameTest1 == true ) {				confirm_msgFN1 = "WARNING !! " + fieldDescription + " upload - \"" + GNAttachment + "\"\n" + confirm_msgFN ;				if (confirm(confirm_msgFN1) == false) {					errorMsg = GNAttachment +  " contains spaces in the filename.\n" ;					errorMsg += "Change the filename on your computer, and upload again." ;					return errorMsg ;				}			}			FileNameTest2 = invalidFileNameExp2.test(GNAttachment) ;			if ( FileNameTest2 == true ) {				confirm_msgFN1 = "WARNING !! " + fieldDescription + " upload - \"" + GNAttachment + "\"\n" + confirm_msgFN2 ;				alert(confirm_msgFN1) 				errorMsg = GNAttachment +  " contains invalid characters in the filename.\n" ;				errorMsg += "Change the filename on your computer, and upload again." ;				return errorMsg ;			}			frm[ fieldName ].value = GNAttachment ;			fileUploadFlag = "Yes" ;			//now set the date			//alert ( intDateUploadFieldName )			if ( frm [ intDateUploadFieldName ] ) {				frm [ intDateUploadFieldName ].value = currentDateText ;			}		}	}	// now do the attachment removal	if (AttachmentDetachObj) {		if (AttachmentDetachObj.checked == true) {			frm [ fieldName ].value = "" ;			if ( formReload != "" ) {				frm [ formReload ].value = "Y" ;				// add logic here to clear the date in the date upload field				if ( frm [ intDateUploadFieldName ] ) {					frm [ intDateUploadFieldName ].value = "" ;				}			}		}	}	return errorMsg ;}// Field validations - checks for valig image extensions ( .gif .jpg .jpeg .png .swf )function GNCheckExtension(fieldName, fieldType) {	var frm = document.forms[0];	errorMsg = '' ;	if ( frm ["DeleteDocument"] ) {		if  (frm ["DeleteDocument"] [0].checked == true ) {			return errorMsg ;		}	}	intAttachmentName = frm [ fieldName ].value ;	var confirm_msgBMP = "";	confirm_msgBMP += "____________________________________________________\n\n";	confirm_msgBMP += "You have chosen to upload a 'BitMap' (.bmp).\n";	confirm_msgBMP += "This is not a standard web image format, and can only be\n";	confirm_msgBMP += "viewed by Microsoft's Internet Explorer. It is bulky and\n";	confirm_msgBMP += "slow-loading, and should be avoided if possible.\n";	confirm_msgBMP += "To continue with the current upload, Click \"OK\"\n";	confirm_msgBMP += "Otherwise to replace it, Click \"Cancel\"\n";	confirm_msgBMP += "_____________________________________________________\n";		if ( fieldType == "Image" && intAttachmentName != "" ) {		posLastDot = intAttachmentName.lastIndexOf(".")		GNExtension = intAttachmentName.substring(posLastDot+1, intAttachmentName.length)		if ( GNExtension == "bmp" ) {			if (confirm(confirm_msgBMP) == false) {				errorMsg = intAttachmentName +  " is a non-standard BitMap file.\n" ;				errorMsg += "Choose again and select a web-standard format." ;				return errorMsg ;			}			return errorMsg ;		}		var validExtensionRegExp = new RegExp("gif|jpg|jpeg|png|swf") ;		ExtensionTest1 = validExtensionRegExp.test(GNExtension) ;		if ( ExtensionTest1 == false ) {			errorMsg = intAttachmentName +  " is not a web-standard image format\n" ;			errorMsg += "and can not be displayed as an image.\n" ;			errorMsg += "Choose an image in a web-standard format. (.jpg, .gif, .jpeg, .png, .swf)" ;			return errorMsg ;		}	}	return errorMsg ;}// Field validations - General fieldfunction validateField (fieldName, fieldDescription) {	errorMsg = '' ;	fieldValue = document.forms[0] [ fieldName].value;	if(fieldValue == "" || fieldValue == " " || fieldValue == "_") {		errorMsg = fieldDescription +  " is required and can't be blank" ;	}	return errorMsg ;}function validateField1 (fieldName, fieldDescription) {	errorMsg = '' ;	fieldValue = document.forms[1] [ fieldName].value;	if(fieldValue == "" || fieldValue == " " || fieldValue == "_") {		errorMsg = fieldDescription +  " is required and can't be blank" ;	}	return errorMsg ;}// Field Validations - Password fieldfunction validatePwdField (fieldName, fieldDescription) {	errorMsg = '' ;	fieldValue = document.forms[0] [ fieldName].value;	if(fieldValue.length < 7) {		errorMsg = fieldDescription +  " must be at least 7 characters " ;	}	if(fieldValue == "" || fieldValue == " " || fieldValue == "_") {		errorMsg = fieldDescription +  " can't be blank " ;	}	return errorMsg ;}function validatePwdField1 (fieldName, fieldDescription) {	errorMsg = '' ;	fieldValue = document.forms[1] [ fieldName].value;	if(fieldValue.length < 7) {		errorMsg = fieldDescription +  " must be at least 7 characters " ;	}	if(fieldValue == "" || fieldValue == " " || fieldValue == "_") {		errorMsg = fieldDescription +  " can't be blank " ;	}	return errorMsg ;}// Field validations - Same value in seperate fields function validateSameValue (fieldName1, fieldName2, fieldDescription) {	errorMsg = '' ;	fieldValue1 = document.forms[0] [ fieldName1].value;	fieldValue2 = document.forms[0] [ fieldName2].value;	if(fieldValue1 != fieldValue2 ) {		errorMsg = fieldDescription +  " are not the same, please re-enter." ;		// if (firstError == "" ) {		//	firstError = fieldName1 ;		// }	}	return errorMsg ;} function validateSameValue1 (fieldName1, fieldName2, fieldDescription) {	errorMsg = '' ;	fieldValue1 = document.forms[1] [ fieldName1].value;	fieldValue2 = document.forms[1] [ fieldName2].value;	if(fieldValue1 != fieldValue2 ) {		errorMsg = fieldDescription +  " are not the same, please re-enter." ;		// if (firstError == "" ) {		//	firstError = fieldName1 ;		// }	}	return errorMsg ;}// Field validations - General field with invalid char replacementfunction validateJSField (fieldName, fieldDescription) {	errorMsg = '' ;	fieldValue = document.forms[0] [ fieldName].value;	if ( fieldValue.indexOf("'") != -1 || fieldValue.indexOf('"') != -1) {		replaceFieldSubstring(fieldName, "'", "") ;		replaceFieldSubstring(fieldName, '"', "") ;			var warn_msg1 = "ALERT !!\n";		warn_msg1 += "__________________________________________\n\n";		warn_msg1 += "------   " + fieldDescription + "   ------\n";		warn_msg1 += "You entered a character, (probably an apostrophe)\n";		warn_msg1 += "that would have caused the system to display your\n";		warn_msg1 += "information incorrectly.\n\n";		warn_msg1 += "This has been removed.\n";		warn_msg1 += "___________________________________________\n";		alert(warn_msg1);	}	fieldValue = document.forms[0] [ fieldName].value;	if(fieldValue == "" || fieldValue == " " || fieldValue == "_") {		errorMsg = fieldDescription +  "  is required and can't be blank" ;	}	return errorMsg ;}// Field warnings - No text enteredfunction checkTextFieldEmpty (fieldName, fieldNameDisplayed, fieldDescription) {	errorMsg = '' ;	var warn_msg1 = "WARNING !!\n";	warn_msg1 += "__________________________________________\n\n";	warn_msg1 += "------   " + fieldDescription + "   ------\n";	warn_msg1 += "This is marked as visible, but no text has been entered.\n";	warn_msg1 += "Do you want to continue?\n";	warn_msg1 += "___________________________________________\n";	trim (fieldName) ;	fieldRadioOn = document.forms[0] [ fieldNameDisplayed] [0].checked;	if (fieldRadioOn == true) {				fieldValue = document.forms[0] [ fieldName].value;		if ( fieldValue == "" || fieldValue == " ") {			if (confirm(warn_msg1) == false) {				errorMsg = fieldDescription +  " is blank but should contain some text" ;			}		}	}	return errorMsg ;}// Field validations - Integer Value (using pattern matching)function validateInteger (fieldName, fieldDescription) {	errorMsg = '' ;	var anyNonNumbersRegExp = new RegExp("\\D") ;	var anyNumbersRegExp = new RegExp("\\d") ;	var validNumbersRegExp = new RegExp("\\d{1,4}") ;	fieldValue = document.forms[0] [ fieldName].value;	NonNumbersTest = anyNonNumbersRegExp.test(fieldValue) ;	ValidNumbersTest = validNumbersRegExp.test(fieldValue) ;	if (NonNumbersTest == true) {		errorMsg = fieldDescription +  " must be a positive number (no alpha)" ;		return errorMsg ;	}	if (ValidNumbersTest == false) {		errorMsg = fieldDescription +  " must be a number between 1 & 9999" ;		return errorMsg ;	}	return errorMsg ;}// Field validations - Integer Value (using pattern matching) 3 integers enteredfunction validateInteger3 (fieldName, fieldDescription) {	errorMsg = '' ;	var anyNonNumbersRegExp = new RegExp("\\D") ;	var anyNumbersRegExp = new RegExp("\\d") ;	var validNumbersRegExp = new RegExp("\\d{1,3}") ;	fieldValue = document.forms[0] [ fieldName].value;	NonNumbersTest = anyNonNumbersRegExp.test(fieldValue) ;	ValidNumbersTest = validNumbersRegExp.test(fieldValue) ;	if (NonNumbersTest == true) {		errorMsg = fieldDescription +  " must be a positive number (no alpha)" ;		return errorMsg ;	}	if (ValidNumbersTest == false) {		errorMsg = fieldDescription +  " must be a number between 1 & 999" ;		return errorMsg ;	}	return errorMsg ;}// Field validations - Image Height and Widthfunction validateHeightandWidth(fieldName1, fieldDescription1 , fieldName2, fieldDescription2 ) {	errorMsg = '' ;	trim (fieldName1) ;	trim (fieldName2) ;	fieldValue1 = document.forms[0] [ fieldName1].value	fieldValue2 = document.forms[0] [ fieldName2].value	if (fieldValue1 == "" || fieldValue2 == "") {		var warn_msg2 = "";		warn_msg2   = "WARNING !!\n";		warn_msg2  += "_________________________________________________\n\n";		warn_msg2 += "You have not entered either an image width or image height.\n";		warn_msg2 += "Without these, a web page with images will not load efficiently.\n";		warn_msg2 += "Are you sure you wish to continue?\n";		warn_msg2 += "_________________________________________________\n";		if (confirm(warn_msg2) == true) {			document.forms[0] [ fieldName1].value = '' ;			document.forms[0] [ fieldName2].value = '' ;			return errorMsg ;		} else {			errorMsg = "Image " + fieldDescription1 + " or " +  fieldDescription2 + " is required" ;			return errorMsg ;		}	}	return errorMsg ;}// Field validations - HTML Color (using pattern matching)function validateHTMLColor (fieldName, fieldDescription) {	errorMsg = '' ;	var validHTMLColorRegExp = new RegExp("\\#[(0-9a-f) | ( 0-9A-F)]{6}") ;	var invalidHTMLColorRegExp1 = new RegExp("\\#[(0-9a-f) | ( 0-9A-F)]{7}") ;	var invalidHTMLColorRegExp2 = new RegExp("\\\s") ;	fieldValue = document.forms[0] [ fieldName].value;	if (fieldValue == "None") return errorMsg ;	ValidColorsTest = validHTMLColorRegExp.test(fieldValue) ;	InValidColorsTest1 = invalidHTMLColorRegExp1.test(fieldValue) ;	InValidColorsTest2 = invalidHTMLColorRegExp2.test(fieldValue) ;	if (InValidColorsTest1 == true) {		errorMsg = fieldDescription +  " must be a valid HTML color (#999999) - # & 6 chars" ;		return errorMsg ;	}	if (InValidColorsTest2 == true) {		errorMsg = fieldDescription +  " must be a valid HTML color (#999999) - no spaces" ;		return errorMsg ;	}	if (ValidColorsTest == false) {		errorMsg = fieldDescription +  " must be a valid HTML color (#999999)" ;		return errorMsg ;	}	return errorMsg ;}// Field warnings - No LINK text enteredfunction checkLinkFieldEmpty (fieldName, fieldNameDisplayed, fieldDescription) {	errorMsg = '' ;	var warn_msg1 = "";	warn_msg1 += "WARNING !!\n";	warn_msg1 += "__________________________________________\n\n";	warn_msg1 += "------   " + fieldDescription + "   ------\n";	warn_msg1 += "This is marked as visible, but no text has been entered.\n";	warn_msg1 += "Do you want to continue?\n";	warn_msg1 += "___________________________________________\n";	trim (fieldName) ;	fieldRadioOn = document.forms[0] [ fieldNameDisplayed] [0].checked;	if (fieldRadioOn == true) {				fieldValue = document.forms[0] [ fieldName].value;		fieldLength = fieldValue.length ;		GNLinkChars += parseInt(fieldLength) ;		GNBestLinkChars += parseInt(fieldLength * 8) ;		GNBestLinkChars += parseInt(20) ;		if ( fieldValue == "" || fieldValue == " ") {			if (confirm(warn_msg1) == false) {				errorMsg = fieldDescription +  " is blank but should contain text for Links" ;			}		}	}	return errorMsg ;}// Field validations - E-Mail field (using pattern matching)function validateEmailField (fieldName, fieldDescription) {	errorMsg = '' ;	emailStr = document.forms[0] [ fieldName].value;		var GNEmailPattern=/^(.+)@(.+)$/	var GNEmailSpecialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"	var GNEmailValidChars="\[^\\s" + GNEmailSpecialChars + "\]"	var GNEmailQuoteUser="(\"[^\"]*\")"	var GNEmailIPDomainPattern=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/	var GNEmailPart=GNEmailValidChars + '+'	var GNEmailWord="(" + GNEmailPart + "|" + GNEmailQuoteUser + ")"	var GNEmailUserNamePattern = new RegExp("^" + GNEmailWord + "(\\." + GNEmailWord + ")*$")	var GNEmailUserDomainPattern = new RegExp("^" + GNEmailPart + "(\\." + GNEmailPart +")*$")	// Break the Email address into two words based on the "@" sign in the middle	var GNEmailMatchArray=emailStr.match(GNEmailPattern)	if (GNEmailMatchArray == null) {		errorMsg = fieldDescription +  " requires '@' (johndoe@abc.com)" ;		return errorMsg ;	}	var GNEmailUserName=GNEmailMatchArray[1]	var GNEmailUserDomain=GNEmailMatchArray[2]	// See if  User Name  is valid 	if (GNEmailUserName.match(GNEmailUserNamePattern) == null) {		errorMsg = fieldDescription +  " invalid username ->" + GNEmailUserName ;		return errorMsg ;	}	//if the e-mail address is at an IP address, validate IP address is valid.//	var IPArray=GNEmailUserDomain.match(GNEmailIPDomainPattern)//		if (IPArray!=null) {//		// this is an IP address//			for (var i=1;i<=4;i++) {//				if (IPArray[i]>255) {//				errorMsg = fieldDescription +  " invalid Destination IP address ->" + GNEmailUserDomain ;//				return errorMsg ;//			}//		}		// return true//	}	// validate the symbolic name	var GNDomainArray=GNEmailUserDomain.match(GNEmailUserDomainPattern)	if (GNDomainArray==null) {		errorMsg = fieldDescription +  " invalid Domain name ->"  + GNEmailUserDomain ;		return errorMsg ;	}// validate that the domain name ends in a three-letter word (like com, edu, gov) or a two-letter word,	var GNDomainNamePattern=new RegExp(GNEmailPart,"g")	var GNDomainNameArray=GNEmailUserDomain.match(GNDomainNamePattern)	var len=GNDomainNameArray.length	if (GNDomainNameArray[GNDomainNameArray.length-1].length<2 || 		GNDomainNameArray[GNDomainNameArray.length-1].length>3) {		errorMsg = fieldDescription +  " address must end in a three-letter domain, or two letter country. ->" + GNDomainNameArray[GNDomainNameArray.length-1] ;		return errorMsg ;	}	// Make sure there's a host name preceding the domain.	if (len<2) {		errorMsg = fieldDescription +  " address is missing a hostname. (abc.com)" ;		return errorMsg ;	}	return errorMsg ;}function validateEmailField1 (fieldName, fieldDescription) {	errorMsg = '' ;	emailStr = document.forms[1] [ fieldName].value;		var GNEmailPattern=/^(.+)@(.+)$/	var GNEmailSpecialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"	var GNEmailValidChars="\[^\\s" + GNEmailSpecialChars + "\]"	var GNEmailQuoteUser="(\"[^\"]*\")"	var GNEmailIPDomainPattern=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/	var GNEmailPart=GNEmailValidChars + '+'	var GNEmailWord="(" + GNEmailPart + "|" + GNEmailQuoteUser + ")"	var GNEmailUserNamePattern = new RegExp("^" + GNEmailWord + "(\\." + GNEmailWord + ")*$")	var GNEmailUserDomainPattern = new RegExp("^" + GNEmailPart + "(\\." + GNEmailPart +")*$")	// Break the Email address into two words based on the "@" sign in the middle	var GNEmailMatchArray=emailStr.match(GNEmailPattern)	if (GNEmailMatchArray == null) {		errorMsg = fieldDescription +  " requires '@' (johndoe@abc.com)" ;		return errorMsg ;	}	var GNEmailUserName=GNEmailMatchArray[1]	var GNEmailUserDomain=GNEmailMatchArray[2]	// See if  User Name  is valid 	if (GNEmailUserName.match(GNEmailUserNamePattern) == null) {		errorMsg = fieldDescription +  " invalid username ->" + GNEmailUserName ;		return errorMsg ;	}	//if the e-mail address is at an IP address, validate IP address is valid.//	var IPArray=GNEmailUserDomain.match(GNEmailIPDomainPattern)//		if (IPArray!=null) {//		// this is an IP address//			for (var i=1;i<=4;i++) {//				if (IPArray[i]>255) {//				errorMsg = fieldDescription +  " invalid Destination IP address ->" + GNEmailUserDomain ;//				return errorMsg ;//			}//		}		// return true//	}	// validate the symbolic name	var GNDomainArray=GNEmailUserDomain.match(GNEmailUserDomainPattern)	if (GNDomainArray==null) {		errorMsg = fieldDescription +  " invalid Domain name ->"  + GNEmailUserDomain ;		return errorMsg ;	}// validate that the domain name ends in a three-letter word (like com, edu, gov) or a two-letter word,	var GNDomainNamePattern=new RegExp(GNEmailPart,"g")	var GNDomainNameArray=GNEmailUserDomain.match(GNDomainNamePattern)	var len=GNDomainNameArray.length	if (GNDomainNameArray[GNDomainNameArray.length-1].length<2 || 		GNDomainNameArray[GNDomainNameArray.length-1].length>3) {		errorMsg = fieldDescription +  " address must end in a three-letter domain, or two letter country. ->" + GNDomainNameArray[GNDomainNameArray.length-1] ;		return errorMsg ;	}	// Make sure there's a host name preceding the domain.	if (len<2) {		errorMsg = fieldDescription +  " address is missing a hostname. (abc.com)" ;		return errorMsg ;	}	return errorMsg ;}// Field validations - Select Box function chkSelectBox(fieldName, fieldDescription, chkWhat) {	errorMsg = '' ;	choice = document.forms[0][fieldName].selectedIndex;	textChoice = document.forms[0][fieldName].options[choice].text;	if (textChoice == chkWhat) {		errorMsg = fieldDescription +  " is required, but nothing is selected" ;	}	return errorMsg ;}function chkSelectBox1 (fieldName, fieldDescription, chkWhat) {	errorMsg = '' ;	choice = document.forms[1][fieldName].selectedIndex;	textChoice = document.forms[1][fieldName].options[choice].text;	if (textChoice == chkWhat) {		errorMsg = fieldDescription +  " is required, but nothing is selected" ;	}	return errorMsg ;}// Field validations - Check Box function chkCheckBox(fieldName, fieldDescription) {	errorMsg = '' ;	numSelected = 0 ;	if ( document.forms[0][fieldName].length ) {		numBoxes = document.forms[0][fieldName].length;		for (var i = 0; i < numBoxes; i++)  {			if ( document.forms[0][fieldName][i].checked == true ) { numSelected += 1 ; }		}	} else {		if ( document.forms[0][fieldName].checked == true ) { numSelected = 1 ; }	}	if (numSelected == 0) {		errorMsg = fieldDescription +  " is required, but nothing is checked" ;	}	return errorMsg ;}function chkCheckBox1 (fieldName, fieldDescription) {	errorMsg = '' ;	numSelected = 0 ;	if ( document.forms[1][fieldName].length ) {		numBoxes = document.forms[1][fieldName].length;		for (var i = 0; i < numBoxes; i++)  {			if ( document.forms[1][fieldName][i].checked == true ) { numSelected += 1 ; }		}	} else {		if ( document.forms[1][fieldName].checked == true ) { numSelected = 1 ; }	}	if (numSelected == 0) {		errorMsg = fieldDescription +  " is required, but nothing is checked" ;	}	return errorMsg ;}// Field validations - Radio Buttonfunction chkRadioButton(fieldName, fieldDescription) {	errorMsg = '' ;	radioChecked = false ;	numButtons = document.forms[0][fieldName].length;	for (var i = 0; i < numButtons ;  i++) {		if (document.forms[0][fieldName][i].checked == true) {			radioChecked = true;		}	}		if (radioChecked == false ) {		errorMsg = fieldDescription +  " is required, but nothing is selected" ;	}	return errorMsg ;}// make sure Public is OFF if DELETE is Yesfunction validateMarkForDelete () {	errorMsg = '' ;	publicRadio = document.forms[0].Public[0].checked;	deleteRadio = document.forms[0].DeleteDocument[0].checked;	if (publicRadio == true && deleteRadio == true ) {		errorMsg = "Mark for deletion - can't delete Public documents, set Public to No" ;	}	return errorMsg ;}// Field validations - Zip Codefunction validateZipCode (fieldName, fieldDescription) {	errorMsg = '' ;	fieldValue = document.forms[0] [ fieldName].value;	// var zipFormat = new RegExp("\^\\d{5}$") ; // this matches EXACTLY five numbers	var zipNewFormat = new RegExp("(\^\\d{5}$)|(\^\\d{5}-\\d{4}$)") ; // matches EXACTLY 12345 OR 12345-6789	var zipUKNewShortFormat = new RegExp("(\[A-Z0-9]{4}\\s\[A-Z0-9]{3}$)") ; // matches EXACTLY UK/Canadian postal code	var zipUKShortFormat = new RegExp("(\[A-Z0-9]{3}\\s\[A-Z0-9]{3}$)") ; // matches EXACTLY UK/Canadian postal code	// var zipUKFormat = new RegExp("(\\w{3}\\s\\w{3}$)") ; // matches EXACTLY UK/Canadian postal code	fiveNewZip = zipNewFormat.test(fieldValue);	UKShortZip = zipUKShortFormat.test(fieldValue);	if (fiveNewZip == false) {		if (UKShortZip == false) {			errorMsg = fieldDescription +  " must be 99999 or 99999-9999 or AAA AAA";		}	}	return errorMsg ;}function validateZipCode1 (fieldName, fieldDescription) {	errorMsg = '' ;	fieldValue = document.forms[1] [ fieldName].value;	// var zipFormat = new RegExp("\^\\d{5}$") ; // this matches EXACTLY five numbers	var zipNewFormat = new RegExp("(\^\\d{5}$)|(\^\\d{5}-\\d{4}$)") ; // matches EXACTLY 12345 OR 12345-6789	var zipUKNewShortFormat = new RegExp("(\[A-Z0-9]{4}\\s\[A-Z0-9]{3}$)") ; // matches EXACTLY UK/Canadian postal code	var zipUKShortFormat = new RegExp("(\[A-Z0-9]{3}\\s\[A-Z0-9]{3}$)") ; // matches EXACTLY UK/Canadian postal code	// var zipUKFormat = new RegExp("(\\w{3}\\s\\w{3}$)") ; // matches EXACTLY UK/Canadian postal code	fiveNewZip = zipNewFormat.test(fieldValue);	UKShortZip = zipUKShortFormat.test(fieldValue);	if (fiveNewZip == false) {		if (UKShortZip == false) {			errorMsg = fieldDescription +  " must be 99999 or 99999-9999 or AAA AAA";		}	}	return errorMsg ;}// Credit Card number Luhn checkfunction CCLuhnCheck(fieldDescription) { 	var result = true;	CCNumber = document.forms[0].CCNumber.value ;	LuhnString = CCNumber + "" ;	var sum = 0; 	var mul = 1; 	var strLen = LuhnString.length;  	for (i = 0; i < strLen; i++) {		var digit = LuhnString.substring(strLen-i-1,strLen-i);		var tproduct = parseInt(digit ,10)*mul;		if (tproduct >= 10) {			sum += (tproduct % 10) + 1;		} else {			sum += tproduct;		}		if (mul == 1) {			mul++;		} else {			mul--;		}	}	if ((sum % 10) != 0) {  result = false; }	if ( result == false ) { 		errorMsg = fieldDescription +  " are not valid" ; 	} else {		errorMsg = "" ;	}    	return errorMsg;}// ---------------------------------- validation subroutines -----------------------------function ErrorMsg() {	//  This is the object you create to keep track of errors in the document	this.aobj_Errors = new Array();		//  Creates a new array of objects	this.errors = false;			//  Indicates no errors in this document.	this.AddCategory = AddCategory;	this.AddMessage = AddMessage;	this.DisplayMessage = DisplayMessage;}function NewCategory( str_Name) {	//  Initializes the category values	this.str_Name = str_Name;	//  The name of the category	this.str_Error = "";		//  The error messages for this category}function AddCategory( str_Name ) {	// Creates a new category object at the next space in the array	this.aobj_Errors[this.aobj_Errors.length] = new NewCategory (str_Name );	this.NewCategory = NewCategory;}function AddMessage( str_Name, str_Msg ) {	//  Adds messages to the appropriate category.  We need to loop through the array until we find the	// appropriate category.	for (var i = 0; i < this.aobj_Errors.length; i++)  {		if (this.aobj_Errors[i].str_Name == str_Name) {		this.aobj_Errors[i].str_Error += "   *   " + str_Msg + "\n";	// Format the message		this.errors = true;					// Record that there is an error in this object		return true;		}	}	//  If the category can't be found return an error message	alert ("Category " + str_Name + " not found in object.  Please initialize the category using the AddCategory function.");	return false;}function DisplayMessage() {	// Displays the error messages.  	// If none, false is returned and no message is displayed.	if (this.errors == false)   return false;	else {		var str_msg = "";		str_msg   = "____________________________________________________\n\n";		str_msg += "Your document was not saved because of the error(s) listed below.\n";		str_msg += "Please correct the error(s) and re-save.\n";		str_msg += "____________________________________________________\n";		for (var i = 0; i < this.aobj_Errors.length; i++)  {	// Go through all of the objects			if (this.aobj_Errors[i].str_Error != '') {	//  If errors,  write the category title and errors			str_msg += "\n" + this.aobj_Errors[i].str_Name + "\n";			str_msg += this.aobj_Errors[i].str_Error + "\n";			}		}		alert(str_msg);	// Display the error message		return true;	}}//------------------------------------------------ General routinesfunction trim (field) {	if ( field == null ) return;	var tempString = document.forms[0] [ field ] [ "value" ];	if ( tempString == "" ) return;	var startPos = 0;	var newString = '';	var testCharPos = 0;	tempString = tempString + " ";	var tempLength = tempString.length;	var endPos = tempLength + 1;	while (startPos < endPos) {		testCharPos = tempString.indexOf(" ", startPos);		newString = tempString.substring(0,testCharPos + 1);		for (var i = testCharPos + 1; i < tempLength + 1; i++)  {			if ( tempString.charAt(i) != " " ) break;		}		newString = newString + tempString.substring(i, tempLength) + '';		tempString = newString + '';		if ( i == tempLength) break;		tempLength = tempString.length;		startPos = testCharPos + 1;		endPos = tempLength + 1;	}	tempLength = tempString.length;	if ( tempString.charAt(tempLength - 1) == " " ) {		tempString =  tempString.substring(0, tempLength - 1) + '';	}	if ( tempString.charAt(0) == " " ) {		tempString =  tempString.substring(1, tempLength) + '';	}document.forms[0] [ field ] [ "value" ] = tempString;}function removeSpaces (field) {	if ( field == null ) return;	var tempString = document.forms[0] [ field ] [ "value" ];	if ( tempString == "" ) return;	var startPos = 0;	var newString = '';	var testCharPos = 0;	tempString = tempString + " ";	var tempLength = tempString.length;	var endPos = tempLength + 1;	while (startPos < endPos) {		testCharPos = tempString.indexOf(" ", startPos);		newString = tempString.substring(0,testCharPos);		for (var i = testCharPos + 1; i < tempLength + 1; i++)  {			if ( tempString.charAt(i) != " " ) break;		}		newString = newString + tempString.substring(i, tempLength) + '';		tempString = newString + '';		if ( i == tempLength) break;		tempLength = tempString.length;		startPos = testCharPos + 1;		endPos = tempLength + 1;	}	tempLength = tempString.length;	if ( tempString.charAt(tempLength - 1) == " " ) {		tempString =  tempString.substring(0, tempLength - 1) + '';	}	if ( tempString.charAt(0) == " " ) {		tempString =  tempString.substring(1, tempLength) + '';	}document.forms[0] [ field ] [ "value" ] = tempString;}function replaceFieldSubstring(field, search, replace) {	var tempCharString = document.forms[0] [ field ].value + '';	var searchChars = search + '';	var replaceChars = replace + '';	p = 0;	while (p < tempCharString.length && (p = tempCharString.indexOf(searchChars, p)) >= 0) {		tempCharString = tempCharString.substring(0, p) + replaceChars + tempCharString.substring(p + searchChars.length, tempCharString.length);		p += replaceChars.length;	}	document.forms[0] [ field ] [ "value" ] = tempCharString;}//Returns correct year for any year after 1000function getFullYear(value) {	var y = value.getYear();	if ( y < 1000) y += 1900;	return y;}function GNChooseColor(ColorField) {	jsColorField = ColorField ;	fieldName1 = jsColorField ;	param1 = document.forms[0] [ fieldName1 ] .value ;	fullOpenCommand = GNServerPath + "/fSYSColorPicker?OpenForm&Name=" + jsColorField + "XGX" + param1 ;	composeString = replaceSubstring(fullOpenCommand, " ", "+") ;	iHeight = "370" ; 	iWidth = "400" ; 	openGNDialog(composeString, iWidth, iHeight, setColorChoices, ",scrollbars=no") ;}