<!--// 
//################################################################################
//##              -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =-                 #
//## --------------------------------------------------------------------------- #
//##  JS Auto Form Validator version 3.1.7 (12.12.2010)                          #
//##  Developed by:  ApPhp <info@apphp.com>                                      #
//##  License:       GNU LGPL v.3                                                #
//##  Site:          http://www.apphp.com/js-fvVocabulary/                       #
//##  Copyright:     JS Auto Form Validator (c) 2006-2010. All rights reserved.  #
//##                                                                             #
//################################################################################
//
// Supported languages:
//     en - English, es - Espanol, fr - Francais, ja - Japanese, de - German
//
// Usage:
// -----
// *** copy & paste these lines between <head> and </head> tags
// <script type='text/javascript' src='lang/jsafv-en.js'></script>";
// <script type='text/javascript' src='chars/diactric_chars_utf8.js'></script>";
// <script type='text/javascript' src='form.scripts.js'></script>
// <script type='text/javascript'>
//	  var jsFormValidator = new FormValidator();        // create new instance of object
//    jsFormValidator.setOutputAlert("popup");          // optional - "popup" or "div"
//    jsFormValidator.setOutputContainer("divErrors");  // optional - ID of error <DIV> container
// </script>
//
// *** copy & paste these lines before your </form> tag
// <!--
//  first parameter  (required) - form name
//  second parameter (optional, default - false) - handle all fields or handle each field separately
//  third parameter  (optional, default - false) - handle hidden fields or not
//  fourth parameter (optional, default - ".") - decimal point delimiter
// -->
// <input type="submit"
//        name="button"
//        value="Submit"
//        onClick="return jsFormValidator.onSubmitCheck(document.forms['form_name'], false, false, '.');"> 
//
////////////////////////////////////////////////////////////////////////////////

FormValidator = function(){

    /******************************************************************************
     * CLASS PROPERTIES
     *****************************************************************************/
    this.digits="0123456789";
    this.digits1="0123456789.";
    this.digits2="0123456789,";
    this.digits3="0123456789.,";
    this.textchars="/'\"[]{}()*&^%$#@!~?<>-_+=|\\ \r\t\n.,:;`";
    this.lwr="abcdefghijklmnopqrstuvwxyz";
    this.upr="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    this.loginchars="_";
    
    // r - required, s - simple
    this.rtypes="rs";
    // n - numeric,     i - integer,      f - float,
    // a - alphabetic,  t - text,         e - email,
    // p - password,    l - login,        y - any (generally used for non-english symbols and text),       
    // z - zipcode,     v - verified,     c - checked (for checkboxes),
    // u - url,         s - SSN number,   m - telephone
    // x - template     b - alphanumeric, r - checked (for radiobuttons) 
    // (for example - name="rxTemplate1" template="(ddd)-ddd-dd-dd", where d - digit, c - character)
    // (for example - name="rtUsername" minlength="5", where minlength - minimum length of entered text)
    this.vtypes="nifabtepylzvcusmxr";
    // for numbers:   s - signed, u - unsigned,   p - positive,   n - negative
    // for strings:   u - upper,  l - lower,      n - normal,     y - any
    // for telephone: m - mobile, f - fixed (stationary), i - international, y - any
    this.svtypes="supnlymfi";
    
    this.vForm = "";    
    function makeArray(n){for(var i=1; i<=n;i++){this[i]=0;}return this;};
    this.dInM=makeArray(12);this.dInM[1]=31;this.dInM[2]=29;this.dInM[3]=31;this.dInM[4]=30;this.dInM[5]=31;this.dInM[6]=30;this.dInM[7]=31;this.dInM[8]=31;this.dInM[9]=30;this.dInM[10]=31;this.dInM[11]=30;this.dInM[12]=31;
    this.PassLength=6;
    this.LoginLength=6;
    
    this.bgcolor_error = "#FFFFd7"; // old "#ff8822";
    this.bgcolor_normal_1 = "#ffffff";
    this.bgcolor_normal_2 = "#fcfaf6";
    
    this.whitespace=" \t\n\r";                     
    this.decimalPointDelimiter=".";                  
    this.phoneNumberDelimiters="()- ";  
    this.validPhoneChars=this.digits + this.phoneNumberDelimiters;
    this.validWorldPhoneChars=this.digits + this.phoneNumberDelimiters + "+";
    
    this.digitsInSocialSecurityNumber=9;
    this.digitsInPhoneNumber=12;
    this.digitsInMinPhoneNumber=5;
    this.digitsInZIPCode1=5;
    this.digitsInZIPCode2=9;
    this.ZIPCodeDelimiters="-";
    this.validZIPCodeChars=this.digits + this.ZIPCodeDelimiters;
    this.creditCardDelimiters=" ";
    this.DEOK=false;
    this.alertOutputType="div"; // popup|div
    this.alertOutputId="";
    this.msgPrefix = "&#8226; ";
    
    /******************************************************************************
     * CLASS METHODS
     *****************************************************************************/
    this.isEmpty = function(s){return((s==null)||(s.length==0))};
    this.isShorter = function(str_text, str_length){s_length=(str_length==null) ? "1" : str_length;if(str_text.length < s_length) return true;else return false;};
    this.isValid = function(parm,val){if(parm=="")return true;for(i=0;i<parm.length;i++){if(val.indexOf(parm.charAt(i),0)==-1)return false;}return true;};
    this.isLower = function(parm){return this.isValid(parm,this.lwr + this.textchars + this.digits);};
    this.isSubmitReqType = function(parm){return this.isLower(parm) && this.isValid(parm,this.rtypes);};
    this.isSubmitVarType = function(parm){return this.isLower(parm) && this.isValid(parm,this.vtypes);};
    this.isSubmitSubVarType = function(parm){return this.isLower(parm) && this.isValid(parm,this.svtypes);};
    this.isNumeric = function(parm,type){ptype=(type==null)?"0":type; pdigits=-1;switch(ptype){case 0:pdigits=this.digits;break;case1:pdigits=this.digits1;break;case 2:pdigits=this.digits2;break;case 3:pdigits=this.digits3;break;default:pdigits=this.digits;break;}return this.isValid(parm,pdigits);};
    this.isUpper = function(parm){return this.isValid(parm,this.upr + this.textchars + this.digits);};
    this.isAlpha = function(parm){return this.isValid(parm,this.lwr + this.upr);};
    this.isDigit = function(c){return ((c>="0")&&(c<="9"))};
    this.isLetterOrDigit = function(c){return (this.isLetter(c) || this.isDigit(c))};

    this.isText = function(parm){return this.isValid(parm,this.lwr + this.upr + this.digits3 + this.textchars + diac_lwr + diac_upr);};
    this.isAny = function(parm){return true;};
    this.isLetter = function(c){return (((c>="a")&&(c<="z"))||((c>="A")&&(c<="Z")))};
    
    // integer checking
    this.isInteger = function(s){ i; if(this.isEmpty(s)) if(this.isInteger.arguments.length==1) return this.DEOK; else return (this.isInteger.arguments[1]==true); for(i=0;i< s.length;i++){ c=s.charAt(i); if(!this.isDigit(c)) return false; } return true;};
    this.isSignedInteger = function(s){ if(this.isEmpty(s)){ if(this.isSignedInteger.arguments.length==1) return this.DEOK; else return (this.isSignedInteger.arguments[1]==true); }else{ startPos=0; secondArg=this.DEOK; if(this.isSignedInteger.arguments.length>1) secondArg=this.isSignedInteger.arguments[1]; if((s.charAt(0)=="-") || (s.charAt(0)=="+")) startPos=1; return (this.isInteger(s.substring(startPos,s.length),secondArg));}};
    this.isPositiveInteger = function(s){secondArg=this.DEOK;if(this.isPositiveInteger.arguments.length > 1) secondArg=this.isPositiveInteger.arguments[1];return (this.isSignedInteger(s,secondArg) && ((this.isEmpty(s) && secondArg) || (parseInt(s) > 0)));};
    this.isNegativeInteger = function(s){secondArg=this.DEOK;if(this.isNegativeInteger.arguments.length > 1) secondArg=this.isNegativeInteger.arguments[1]; return (this.isSignedInteger(s,secondArg) && ((this.isEmpty(s) && secondArg) || (parseInt(s) < 0)));};
    this.isIntegerInRange = function(s,a,b){if(this.isEmpty(s))if(this.isIntegerInRange.arguments.length==1) return this.DEOK;else return (this.isIntegerInRange.arguments[1]==true);if(!this.isInteger(s, false)) return false;num=parseInt(s);return ((num >=a) && (num <=b));};

    // float checking
    this.isFloat = function(s){i=0; seenDecimalPoint=false; if(this.isEmpty(s)){ if (this.isFloat.arguments.length==1) return this.DEOK; else return (this.isFloat.arguments[1]==true); } if(s==this.decimalPointDelimiter) return false; for(i=0; i < s.length; i++){ c=s.charAt(i); if((c==this.decimalPointDelimiter) && !seenDecimalPoint) seenDecimalPoint=true; else if(!this.isDigit(c)) return false; } return true;};
    this.isSignedFloat = function(s){if(this.isEmpty(s)) if(this.isSignedFloat.arguments.length==1) return this.DEOK; else return (this.isSignedFloat.arguments[1]==true); else{ startPos=0;secondArg=!this.DEOK; if(this.isSignedFloat.arguments.length > 1) secondArg=this.isSignedFloat.arguments[1]; if((s.charAt(0)=="-") || (s.charAt(0)=="+")) startPos=1; return (this.isFloat(s.substring(startPos, s.length), secondArg))}};
    this.isPositiveFloat = function(s){secondArg=this.DEOK;if(this.isPositiveFloat.arguments.length > 1) secondArg=this.isPositiveFloat.arguments[1];return (this.isSignedFloat(s,secondArg) && ((this.isEmpty(s) && secondArg) || (parseInt(s) > 0)));};
    this.isNegativeFloat = function(s){secondArg=this.DEOK;if(this.isNegativeFloat.arguments.length > 1) secondArg=this.isNegativeFloat.arguments[1];return (this.isSignedFloat(s,secondArg) && ((this.isEmpty(s) && secondArg) || (parseInt(s) < 0)));};
    
    this.isAlphabetic = function(s){i=0;if(this.isEmpty(s))if(this.isAlphabetic.arguments.length==1) return this.DEOK;else return (this.isAlphabetic.arguments[1]==true);for(i=0;i<s.length;i++){c=s.charAt(i);if(!this.isLetter(c)) return false;}return true;};
    this.isAlphanumeric = function(s){i=0; if(this.isEmpty(s)) if(this.isAlphanumeric.arguments.length==1) return this.DEOK; else return (this.isAlphanumeric.arguments[1]==true);for(i=0;i<s.length;i++){c=s.charAt(i);if(!this.isLetter(c) && !this.isDigit(c)) return false;}return true;};
    this.isZipCode = function(s){return (!this.isShorter(s,this.digitsInZIPCode1) && this.isValid(s,this.validZIPCodeChars));};
    this.isEmail = function(s){ if(this.isEmpty(s)) if(this.isEmail.arguments.length==1) return this.DEOK; else return(this.isEmail.arguments[1]==true); regexp = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/; if(regexp.test(s)){ return true; }else{ return false; } };
    this.isPassword = function(s){return !this.isShorter(s,this.PassLength) && this.isValid(s,this.lwr+this.upr + this.digits + this.textchars);};;
    this.isLogin = function(s){return (!this.isShorter(s,this.LoginLength) && this.isValid(s.charAt(0),this.lwr + this.upr) && this.isValid(s,this.lwr + this.upr + this.digits + this.loginchars));};;
    
    // phones checking
    this.isPhoneNumber = function(s){ return (this.isValid(s,this.validPhoneChars) && (s.length >= this.digitsInMinPhoneNumber && s.length <= this.digitsInPhoneNumber));};
    this.isMobPhoneNumber = function(s){ return (this.isValid(s,this.validPhoneChars) && (s.length >= this.digitsInMinPhoneNumber && s.length <= this.digitsInPhoneNumber));};
    this.isFixPhoneNumber = function(s){ return (this.isInteger(s) && (s.length >= this.digitsInMinPhoneNumber && s.length <= this.digitsInPhoneNumber));};
    this.isInternationalPhoneNumber = function(s){ return (this.isPositiveInteger(s));};

    // datetime checking    
    this.isYear = function(s){if(this.isEmpty(s))if(this.isYear.arguments.length==1)return this.DEOK; else return (this.isYear.arguments[1]==true); if (!isNonnegativeInteger(s)) return false; return (s.length==4);};
    this.isMonth = function(s){if(this.isEmpty(s))if(this.isMonth.arguments.length==1)return this.DEOK;else return (this.isMonth.arguments[1]==true);return this.isIntegerInRange(s,1,12);};
    this.isDay = function(s){if(this.isEmpty(s))if(this.isDay.arguments.length==1)return this.DEOK;else return (this.isDay.arguments[1]==true);return this.isIntegerInRange(s, 1, 31);};
    this.daysInFebruary = function(year){return(((year % 4==0) && ((!(year % 100==0)) || (year % 400==0) ) ) ? 29 : 28 );};
    this.isDate = function(year,month,day){if(!(this.isYear(year,false) && this.isMonth(month, false) && this.isDay(day, false))) return false; intYear=parseInt(year); intMonth=parseInt(month); intDay=parseInt(day); if (intDay > this.dInM[intMonth]) return false; if ((intMonth==2) && (intDay > this.daysInFebruary(intYear))) return false; return true;};
    
    this.isChecked = function(frm,ind){ return frm.elements[ind].checked;};
    this.isURL = function(url){ regexp = /^(([\w]+:)?\/\/)?(([\d\w]|%[a-fA-f\d]{2,2})+(:([\d\w]|%[a-fA-f\d]{2,2})+)?@)?([\d\w][-\d\w]{0,253}[\d\w]\.)+[\w]{2,4}(:[\d]+)?(\/([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)*(\?(&?([-+_~.\d\w]|%[a-fA-f\d]{2,2})=?)*)?(#([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)?$/; if(regexp.test(url)){ return true; } return false;};
    this.isSSN = function(s){var match_num = s.match(/^(\d{3})-?\d{2}-?\d{4}$/);var dashes = s.split('-').length - 1;if(match_num == null || dashes == 1){return false;}return true;};
    
    this.isTemplate = function(t,s){if(t){if(t.length != s.length) return false; for(var i=0; i < t.length; i++){ if((t.charAt(i) == "d" || t.charAt(i) == "D") && this.isDigit(s.charAt(i))){ }else if((t.charAt(i) == "c" || t.charAt(i) == "C") && this.isAlpha(s.charAt(i))){ }else if(t.charAt(i) == s.charAt(i)){ }else{return false;}} return true;}return true;};    
    this.isButtons = function(el){if(el.type && ((el.type.substring(0,6) == "submit") || (el.type.substring(0,6) == "button") || (el.type.substring(0,5) == "reset"))){ return true; } return false;};    
    this.getProValidateFieldValue = function(frm,p_ind){cur_field_name=frm.elements[p_ind].name.substring(2,frm.elements[p_ind].name.length);cur_field_prefics = frm.elements[p_ind].name.substring(0,2);found_field_ind=-1;for(gvind=0;((gvind<frm.elements.length) && (found_field_ind==-1));gvind++){if((frm.elements[gvind].name != undefined) && (cur_field_name==frm.elements[gvind].name.substring(2, frm.elements[gvind].name.length)) && (cur_field_prefics != frm.elements[gvind].name.substring(0,2))){found_field_ind=gvind; break;}}if(found_field_ind !=-1) return frm.elements[found_field_ind].value;else return -1;};
    this.getValidateField = function(frm,p_ind,ret_type){cur_field_name=frm.elements[p_ind].name.substring(2,frm.elements[p_ind].name.length);found_field_ind=-1;for(gvind=0;((gvind<frm.elements.length) && (found_field_ind==-1));gvind++){if((frm.elements[gvind].name != undefined) && cur_field_name==frm.elements[gvind].name.substring(2, frm.elements[gvind].name.length))found_field_ind=gvind;}if(found_field_ind !=-1){if(ret_type=="type") return frm.elements[found_field_ind].name.charAt(1);else return frm.elements[found_field_ind].title;}else{return 0;}};
    this.isValidateField = function(frm,p_ind){validation_result=false;cur_field_name=frm.elements[p_ind].name.substring(2,frm.elements[p_ind].name.length);cur_field_type=frm.elements[p_ind].name.charAt(1);found_field_ind=-1;for(vind=0;((vind<frm.elements.length)&&(found_field_ind==-1));vind++){if((frm.elements[vind].name != undefined) && (cur_field_type != frm.elements[vind].name.charAt(1)) && (cur_field_name==frm.elements[vind].name.substring(2, frm.elements[vind].name.length)))found_field_ind=vind;}if(found_field_ind !=-1){if(frm.elements[found_field_ind].name.charAt(1)=="e"){validation_result=this.isEmail(frm.elements[p_ind].value);}else if(frm.elements[found_field_ind].name.charAt(1)=="p"){validation_result=this.isPassword(frm.elements[p_ind].value);}else{validation_result=false;}}else{validation_result=false;}return validation_result;};
    this.equalValidateField = function(frm,p_ind){validation_result=false;cur_field_name=frm.elements[p_ind].name.substring(2,frm.elements[p_ind].name.length);cur_field_type=frm.elements[p_ind].name.charAt(0);found_field_ind=-1;for(evind=0;((evind<frm.elements.length) && (found_field_ind==-1)); evind++){ if((frm.elements[evind].name != undefined) && (cur_field_type != frm.elements[evind].name.charAt(1)) && (cur_field_name==frm.elements[evind].name.substring(2, frm.elements[evind].name.length))) found_field_ind=evind; }if(found_field_ind !=-1){validation_result=(frm.elements[p_ind].value==frm.elements[found_field_ind].value);}else{validation_result=false;}return validation_result;};
    
    this.setNormalBackground = function(frm, ind){if((frm.elements[ind].type) && frm.elements[ind].type.substring(0,6) != "select"){frm.elements[ind].style.background = this.bgcolor_normal_1;}else{frm.elements[ind].style.background = this.bgcolor_normal_2;}};
    this.setErrorBackground = function(frm, ind){frm.elements[ind].style.background = this.bgcolor_error;};
    this.getFieldTitle = function(frm,ind){title_field=frm.elements[ind].title;if(title_field=="")title_field=frm.elements[ind].name.substring(3,frm.elements[ind].name.length);return title_field;};
    this.onSubmit = function(frm){return true;};
    
    this.setFocus = function(ind,is_first_found){        
        if((!is_first_found) && this.vForm.elements[ind] && (this.vForm.elements[ind].style.display != "none") && !this.vForm.elements[ind].disabled) {
            this.vForm.elements[ind].focus();
        }
    };

    this.setSelect = function(ind){        
        if((this.vForm.elements[ind].type) && (this.vForm.elements[ind].type.substring(0,6) !="select")){
            this.vForm.elements[ind].select();
        }
    };
    
    this.setOutputAlert = function(otype){
        var otype_ = (otype != null && otype == "div") ? otype : "popup";
        this.alertOutputType = otype_;
    };

    this.setOutputContainer = function(el){
        var el_ = (el != null) ? el : "";
        this.alertOutputId = el_;
    };   
    
    this.outputAlert = function(output){
        if(this.alertOutputType == "popup"){
            alert(output);
        }else{
            output = output.replace(/</g, "&lt;");
            output = output.replace(/>/g, "&gt;");
            output = output.replace(/\n/g, "<br>");
            if(document.getElementById(this.alertOutputId)){
                document.getElementById(this.alertOutputId).style.display = "block";
                document.getElementById(this.alertOutputId).innerHTML = output;
            }
        }        
    };    

    this.onReqAlert = function(frm,ind,all_fields){
        check_all_fields = (all_fields==null) ? false : true;
        is_first_found = (is_found==null) ? false : is_found;
        title_of_field=this.getFieldTitle(frm,ind);
        this.setErrorBackground(frm, ind);
        this.setFocus(ind,is_first_found);
        if(check_all_fields){
            /// return "The <" + title_of_field + "> is a required field!\n";
            return this.msgPrefix+fvVocabulary._MSG['MSG_1'].replace(/_TITLE_OF_FIELD_/g, title_of_field)+"\n";
        }else{
            // "The <" + title_of_field + "> is a required field!\nPlease, enter a valid " + title_of_field + "."
            this.outputAlert(this.msgPrefix+fvVocabulary._MSG['MSG_2'].replace(/_TITLE_OF_FIELD_/g, title_of_field)+"\n");
            this.setSelect(ind);
            return false;        
        }
    };

    this.onMinAlert = function(frm,ind,minlength,all_fields){
        check_all_fields = (all_fields==null) ? false : true;
        is_first_found = (is_found==null) ? false : is_found;
        title_of_field=this.getFieldTitle(frm,ind);
        this.setErrorBackground(frm, ind);
        this.setFocus(ind,is_first_found);
        if(check_all_fields){
            /// return "The <" + title_of_field + "> must be at least <_X_> characters long!\n";
            return this.msgPrefix+fvVocabulary._MSG['MSG_7'].replace(/_TITLE_OF_FIELD_/g, title_of_field).replace(/_X_/g, minlength)+"\n";
        }else{
            /// return "The <" + title_of_field + "> must be at least <_X_> characters long! Please, re-enter.\n";
            this.outputAlert(this.msgPrefix+fvVocabulary._MSG['MSG_7'].replace(/_TITLE_OF_FIELD_/g, title_of_field).replace(/_X_/g, minlength)+"\n");
            this.setSelect(ind);
            return false;        
        }
    };

    this.onInvalidAlert = function(frm,ind,ftype,fstype,all_fields)
    {
        check_all_fields = (all_fields==null) ? false : true;
        is_first_found = (is_found==null) ? false : is_found;
        type_of_field=fvVocabulary._MSG["SNT_1"];
        title_of_field=this.getFieldTitle(frm,ind);
        var field_template = "";
        var field_minlength = "";
        var sub_type_of_field, sub_type_of_field2, sub_type_of_field3;
        if(window.all){
            field_template = (frm.elements[ind].attributes.item('template')) ? frm.elements[ind].attributes.item('template').value : "";
        }else{
            field_template = frm.elements[ind].getAttribute('template');
        }
    
        switch(fstype){ //supnly mfi
            case 's': sub_type_of_field=fvVocabulary._MSG["SNT_2"]; break;
            case 'u': sub_type_of_field=fvVocabulary._MSG["SNT_3"]; sub_type_of_field2=fvVocabulary._MSG["SNT_4"]; break;
            case 'p': sub_type_of_field=fvVocabulary._MSG["SNT_5"]; break;
            case 'n': sub_type_of_field=fvVocabulary._MSG["SNT_6"]; sub_type_of_field2=fvVocabulary._MSG["SNT_7"]; break;
            case 'l': sub_type_of_field=fvVocabulary._MSG["SNT_8"]; sub_type_of_field2=fvVocabulary._MSG["SNT_8"]; break;
            
            case 'm': sub_type_of_field3=fvVocabulary._MSG["SNT_26"]; break;
            case 'f': sub_type_of_field3=fvVocabulary._MSG["SNT_27"]; break;
            case 'i': sub_type_of_field3=fvVocabulary._MSG["SNT_28"]; break;
            
            default: sub_type_of_field=fvVocabulary._MSG["SNT_9"];
                     sub_type_of_field2=fvVocabulary._MSG["SNT_9"];
                     sub_type_of_field3=fvVocabulary._MSG["SNT_25"];
                break; 
        }
    
        switch(ftype){
            case 'n': type_of_field=fvVocabulary._MSG['SNT_10'].replace("_SUB_TYPE_OF_FIELD_", sub_type_of_field); break;
            case 'i': type_of_field=fvVocabulary._MSG['SNT_11'].replace("_SUB_TYPE_OF_FIELD_", sub_type_of_field); break;
            case 'f': type_of_field=fvVocabulary._MSG['SNT_12'].replace("_SUB_TYPE_OF_FIELD_", sub_type_of_field); break;
            case 'a': type_of_field=fvVocabulary._MSG['SNT_13'].replace("_SUB_TYPE_OF_FIELD_", sub_type_of_field); break;
            case 'b': type_of_field=fvVocabulary._MSG['SNT_29']; break;
            case 't': type_of_field=fvVocabulary._MSG['SNT_14'].replace("_SUB_TYPE_OF_FIELD_", sub_type_of_field2); break;
            case 'p': type_of_field=fvVocabulary._MSG['SNT_15'].replace("_PASS_LENGTH_", this.PassLength); break;
            case 'l': type_of_field=fvVocabulary._MSG['SNT_16'].replace("_LOGIN_LENGTH_", this.LoginLength); break;
            case 'z': type_of_field=fvVocabulary._MSG['SNT_17']; break;
            case 'e': type_of_field=fvVocabulary._MSG['SNT_18']; break;
            case 'v': if(this.getValidateField(frm, ind, "type")=="e")
                        type_of_field=fvVocabulary._MSG['SNT_18']; 
                      else if(this.getValidateField(frm, ind, "type")=="p")
                        type_of_field=fvVocabulary._MSG['SNT_19'].replace("_PASS_LENGTH_", this.PassLength); 
                      else
                        type_of_field=fvVocabulary._MSG['SNT_20'];
                      break;
            case 'c': type_of_field=""; break;
            case 'u': type_of_field=fvVocabulary._MSG['SNT_21']; break;
            case 's': type_of_field=fvVocabulary._MSG['SNT_22']; break;
            case 'x': type_of_field=fvVocabulary._MSG['SNT_23'].replace("_TEMPLATE_", field_template); break;
            case 'm': type_of_field=fvVocabulary._MSG['SNT_24'].replace("_SUB_TYPE_OF_FIELD_", sub_type_of_field3); break;
            case 'r': type_of_field=""; break;
            default: break; 
        }
        this.setErrorBackground(frm,ind);
        this.setFocus(ind,is_first_found);
        if(check_all_fields){
            // "You have to sign <" + title_of_field + "> box as checked!"
            if(ftype == "c") return this.msgPrefix+fvVocabulary._MSG['MSG_3'].replace("_TITLE_OF_FIELD_", title_of_field)+"\n";
            // You have to check at least one <_TITLE_OF_FIELD_> radio button!
            else if(ftype == "r") return this.msgPrefix+fvVocabulary._MSG['MSG_6'].replace("_TITLE_OF_FIELD_", title_of_field)+"\n";
            // "The <" + title_of_field + "> field must " + type_of_field + "!"        
            else return this.msgPrefix+fvVocabulary._MSG['MSG_4'].replace("_TITLE_OF_FIELD_", title_of_field).replace("_TYPE_OF_FIELD_", type_of_field)+"\n";        
        }else{
            // "You have to sign <" + title_of_field + "> box as checked!"
            if(ftype == "c") this.outputAlert(this.msgPrefix+fvVocabulary._MSG['MSG_3'].replace("_TITLE_OF_FIELD_", title_of_field)+"\n");
            // You have to check at least one <_TITLE_OF_FIELD_> radio button!
            else if(ftype == "r") this.outputAlert(this.msgPrefix+fvVocabulary._MSG['MSG_6'].replace("_TITLE_OF_FIELD_", title_of_field)+"\n");
            // "The <" + title_of_field + "> field must " + type_of_field + "!"
            else this.outputAlert(this.msgPrefix+fvVocabulary._MSG['MSG_4'].replace("_TITLE_OF_FIELD_", title_of_field).replace("_TYPE_OF_FIELD_", type_of_field)+"\n");
            this.setSelect(ind);
            return false;            
        }
    };
    
    this.onNotEqualAlert = function(frm,ind,all_fields,is_found)
    {
        check_all_fields = (all_fields==null) ? false : true;
        is_first_found = (is_found==null) ? false : is_found;
        type_of_field=this.getValidateField(frm, ind, "name");
        title_of_field=this.getFieldTitle(frm,ind);
        if(type_of_field==0) type_of_field="required field";
        this.setErrorBackground(frm, ind);
        this.setFocus(ind,is_first_found);
        if(check_all_fields){
            // "The <" + title_of_field + "> field must be match with " + type_of_field + "!\n";        
            return this.msgPrefix+fvVocabulary._MSG['MSG_5'].replace("_TITLE_OF_FIELD_", title_of_field).replace("_TYPE_OF_FIELD_", type_of_field)+"\n";
        }else{
            // "The <" + title_of_field + "> field must be match with " + type_of_field + "!\n";        
            this.outputAlert(this.msgPrefix+fvVocabulary._MSG['MSG_5'].replace("_TITLE_OF_FIELD_", title_of_field).replace("_TYPE_OF_FIELD_", type_of_field)+"\n");        
            this.setSelect(ind);
            return false;
        }
    };
    
    // parametr - check hidden fields+check display.none fileds 
    this.onSubmitCheck = function(frm, handle_all_fields, handle_hidden_fields, decimal_point_delimiter)
    {
        this.vForm = frm;
        var arrRaduoButtoms = new Array();
        if(this.alertOutputType != "div"){
            this.msgPrefix = "";
            if(document.getElementById(this.alertOutputId)) document.getElementById(this.alertOutputId).style.display = "none";
        }else{
            this.msgPrefix = "&#8226; ";
        }
        
        check_all_fields = (handle_all_fields == null) ? false : handle_all_fields;
        check_hidden_fields = (handle_hidden_fields == null) ? false : handle_hidden_fields;
        this.decimalPointDelimiter = (decimal_point_delimiter == null) ? this.decimalPointDelimiter : decimal_point_delimiter;
        is_required="";
        a_type="";
        b_type="";
        msg = "";
        is_found = false;
        var field_template;
        var field_minlength;
        
        for(ind=0;ind<frm.elements.length;ind++){
            if(frm.elements[ind].type == undefined) continue; 
            if(!this.isButtons(frm.elements[ind])) this.setNormalBackground(frm,ind);
        }
        
        for(ind=0;ind<frm.elements.length;ind++){        
            if((frm.elements[ind].type == undefined) || this.isButtons(frm.elements[ind])){
                continue;
            }
            if(!check_hidden_fields){            
               if((frm.elements[ind].type) && (frm.elements[ind].type.substring(0,6) == "hidden")) continue;
            }
            is_required=frm.elements[ind].name.charAt(0);
            a_type=frm.elements[ind].name.charAt(1);
            b_type=frm.elements[ind].name.charAt(2);       
           
            if(!this.isSubmitSubVarType(b_type)) b_type = "";        
            true_value=true;
            if(this.isSubmitReqType(is_required)
               && this.isSubmitVarType(a_type)
               && (((frm.elements[ind].style.display !="none") && (frm.elements[ind].type != 'textarea')) || (frm.elements[ind].type == 'textarea'))
              )
            {
                field_value=frm.elements[ind].value; //trim
                if(is_required=='r'){
                    if(window.all){ field_minlength = (frm.elements[ind].attributes.item('minlength')) ? frm.elements[ind].attributes.item('minlength').value : "";}
                    else field_minlength = frm.elements[ind].getAttribute('minlength');
                    if(this.isEmpty(field_value)){
                        if(check_all_fields){
                            msg += this.onReqAlert(frm,ind,check_all_fields,is_found);
                            is_found = true;                                                
                            continue;
                        }else{
                            return this.onReqAlert(frm,ind);
                        }
                    }else if(field_minlength != "" && this.isShorter(field_value, field_minlength)){
                        if(check_all_fields){
                            msg += this.onMinAlert(frm,ind,field_minlength,check_all_fields,is_found);
                            is_found = true;                                                
                            continue;
                        }else{
                            return this.onMinAlert(frm,ind,field_minlength);
                        }                        
                    }else{
                        this.setNormalBackground(frm,ind);
                    }
                };
                if(((is_required=='r') ||
                   ((is_required=='s') && (!this.isEmpty(field_value)))) ||
                   ((a_type=='v') && (!this.isEmpty(this.getProValidateFieldValue(frm,ind)))) 
                ){
                    switch(a_type){
                        case 'a':
                            // Alphabetic
                            switch (b_type){                   
                                case 'u': if(!this.isAlphabetic(field_value) || !this.isUpper(field_value)) { true_value=false; } break;
                                case 'l': if(!this.isAlphabetic(field_value) || !this.isLower(field_value)) { true_value=false; } break;
                                case 'n': if(!this.isAlphabetic(field_value)) { true_value=false; } break;
                                case 'y': if(!this.isAlphabetic(field_value)) { true_value=false; } break;
                                default: if(!this.isAlphabetic(field_value))  { true_value=false; } break;
                            }
                            break;                        
                        case 'b':
                            // Alphanumeric
                            switch(b_type){                   
                                default: if(!this.isAlphanumeric(field_value)) { true_value=false; } break;
                            }
                            break;                        
                        case 'c':
                            // Check boxes
                            if(is_required=='r'){
                                if(!this.isChecked(frm,ind))  { true_value=false; }
                            }
                            break;
                        case 'e':
                            // Email
                            switch (b_type){                   
                                case 'u': if(!this.isEmail(field_value) || !this.isUpper(field_value)) { true_value=false; } break;
                                case 'l': if(!this.isEmail(field_value) || !this.isLower(field_value)) { true_value=false; } break;
                                case 'n': if(!this.isEmail(field_value)) { true_value=false; } break;
                                case 'y': if(!this.isEmail(field_value)) { true_value=false; } break;
                                default: if(!this.isEmail(field_value))  { true_value=false; } break;
                            }
                            break;                        
                        case 'f':
                            // Float  
                            switch (b_type){                   
                                case 's': if(!this.isSignedFloat(field_value))     { true_value=false; } break;
                                case 'u': if(!this.isFloat(field_value))           { true_value=false; } break;
                                case 'p': if(!this.isPositiveFloat(field_value))   { true_value=false; } break;
                                case 'n': if(!this.isNegativeFloat(field_value))   { true_value=false; } break;
                                default: if(!this.isSignedFloat(field_value))      { true_value=false; } break;
                            }
                            break;                        
                        case 'i':
                            // Integer
                            switch (b_type){                   
                                case 's': if(!this.isSignedInteger(field_value))   { true_value=false; } break;
                                case 'u': if(!this.isInteger(field_value))         { true_value=false; } break;
                                case 'p': if(!this.isPositiveInteger(field_value)) { true_value=false; } break;
                                case 'n': if(!this.isNegativeInteger(field_value)) { true_value=false; } break;
                                default:  if(!this.isSignedInteger(field_value))   { true_value=false; } break;
                            }
                            break;
                        case 'l':
                            // Login
                            if(!this.isLogin(field_value))    { true_value=false; }
                            break;
                        case 'm':
                            // Phones
                            switch (b_type){                   
                                case 'm': if(!this.isMobPhoneNumber(field_value)) { true_value=false; } break;
                                case 'f': if(!this.isFixPhoneNumber(field_value)) { true_value=false; } break;
                                case 'i': if(!this.isInternationalPhoneNumber(field_value)) { true_value=false; } break;
                                case 'y': if(!this.isPhoneNumber(field_value))  { true_value=false; } break;
                                default:  if(!this.isPhoneNumber(field_value))  { true_value=false; } break;
                            }
                            break;                        
                        case 'n':
                            // Numeric
                            if(!this.isNumeric(field_value, 3)) { true_value=false; }
                            break;
                        case 'p':
                            // Password
                            if(!this.isPassword(field_value)) { true_value=false; }
                            break;                        
                        case 'r':
                            // Radio buttons 
                            if(is_required=='r'){
                                true_value=false; 
                                for(jnd=0; jnd < frm.elements.length; jnd++){
                                    if(frm.elements[jnd].name == frm.elements[ind].name){
                                        if(frm.elements[jnd].checked){
                                            true_value=true;
                                            break; 
                                        }
                                    }
                                }                                
                            }
                            break;                        
                        case 's':
                            // SSN 
                            if(!this.isSSN(field_value))      { true_value=false; }
                            break;                            
                        case 't':
                            // Text
                            switch (b_type){                   
                                case 'u': if(!this.isText(field_value) || !this.isUpper(field_value)) { true_value=false; } break;
                                case 'l': if(!this.isText(field_value) || !this.isLower(field_value)) { true_value=false; } break;
                                case 'n': if(!this.isText(field_value)) { true_value=false; } break;
                                case 'y': if(!this.isText(field_value)) { true_value=false; } break;
                                default: if(!this.isText(field_value))  { true_value=false; } break;
                            }
                            break;                        
                        case 'u':
                            // URL
                            if(!this.isURL(field_value)) { true_value=false; }
                            break;
                        case 'v':
                            // Validators
                            if(!this.isValidateField(frm, ind)){
                                true_value=false;
                            }else if(!this.equalValidateField(frm, ind)){
                                if(check_all_fields){
                                    msg += this.onNotEqualAlert(frm, ind, check_all_fields, is_found);
                                }else{
                                    return this.onNotEqualAlert(frm, ind);
                                }
                                is_found = true;
                            }                              
                            break;
                        case 'x':
                            // Templates
                            if(window.all){
                                field_template = (frm.elements[ind].attributes.item('template')) ? frm.elements[ind].attributes.item('template').value : "";
                            }else{
                                field_template = frm.elements[ind].getAttribute('template');
                            }
                            if(!this.isTemplate(field_template, field_value)) { true_value=false; } break;                            
                        case 'y':
                            // Any
                            if(!this.isAny(field_value)) { true_value=false; }
                            break;
                        case 'z':
                            // Post (zip) code
                            if(!this.isZipCode(field_value)) { true_value=false; }
                            break;
                        default: break; 
                    }
                    if(!true_value){
                        if(a_type != "r"){
                            if(check_all_fields){
                                msg += this.onInvalidAlert(frm, ind, a_type, b_type, check_all_fields, is_found, field_template);    
                            }else{
                                return this.onInvalidAlert(frm, ind, a_type, b_type);                
                            }                                
                        }else if(a_type == "r"){
                            // handle radiobuttons
                            if(!arrRaduoButtoms.has(frm.elements[ind].name)){
                                if(check_all_fields){
                                    msg += this.onInvalidAlert(frm, ind, a_type, b_type, check_all_fields, is_found, field_template);                                            
                                }else{
                                    return this.onInvalidAlert(frm, ind, a_type, b_type);                
                                }
                                arrRaduoButtoms.push(frm.elements[ind].name);    
                            }else{
                                this.setErrorBackground(frm,ind); 
                            }
                        }
                        is_found = true;
                    }
                }                            
            }
        }
        if(check_all_fields){
            if(msg != ""){
                this.outputAlert(msg);  
                return false;
            }            
        }    
        return true;    
    };  
    
    
    /* extend array functionality */
    Array.prototype.has = function(value)
    {    
        var i;
        for(var i = 0, loopCnt = this.length; i < loopCnt; i++){
            if(this[i].toLowerCase() == value.toLowerCase()){
                return true;
            }
        }    
        return false;    
    };
    
    
}
//-->
