// FormValidator.js - packed by http://javascriptcompressor.com if(typeof Data=="undefined")var Data={};Data.FormValidator=function(){var profile_file,profiles,defaults;this.profile_file=profile_file;this.profiles=profiles;this.defaults=defaults};Data.FormValidator.VERSION='0.06';Data.FormValidator.prototype.validate=function(frmObj,profile){var data_set=this.check(frmObj,profile);var returnVal=new Array();returnVal[0]=data_set.valid();returnVal[1]=data_set.missing();returnVal[2]=data_set.validate_invalid||new Array();returnVal[3]=data_set.unknown();return returnVal};Data.FormValidator.prototype.check=function(frmObj,profile){var defaults=new Object();defaults.profile_file=this.profile_file;defaults.profiles=this.profiles;defaults.defaults=this.defaults;var dfvc=new Data.FormValidator.check(frmObj,profile,defaults);return dfvc};Data.FormValidator.check=function(frmObj,profile,defaults){var dfv=new Data.FormValidator();this.frmObj=frmObj;if(typeof(profile)=="string"){alert("TOOD: UNSUPPORTED PROFILE TYPE 'string'");return false}else{this.profile=profile}var results=new Data.FormValidator.Results(profile,frmObj);return results};Data.FormValidator.check_and_report=function(frmObj,profile,goodColor,badColor){goodColor=goodColor||"#FFFFFF";badColor=badColor||"#FFFF99";var results=Data.FormValidator.check(frmObj,profile);results.cleanForm(frmObj,goodColor);if(!results.success()){var error_text="";var msgs=results.msgs();for(field in results.missing_required){results.changeStyle(frmObj,field,badColor);error_text+="Field ["+field+"] is required.\n"}for(field in results.missing_dependency){for(i in results.missing_dependency[field]){var dep=results.missing_dependency[field][i];results.changeStyle(frmObj,dep,badColor);error_text+="Marking field ["+field+"] requires field ["+dep+"] also be filled in.\n"}}for(group in results.missing_depgroup){var completed=results.missing_depgroup[group]['completed'];var incomplete=results.missing_depgroup[group]['incomplete'];for(i in incomplete){results.changeStyle(frmObj,incomplete[i],badColor)}error_text+="Marking field(s) ["+completed.join(', ')+"] requires field(s) ["+incomplete.join(', ')+"] also be filled in.\n"}for(field in results.invalid){results.changeStyle(frmObj,field,badColor);error_text+=(msgs[field])?"Field ["+field+"] : "+msgs[field]:"Improperly formatted data in field ["+field+"].";error_text+="\n"}alert("There is a problem with your form.\n\n"+error_text);return false}else{return true}};Data.FormValidator.prototype.load_profiles=function(){};Data.FormValidator.prototype._mergeProfiles=function(defaults,profile){};Data.FormValidator.prototype._check_profile_syntax=function(profile){};Data.FormValidator.Results=function(profile,frmObject){this.profile=profile;this.constraints=new Data.FormValidator.Constraints();this._process(profile,frmObject)};Data.FormValidator.Results.prototype.success=function(){return!(this.has_invalid()||this.has_missing())};Data.FormValidator.Results.prototype.has_missing=function(){var count=0;for(i in this.missing){count++}return count};Data.FormValidator.Results.prototype.has_invalid=function(){var count=0;for(i in this.invalid){count++}return count};Data.FormValidator.Results.prototype.has_unknown=function(){var count=0;for(i in this.unknown){count++}return count};Data.FormValidator.Results.prototype.has_missing_required=function(){var count=0;for(i in this.missing_required){count++}return count};Data.FormValidator.Results.prototype.has_missing_dependency=function(){var count=0;for(i in this.missing_dependency){count++}return count};Data.FormValidator.Results.prototype.has_missing_depgroup=function(){var count=0;for(i in this.missing_depgroup){count++}return count};Data.FormValidator.Results.prototype._process=function(profile,frmObj){this.valid=new Object();this.invalid=new Object();this.validate_invalid=new Array();this.missing=new Object();this.unknown=new Object();this.missing_required=new Object();this.missing_dependency=new Object();this.missing_depgroup=new Object();this.regexp_test=new RegExp();this.regexp_test.compile('^/(.*)/(g|i|gi|ig)?$');this.required=new Object();this.optional=new Object();if(this.isArray(profile.required)){for(i in profile.required){this.required[profile.required[i]]=1}}if(this.isArray(profile.optional)){for(i in profile.optional){this.optional[profile.optional[i]]=1}}if(this.isArray(profile.required)){for(i in profile.required){if(this.emptyField(frmObj,profile.required[i])){this.missing[profile.required[i]]=1;this.missing_required[profile.required[i]]=1}}}if((typeof(profile.dependencies)=="object")&&(!this.isArray(profile.dependencies))){for(fieldName in profile.dependencies){if(!this.emptyField(frmObj,fieldName)){if(this.isArray(profile.dependencies[fieldName])){for(i in profile.dependencies[fieldName]){var dep=profile.dependencies[fieldName][i];if(this.emptyField(frmObj,dep)){this.missing[dep]=1;if(!this.isArray(this.missing_dependency[fieldName])){this.missing_dependency[fieldName]=new Array()}this.missing_dependency[fieldName][this.missing_dependency[fieldName].length]=dep}}}}}}if((typeof(profile.dependency_groups)=="object")&&(!this.isArray(profile.dependency_groups))){for(group in profile.dependency_groups){if(this.isArray(profile.dependency_groups[group])){var require_all=false;var completed=new Array();var incomplete=new Array();for(i in profile.dependency_groups[group]){var fieldName=profile.dependency_groups[group][i];if(!this.emptyField(frmObj,fieldName)){require_all=true;completed[completed.length]=fieldName}}if(require_all){var missed_depgroup=false;for(i in profile.dependency_groups[group]){var fieldName=profile.dependency_groups[group][i];if(this.emptyField(frmObj,fieldName)){this.missing[fieldName]=1;incomplete[incomplete.length]=fieldName;missed_depgroup=true}}if(missed_depgroup){this.missing_depgroup[group]=new Object();this.missing_depgroup[group]['completed']=completed;this.missing_depgroup[group]['incomplete']=incomplete}}}}}if((typeof(profile.constraints)=="object")&&(!this.isArray(profile.constraints))){for(fieldName in profile.constraints){if((!this.required[fieldName])&&(!this.optional[fieldName])){continue}if(!this.emptyField(frmObj,fieldName)){var checks;if(this.isArray(profile.constraints[fieldName])){checks=profile.constraints[fieldName]}else if((typeof(profile.constraints[fieldName])=="object")||(typeof(profile.constraints[fieldName])=="string")){checks=new Array();checks[0]=profile.constraints[fieldName]}else{continue}for(i in checks){var check=checks[i];var c=new Object();c.name=check;c.constraint=check;if((typeof(check)=="object")&&(!this.isArray(check))){c.constraint=check.constraint_method||check.constraint;c.name=check.name;c.params=check.params;c.is_method=(check.constraint_method)?1:0}var failedTest=false;var re_parts;if(re_parts=this.regexp_test.exec(c.constraint)){var constraint=new RegExp(re_parts[1],re_parts[2]);var fieldValues=this.getField(frmObj,fieldName);for(var x=0;x=0;i--){var digit=parseInt(new_card.charAt(i),10);var product=multiplier*digit;the_sum+=(product>9)?product-9:product;multiplier=3-multiplier}the_sum%=10;if(the_sum)the_sum=10-the_sum;if(the_sum==new_card.charAt(card_length-1)){var final_re=/^([\d\s]*)$/;var re_parts;if(re_parts=final_re.exec(the_card)){return re_parts[1]}else{return false}}else{return false}};Data.FormValidator.Constraints.prototype.match_cc_exp=function(val){var matched_month;var matched_year;var re=new RegExp('^(\\d+)/(\\d+)$');var re_parts;if(re_parts=re.exec(val)){matched_month=parseInt(re_parts[1],10);matched_year=parseInt(re_parts[2],10)}else{return false}if(matched_month<1||matched_month>12)return false;if(matched_year<1900){matched_year+=(matched_year<70)?2000:1900}var now=new Date();var nowMonth=now.getMonth();var nowYear=now.getYear();if(nowYear.toString().length<4){nowYear+=1900}if((matched_year255)return false}return ip};Data.FormValidator.Results.prototype.msgs=function(controls){var profile=new Object();profile.prefix='';profile.missing='Missing';profile.invalid='Invalid';profile.invalid_separator=' ';profile.format='* %s';profile.constraints=new Object();if((typeof(this.profile.msgs)=="object")&&(!this.isArray(this.profile.msgs))){for(key in this.profile.msgs){profile[key]=this.profile.msgs[key]}}var msgs=new Object();if(this.has_invalid()){for(field in this.invalid){var invalidTests=new Array();for(i in this.invalid[field]){var invalidName=this.invalid[field][i];var err_msg=profile.constraints[invalidName]||profile.invalid;invalidTests[invalidTests.length]=err_msg}msgs[field]=invalidTests.join(profile.invalid_separator)}}if(this.has_missing()){for(field in this.missing){msgs[field]=profile.missing}}return msgs};Data.FormValidator.Results.prototype.changeStyle=function(frmObj,fieldName,badColor){var fieldList=this.getElementListByName(frmObj,fieldName);if(!this.isArray(fieldList)){return false}if(!badColor.length){badColor="#FFFF99"}for(var i=0;i0)?elList:false};Data.FormValidator.Results.prototype.isArray=function(thisObject){return this.isValidObject(thisObject)&&thisObject.constructor==Array};Data.FormValidator.Results.prototype.isValidObject=function(thisObject){if(null==thisObject){return false}else if('undefined'==typeof(thisObject)){return false}else{return true}};Data.FormValidator.Results.prototype.hasSelected=function(selectObj){var allData=new Array();if(selectObj.type.indexOf("multiple")!=-1){for(var a=0;a0){var t_index=selectObj.options.selectedIndex;var t_value=(t_index==0)?selectObj.options[t_index].value:(selectObj.options[t_index].value.length)?selectObj.options[t_index].value:selectObj.options[t_index].text;if(!this.blankText(t_value)){allData[allData.length]=t_value}}return(allData.length>0)?allData:false};Data.FormValidator.Results.prototype.hasChecked=function(checkboxObj){return this.hasRadioOrCheckbox(checkboxObj)};Data.FormValidator.Results.prototype.hasRadio=function(radioObj){return this.hasRadioOrCheckbox(radioObj)};Data.FormValidator.Results.prototype.hasRadioOrCheckbox=function(thisObj){var allData=new Array();if(thisObj.checked){allData[allData.length]=thisObj.value}return(allData.length>0)?allData:false};Data.FormValidator.Results.prototype.hasMCEText=function(mceObj){var allData=new Array();var fieldName=mceObj.name;if(typeof tinyMCE=="undefined"){var txtData=this.hasText(mceObj);if(txtData)allData=txtData}else{if((typeof tinyMCE.majorVersion=="undefined")||(typeof tinyMCE.majorVersion!="undefined"&&tinyMCE.majorVersion<2)){tinyMCE.execInstanceCommand(fieldName,'mceFocus')}allData[allData.length]=tinyMCE.getContent()}return(allData.length>0)?allData:false};Data.FormValidator.Results.prototype.hasText=function(textObj){var allData=new Array();allData[allData.length]=textObj.value;return(allData.length>0)?allData:false};Data.FormValidator.Results.prototype.blankText=function(textObj){if(textObj==null){return true}for(var i=0;i