var undef;var isFocusSet;var internalRules;function performCheck(J,H,D){isFocusSet=false;var I=makeRules(H);internalRules=makeRules(H);this.f=document.forms[J];if(!this.f){debug("DEBUG: could not find form object "+J);return null}var G=new Array();var C=0;if(I.length){for(var E=0;E<I.length;E++){var F=I[E];if(F!=null){highlight(getField(f,F.el),inputclassnormal)}}}else{if(I!=null){highlight(getField(f,I.el),inputclassnormal)}}if(I.length){for(var E=0;E<I.length;E++){var F=I[E];var B=null;if(F==null){}else{if(F.ruleType=="pre-condition"||F.ruleType=="post-condition"||F.ruleType=="andor-operator"){}else{if(F.ruleName=="implies"){pre=F.el;post=F.comparisonValue;var A=getField(f,I[pre].el).className;if(checkRule(f,I[pre])==null&&checkRule(f,I[post])!=null){B=deleteInline(F.alertMsg)+"__inline__"+I[post].el}else{if(checkRule(f,I[pre])!=null){getField(f,I[pre].el).className=A}}}else{B=checkRule(f,F)}}}if(B!=null){G[C]=B;C++}}}else{var K=I;err=checkRule(f,K);if(err!=null){G[0]=err}}return displayAlert(G,D)}function checkKeyPress(E,G,A){var F=null;if(getBrowser()=="msie"){F=window.event.keyCode}else{if(getBrowser()=="netscape"||getBrowser()=="firefox"){F=E.which}}var H=makeRules(A);var B=true;if(H.length){for(var D=0;D<H.length;D++){var C=H[D];if(C.ruleName=="keypress"&&C.el==G.name){B=isKeyAllowed(F,C.comparisonValue);break}}}else{var C=H;if(C.ruleName=="keypress"&&C.el==G.name){B=isKeyAllowed(F,C.comparisonValue)}}if(!B){if(getBrowser()=="msie"){window.event.keyCode=0}else{if(getBrowser()=="netscape"||getBrowser()=="firefox"){E.preventDefault();E.stopPropagation();E.returnValue=false}}}return false}function displayAlert(C,B){var A=null;clearAllInlineDivs();if(B=="classic"){A=displayClassic(C)}else{if(B=="innerHtml"){A=displayInnerHtml(C)}else{if(B=="inline"){A=displayInline(C)}else{if(B=="jsVar"){A=displayJsVar(C)}else{debug("DEBUG: alert type "+B+" not supported")}}}}return A}function displayClassic(B){var C="";if(B!=null&&B.length>0){if(strTrim(HEADER_MSG).length>0){C+=HEADER_MSG+"\n\n"}for(var A=0;A<B.length;A++){C+=" "+deleteInline(B[A])+"\n"}if(strTrim(FOOTER_MSG).length>0){C+="\n"+FOOTER_MSG}alert(C);return false}else{return true}}function displayInnerHtml(B){if(B!=null&&B.length>0){var C="";if(strTrim(HEADER_MSG).length>0){C+=HEADER_MSG}C+="<ul>";for(var A=0;A<B.length;A++){C+="<li>"+deleteInline(B[A])+"</li>"}C+="</ul>";if(strTrim(FOOTER_MSG).length>0){C+=FOOTER_MSG}document.getElementById(errorsdiv).innerHTML=C;document.getElementById(errorsdiv).className=innererror;document.getElementById(errorsdiv).style.display="block";return false}else{document.getElementById(errorsdiv).innerHTML="";document.getElementById(errorsdiv).className="";document.getElementById(errorsdiv).style.display="none";return true}}function displayInline(C){if(C!=null&&C.length>0){var A=new Array();var D=0;for(var B=0;B<C.length;B++){var E=C[B].substring(C[B].indexOf("__inline__")+10);if(document.getElementById(errorsdiv+"_"+E)){document.getElementById(errorsdiv+"_"+E).innerHTML=deleteInline(C[B]);document.getElementById(errorsdiv+"_"+E).className=innererror;document.getElementById(errorsdiv+"_"+E).style.display="block"}else{A[D]=C[B];D++}}if(D>0){displayInnerHtml(A)}return false}else{return true}}function clearAllInlineDivs(){var C=document.getElementsByTagName("div");for(var B=0;B<C.length;B++){var A=C[B].id;if(A.indexOf(errorsdiv+"_")==0){document.getElementById(A).innerHTML="";document.getElementById(A).className="";document.getElementById(A).style.display="none"}}}function displayJsVar(B){document.getElementById(errorsdiv).className="";document.getElementById(errorsdiv).style.display="none";if(B!=null&&B.length>0){for(var A=0;A<B.length;A++){B[A]=deleteInline(B[A])}var C="";C+="<script>var jsErrors;</script>";document.getElementById(errorsdiv).innerHTML=C;jsErrors=B;return false}else{document.getElementById(errorsdiv).innerHTML="<script>var jsErrors;</script>";return true}}function rule(B,D,C,A,E){if(!checkArguments(arguments)){return false}tmp=B.split(":");nameDisplayed="";if(tmp.length==2){nameDisplayed=tmp[1];B=tmp[0]}this.el=B;this.nameDisplayed=nameDisplayed;this.ruleName=D;this.comparisonValue=C;this.ruleType=E;if(A==undef||A==null){this.alertMsg=getDefaultMessage(B,nameDisplayed,D,C)+"__inline__"+this.el}else{this.alertMsg=A+"__inline__"+this.el}}function checkRule(f,a){retVal=null;if(a!=null){if(a.ruleName=="custom"){var b=" retVal = "+a.el;eval(b)}else{if(a.ruleName=="and"){var c=a.el;var d=a.comparisonValue;if(checkRule(f,internalRules[c])!=null){retVal=a.alertMsg;if(a.ruleType=="pre-condition"||a.ruleType=="andor-operator"){}}else{var e=d.split("-");for(var k=0;k<e.length;k++){if(checkRule(f,internalRules[e[k]])!=null){retVal=a.alertMsg;if(a.ruleType=="pre-condition"||a.ruleType=="andor-operator"){}break}}}}else{if(a.ruleName=="or"){var c=a.el;var d=a.comparisonValue;var g=false;if(checkRule(f,internalRules[c])==null){g=true}else{if(a.ruleType=="pre-condition"||a.ruleType=="andor-operator"){}var e=d.split("-");for(var k=0;k<e.length;k++){if(checkRule(f,internalRules[e[k]])==null){g=true;break}else{if(a.ruleType=="pre-condition"||a.ruleType=="andor-operator"){}}}}if(g){highlight(getField(f,internalRules[c].el),inputclassnormal);var e=d.split("-");for(var k=0;k<e.length;k++){highlight(getField(f,internalRules[e[k]].el),inputclassnormal)}}else{retVal=a.alertMsg}}else{el=getField(f,a.el);if(el==null){debug("DEBUG: could not find element "+a.el);return null}var h=null;if(el.type){if(el.type=="hidden"||el.type=="text"||el.type=="password"||el.type=="textarea"){h=checkText(el,a)}else{if(el.type=="checkbox"){h=checkCheckbox(el,a)}else{if(el.type=="select-one"){h=checkSelOne(el,a)}else{if(el.type=="select-multiple"){h=checkSelMul(el,a)}else{if(el.type=="radio"){h=checkRadio(el,a)}else{debug("DEBUG: type "+el.type+" not supported")}}}}}}else{h=checkRadio(el,a)}retVal=h}}}}return retVal}function checkArguments(A){if(A.length<4){debug("DEBUG: rule requires four arguments at least");return false}else{if(A[0]==null||A[1]==null){debug("DEBUG: el and ruleName are required");return false}}return true}function checkRadio(B,E){var C=null;if(E.ruleName=="required"){var F=B;var D=false;if(isNaN(F.length)&&F.checked){D=true}else{for(var A=0;A<F.length;A++){if(F[A].checked){D=true;break}}}if(!D){highlight(B,inputclasserror);C=E.alertMsg}}else{if(E.ruleName=="equal"){var F=B;var D=false;if(isNaN(F.length)&&F.checked){if(F.value==E.comparisonValue){D=true}}else{for(var A=0;A<F.length;A++){if(F[A].checked){if(F[A].value==E.comparisonValue){D=true;break}}}}if(!D){C=E.alertMsg}}else{if(E.ruleName=="notequal"){var F=B;var D=false;if(isNaN(F.length)&&F.checked){if(F.value!=E.comparisonValue){D=true}}else{for(var A=0;A<F.length;A++){if(F[A].checked){if(F[A].value!=E.comparisonValue){D=true;break}}}}if(!D){C=E.alertMsg}}else{debug("DEBUG: rule "+E.ruleName+" not supported for radio")}}}return C}function checkText(a,b){err=null;if(trimenabled){a.value=strTrim(a.value)}if(b.ruleName=="required"){if(a.value==null||a.value==""){highlight(a,inputclasserror);err=b.alertMsg}}else{if(b.ruleName=="equal"){err=checkEqual(a,b)}else{if(b.ruleName=="notequal"){err=checkNotEqual(a,b)}else{if(b.ruleName=="numeric"){reg=new RegExp("^[0-9]*$");if(!reg.test(a.value)){highlight(a,inputclasserror);err=b.alertMsg}}else{if(b.ruleName=="alphabetic"){reg=new RegExp("^[A-Za-z]*$");if(!reg.test(a.value)){highlight(a,inputclasserror);err=b.alertMsg}}else{if(b.ruleName=="alphanumeric"){reg=new RegExp("^[A-Za-z0-9]*$");if(!reg.test(a.value)){highlight(a,inputclasserror);err=b.alertMsg}}else{if(b.ruleName=="alnumhyphen"){reg=new RegExp("^[A-Za-z0-9-_]*$");if(!reg.test(a.value)){highlight(a,inputclasserror);err=b.alertMsg}}else{if(b.ruleName=="alnumhyphenat"){reg=new RegExp("^[A-Za-z0-9-_@]*$");if(!reg.test(a.value)){highlight(a,inputclasserror);err=b.alertMsg}}else{if(b.ruleName=="alphaspace"){reg=new RegExp("^[A-Za-z0-9-_ \n\r\t]*$");if(!reg.test(a.value)){highlight(a,inputclasserror);err=b.alertMsg}}else{if(b.ruleName=="email"){reg=new RegExp("^(([0-9a-zA-Z]+[-._+&])*[0-9a-zA-Z]+@([-0-9a-zA-Z]+[.])+[a-zA-Z]{2,6}){0,1}$");if(!reg.test(a.value)){highlight(a,inputclasserror);err=b.alertMsg}}else{if(b.ruleName=="maxlength"){if(isNaN(b.comparisonValue)){debug("DEBUG: comparisonValue for rule "+b.ruleName+" not a number")}else{if(a.value.length>b.comparisonValue){highlight(a,inputclasserror);err=b.alertMsg}}}else{if(b.ruleName=="minlength"){if(isNaN(b.comparisonValue)){debug("DEBUG: comparisonValue for rule "+b.ruleName+" not a number")}else{if(a.value.length<b.comparisonValue){highlight(a,inputclasserror);err=b.alertMsg}}}else{if(b.ruleName=="numrange"){reg=new RegExp("^[-+]{0,1}[0-9]*[.]{0,1}[0-9]*$");if(!reg.test(unformatNumber(a.value))){highlight(a,inputclasserror);err=b.alertMsg}else{regRange=new RegExp("^[0-9]+-[0-9]+$");if(!regRange.test(b.comparisonValue)){debug("DEBUG: comparisonValue for rule "+b.ruleName+" not in format number1-number2")}else{rangeVal=b.comparisonValue.split("-");if(eval(unformatNumber(a.value))<eval(rangeVal[0])||eval(unformatNumber(a.value))>eval(rangeVal[1])){highlight(a,inputclasserror);err=b.alertMsg}}}}else{if(b.ruleName=="regexp"){reg=new RegExp(b.comparisonValue);if(!reg.test(a.value)){highlight(a,inputclasserror);err=b.alertMsg}}else{if(b.ruleName=="integer"){err=checkInteger(a,b)}else{if(b.ruleName=="double"){err=checkDouble(a,b)}else{if(b.ruleName=="date"){err=checkDate(a,b)}else{if(b.ruleName=="date_lt"){err=checkDateLessThan(a,b,false)}else{if(b.ruleName=="date_le"){err=checkDateLessThan(a,b,true)}else{if(b.ruleName=="keypress"){}else{if(b.ruleName=="empty"){if(a.value!=null&&a.value!=""){highlight(a,inputclasserror);err=b.alertMsg}}else{debug("DEBUG: rule "+b.ruleName+" not supported for "+a.type)}}}}}}}}}}}}}}}}}}}}}return err}function checkInteger(A,B){reg=new RegExp("^[-+]{0,1}[0-9]*$");if(!reg.test(A.value)){highlight(A,inputclasserror);return B.alertMsg}}function checkDouble(B,C){var A=DECIMAL_SEP;reg=new RegExp("^[-+]{0,1}[0-9]*["+A+"]{0,1}[0-9]*$");if(!reg.test(B.value)){highlight(B,inputclasserror);return C.alertMsg}}function checkDate(B,C){error=null;if(B.value!=""){var A=DATE_FORMAT;ddReg=new RegExp("dd");MMReg=new RegExp("MM");yyyyReg=new RegExp("yyyy");if(!ddReg.test(A)||!MMReg.test(A)||!yyyyReg.test(A)){debug("DEBUG: locale format "+A+" not supported")}else{ddStart=A.indexOf("dd");MMStart=A.indexOf("MM");yyyyStart=A.indexOf("yyyy")}strReg=A.replace("dd","[0-9]{2}").replace("MM","[0-9]{2}").replace("yyyy","[0-9]{4}");reg=new RegExp("^"+strReg+"$");if(!reg.test(B.value)){highlight(B,inputclasserror);error=C.alertMsg}else{dd=B.value.substring(ddStart,ddStart+2);MM=B.value.substring(MMStart,MMStart+2);yyyy=B.value.substring(yyyyStart,yyyyStart+4);if(!checkddMMyyyy(dd,MM,yyyy)){highlight(B,inputclasserror);error=C.alertMsg}}}return error}function checkDateLessThan(E,F,C){error=null;var B=checkDate(E,F)==null?true:false;if(B&&E.value!=""){var A=DATE_FORMAT;ddStart=A.indexOf("dd");MMStart=A.indexOf("MM");yyyyStart=A.indexOf("yyyy");dd=E.value.substring(ddStart,ddStart+2);MM=E.value.substring(MMStart,MMStart+2);yyyy=E.value.substring(yyyyStart,yyyyStart+4);myDate=""+yyyy+MM+dd;strReg=A.replace("dd","[0-9]{2}").replace("MM","[0-9]{2}").replace("yyyy","[0-9]{4}");reg=new RegExp("^"+strReg+"$");var G=F.comparisonValue.indexOf("$")==0?true:false;var D="";if(G){toSplit=F.comparisonValue.substr(1);tmp=toSplit.split(":");if(tmp.length==2){D=this.getField(f,tmp[0]).value}else{D=this.getField(f,F.comparisonValue.substr(1)).value}}else{D=F.comparisonValue}if(!reg.test(D)){highlight(E,inputclasserror);error=F.alertMsg}else{cdd=D.substring(ddStart,ddStart+2);cMM=D.substring(MMStart,MMStart+2);cyyyy=D.substring(yyyyStart,yyyyStart+4);cDate=""+cyyyy+cMM+cdd;if(C){if(!checkddMMyyyy(cdd,cMM,cyyyy)||myDate>cDate){highlight(E,inputclasserror);error=F.alertMsg}}else{if(!checkddMMyyyy(cdd,cMM,cyyyy)||myDate>=cDate){highlight(E,inputclasserror);error=F.alertMsg}}}}else{if(E.value!=""){highlight(E,inputclasserror);error=F.alertMsg}}return error}function checkEqual(B,C){error=null;var D=C.comparisonValue.indexOf("$")==0?true:false;var A="";if(D){toSplit=C.comparisonValue.substr(1);tmp=toSplit.split(":");if(tmp.length==2){A=this.getField(f,tmp[0]).value}else{A=this.getField(f,C.comparisonValue.substr(1)).value}}else{A=C.comparisonValue}if(B.value!=A){highlight(B,inputclasserror);error=C.alertMsg}return error}function checkNotEqual(B,C){error=null;var D=C.comparisonValue.indexOf("$")==0?true:false;var A="";if(D){toSplit=C.comparisonValue.substr(1);tmp=toSplit.split(":");if(tmp.length==2){A=this.getField(f,tmp[0]).value}else{A=this.getField(f,C.comparisonValue.substr(1)).value}}else{A=C.comparisonValue}if(B.value==A){highlight(B,inputclasserror);error=C.alertMsg}return error}function checkddMMyyyy(A,C,B){retVal=true;if((A<1)||(A>31)||(C<1)||(C>12)||(A==31&&(C==2||C==4||C==6||C==9||C==11))||(A>29&&C==2)||(A==29&&(C==2)&&((B%4>0)||(B%4==0&&B%100==0&&B%400>0)))){retVal=false}return retVal}function checkCheckbox(A,B){if(B.ruleName=="required"){if(!A.checked){highlight(A,inputclasserror);return B.alertMsg}}else{if(B.ruleName=="equal"){if(!A.checked||A.value!=B.comparisonValue){highlight(A,inputclasserror);return B.alertMsg}}else{if(B.ruleName=="notequal"){if(!A.checked||A.value==B.comparisonValue){highlight(A,inputclasserror);return B.alertMsg}}else{debug("DEBUG: rule "+B.ruleName+" not supported for "+A.type)}}}}function checkSelOne(A,C){if(C.ruleName=="required"){var B=false;var D=A.selectedIndex;if(D>=0&&A.options[D].value){B=true}if(!B){highlight(A,inputclasserror);return C.alertMsg}}else{if(C.ruleName=="equal"){var B=false;var D=A.selectedIndex;if(D>=0&&A.options[D].value==C.comparisonValue){B=true}if(!B){highlight(A,inputclasserror);return C.alertMsg}}else{if(C.ruleName=="notequal"){var B=false;var D=A.selectedIndex;if(D>=0&&A.options[D].value!=C.comparisonValue){B=true}if(!B){highlight(A,inputclasserror);return C.alertMsg}}else{debug("DEBUG: rule "+C.ruleName+" not supported for "+A.type)}}}}function checkSelMul(B,D){if(D.ruleName=="required"){var C=false;opts=B.options;for(var A=0;A<opts.length;A++){if(opts[A].selected&&opts[A].value){C=true;break}}if(!C){highlight(B,inputclasserror);return D.alertMsg}}else{if(D.ruleName=="equal"){var C=false;opts=B.options;for(var A=0;A<opts.length;A++){if(opts[A].selected&&opts[A].value==D.comparisonValue){C=true;break}}if(!C){highlight(B,inputclasserror);return D.alertMsg}}else{if(D.ruleName=="notequal"){var C=false;opts=B.options;for(var A=0;A<opts.length;A++){if(opts[A].selected&&opts[A].value!=D.comparisonValue){C=true;break}}if(!C){highlight(B,inputclasserror);return D.alertMsg}}else{debug("DEBUG: rule "+D.ruleName+" not supported for "+B.type)}}}}function debug(A){if(debugmode){alert(A)}}function strTrim(A){return A.replace(/^\s+/,"").replace(/\s+$/,"")}function makeRules(A){var C=new Array();if(A.length){for(var B=0;B<A.length;B++){C[B]=splitRule(A[B])}}else{C[0]=splitRule(A)}return C}function splitRule(B){var A=null;if(B!=undef){params=B.split(RULE_SEP);switch(params.length){case 2:A=new rule(params[0],params[1],null,null,null);break;case 3:if(threeParamRule(params[1])){A=new rule(params[0],params[1],params[2],null,null)}else{if(params[2]=="pre-condition"||params[2]=="post-condition"||params[2]=="andor-operator"){A=new rule(params[0],params[1],null,"foo",params[2])}else{A=new rule(params[0],params[1],null,params[2],null)}}break;case 4:if(threeParamRule(params[1])&&(params[3]=="pre-condition"||params[3]=="post-condition"||params[3]=="andor-operator")){A=new rule(params[0],params[1],params[2],"foo",params[3])}else{A=new rule(params[0],params[1],params[2],params[3],null)}break;default:debug("DEBUG: wrong definition of rule")}}return A}function threeParamRule(A){return(A=="equal"||A=="notequal"||A=="minlength"||A=="maxlength"||A=="date_lt"||A=="date_le"||A=="implies"||A=="regexp"||A=="numrange"||A=="keypress"||A=="and"||A=="or")?true:false}function highlight(B,A){if(!isFocusSet&&A==inputclasserror){B.focus();isFocusSet=true}if(B!=undef&&inputhighlight){if(multipleclassname){highlightMultipleClassName(B,A)}else{B.className=A}}}function highlightMultipleClassName(B,A){re=new RegExp("(^|\\s)("+inputclassnormal+"|"+inputclasserror+")($|\\s)");B.className=strTrim(((typeof B.className!="undefined")?B.className.replace(re,""):"")+" "+A)}function getDefaultMessage(B,A,D,C){if(A.length==0){A=B}var E=DEFAULT_MSG;if(D=="required"){E=REQUIRED_MSG.replace("{1}",A)}else{if(D=="minlength"){E=MINLENGTH_MSG.replace("{1}",A).replace("{2}",C)}else{if(D=="maxlength"){E=MAXLENGTH_MSG.replace("{1}",A).replace("{2}",C)}else{if(D=="numrange"){E=NUMRANGE_MSG.replace("{1}",A).replace("{2}",C)}else{if(D=="date"){E=DATE_MSG.replace("{1}",A)}else{if(D=="numeric"){E=NUMERIC_MSG.replace("{1}",A)}else{if(D=="integer"){E=INTEGER_MSG.replace("{1}",A)}else{if(D=="double"){E=DOUBLE_MSG.replace("{1}",A)}else{if(D=="equal"){E=EQUAL_MSG.replace("{1}",A).replace("{2}",getComparisonDisplayed(C))}else{if(D=="notequal"){E=NOTEQUAL_MSG.replace("{1}",A).replace("{2}",getComparisonDisplayed(C))}else{if(D=="alphabetic"){E=ALPHABETIC_MSG.replace("{1}",A)}else{if(D=="alphanumeric"){E=ALPHANUMERIC_MSG.replace("{1}",A)}else{if(D=="alnumhyphen"){E=ALNUMHYPHEN_MSG.replace("{1}",A)}else{if(D=="alnumhyphenat"){E=ALNUMHYPHENAT_MSG.replace("{1}",A)}else{if(D=="alphaspace"){E=ALPHASPACE_MSG.replace("{1}",A)}else{if(D=="email"){E=EMAIL_MSG.replace("{1}",A)}else{if(D=="regexp"){E=REGEXP_MSG.replace("{1}",A).replace("{2}",C)}else{if(D=="date_lt"){E=DATE_LT_MSG.replace("{1}",A).replace("{2}",getComparisonDisplayed(C))}else{if(D=="date_le"){E=DATE_LE_MSG.replace("{1}",A).replace("{2}",getComparisonDisplayed(C))}else{if(D=="empty"){E=EMPTY_MSG.replace("{1}",A)}}}}}}}}}}}}}}}}}}}}return E}function getComparisonDisplayed(A){comparisonDisplayed=A;if(A.substring(0,1)=="$"){A=A.substring(1,A.length);tmp=A.split(":");if(tmp.length==2){comparisonDisplayed=tmp[1]}else{comparisonDisplayed=A}}return comparisonDisplayed}function getBrowser(){brs=navigator.userAgent.toLowerCase();var A;if(brs.search(/msie\s(\d+(\.?\d)*)/)!=-1){A="msie"}else{if(brs.search(/netscape[\/\s](\d+([\.-]\d)*)/)!=-1){A="netscape"}else{if(brs.search(/firefox[\/\s](\d+([\.-]\d)*)/)!=-1){A="firefox"}else{A="unknown"}}}return A}function isKeyAllowed(D,B){retval=false;var A;if(D==8){retval=true}else{for(var C=0;C<B.length;C++){A=B.charCodeAt(C);if(A==D){retval=true;break}}}return retval}function getField(B,C){var A=null;try{if(B.elements[C]){A=B.elements[C]}else{if(document.getElementById(C)){A=document.getElementById(C)}}}catch(e){if(document.getElementById(C)){A=document.getElementById(C)}}return A}function unformatNumber(B){var A=B.replace(THOUSAND_SEP,"");A=A.replace(DECIMAL_SEP,".");return A}function deleteInline(A){if(A.indexOf("__inline__")==-1){return A}else{return A.substring(0,A.indexOf("__inline__"))}}jQuery.fn.extend({yav:function(params,yav_config){var yavC=jQuery.extend({errorsdiv:"yavDiv",debugmode:false,DEFAULT_MSG:"",inputclassnormal:"i",inputhighlight:"h",inputclasserror:"c",trimenabled:true,RULE_SEP:"|",multipleclassname:true},yav_config);var params=jQuery.extend({errorDiv:"errorDiv",errorMessage:"ERROR, please correct",errorClass:"error",errorTag:"p",errorPosition:"before",onError:"",onOk:""},params);for(var name in yavC){window[name]=yavC[name]}var yav_defRules=new Array("alnumhyphen","alnumhyphenat","alphabetic","alphanumeric","alphaspace","date","date_le","date_lt","double","email","empty","equal","integer","keypress","maxlength","minlength","notequal","numeric","numrange","regexp","required");function setRules(o){var rules=new Array();var conds=new Array();var str_rule="";if(jQuery(o).is("form")){jQuery("input, textarea, select",o).each(function(){m=this.className.match(/\{.*\}/);if(m!=null){$(this).attr("alt",m);this.className=this.className.replace(/\{.*\}/,"")}var f_alt={};try{f_alt=eval("("+$(this).attr("alt")+")");f_alt=(typeof f_alt=="undefined")?{}:f_alt}catch(e){}var the_rule=setRules(this);for(var j=0;j<the_rule.length;j++){try{var condition=f_alt.condition;var require_condition=f_alt.require;if(typeof condition!="undefined"){if(typeof condition.name!="undefined"){condition=[condition]}var cond_index="";for(var i=0;i<condition.length;i++){if(typeof conds[condition[i].name]!="undefined"){conds[condition[i].name].indexes.push(((cond_index=="")?cond_index=rules.push(the_rule[j]):cond_index)-1);if(typeof require_condition!="undefined"&&require_condition=="post-condition"){conds[condition[i].name].postcondition=conds[condition[i].name].indexes.length-1}}else{conds[condition[i].name]={id:((typeof condition[i].id=="undefined")?this.id:condition[0].id),type:condition[i].type,msg:condition[i].msg,indexes:[((cond_index=="")?cond_index=rules.push(the_rule[j]):cond_index)-1],require:((typeof condition[i].require=="undefined")?null:condition[i].require),group:((typeof condition[i].group!="undefined")?condition[i].group:null),postcondition:((typeof require_condition!="undefined"&&require_condition=="post-condition")?0:null)}}}}else{rules.push(the_rule[j])}}catch(e){if(the_rule[j]!=null){rules.push(the_rule[j])}}}if(the_rule[0]!=null&&typeof(f_alt.event)!="undefined"){this.yavrules=the_rule;var yavhandler=function(){resetMsgs();var parent_form=$(this).parents("form");if(!performCheck(parent_form[0].id,this.yavrules,'jsVar')){showErrors(parent_form[0])}};var fieldevents=f_alt.event.replace(" ","").split(",");for(var e=0;e<fieldevents.length;e++){$(this).bind(fieldevents[e],yavhandler)}}});var conditional_rule="";for(var name in conds){if(conds.hasOwnProperty(name)&&conds[name].group==null){if(conds[name].postcondition!=null){conds[name].indexes.push(conds[name].indexes[conds[name].postcondition]);conds[name].indexes.splice(conds[name].postcondition,1)}conds[name].indexes=conds[name].indexes.reverse();conditional_rule=conds[name].indexes.pop()+"|"+conds[name].type+"|"+strParams(conds[name].indexes,"-")+"|"+((conds[name].require==null)?"{id:'"+conds[name].id+"',msg:'"+conds[name].msg+"'}":conds[name].require);conds[name].rule_index=rules.push(conditional_rule)-1}}for(var name in conds){if(conds.hasOwnProperty(name)&&conds[name].group!=null){conds[name].group=conds[name].group.reverse();conditional_rule=conds[conds[name].group.pop()].rule_index+"|"+conds[name].type+"|";for(var i=0;i<conds[name].group.length;i++){conds[name].group[i]=conds[conds[name].group[i]].rule_index}conditional_rule+=strParams(conds[name].group,"-")+"|"+((conds[name].require==null)?"{id:'"+conds[name].id+"',msg:'"+conds[name].msg+"'}":conds[name].require);rules.push(conditional_rule)}}return rules}else{var arr_rules=new Array();var num_rules=0;for(var i=0;i<yav_defRules.length;i++){if(jQuery(o).is("."+yav_defRules[i])){try{str_rule=createRule(o,yav_defRules[i],(jQuery(o).attr("title")),((typeof eval("("+jQuery(o).attr("alt")+")").params!="undefined"&&typeof eval("("+jQuery(o).attr("alt")+")").params[0]=="object")?eval("("+jQuery(o).attr("alt")+")").params[num_rules]:eval("("+jQuery(o).attr("alt")+")").params),eval("("+jQuery(o).attr("alt")+")").require)}catch(e){str_rule=createRule(o,yav_defRules[i],(jQuery(o).attr("title")))}arr_rules.push(str_rule);num_rules++}}var rulename;for(rulename in jQuery.yav_customfunctions){if(jQuery(o).is("."+rulename)){try{str_rule=createRule(o,"jQuery.yav_customfunctions."+rulename,(jQuery(o).attr("title")),((typeof eval("("+jQuery(o).attr("alt")+")").params[0]=="object")?eval("("+jQuery(o).attr("alt")+")").params[num_rules]:eval("("+jQuery(o).attr("alt")+")").params),eval("("+jQuery(o).attr("alt")+")").require)}catch(e){str_rule=createRule(o,"jQuery.yav_customfunctions."+rulename,(jQuery(o).attr("title")))}arr_rules.push(str_rule);num_rules++}}}return((arr_rules.length>0)?arr_rules:[null])}function createRule(o,rulename,text,rule_params,require){if(typeof rule_params!="undefined"&&typeof rule_params!="object"){rule_params=[rule_params]}else if(typeof rule_params=="undefined"){rule_params=[]}if(rulename.indexOf("jQuery.yav")>=0){return rulename+"({id:'"+o.id+"',msg:'"+text+"'"+((typeof(require)=="undefined")?"":",require:'"+require+"'")+"}"+((rule_params.length==0)?"":",")+strParams(rule_params,",")+")|custom"}else{return o.id+"|"+rulename+"|"+((rule_params.length>0)?(strParams(rule_params,"-")+"|"):"")+((typeof(require)=="undefined")?"{id:'"+o.id+"',msg:'"+text+"'}":require)}}function strParams(arrParam,separator){var str="";for(var i=0;i<arrParam.length;i++){str+=((separator=="-")?"":"'")+arrParam[i]+((separator=="-")?"":"'")+separator}return str.substr(0,str.length-1)}function showErrors(o){var error_is_shown=new Array();jQuery(params.errorTag+"."+params.errorClass,o).remove();jQuery("#"+params.errorDiv).html("<"+params.errorTag+" class='"+params.errorClass+"'>"+params.errorMessage+"</"+params.errorTag+">");for(var i=0;i<jsErrors.length;i++){objError=(typeof(jsErrors[i])=="object")?jsErrors[i]:eval("("+jsErrors[i]+")");if(typeof error_is_shown[objError.id]=="undefined"&&typeof objError.require=="undefined"){error_is_shown[objError.id]=1;evalText="jQuery('#"+objError.id+"')."+params.errorPosition+"(\""+"<"+params.errorTag+" class='"+params.errorClass+"'>"+objError.msg+"</"+params.errorTag+">"+"\")";eval(evalText);jQuery("#"+objError.id).addClass(inputclasserror)}}if(jQuery("#"+params.errorDiv).size()>0){jQuery("#"+params.errorDiv)[0].scrollIntoView(true)}}function resetMsgs(){jQuery("#"+yavC.errorsdiv).remove();jQuery("#"+params.errorDiv).html("");jQuery(params.errorTag+"."+params.errorClass,this).remove();jQuery("body").append("<div id='"+yavC.errorsdiv+"'></div>");jQuery("."+yavC.inputclasserror).removeClass(yavC.inputclasserror)}jQuery.yav_customfunctions=params.custom;return this.each(function(){setRules(this);jQuery(this).bind("submit",function(){resetMsgs();var formRules=setRules(this);if(formRules.length==0||performCheck(this.id,formRules,'jsVar')){return((typeof params.onOk=="function")?params.onOk(this):true)}else{showErrors(this);return((typeof params.onError=="function")?params.onError(this):false)}})})}});if(typeof(deleteInline)=="function"){jQuery.deleteInline=deleteInline;deleteInline=function(msg){if(typeof(msg)=="string"){return jQuery.deleteInline(msg)}else{return msg}}}else{function highlight(el,clazz){}}
