var _____WB$wombat$assign$function_____ = function(name) {return (self._wb_wombat && self._wb_wombat.local_init && self._wb_wombat.local_init(name)) || self[name]; }; if (!self.__WB_pmw) { self.__WB_pmw = function(obj) { this.__WB_source = obj; return this; } } { let window = _____WB$wombat$assign$function_____("window"); let self = _____WB$wombat$assign$function_____("self"); let document = _____WB$wombat$assign$function_____("document"); let location = _____WB$wombat$assign$function_____("location"); let top = _____WB$wombat$assign$function_____("top"); let parent = _____WB$wombat$assign$function_____("parent"); let frames = _____WB$wombat$assign$function_____("frames"); let opener = _____WB$wombat$assign$function_____("opener"); function validator() { this.inputName = new Array(); this.validationType = new Array(); this.validationParams = new Array(); this.formName = new Array(); this.errorMessage = new Array(); this.optionalFlag = new Array(); this.length = 0; this.emptyErrorMessage = "The required field is missing: "; this.showError = true; this.min_pass_length = 0; this.max_pass_length = 0; this.validate = validate; this.validateOne = validateOne; this.validateOneIndexed = validateOneIndexed; this.validateOneField = validateOneField; this.required = required; this.requiredEx = requiredEx; this.optional = optional; this.optionalEx = optionalEx; this.unrequired = unrequired; this.setpasswordsize = setpasswordsize; this.setvalidation = setvalidation; this.hasValue = hasValue; this.displayError = displayError; this.getIndex = getIndex; ////////////////////////////////////// // Validation Methods go here ///////////////////////////////////// // When adding new methods, be sure to the hasValue method if any "special" // handling is required (mainly if the element consists of more than one field). // this.isInputValid = isInputValid; this.isEmailValid = isEmailValid; this.isWysiwygValid = isWysiwygValid; this.isEitherValid = isEitherValid; this.isLengthValid = isLengthValid; this.isCCExpValid = isCCExpValid; this.isCCNumValid = isCCNumValid; this.isPasswordValid = isPasswordValid; this.isPhoneValid = isPhoneValid; this.isFaxValid = isPhoneValid; // Yes, this is intentional this.isZipValid = isZipValid; this.isCurrencyValid = isCurrencyValid; this.isFloatValid = isFloatValid; this.isIntegerValid = isIntegerValid; this.isUsernameValid = isUsernameValid; this.isURLValid = isURLValid; this.isEmailListValid = isEmailListValid; this.isDateValid = isDateValid; this.isTimeValid = isTimeValid; this.isMinChecked = isMinChecked; this.isFileValid = isFileValid; this.isFileExValid = isFileExValid; } function getFormObject(formNameTemp) { if(typeof formNameTemp == 'string') { formName = eval("document."+formNameTemp); }else{ formName = formNameTemp; } return formName; } function getInputObject(formNameTemp,inputNameTemp) { if ( (typeof formNameTemp == 'string') && (typeof inputNameTemp == 'string') ) { formName = eval("document."+formNameTemp); inputName = formName.elements[ inputNameTemp ]; } else if (typeof inputNameTemp == 'string') { formName = getFormObject(formNameTemp); inputName = formName[inputNameTemp]; } else { inputName = inputNameTemp; } return inputName; } function setpasswordsize( min, max ) { this.min_pass_length = min; this.max_pass_length = max; } function validateOne(validatedForm, validatedField) { var index = this.getIndex( validatedForm, validatedField ); if ( index < 0 ) { optionalFlag = true; validationType = "REGULAR"; validationParams = ''; } else { validationType = this.validationType[index]; optionalFlag = this.optionalFlag[index]; validationParams = this.validationParams[index]; } return this.validateOneField(validatedForm, validatedField, validationType, optionalFlag, false, validationParams); } function validateOneIndexed(i) { theForm = this.formName[i]; theField = this.inputName[i]; theValidation = this.validationType[i]; optionalFlag = this.optionalFlag[i]; validationParams = this.validationParams[i]; return this.validateOneField(theForm, theField, theValidation, optionalFlag, true, validationParams); } function validateOneField(theForm, theField, theValidation, optionalFlag, bMsg, theParams) { if ( optionalFlag && ! this.hasValue( theForm, theField, theValidation ) ) { return true; } if ( theValidation == null || theValidation == "REGULAR" ) { if ( ! this.isInputValid(theForm,theField,false,bMsg) ) { return false; } } else if ( theValidation == "WYSIWYG") { if ( ! this.isWysiwygValid(theForm,theField,bMsg) ) { return false; } } else if ( theValidation == "EMAIL") { if ( ! this.isEmailValid(theForm,theField,bMsg) ) { return false; } } else if ( theValidation == "CC_EXP") { if ( ! this.isCCExpValid(theForm,theField,bMsg) ) { return false; } } else if(theValidation == "CC_NUM") { if ( ! this.isCCNumValid(theForm, theField,bMsg) ) { return false; } } else if(theValidation == "EITHER") { if ( ! this.isEitherValid( theForm, theField,bMsg) ) { return false; } } else if(theValidation == "LENGTH") { if ( ! this.isLengthValid( theForm, theField,bMsg) ) { return false; } } else if(theValidation == "PASSWORD") { if ( ! this.isPasswordValid( theForm, theField, theField + "_VERIFY", bMsg) ) { return false; } } else if(theValidation == "MIN_CHECKED") { if ( ! this.isMinChecked(theForm,theField,bMsg)) { return false; } } else if ( theValidation == "FILE") { if ( ! this.isFileValid(theForm,theField,bMsg) ) { return false; } } else if ( theValidation == "FILE_EXT") { if ( ! this.isFileExValid(theForm,theField,bMsg,theParams) ) { return false; } } else if(theValidation == "ZIP") { if ( ! this.isZipValid(theForm,theField,bMsg) ) { return false; } } else if ( theValidation == "PHONE") { if ( ! this.isPhoneValid(theForm,theField,bMsg) ) { return false; } } else if ( theValidation == "CURRENCY") { if ( ! this.isCurrencyValid(theForm,theField,bMsg) ) { return false; } } else if ( theValidation == "FLOAT") { if ( ! this.isFloatValid(theForm,theField,bMsg) ) { return false; } } else if ( theValidation == "INTEGER") { if ( ! this.isIntegerValid(theForm,theField,bMsg) ) { return false; } } else if ( theValidation == "USERNAME") { if ( ! this.isUsernameValid(theForm,theField,bMsg) ) { return false; } } else if ( theValidation == "URL") { if ( ! this.isURLValid(theForm,theField,bMsg) ) { return false; } } else if ( theValidation == "EMAIL_LIST") { if ( ! this.isEmailListValid(theForm,theField,bMsg) ) { return false; } } else if ( theValidation == "DATE") { if ( ! this.isDateValid(theForm,theField,bMsg)) { return false; } } else if ( theValidation == "TIME") { if ( ! this.isTimeValid(theForm,theField,bMsg)) { return false; } } return true; } function validate(validatedForm) { for( var i = 0; i < this.length; i++ ) { if (!this.validateOneIndexed(i)) return false; } return true; } function getIndex( formName, inputName ) { for ( var i = 0; i < this.length; ++i ) { if ( this.formName[i] == formName && this.inputName[i] == inputName ) { return i; } } return -1; } function optional(formName,inputName,message,validationType) { this.setvalidation(formName, inputName, message, validationType, true, '') } function optionalEx(formName,inputName,message,validationType, Params) { this.setvalidation(formName, inputName, message, validationType, true, Params) } function required(formName, inputName, message, validationType) { this.setvalidation(formName, inputName, message, validationType, false, '') } function requiredEx(formName, inputName, message, validationType, Params) { this.setvalidation(formName, inputName, message, validationType, false, Params) } function setvalidation(formName,inputName,message,validationType,optionalFlag, Params) { var index = this.getIndex( formName, inputName ); if ( index < 0 ) { this.formName[this.length] = formName; this.inputName[this.length] = inputName; this.validationType[this.length] = validationType; this.errorMessage[this.length] = message; this.optionalFlag[this.length] = optionalFlag; this.validationParams[this.length] = Params; this.length++; } else { this.optionalFlag[ index ] = optionalFlag; this.validationType[ index ] = validationType; this.validationParams[ index ] = Params; } } function unrequired(formName,inputName,validationType) { var index = this.getIndex( formName, inputName ); if ( index >= 0 ) { this.validationType[ index ] = "NONE"; } } function hasValue( theForm, theField, theValidation ) { // Need to handle the special cases ( multiple fields ) separately if ( theValidation == "CC_EXP" ) { MonthField = getInputObject(theForm,theField + "_MONTH"); YearField = getInputObject(theForm,theField + "_YEAR"); MonthVal = getValue( MonthField ); YearVal = getValue( YearField ); return ( ! isEmpty( MonthVal ) || ! isEmpty( YearVal ) ); } else if ( theValidation == "EITHER" || theValidation == "FILE" ) { // There's nothing to do here. return true; } else if (theValidation == "FILE_EXT" ) { return ! isEmpty(getValue(getInputObject(theForm,theField + '_file' ))); } else if ( theValidation == "PASSWORD" ) { pwdField = getInputObject(theForm,theField ); verifyField = getInputObject(theForm,theField + "_VERIFY"); pwdVal = getValue( pwdField ); verifyVal = getValue( verifyField ); return ( ! isEmpty( pwdVal ) || ! isEmpty( verifyVal ) ); } else if ( theValidation == "MIN_CHECKED" ) { args = theField.replace(/ /g,"").split("&"); for ( j = 1; j < args.length; j++ ) { fieldName = args[j]; objField = getInputObject(formName,fieldName ); if ( objField.checked ) { return true; } } return false; } else if ( theValidation == "DATE" ) { MonthField = getInputObject(theForm,theField + "_MONTH"); DayField = getInputObject(theForm,theField + "_DAY"); YearField = getInputObject(theForm,theField + "_YEAR"); MonthVal = getValue( MonthField ); DayVal = getValue( DayField ); YearVal = getValue( YearField ); return ( !isEmpty( MonthVal ) || !isEmpty( DayVal ) || !isEmpty( YearVal ) ); } else if ( theValidation == "TIME" ) { HourField = getInputObject(theForm,theField + "_HOUR"); MinuteField = getInputObject(theForm,theField + "_MINUTE"); AMPMField = getInputObject(theForm,theField + "_AMPM"); HourVal = getValue( HourField ); MinuteVal = getValue( MinuteField ); AMPMVal = getValue( AMPMField ); return ( !isEmpty( HourVal ) || !isEmpty( MinuteVal ) || !isEmpty( AMPMVal ) ); } else { objField = getInputObject(theForm,theField); theVal = getValue( objField ); return ( ! isEmpty( theVal ) ); } } function displayError(formName,inputName,errorType) { if(this.showError==false) return; var index = this.getIndex( formName,inputName ); if ( index >= 0 ) { if ( this.errorMessage[ index ] != null ) { alert( this.errorMessage[index] ); return; } } if(errorType=="EMPTY") { alert(this.emptyErrorMessage+' '+inputName); } } function isInputValid(formNameTmp,inputName,suppressError,bMsg) { elementName = getInputObject(formNameTmp,inputName); if ( ! elementName ) { alert( "Error getting Element: " + inputName ); return false; } if ( (elementName.type == "text") || (elementName.type == "textarea") || (elementName.type == "hidden") || (elementName.type == "file") || elementName.type == "password" ) { if(elementName.value=='') { if ( suppressError != true ) { if (bMsg) this.displayError(formNameTmp,elementName.name,"EMPTY"); if (bMsg && elementName.type != "hidden") elementName.focus(); } return false; } } else if(elementName.type=='select-one'|| elementName.type=='select') { var index=elementName.selectedIndex; if(index==-1 || elementName.options[index].value == "") { if ( suppressError != true ) { if (bMsg) this.displayError(formNameTmp,elementName.name,"EMPTY"); if (bMsg) elementName.focus(); } return false; } } else if(elementName.type=='checkbox') { if(elementName.checked==false) { if ( suppressError != true ) { if (bMsg) this.displayError(formNameTmp,inputName,"EMPTY"); } return false; } } else if(elementName.type=='radio') { if (elementName.checked) { return true; } if ( suppressError != true ) { if (bMsg) this.displayError(formNameTmp,inputName,"EMPTY"); } return false; } else if(elementName[0].type=='radio') { var r; for ( r = 0; r < elementName.length; ++r ) { if(elementName[r].checked == true ) { return true; } } if ( suppressError != true ) { if (bMsg) this.displayError(formNameTmp,inputName,"EMPTY"); } return false; } else if ( elementName.type == null ) { radioLength=elementName.length; if ( ! (radioLength > 0 ) ) { return false; } for ( j = 0; j < radioLength; j++) { if( elementName[j].checked == true) { return true; } } if ( suppressError != true ) { if (bMsg) this.displayError(formNameTmp,inputName,"EMPTY"); } return false; } else { if(elementName.value=='') { if ( suppressError != true ) { if (bMsg) this.displayError(formNameTmp,elementName.name,"EMPTY"); if (bMsg) elementName.focus(); } return false; } } return true; } function isWysiwygValid( formName, wysiwygTemp, bMsg ) { wysiwygfield = getInputObject( formName, wysiwygTemp ); if ( isEmptyWysiwyg( wysiwygfield ) ) { if (bMsg) this.displayError(formName,wysiwygTemp,"EMPTY"); return false; } return true; } function isEmailValid( formName, emailTemp, bMsg ) { emailField = getInputObject( formName, emailTemp ); if ( ! isEmail( emailField ) ) { if (bMsg) emailField.focus(); if (bMsg) this.displayError(formName,emailTemp,"EMPTY"); return false; } return true; } function isCCNumValid( formName, fieldName, bMsg ) { cc_number = getInputObject(formName, fieldName ); if ( ! isCreditCardNumber( cc_number ) ) { if (bMsg) cc_number.focus(); if (bMsg) this.displayError(formName,fieldName,"EMPTY"); return false; } return true; } function isCCExpValid( formName, fieldName, bMsg ) { monField = getInputObject(formName, fieldName + "_MONTH" ); yearField = getInputObject(formName, fieldName + "_YEAR" ); idx = monField.selectedIndex; cc_month = monField.options[idx].value; idx = yearField.selectedIndex; cc_year = yearField.options[idx].value; if ( ! cc_year || ! cc_month ) { if (bMsg) this.displayError(formName,fieldName,"EMPTY"); return false; } thismonth = 12; thisyear = 2008; if ( cc_year > thisyear ) { return true; } else if ( cc_year < thisyear ) { if (bMsg) yearField.focus(); if (bMsg) this.displayError(formName,fieldName,"EMPTY"); return false; } if ( cc_month < thismonth ) { if (bMsg) monField.focus(); if (bMsg) this.displayError(formName,fieldName,"EMPTY"); return false; } return true; } function isEitherValid(formName,fieldnames, bMsg) { vals = fieldnames.replace(/ /g,"").split("&"); for ( j = 0; j < vals.length; j++ ) { if ( isInputValid(formName,vals[j],true,true) ) { return true; } } field1 = getInputObject(formName,vals[0]); if (bMsg) field1.focus(); if (bMsg) this.displayError(formName,fieldnames,"EMPTY"); return false; } function isLengthValid(formName,fieldname, bMsg) { params = fieldname.replace(/ /g,"").split("&"); minlength = parseInt( params[1], 10 ); maxlength = parseInt(params[2], 10 ); elementObj = getInputObject(formName,params[0]); strlength = elementObj.value.length; if ( strlength > maxlength ) { if (bMsg) elementObj.focus(); if (bMsg) this.displayError(formName,fieldname,"EMPTY"); return false; } if ( minlength > 0 && strlength < minlength ) { if (bMsg) elementObj.focus(); if (bMsg) this.displayError(formName,fieldname,"EMPTY"); return false; } return true; } function isPasswordValid( formName, pwd1Temp, pwd2Temp, bMsg ) { pwd1 = getInputObject( formName, pwd1Temp ); pwd2 = getInputObject( formName, pwd2Temp); if ( pwd1.value != pwd2.value ) { if (bMsg) pwd1.focus(); if (bMsg) alert("The password you provided does not match the confirmation password. Please try again!"); return false; } if ( this.min_pass_length > 0 ) { if(pwd1.value.length < this.min_pass_length ) { if (bMsg) pwd1.focus(); if (bMsg) alert("Passwords must be at least " + this.min_pass_length + " characters long. Please try again!"); return false; } } if ( this.max_pass_length > 0 ) { if ( pwd1.value.length > this.max_pass_length ) { if (bMsg) pwd1.focus(); if (bMsg) alert("Passwords cannot be longer than " + this.max_pass_length + " characters long. Please try again!"); return false; } } return true; } function isMinChecked( formName, orig_field_name, bMsg ) { var j; var args = orig_field_name.replace(/ /g,"").split("&"); min = args[0]; num_checked = 0; for ( j = 1; j < args.length; j++ ) { fieldName = args[j]; theField = getInputObject(formName,fieldName ); if ( theField.checked ) { num_checked++; } } if ( num_checked < min ) { if (bMsg) theField.focus(); if (bMsg) this.displayError(formName, orig_field_name ); return false; } return true; } // Requires 2 fields, a text field containing existing filename and // a file upload field, which has the same name as the text field with // "_file" appended to it function isFileValid(formName,fieldName, bMsg) { fileName_exist = getInputObject(formName,fieldName); fileName_upload = getInputObject(formName,fieldName + "_file" ); if ( fileName_exist.value == '' && fileName_upload.value == '' ) { if (bMsg) fileName_upload.focus(); if (bMsg) this.displayError(formName,fieldName,"EMPTY"); return false; } return true; } function isFileExValid(formName,fieldName, bMsg, theParams) { var ind, ext, i; var exts = theParams.split(','); fileName_exist = getInputObject(formName,fieldName); fileName_upload = getInputObject(formName,fieldName + "_file" ); if ( fileName_exist.value == '' && fileName_upload.value == '' ) { if (bMsg) fileName_upload.focus(); if (bMsg) this.displayError(formName,fieldName,"EMPTY"); return false; } if (isEmpty(fileName_upload.value) && !isEmpty(fileName_exist.value)) { return true; } ind = fileName_upload.value.lastIndexOf('.'); ext = fileName_upload.value.substring(ind+1,fileName_upload.value.length) for(i = 0; i < exts.length; i++) { if (exts[i].toLowerCase() == ext.toLowerCase()) { return true; } } if (bMsg) fileName_upload.focus(); if (bMsg) this.displayError(formName,fieldName,"EMPTY"); return false; } function isZipValid(formName,zipTemp, bMsg) { zipCode = getInputObject(formName,zipTemp); if ( ! isZip( zipCode ) ) { if (bMsg) this.displayError(formName, zipTemp ); if (bMsg) zipCode.focus(); return false; } return true; } function isPhoneValid(formName,phoneTemp, bMsg) { phoneNumber = getInputObject(formName,phoneTemp); if ( ! isPhone( phoneNumber ) ) { if (bMsg) phoneNumber.focus(); if (bMsg) this.displayError(formName, phoneTemp ); return false; } return true; } function isCurrencyValid( FormName, FieldName, bMsg ) { theField = getInputObject( FormName, FieldName ); if ( ! isCurrency( theField ) ) { if (bMsg) this.displayError(FormName, FieldName ); if (bMsg) theField.focus(); return false; } return true; } function isFloatValid( FormName, FieldName, bMsg ) { theField = getInputObject( FormName, FieldName ); if ( ! isFloat( theField ) ) { if (bMsg) this.displayError(FormName, FieldName ); if (bMsg) theField.focus(); return false; } return true; } function isIntegerValid( FormName, FieldName, bMsg ) { theField = getInputObject( FormName, FieldName ); if ( ! isInteger( theField ) ) { if (bMsg) this.displayError(FormName, FieldName ); if (bMsg) theField.focus(); return false; } return true; } function isUsernameValid( FormName, FieldName, bMsg ) { theField = getInputObject( FormName, FieldName ); if ( ! isUserName( theField ) ) { if (bMsg) this.displayError(FormName, FieldName ); if (bMsg) theField.focus(); return false; } return true; } function isURLValid( FormName, FieldName, bMsg ) { theField = getInputObject( FormName, FieldName ); if ( ! isURL( theField ) ) { if (bMsg) this.displayError(FormName, FieldName ); if (bMsg) theField.focus(); return false; } return true; } function isEmailListValid( FormName, FieldName, bMsg ) { theField = getInputObject( FormName, FieldName ); if ( ! isEmailList( theField ) ) { if (bMsg) this.displayError(FormName, FieldName ); if (bMsg) theField.focus(); return false; } return true; } function isDateValid( FormName, FieldName, bMsg ) { MonthField = getInputObject( FormName, FieldName + "_MONTH" ); DayField = getInputObject( FormName, FieldName + "_DAY" ); YearField = getInputObject( FormName, FieldName + "_YEAR" ); idx = MonthField.selectedIndex; MonthValue = MonthField.options[ idx ].value; DayValue = DayField.value; idx = YearField.selectedIndex; YearValue = YearField.options[ idx ].value; if ( ! CheckDate( MonthValue, DayValue, YearValue ) ) { if (bMsg) this.displayError(FormName, FieldName ); if (bMsg) MonthField.focus(); return false; } return true; } function isTimeValid( FormName, FieldName, bMsg ) { HourField = getInputObject( FormName, FieldName + "_HOUR" ); MinuteField = getInputObject( FormName, FieldName + "_MINUTE" ); AMPMField = getInputObject( FormName, FieldName + "_AMPM" ); HourVal = getValue( HourField ); MinuteVal = getValue( MinuteField ); AMPMVal = getValue( AMPMField ); if (isEmpty( HourVal ) || isEmpty( MinuteVal ) || isEmpty( AMPMVal )) { if (bMsg) this.displayError(FormName, FieldName ); if (bMsg) HourField.focus(); return false; } return true; } // ********************************************************************************* // // Public functions // function isCurrency(Field) { strValue = Field.value; regexp = /^(([0-9]{1,3}(\,[0-9]{3})*)|([0-9]{0,3}))(\.[0-9]{2})?$/ if (isEmpty(strValue)) { return false; } return regexp.test(strValue); } function isFloat(Field) { strValue = Field.value; regexp = /^(\+|\-)?([0-9]+)(((\.|\,)?([0-9]+))?)$/ if (isEmpty(strValue)) { return false; } return regexp.test(strValue); } function isInteger(Field) { strValue = getValue(Field); regexp = /^(\+|\-)?([0-9]+)$/ if (isEmpty(strValue)) { return false; } return regexp.test(strValue); } function isUserName(Field) { strValue = getValue(Field); regexp = /^([^\\\/ ]+)$/ if (isEmpty(strValue)) { return false; } return regexp.test(strValue); } function isCreditCardNumber(Field) { var iChkSum=0; var ccnum = getValue(Field); ccnum = ccnum.replace( /\D/g, "" ); // check for correct card number length if (ccnum.length<13) return false; // make an array and fill it with the individual digits of the cc number ccnumchk=new Array; for (iLoop=0; iLoop < ccnum.length; iLoop++) { ccnumchk[ccnum.length-1-iLoop] = ccnum.substring(iLoop, iLoop+1); } // perform the weird mathematical method (some base 10 stuff) to // convert the number to a two digit number // for those of you who aren't as familiar with the js operators // i'll comment some of the math lines...well, really just one var skemp=0; for (iLoop=0; iLoop < ccnum.length; iLoop++) { // if splits is an even number... if (iLoop %2 != 0) { ccnumchk[iLoop]=ccnumchk[iLoop]*2; if (ccnumchk[iLoop] >= 10) ccnumchk[iLoop]=ccnumchk[iLoop]-9; } // switch ccnumchk[splits] to a number ccnumchk[iLoop]++; ccnumchk[iLoop]--; iChkSum = iChkSum + ccnumchk[iLoop].valueOf(); } if (iChkSum%10 != 0) { return false; } // The result isn't base 10 return true; } function isEmail(Field) { strValue = getValue(Field); regexp = /^[A-Za-z0-9]+[A-Za-z0-9\_\-\.]*\@([A-Za-z0-9\-]+\.)+[A-Za-z]{2,5}$/ if (isEmpty(strValue)) { return false; } return regexp.test(strValue); } function isEmptyWysiwyg(Field) { strValue = getValue(Field); // delete all default tags rexp = / /gi; strValue = strValue.replace(rexp, ''); rexp = /

<\/p>/gi; strValue = strValue.replace(rexp, ''); rexp = /

 <\/p>/gi; strValue = strValue.replace(rexp, ''); if (isEmpty(strValue)) { return true; } return false; } function isURL(Field) { strValue = getValue(Field); regexp = /^http(s?):\/\/([^$@\\ ]+)$/i if (isEmpty(strValue)) { return false; } return regexp.test(strValue); } function isEmailList(Field) { strValue = getValue(Field); // delete all spaces near comma rexp = /, /gi; strValue = strValue.replace(rexp, ','); rexp = / ,/gi; strValue = strValue.replace(rexp, ','); strArray = strValue.split(","); regexp = /^[A-Za-z0-9]+[A-Za-z0-9\_\-\.]*\@([A-Za-z0-9\-]+\.)+[A-Za-z]{2,5}$/ for (var i=0; i < strArray.length; i++) { if (isEmpty(strArray[i])) return false; if (!regexp.test(strArray[i])) return false; } // set new field value (with removed spaces between comma and addresses) Field.value = strValue; return true; } function isZip(Field) { strValue = getValue(Field); if (isEmpty(strValue)) { return false; } if (strValue.indexOf('-') >=0 ) { regexp = /^\d{5}-\d{4}$/ } else { regexp = /^\d{5}$/ } bIsZip = regexp.test(strValue); if (!bIsZip ) { regexp = /^[ABCEGHJKLMNPRSTVXY]\d[A-Z] \d[A-Z]\d/ bIsZip = regexp.test(strValue); } if (!bIsZip ) { regexp = /^^1{0,1} *(-| ){0,1} *[\(]*[0-9]{0,3}[\)]* *(-| ){0,1} *[0-9]{3} *(-| ){0,1} *[0-9]{4}$/ bIsZip = regexp.test(strValue); } return bIsZip; } function isPhone(Field) { strValue = getValue(Field); regexp = /^1{0,1} *(-| ){0,1} *[\(]*[0-9]{0,3}[\)]* *(-| ){0,1} *[0-9]{3} *(-| ){0,1} *[0-9]{4}$/; if (isEmpty(strValue)) { return false; } return regexp.test(strValue); } function isFax(Field) { strValue = getValue(Field); regexp = /^\d{3}-\d{3}-\d{4}$/ if (isEmpty(strValue)) { return false; } return regexp.test(strValue); } function isEmpty(s) { if (s == null || trim(s) == '') { return true; } else { return false; } } function isText(f) { return !isEmptyField(f); } function CheckDate(m,d,y) { Months = "31/!/28/!/31/!/30/!/31/!/30/!/31/!/31/!/30/!/31/!/30/!/31"; MonthArray = Months.split("/!/"); if (isNaN(parseInt(m,10))) return false; if (isNaN(parseInt(d,10))) return false; if (isNaN(parseInt(y,10))) return false; d = parseInt(d,10); y = parseInt(y,10); m = parseInt(m,10); y = convertYear(y); if (y <= 1900 ) return false; if (m < 1 || m > 12 ) return false; if ( isLeapYear(y)) MonthArray[1] = eval(eval(MonthArray[1]) + 1); if (d<1 || MonthArray[m-1] < d ) return false; return true; } function convertYear(y) { var borderYEAR = 40; yearvalue = parseInt(y,10); if (isNaN(yearvalue)) return y; if (yearvalue - borderYEAR <= 0) { yearvalue = yearvalue + 2000 } else if (yearvalue - 100 < 0) { yearvalue = yearvalue + 1900 } return yearvalue; } function isLeapYear(Year) { if(Math.round(Year/4) == Year/4){ if(Math.round(Year/100) == Year/100){ if(Math.round(Year/400) == Year/400) return true; else return false; }else return true; } return false; } function getValue(Field) { fieldType = Field.type; if (fieldType == "text") { return getTextValue(Field); } else if (fieldType == "hidden") { return getTextValue(Field); } else if (fieldType == "select-one") { return getListValue(Field); } else if (fieldType == "textarea") { return getTextValue(Field); } else if (fieldType == "file") { return getTextValue(Field); } else if (fieldType == "password") { return getTextValue(Field); } else if (fieldType == "checkbox") { return getCheckboxValue(Field); } else if (isNaN(fieldType)) { return getRadioValue(Field); } else { return getTextValue(Field); } } function getListValue(Field) { return Field[Field.selectedIndex].value; } function getTextValue(Field) { return Field.value; } function getCheckboxValue(Field) { if (Field.checked) return Field.value; return ''; } function getRadioValue(Field) { found = false; if(isNaN(Field.length)) { return Field.value; } for(var i=0; i< Field.length; i++) { if ( Field[i].checked ) { return Field[i].value; break; } } return !found; } function trim(str) { while (str.substring(0,1) == " ") { str = str.substring(1,str.length); } while (str.substring(str.length-1,str.length) == " ") { str = str.substring(0,str.length-1); } return str; } function PutDate(iMonth, iDay, iYear, sMonthCtrlName, sDayCtrlName, sYearCtrlName) { var sMonth, sDay, sYear; var iTmp; sMonth = 'opener.' + sMonthCtrlName; sDay = 'opener.' + sDayCtrlName; sYear = 'opener.' + sYearCtrlName; iTmp = eval(sYear + '[1].value'); if (typeof(opener.document) != 'object') { window.close(); return; } if (opener.document == null) { window.close(); return; } // SET THE VALUE OF THE FIELD THAT WAS PASSED TO THE CALENDAR if (typeof(eval(sMonth)) == "object") eval(sMonth + '.selectedIndex = ' + iMonth); if (typeof(eval(sDay)) == "object") eval(sDay + '.value = ' + iDay); if (typeof(eval(sYear)) == "object") eval(sYear + '.selectedIndex = ' + (iYear-iTmp+1)); // GIVE FOCUS BACK TO THE DATE FIELD if (typeof(eval(sMonth)) == "object") eval(sMonth + '.focus()'); window.close(); } function PickDate(iMonth, iDay, iYear, sMonthCtrlName, sDayCtrlName, sYearCtrlName) { var sURL; sURL = '/includes/datepicker.asp?MONTH=' + iMonth + '&DAY=' + iDay + '&YEAR=' + iYear + '&M_NAME=' + sMonthCtrlName + '&D_NAME=' + sDayCtrlName + '&Y_NAME=' + sYearCtrlName; var newwin = window.open(sURL, 'calendar', 'TOP=150,LEFT=300,WIDTH=170,HEIGHT=220,RESIZABLE=yes,SCROLLBARS=no,STATUS=0'); if (newwin != null) { if (newwin.opener == null) newwin.opener = self; } } function isEmptyList(Field) { return isEmpty(Field[Field.selectedIndex].value); } function isEmptyText(Field) { return isEmpty(Field.value) } function isEmptyCheckbox(Field) { return !Field.checked; } function isEmptyField(Field) { fieldType = Field.type; if (fieldType == "text") { return isEmptyText(Field); } else if (fieldType == "hidden") { return isEmptyText(Field); } else if (fieldType == "file") { return isEmptyText(Field); } else if (fieldType == "select-one") { return isEmptyList(Field); } else if (fieldType == "textarea") { return isEmptyText(Field); } else if (fieldType == "password") { return isEmptyText(Field); } else if (fieldType == "checkbox") { return isEmptyCheckbox(Field) } else if (isNaN(fieldType)) { return isEmptyRadio(Field) } else { return isEmptyText(Field); } } function isDefined(obj) { if(typeof(obj) == "undefined") { return false; } else { return true; } } function isEmptyRadio(Field) { found = false; if(isNaN(Field.length)) { return !Field.checked; } for(var i=0; i< Field.length; i++) { if ( Field[i].checked ) { found = true; break; } } return !found; } function formatCurrency(num, bPrintDollarSign) { num = num.toString().replace(/\$|\,/g,''); if(isNaN(num)) num = "0"; sign = (num == (num = Math.abs(num))); num = Math.floor(num*100+0.50000000001); cents = num%100; num = Math.floor(num/100).toString(); if(cents<10) cents = "0" + cents; for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++) num = num.substring(0,num.length-(4*i+3))+','+ num.substring(num.length-(4*i+3)); if (bPrintDollarSign) { return (((sign)?'':'-') + '$' + num + '.' + cents); } else { return (((sign)?'':'-') + '' + num + '.' + cents); } } function ProgressBarStartUpload(oField) { var iProgress = 161; winstyle="height=150,width=500,status=no,toolbar=no,menubar=no,location=no"; window.open("/includes/progressbarframe.asp?PROGRESS=" + iProgress,null,winstyle); oField.value = iProgress; } oValidator = new validator(); function OpenPopup(sURL, sWindowName, iWidth,iHeight, sScrollYesNo, sResizableYesNo){ var fLeftPosition, fTopPosition; var sSettings; fLeftPosition = (screen.width) ? (screen.width-iWidth)/2 : 0; fTopPosition = (screen.height) ? (screen.height-iHeight)/2 : 0; sSettings = 'height='+ iHeight +',width='+ iWidth +',top='+ fTopPosition +',left='+ fLeftPosition +',scrollbars='+ sScrollYesNo +',resizable=' + sResizableYesNo window.open(sURL, sWindowName, sSettings) } function limit(fname, width, maxChar) { ctrl = document.getElementById(fname); x = maxChar - ctrl.value.length; if (x < 0) { ctrl.value = ctrl.value.substring(0, maxChar); x = 0; } var ta1, ta2, d; ta1 = document.getElementById(fname + 'TA1'); ta1.style.width = Math.floor(width*(maxChar-x)/maxChar) + 'px'; ta1.alt = maxChar-x+" chars used"; ta2 = document.getElementById(fname + 'TA2'); ta2.style.width = Math.floor(width*x/maxChar) + 'px'; ta2.alt = x + " chars available"; d = document.getElementById(fname + 'DIV'); d.innerHTML = x + " characters left "; window.status = ta1.width + " : " + ta2.width; } function fnFormatFileName(sFileName) { if( "string" == typeof( sFileName ) ) { sFileName = sFileName.replace( /[\W]/gi , "" ); return sFileName; } } function GetOrder(sInput) { var oUserData = document.all(sInput); if (null != oUserData && oUserData != "" && "undefined" != oUserData) { var sUserData = oUserData.getAttribute( "userdata" ); if (sUserData != null) return sUserData; else return ''; } } /* XML FUNCTIONS */ function XmlHTTP() { var obj = null; try { obj = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { try { obj = new ActiveXObject("Microsoft.XMLHTTP"); } catch(oc){ obj = null; } } if(!obj&&typeof XMLHttpRequest!= "undefined") { obj = new XMLHttpRequest(); } return obj; } function ClearDropdown(sForm, sElement) { var deleteIndex; while (document.forms['' + sForm + ''].elements['' + sElement + ''].options.length > 0) { deleteIndex=document.forms['' + sForm + ''].elements['' + sElement + ''].options.length - 1; document.forms['' + sForm + ''].elements['' + sElement + ''].options[deleteIndex] = null; } } function LoadDropdown(sForm, sElement, sData) { var myOption, iLoop, insertIndex, sPair, myOptions; myOptions = sData.split("||"); for (iLoop = 0; iLoop < myOptions.length; iLoop++) { sPair = myOptions[iLoop].split("|"); myOption=new Option(); myOption.text= sPair[1]; myOption.value= sPair[0]; if (document.forms['' + sForm + ''].elements['' + sElement + ''].selectedIndex > 0) { insertIndex = document.forms['' + sForm + ''].elements['' + sElement + ''].selectedIndex; } else { insertIndex = document.forms['' + sForm + ''].elements['' + sElement + ''].options.length; } document.forms['' + sForm + ''].elements['' + sElement + ''].options[insertIndex] = myOption; } } function SearchStoreFromAd() { if (document.getElementById('merchandise_keywords')) { var merchandise_keywords = getValue(document.getElementById('merchandise_keywords')); var store_window = window.open("http://web.archive.org/web/20081205042915/http://store.houstontexans.com/searchHandler/index.jsp?searchId=20097006291&keywords=" + merchandise_keywords); } } function resizeWindow(width, height) { window.resizeTo(width, height); } function ChangeLargerVideoLink(mm_file_id) { document.getElementById('large_video_link').href = '/VideoPlayer.asp?mm_file_id=' + mm_file_id + '&play_clip=y'; } function CancelHomepagePlayer(mm_file_id) { document.getElementById('multimedia_player').src = '/includes/iframes/multimedia_video.asp?mm_file_id=' + mm_file_id + '&is_home=y&play_clip='; } function launchCommentWindow(story_id, photo_id, mm_file_id) { url = "/comments.asp?story_id=" + story_id + "&photo_id=" + photo_id + "&mm_file_id=" + mm_file_id; var commentWindow = window.open(url,'commentWindow','width=440,height=600,scrollbars=yes,resizable=0,TOOLBAR=0,LOCATION=0,DIRECTORIES=0,STATUS=0,menubar=0'); } function GetAjaxShortDate(sForm,sFldId,sDATE_FIELD,sMonthValue,sDayValue,sYearValue,iAgeRestriction){ xml = XmlHTTP(); if(xml){ var oDiv=document.getElementById(sFldId); var dDate=new Date(); var sDateValue=''; sDateValue=sMonthValue+'/'+sDayValue+'/'+sYearValue; xml.open("GET","/includes/ajax/ajax_short_date.asp?FORM_NAME="+sForm+"&FIELD_ID="+sFldId+"&DATE_VALUE="+sDateValue+"&DATE_FIELD="+sDATE_FIELD+"&AGE_RESTRICTION="+iAgeRestriction+"&NOW="+encodeURIComponent(dDate.getTime()),false); xml.send(null); oDiv.innerHTML = xml.responseText; } } function AddMemberBookmark(page_name, page_url, story_id, mm_file_id, pg_section_id) { xml = XmlHTTP(); if (xml) { xml.open("POST","/includes/ajax/member_bookmark.asp?mode=ADD&page_name=" + page_name + "&page_url=" + page_url + "&story_id=" + story_id + "&mm_file_id=" + mm_file_id + "&pg_section_id=" + pg_section_id, true); xml.onreadystatechange = function() { if (xml.readyState == 4 && xml.responseText) { if (!xml.responseText == '') { alert(xml.responseText); } else { alert('An error occured trying to bookmark this page. Please try again later.'); } } } xml.send(""); } } function JumpToGallery(o) { if (!isEmpty(getValue(o))) { if ((getValue(o).substr(0, 1)) == 'k') { document.location = '/photos/index.asp?f_photo_search_module_process=y&f_keyword_id=' + getValue(o).substr(1); } else { document.location = '/photos/index.asp?section_id=' + getValue(o); } } } function ChooseStylesheet(o) { if (!isEmpty(getValue(o))) { document.location = '/index.asp?css=' + getValue(o); } } function navSwitch(btnName,btnSrc) { btnName.src=btnSrc; } function openBrWindow(theURL,winName,features) { window.open(theURL,winName,features); } } /* FILE ARCHIVED ON 04:29:15 Dec 05, 2008 AND RETRIEVED FROM THE INTERNET ARCHIVE ON 10:49:07 Apr 30, 2024. JAVASCRIPT APPENDED BY WAYBACK MACHINE, COPYRIGHT INTERNET ARCHIVE. ALL OTHER CONTENT MAY ALSO BE PROTECTED BY COPYRIGHT (17 U.S.C. SECTION 108(a)(3)). */ /* playback timings (ms): captures_list: 1.043 exclusion.robots: 0.122 exclusion.robots.policy: 0.108 cdx.remote: 0.094 esindex: 0.015 LoadShardBlock: 171.195 (3) PetaboxLoader3.datanode: 189.093 (4) PetaboxLoader3.resolve: 73.189 (2) load_resource: 131.276 */