function isDate(a){var b=DaysArray(12);var c=a.indexOf(dtCh);var d=a.indexOf(dtCh,c+1);var e=a.substring(0,c);var f=a.substring(c+1,d);var g=a.substring(d+1);strYr=g;if(f.charAt(0)=="0"&&f.length>1)f=f.substring(1);if(e.charAt(0)=="0"&&e.length>1)e=e.substring(1);for(var h=1;h<=3;h++){if(strYr.charAt(0)=="0"&&strYr.length>1)strYr=strYr.substring(1)}month=parseInt(e);day=parseInt(f);year=parseInt(strYr);if(c==-1||d==-1){alert("Please enter the date.");return"d"}else if(e.length<1||month<1||month>12){alert("Please enter a valid month");return"m"}else if(f.length<1||day<1||day>31||month==2&&day>daysInFebruary(year)||day>b[month]){alert("Please enter a valid day");return"d"}else if(g.length!=4||year==0||year<minYear||year>maxYear){alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear);return"y"}else if(a.indexOf(dtCh,d+1)!=-1||isInteger(stripCharsInBag(a,dtCh))==false){alert("Please enter a valid date");return"d"}else{return true}}function DaysArray(a){for(var b=1;b<=a;b++){this[b]=31;if(b==4||b==6||b==9||b==11){this[b]=30}if(b==2){this[b]=29}}return this}function daysInFebruary(a){return a%4==0&&(!(a%100==0)||a%400==0)?29:28}function stripCharsInBag(a,b){var c;var d="";for(c=0;c<a.length;c++){var e=a.charAt(c);if(b.indexOf(e)==-1)d+=e}return d}function isInteger(a){var b;for(b=0;b<a.length;b++){var c=a.charAt(b);if(c<"0"||c>"9")return false}return true}function rtrim(a){if(a!=""){var b,c,d,e;b=a.length;c=b;d=true;do{e=a.charAt(c-1);if(e!=" "){d=false}else{if(c==0){d=false}else{c--}}}while(d==true);if(c<b){a=a.substring(0,c)}}return a}function ltrim(a){if(a!=""){var b,c,d,e;b=a.length;c=0;d=true;do{e=a.charAt(c);if(e!=" "){d=false}else{if(c==b){d=false}else{c++}}}while(d==true);if(c>0){a=a.substring(c,b)}}return a}function stripLineFeed(a){var b=a;var c=true;if(b.length>0){while(c==true){if(b.charAt(b.length-1)=="\n"||b.charAt(b.length-1)=="\r"){b=b.substr(0,b.length-1)}else{c=false}}}return b}function trim(a){return ltrim(rtrim(stripLineFeed(a)))}function V2validateData(strValidateStr,objValue,strError){var epos=strValidateStr.search("=");var command="";var cmdvalue="";if(epos>=0){command=strValidateStr.substring(0,epos);cmdvalue=strValidateStr.substr(epos+1)}else{command=strValidateStr}var compControl2="";if(command=="compare"){var arr=strError.split("|");strError=arr[1];compControl2=arr[0]}switch(command){case"Image":case"image":{if(!IsImage(objValue)){alert(IsImage(objValue));return false}break};case"sound":case"Sound":{if(!IsSound(objValue)){return false}break};case"compare":{if(trim(objValue.value)!=document.getElementById(compControl2).value){if(!strError||strError.length==0){strError=objValue.name+" Passwords not matched!!"}document.getElementById(compControl2).focus();alert(strError);return false}break};case"req":case"required":{if(eval(trim(objValue.value).length)==0){objValue.value="";if(!strError||strError.length==0){strError=objValue.name+" : Required Field"}alert(strError);return false}break};case"maxlength":case"maxlen":{if(eval(objValue.value.length)>eval(cmdvalue)){if(!strError||strError.length==0){strError=objValue.name+" : "+cmdvalue+" characters maximum "}alert(strError+"\n[Current length = "+objValue.value.length+" ]");return false}break};case"minlength":case"minlen":{if(eval(objValue.value.length)<eval(cmdvalue)){if(!strError||strError.length==0){strError=objValue.name+" : "+cmdvalue+" characters minimum  "}alert(strError+"\n[Current length = "+objValue.value.length+" ]");return false}break};case"alnum":case"alphanumeric":{var charpos=objValue.value.search("[^A-Za-z0-9._ ]");if(objValue.value.length>0&&charpos>=0){if(!strError||strError.length==0){strError=objValue.name+": Only alpha-numeric characters allowed "}alert(strError+"\n [Error character position "+eval(charpos+1)+"]");return false}break};case"num":case"numeric":{var charpos=objValue.value.search("[^0-9.]");if(objValue.value.length>0&&charpos>=0){if(!strError||strError.length==0){strError=objValue.name+": Only digits allowed "}alert(strError+"\n [Error character position "+eval(charpos+1)+"]");return false}break};case"onlynum":case"onlynumeric":{var charpos=objValue.value.search("[^0-9]");if(objValue.value.length>0&&charpos>=0){if(!strError||strError.length==0){strError=objValue.name+": Only digits allowed "}alert(strError+"\n [Error character position "+eval(charpos+1)+"]");return false}break};case"alphabetic":case"alpha":{var charpos=objValue.value.search("[^A-Za-z ]");if(objValue.value.length>0&&charpos>=0){if(!strError||strError.length==0){strError=objValue.name+": Only alphabetic characters allowed "}alert(strError+"\n [Error character position "+eval(charpos+1)+"]");return false}break};case"alnumhyphen":{var charpos=objValue.value.search("[^A-Za-z0-9-_/ ]");if(objValue.value.length>0&&charpos>=0){if(!strError||strError.length==0){strError=objValue.name+": characters allowed are A-Z,a-z,0-9,-,,/ and _"}alert(strError+"\n [Error character position "+eval(charpos+1)+"]");return false}break};case"alnumhyphenspc":{var charpos=objValue.value.search("[^A-Z a-z 0-9-_,.&@/ ]");if(objValue.value.length>0&&charpos>=0){if(!strError||strError.length==0){strError=objValue.name+": characters allowed are A-Z,a-z,0-9,-,,/ and _"}alert(strError+"\n [Error character position "+eval(charpos+1)+"]");return false}break};case"phone":case"PHONE":{var charpos=objValue.value.search("[^0-9-+()/. ]");if(objValue.value.length>0&&charpos>=0){if(!strError||strError.length==0){strError=objValue.name+": characters allowed are 0-9,-,/,.,+,()"}alert(strError+"\n [Error character position "+eval(charpos+1)+"]");return false}break};case"email":{if(!validateEmailv2(objValue.value)){if(!strError||strError.length==0){strError=" Enter a valid Email address "}alert(strError);return false}break};case"lt":case"lessthan":{if(isNaN(objValue.value)){alert(objValue.name+": Should be a number ");return false}if(eval(objValue.value)>=eval(cmdvalue)){if(!strError||strError.length==0){strError=objValue.name+" : value should be less than "+cmdvalue}alert(strError);return false}break};case"gt":case"greaterthan":{if(isNaN(objValue.value)){alert(objValue.name+": Should be a number ");return false}if(eval(objValue.value)<=eval(cmdvalue)){if(!strError||strError.length==0){strError=objValue.name+" : value should be greater than "+cmdvalue}alert(strError);return false}break};case"notaposnumber":{if(isNaN(objValue.value)||objValue.value<0){if(!strError||strError.length==0){strError=objValue.name+": Invalid characters found "}alert(strError);return false}else return true;break};case"regexp":{alert(cmdvalue);if(objValue.value.length>0){if(!objValue.value.match(cmdvalue)){if(!strError||strError.length==0){strError=objValue.name+": Invalid characters found "}alert(strError);return false}}break};case"dontselect":{if(objValue.selectedIndex==null){alert("BUG: dontselect command for non-select Item");return false}if(objValue.selectedIndex==0){alert(strError);return false}if(objValue.value==eval(cmdvalue)){if(!strError||strError.length==0){strError=objValue.name+": Please Select one option "}alert(strError);return false}break};case"numDate":case"numericDate":{if(isDate(objValue.value)==false){return false}break};case"check2":{if(!objValue.checked){alert(strError);return false}break};case"check3":{if(!document.getElementById("radiocheck").checked){alert(strError);return false}break};case"checkOnSelect":{var arr=strError.split("|");compControl1=arr[0];compControl2=arr[1];strError=arr[2];compControl1=compControl1+".value";compControl1=eval(compControl1);if(compControl1==compControl2){if(objValue.type=="select-one"){if(objValue.selectedIndex==0||objValue.value=="0"||objValue.value==0){alert(strError);return false}if(objValue.value==eval(cmdvalue)){if(!strError||strError.length==0){strError=objValue.name+": Please Select one option "}alert(strError);return false}}if(objValue.type=="text"){if(objValue.value==""){alert(strError);return false}}if(objValue.type=="radio"){if(!document.getElementById("radiocheck").checked){alert(strError);return false}}}break};case"checkOnRadio":{var arr=strError.split("|");compControl1=arr[0];compControl2=arr[1];strError=arr[2];compControlLen=eval(compControl1+".length");for(var i=0;i<compControlLen;i++){if(eval(compControl1+"[i].checked")){var rad_val=eval(compControl1+"[i].value")}}if(rad_val==compControl2){if(objValue.type=="select-one"){if(objValue.selectedIndex==0||objValue.value=="0"||objValue.value==0){alert(strError);return false}if(objValue.value==eval(cmdvalue)){if(!strError||strError.length==0){strError=objValue.name+": Please Select one option "}alert(strError);return false}}if(objValue.type=="text"){if(objValue.value==""){alert(strError);return false}}if(objValue.type=="radio"){if(!document.getElementById("radiocheck").checked){alert(strError);return false}}}break};case"checkOndoubleSelect":{var arr=strError.split("|");compControl1=arr[0];compControl2=arr[1];compControlval1=arr[2];compControlval2=arr[3];strError=arr[4];compControl1=compControl1+".value";compControl1=eval(compControl1);compControl2=compControl2+".value";compControl2=eval(compControl2);if(compControl1==compControlval1&&compControl2==compControlval2){if(objValue.type=="select-one"){if(objValue.selectedIndex==0||objValue.value=="0"||objValue.value==0){alert(strError);return false}if(objValue.value==eval(cmdvalue)){if(!strError||strError.length==0){strError=objValue.name+": Please Select one option "}alert(strError);return false}}if(objValue.type=="text"){if(objValue.value==""){alert(strError);return false}}if(objValue.type=="radio"){if(!document.getElementById("radiocheck").checked){alert(strError);return false}}}break};case"checkOntripleSelect":{var arr=strError.split("|");compControl1=arr[0];compControl2=arr[1];compControl3=arr[2];compControlval1=arr[3];compControlval2=arr[4];compcontrolval4=arr[5];strError=arr[4];compControl1=compControl1+".value";compControl1=eval(compControl1);compControl2=compControl2+".value";compControl2=eval(compControl2);compControl3=compControl3+".value";compControl3=eval(compControl3);if(compControl1==compControlval1&&compControl2==compControlval2&&parseInt(compControl3)==compcontrolval4){if(objValue.type=="select-one"){if(objValue.selectedIndex==0||objValue.value=="0"||objValue.value==0){alert(arr[6]);return false}if(objValue.value==eval(cmdvalue)){if(!strError||strError.length==0){strError=objValue.name+": Please Select one option "}alert(strError);return false}}if(objValue.type=="text"){if(objValue.value==""){alert(arr[6]);return false}}if(objValue.type=="radio"){if(!document.getElementById("radiocheck").checked){alert(arr[6]);return false}}}break};case"checkOntripleSelectFixed":{var arr=strError.split("|");compControl1=arr[0];compControl2=arr[1];compControl3=arr[2];compControlval1=arr[3];compControlval2=arr[4];compcontrolval4=arr[5];strError=arr[4];compControl1=compControl1+".value";compControl1=eval(compControl1);compControl2=compControl2+".value";compControl2=eval(compControl2);compControl3=compControl3+".value";compControl3=eval(compControl3);if(compControl1==compControlval1&&compControl2==compControlval2&&parseInt(compControl3)>=1e4){if(objValue.type=="select-one"){if(objValue.selectedIndex==0||objValue.value=="0"||objValue.value==0){alert(arr[6]);return false}if(objValue.value==eval(cmdvalue)){if(!strError||strError.length==0){strError=objValue.name+": Please Select one option "}alert(strError);return false}}if(objValue.type=="text"){if(objValue.value==""){alert(arr[6]);return false}}if(objValue.type=="radio"){if(!document.getElementById("radiocheck").checked){alert(arr[6]);return false}}}break};case"check_date":{var field_date=document.frmShortForm.dob.value;var field_mon=document.frmShortForm.mob.value;var field_year=document.frmShortForm.yob.value;var dateofbirth=field_mon+"/"+field_date+"/"+field_year;if(field_year!=""&&field_mon!=""&&field_date!=""){a=isDate(dateofbirth);if(a=="d"){document.frmShortForm.dob.focus();return false}else if(a=="m"){document.frmShortForm.mob.focus();return false}else if(a=="y"){document.frmShortForm.yob.focus();return false}}break};case"check_date1":{var field_date=document.frmShortForm.x_C1DOB_day.value;var field_mon=document.frmShortForm.x_C1DOB_month.value;var field_year=document.frmShortForm.x_C1DOB_year.value;var dateofbirth=field_mon+"/"+field_date+"/"+field_year;if(field_year!=""&&field_mon!=""&&field_date!=""){a=isDate(dateofbirth);if(a=="d"){document.frmShortForm.x_C1DOB_day.focus();return false}else if(a=="m"){document.frmShortForm.x_C1DOB_month.focus();return false}else if(a=="y"){document.frmShortForm.x_C1DOB_year.focus();return false}}break};case"check_date2":{var field_date=document.frmShortForm.x_C2DOB_day.value;var field_mon=document.frmShortForm.x_C2DOB_month.value;var field_year=document.frmShortForm.x_C2DOB_year.value;var dateofbirth=field_mon+"/"+field_date+"/"+field_year;if(field_year!=""&&field_mon!=""&&field_date!=""){a=isDate(dateofbirth);if(a=="d"){document.frmShortForm.x_C2DOB_day.focus();return false}else if(a=="m"){document.frmShortForm.x_C2DOB_month.focus();return false}else if(a=="y"){document.frmShortForm.x_C2DOB_year.focus();return false}}break};case"ukphone":{var telnum=objValue.value+" ";if(telnum.length==1){alert(strError+" not provided.");return false}telnum.length=telnum.length-1;var exp=/^(\+)[\s]*(.*)$/;if(exp.test(telnum)==true){alert(strError+" without the country code, please.");return false}while(telnum.indexOf(" ")!=-1){telnum=telnum.slice(0,telnum.indexOf(" "))+telnum.slice(telnum.indexOf(" ")+1)}while(telnum.indexOf("-")!=-1){telnum=telnum.slice(0,telnum.indexOf("-"))+telnum.slice(telnum.indexOf("-")+1)}exp=/^[0-9]{10,11}$/;if(exp.test(telnum)!=true){alert(strError+" should contain 10 or 11 digits.");return false}exp=/^0[0-9]{9,10}$/;if(exp.test(telnum)!=true){alert(strError+" should start with a 0.");return false}exp=/^(01|02|03|05|070|071|072|073|074|075|07624|077|078|079)[0-9]+$/;if(exp.test(telnum)!=true){alert(strError+" is either invalid or inappropriate.");return false}objValue.value=telnum}}return true}function selectOnValue(a,b){var c=trim(a.value);var b=trim(b);if(c==b){alert(c+" = "+b);return true}else{alert(c+" = "+b);return false}}function IsSound(a){var b=trim(a.value);if(b.length>0){b=b.substring(b.length-3,b.length);b=b.toLowerCase();if(b!="MP3"&&b!="mp3"){alert("You selected a ."+b+" file; please select a MP3 file instead!");return false}else return true}return true}function IsImage(a){var b=trim(a.value);if(b.length>0){b=b.substring(b.length-3,b.length);b=b.toLowerCase();if(b!="jpg"&&b!="gif"&&b!="bmp"&&b!="jpeg"){alert("You selected a ."+b+" file; please select a image file instead!");return false}else return true}return true}function validateEmailv2(a){if(a.length<=0){return true}var b=a.match("^(.+)@(.+)$");if(b==null)return false;if(b[1]!=null){var c=/^\"?[\w-_\.]*\"?$/;if(b[1].match(c)==null)return false}if(b[2]!=null){var d=/^[\w-\.]*\.[A-Za-z]{2,4}$/;if(b[2].match(d)==null){var e=/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/;if(b[2].match(e)==null)return false}return true}return false}function vset_validate(){for(var a=0;a<this.vSet.length;a++){if(!this.vSet[a].validate()){return false}}return true}function add_validationdesc(a,b){this.vSet[this.vSet.length]=new ValidationDesc(this.itemobj,a,b)}function ValidationSet(a){this.vSet=new Array;this.add=add_validationdesc;this.validate=vset_validate;this.itemobj=a}function vdesc_validate(){if(!V2validateData(this.desc,this.itemobj,this.error)){if(!this.itemobj.disabled){try{this.itemobj.focus()}catch(a){}}return false}return true}function ValidationDesc(a,b,c){this.desc=b;this.error=c;this.itemobj=a;this.validate=vdesc_validate}function add_validation(a,b,c){if(!this.formobj){alert("BUG: the form object is not set properly");return}var d=this.formobj[a];if(!d)d=document.getElementById(a);if(!d){alert("BUG: Couldnot get the input object named: "+a);return}if(b=="compare"){var e=c.split("|");compControl2=e[0];var f=this.formobj[compControl2];if(!f)f=document.getElementById(compControl2);if(!f){alert("BUG: Couldnot get the input object named: "+compControl2);return}}if(!d.validationset){d.validationset=new ValidationSet(d)}d.validationset.add(b,c)}function form_submit_handler(){if(eval(otherValidation)==false){return false}for(var itr=0;itr<this.form.elements.length;itr++){if(this.form.elements[itr].validationset&&!this.form.elements[itr].validationset.validate()){return false}}if(this.form.addnlvalidation){str=" var ret = "+this.form.addnlvalidation+"()";eval(str);if(!ret)return ret}return true}function clear_all_validations(){for(var a=0;a<this.formobj.elements.length;a++){this.formobj.elements[a].validationset=null}}function set_addnl_vfunction(a){this.formobj.addnlvalidation=a}function Validator(a,b,c){otherValidation=c;this.formobj=document.forms[a];if(!this.formobj){alert("BUG: couldnot get Form object "+a);return}this.btnobj=this.formobj[b];if(!this.btnobj)this.btnobj=document.getElementById(b);if(!this.btnobj){alert("BUG: couldnot get object "+b);return}if(this.formobj.onsubmit){this.formobj.old_onsubmit=this.formobj.onsubmit;this.formobj.onsubmit=null}else{this.formobj.old_onsubmit=null}this.btnobj.onclick=form_submit_handler;this.addValidation=add_validation;this.setAddnlValidationFunction=set_addnl_vfunction;this.clearAllValidations=clear_all_validations}var dtCh="/";var minYear=1900;var maxYear=2100;var otherValidation
