function validateForm(a,c){var b=false;var d="Please correct the following issues:\n\n";var e=d.length;var f="";var g="";var h="";var i=new Array();var k=new Array();for(var l in c)if(l=="__settings"){settings=c[l];f=settings["color_invalid"];g=settings["color_valid"];h=settings["color_standard"]}else{var m=a.elements[l];if((m)&&(!m.disabled)){if(m.type!=undefined)m.style.backgroundColor=h;objx=c[l];message=objx["message"];format=objx["format"];notvalid=objx["notvalid"];regex=objx["regex"];xid=objx["xid"];var n=document.getElementById(xid);if(n!=null)n.style.backgroundColor="";t=objx["section"];var o=document.getElementById(t);if((i[t]==null)&&(o!=null)){i[t]=o;k[t]=0}dependson=objx["dependson"];can_continue=true;if(dependson==undefined)can_continue=true;else{dependee=dependson["field"];dependee_type=dependson["type"];var p=a.elements[dependee];if(dependee_type=="checkbox"){dependee_value=dependson["value"];dependee_ischecked=dependson["ischecked"];if((p.checked.toString()==dependee_ischecked)&&(p.value==dependee_value))can_continue=true;else can_continue=false}if(dependee_type=="radio"){dependee_value=dependson["value"];dependee_ischecked=dependson["ischecked"];can_continue=false;radio_options=dependee_value.split(",");if(p!=undefined)for(var j=0;j<p.length;j++){if((p[j].checked.toString()==dependee_ischecked)&&(isin(p[j].value.toString(),radio_options)))can_continue=true}}if(dependee_type=="select"){dependee_value=dependson["value"];can_continue=false;if(p[p.selectedIndex]==undefined)can_continue=true;else if(p[p.selectedIndex].value==dependee_value)can_continue=true;else can_continue=false}}if((regex!=undefined)&&(regex!='')){var q=new RegExp(regex,"gi");var b=q.test(m.value);if(!b){d+=" - "+message+"\n";m.style.backgroundColor=f;if(o!=null)k[t]++;can_continue=false}else{m.style.backgroundColor=g}}if(can_continue){switch(m.type){case"select-one":case"select":notvalid_options=notvalid.split(",");m.style.backgroundColor=h;if((m.selectedIndex==-1)||(isin(m[m.selectedIndex].value.toString(),notvalid_options))){d+=" - "+message+"\n";m.style.backgroundColor=f;if(o!=null)k[t]++}else m.style.backgroundColor=g;break;case"select-multiple":m.style.backgroundColor=h;if(m.selectedIndex==-1){d+=" - "+message+"\n";m.style.backgroundColor=f;if(o!=null)k[t]++}else m.style.backgroundColor=g;break;case"file":temp="";var n=document.getElementById(xid);if((m.value==notvalid)||(m.value==null)||((format=="date")&&((temp=isValidDate(m.value))!=true))||((format=="email")&&(!isValidEmail(m.value)))){d+=" - "+message+temp+"\n";if(n!=null)n.style.backgroundColor=f;if(o!=null)k[t]++}else if(n!=null)n.style.backgroundColor=g;break;case"textarea":case"text":case"hidden":case"password":temp="";var n=document.getElementById(xid);m.style.backgroundColor=h;notvalid_options=notvalid.split(",");if((isin(m.value.toString(),notvalid_options))||(m.value==null)||((format=="date")&&((temp=isValidDate(m.value))!=true))||((format=="email")&&(!isValidEmail(m.value)))){d+=" - "+message+temp+"\n";m.style.backgroundColor=f;if(n!=null)n.style.backgroundColor=f;if(o!=null)k[t]++}else{m.style.backgroundColor=g;if(n!=null)n.style.backgroundColor=g}break;case"radio":var n=document.getElementById(xid);if(!m.checked){d+=" - "+message+"\n";if(n!=null)n.style.backgroundColor=f;if(o!=null)k[t]++}else if(n!=null)n.style.backgroundColor=g;break;case"checkbox":var n=document.getElementById(xid);if(!m.checked){d+=" - "+message+"\n";if(n!=null)n.style.backgroundColor=f;if(o!=null)k[t]++}else if(n!=null)n.style.backgroundColor=g;break;case undefined:var n=document.getElementById(xid);var r=false;for(var j=0;j<m.length;j++)if(m[j].checked)r=true;if(!r){d+=" - "+message+"\n";if(n!=null)n.style.backgroundColor=f;if(o!=null)k[t]++}else if(n!=null)n.style.backgroundColor=g;break;default:break}}}}for(var s in i){var t=document.getElementById(s);if((t!=null)&&(k[s]!=0))t.style.backgroundColor=f}if(d.length==e){b=true}else{alert(d);b=false}return b}function isValidDate(a){var b=/^(\d{1,2})(\/|-)(\d{1,2})\2(\d{2}|\d{4})$/;var c=a.match(b);if(c==null){return" -- Date is not in a valid format."}month=c[1];day=c[3];year=c[4];if(month<1||month>12){return" -- Month must be between 1 and 12."}if(day<1||day>31){return" -- Day must be between 1 and 31."}if((month==4||month==6||month==9||month==11)&&day==31){return" -- Month "+month+" doesn't have 31 days!"}if(month==2){var d=(year%4==0&&(year%100!=0||year%400==0));if(day>29||(day==29&&!d)){return" -- February "+year+" doesn't have "+day+" days!"}}return true}function isValidEmail(a){var b=/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;if(!b.test(a))return false;else return true}function isin(v,a){var b=false;for(var i=0;i<a.length;i++)if(v==a[i])b=true;return b}