/*
  -------------------------------------------------------------------------
		      JavaScript Form Validator (gen_validatorv31.js)
              Version 3.1.2
	Copyright (C) 2003-2008 JavaScript-Coder.com. All rights reserved.
	You can freely use this script in your Web pages.
	You may adapt this script for your own needs, provided these opening credit
    lines are kept intact.
		
	The Form validation script is distributed free from JavaScript-Coder.com
	For updates, please visit:
	http://www.javascript-coder.com/html-form/javascript-form-validation.phtml
	
	Questions & comments please send to form.val at javascript-coder.com
  -------------------------------------------------------------------------  
*/
function Validator(a){if(this.formobj=document.forms[a]){if(this.formobj.onsubmit){this.formobj.old_onsubmit=this.formobj.onsubmit;this.formobj.onsubmit=null}else this.formobj.old_onsubmit=null;this.formobj._sfm_form_name=a;this.formobj.onsubmit=form_submit_handler;this.addValidation=add_validation;this.setAddnlValidationFunction=set_addnl_vfunction;this.clearAllValidations=clear_all_validations;this.disable_validations=false;document.error_disp_handler=new sfm_ErrorDisplayHandler;this.EnableOnPageErrorDisplay=
validator_enable_OPED;this.EnableOnPageErrorDisplaySingleBox=validator_enable_OPED_SB;this.show_errors_together=true;this.EnableMsgsTogether=sfm_enable_show_msgs_together;document.set_focus_onerror=true;this.EnableFocusOnError=sfm_validator_enable_focus}else alert("Error: couldnot get Form object "+a)}function sfm_validator_enable_focus(a){document.set_focus_onerror=a}function set_addnl_vfunction(a){this.formobj.addnlvalidation=a}function sfm_set_focus(a){document.set_focus_onerror&&a.focus()}
function sfm_enable_show_msgs_together(){this.show_errors_together=true;this.formobj.show_errors_together=true}function clear_all_validations(){for(var a=0;a<this.formobj.elements.length;a++)this.formobj.elements[a].validationset=null}
function form_submit_handler(){var a=true;document.error_disp_handler.clear_msgs();for(var b=0;b<this.elements.length;b++){if(this.elements[b].validationset&&!this.elements[b].validationset.validate())a=false;if(!a&&!this.show_errors_together)break}if(this.addnlvalidation){str=" var ret = "+this.addnlvalidation+"()";eval(str);ret||(a=false)}if(!a){document.error_disp_handler.FinalShowMsg();return false}return true}
function add_validation(a,b,c){var d=null;if(arguments.length>3)d=arguments[3];if(this.formobj){var e=this.formobj[a];if(e.length&&isNaN(e.selectedIndex))e=e[0];if(e){if(!e.validationset)e.validationset=new ValidationSet(e,this.show_errors_together);e.validationset.add(b,c,d);e.validatorobj=this}else alert("Error: Couldnot get the input object named: "+a)}else alert("Error: The form object is not set properly")}
function validator_enable_OPED(){document.error_disp_handler.EnableOnPageDisplay(false)}function validator_enable_OPED_SB(){document.error_disp_handler.EnableOnPageDisplay(true)}function sfm_ErrorDisplayHandler(){this.msgdisplay=new AlertMsgDisplayer;this.EnableOnPageDisplay=edh_EnableOnPageDisplay;this.ShowMsg=edh_ShowMsg;this.FinalShowMsg=edh_FinalShowMsg;this.all_msgs=[];this.clear_msgs=edh_clear_msgs}function edh_clear_msgs(){this.msgdisplay.clearmsg(this.all_msgs);this.all_msgs=[]}
function edh_FinalShowMsg(){this.msgdisplay.showmsg(this.all_msgs)}function edh_EnableOnPageDisplay(a){this.msgdisplay=true==a?new SingleBoxErrorDisplay:new DivMsgDisplayer}function edh_ShowMsg(a,b){var c=[];c.input_element=b;c.msg=a;this.all_msgs.push(c)}function AlertMsgDisplayer(){this.showmsg=alert_showmsg;this.clearmsg=alert_clearmsg}function alert_clearmsg(a){}
function alert_showmsg(a){for(var b="",c=null,d=0;d<a.length;d++){if(null==c)c=a[d].input_element;b+=a[d].msg+"\n"}alert(b);null!=c&&sfm_set_focus(c)}function sfm_show_error_msg(a,b){document.error_disp_handler.ShowMsg(a,b)}function SingleBoxErrorDisplay(){this.showmsg=sb_div_showmsg;this.clearmsg=sb_div_clearmsg}function sb_div_clearmsg(a){a=form_error_div_name(a);show_div_msg(a,"")}
function sb_div_showmsg(a){for(var b="<ul>\n",c=0;c<a.length;c++)b+="<li>"+a[c].msg+"</li>\n";b+="</ul>";a=form_error_div_name(a);show_div_msg(a,b)}function form_error_div_name(a){var b=null;for(var c in a)if(b=a[c].input_element)break;a="";if(b)a=b.form._sfm_form_name+"_errorloc";return a}function DivMsgDisplayer(){this.showmsg=div_showmsg;this.clearmsg=div_clearmsg}function div_clearmsg(a){for(var b in a){var c=element_div_name(a[b].input_element);show_div_msg(c,"")}}
function element_div_name(a){a=a.form._sfm_form_name+"_"+a.name+"_errorloc";return a=a.replace(/[\[\]]/gi,"")}function div_showmsg(a){var b=null;for(var c in a){if(null==b)b=a[c].input_element;var d=element_div_name(a[c].input_element);show_div_msg(d,a[c].msg)}null!=b&&sfm_set_focus(b)}
function show_div_msg(a,b){if(a.length<=0)return false;if(document.layers){divlayer=document.layers[a];if(!divlayer)return;divlayer.document.open();divlayer.document.write(b);divlayer.document.close()}else if(document.all){divlayer=document.all[a];if(!divlayer)return;divlayer.innerHTML=b}else if(document.getElementById){divlayer=document.getElementById(a);if(!divlayer)return;divlayer.innerHTML=b}divlayer.style.visibility="visible"}
function ValidationDesc(a,b,c,d){this.desc=b;this.error=c;this.itemobj=a;this.condition=d;this.validate=vdesc_validate}function vdesc_validate(){if(this.condition!=null)if(!eval(this.condition))return true;if(!validateInput(this.desc,this.itemobj,this.error)){this.itemobj.validatorobj.disable_validations=true;sfm_set_focus(this.itemobj);return false}return true}function ValidationSet(a,b){this.vSet=[];this.add=add_validationdesc;this.validate=vset_validate;this.itemobj=a;this.msgs_together=b}
function add_validationdesc(a,b,c){this.vSet[this.vSet.length]=new ValidationDesc(this.itemobj,a,b,c)}function vset_validate(){for(var a=true,b=0;b<this.vSet.length;b++){a=a&&this.vSet[b].validate();if(!a&&!this.msgs_together)break}return a}
function validateEmail(a){a=a.match("^(.+)@(.+)$");if(a==null)return false;if(a[1]!=null){var b=/^\"?[\w-_\.]*\"?$/;if(a[1].match(b)==null)return false}if(a[2]!=null){b=/^[\w-\.]*\.[A-Za-z]{2,4}$/;if(a[2].match(b)==null){b=/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/;if(a[2].match(b)==null)return false}return true}return false}
function IsCheckSelected(a,b){var c=false,d=a.form.elements[a.name];if(d.length){a=-1;for(var e=0;e<d.length;e++)if(d[e].value==b){a=e;break}if(a>=0)if(d[a].checked=="1")c=true}else if(a.checked=="1")c=true;return c}function TestDontSelectChk(a,b,c){var d=true;d=IsCheckSelected(a,b)?false:true;if(d==false){if(!c||c.length==0)c="Can't Proceed as you selected "+a.name;sfm_show_error_msg(c,a)}return d}
function TestShouldSelectChk(a,b,c){var d=true;d=IsCheckSelected(a,b)?true:false;if(d==false){if(!c||c.length==0)c="You should select "+a.name;sfm_show_error_msg(c,a)}return d}function TestRequiredInput(a,b){var c=true,d=a.value;d=d.replace(/^\s+|\s+$/g,"");if(eval(d.length)==0){if(!b||b.length==0)b=a.name+" : Required Field";sfm_show_error_msg(b,a);c=false}return c}
function TestMaxLen(a,b,c){var d=true;if(eval(a.value.length)>eval(b)){if(!c||c.length==0)c=a.name+" : "+b+" characters maximum ";sfm_show_error_msg(c,a);d=false}return d}function TestMinLen(a,b,c){var d=true;if(eval(a.value.length)<eval(b)){if(!c||c.length==0)c=a.name+" : "+b+" characters minimum  ";sfm_show_error_msg(c,a);d=false}return d}function TestInputType(a,b,c,d){var e=true;b=a.value.search(b);if(a.value.length>0&&b>=0){if(!c||c.length==0)c=d;sfm_show_error_msg(c,a);e=false}return e}
function TestEmail(a,b){var c=true;if(a.value.length>0&&!validateEmail(a.value)){if(!b||b.length==0)b=a.name+": Enter a valid Email address ";sfm_show_error_msg(b,a);c=false}return c}function TestLessThan(a,b,c){var d=true;if(isNaN(a.value)){sfm_show_error_msg(a.name+": Should be a number ",a);d=false}else if(eval(a.value)>=eval(b)){if(!c||c.length==0)c=a.name+" : value should be less than "+b;sfm_show_error_msg(c,a);d=false}return d}
function TestGreaterThan(a,b,c){var d=true;if(isNaN(a.value)){sfm_show_error_msg(a.name+": Should be a number ",a);d=false}else if(eval(a.value)<=eval(b)){if(!c||c.length==0)c=a.name+" : value should be greater than "+b;sfm_show_error_msg(c,a);d=false}return d}function TestRegExp(a,b,c){var d=true;if(a.value.length>0&&!a.value.match(b)){if(!c||c.length==0)c=a.name+": Invalid characters found ";sfm_show_error_msg(c,a);d=false}return d}
function TestDontSelect(a,b,c){var d=true;if(a.selectedIndex==null){sfm_show_error_msg("ERROR: dontselect command for non-select Item");d=false}if(a.selectedIndex==eval(b)){if(!c||c.length==0)c=a.name+": Please Select one option ";sfm_show_error_msg(c,a);d=false}return d}
function TestSelectOneRadio(a,b){for(var c=a.form.elements[a.name],d=false,e=0;e<c.length;e++)if(c[e].checked){d=true;break}if(false==d){if(!b||b.length==0)b="Please select one option from "+a.name;sfm_show_error_msg(b,a)}return d}
function validateInput(a,b,c){var d=true,e=a.search("="),g="",f="";if(e>=0){g=a.substring(0,e);f=a.substr(e+1)}else g=a;switch(g){case "req":case "required":d=TestRequiredInput(b,c);break;case "maxlength":case "maxlen":d=TestMaxLen(b,f,c);break;case "minlength":case "minlen":d=TestMinLen(b,f,c);break;case "alnum":case "alphanumeric":d=TestInputType(b,"[^A-Za-z0-9]",c,b.name+": Only alpha-numeric characters allowed ");break;case "alnum_s":case "alphanumeric_space":d=TestInputType(b,"[^A-Za-z0-9\\s]",
c,b.name+": Only alpha-numeric characters and space allowed ");break;case "num":case "numeric":d=TestInputType(b,"[^0-9]",c,b.name+": Only digits allowed ");break;case "dec":case "decimal":d=TestInputType(b,"[^0-9.]",c,b.name+": Only numbers allowed ");break;case "alphabetic":case "alpha":d=TestInputType(b,"[^A-Za-z]",c,b.name+": Only alphabetic characters allowed ");break;case "alphabetic_space":case "alpha_s":d=TestInputType(b,"[^A-Za-z\\s]",c,b.name+": Only alphabetic characters and space allowed ");
break;case "email":d=TestEmail(b,c);break;case "lt":case "lessthan":d=TestLessThan(b,f,c);break;case "gt":case "greaterthan":d=TestGreaterThan(b,f,c);break;case "regexp":d=TestRegExp(b,f,c);break;case "dontselect":d=TestDontSelect(b,f,c);break;case "dontselectchk":d=TestDontSelectChk(b,f,c);break;case "shouldselchk":d=TestShouldSelectChk(b,f,c);break;case "selone_radio":d=TestSelectOneRadio(b,c);break}return d}
function VWZ_IsListItemSelected(a,b){for(var c=0;c<a.options.length;c++)if(a.options[c].selected==true&&a.options[c].value==b)return true;return false}function VWZ_IsChecked(a,b){if(a.length)for(var c=0;c<a.length;c++){if(a[c].checked=="1"&&a[c].value==b)return true}else if(a.checked=="1")return true;return false};
/*
	Copyright (C) 2003-2009 JavaScript-Coder.com . All rights reserved.
*/
