var SEPARADORDECIMAL=".",FORMATODATA=0,MSG_REQUIRED=" is required",MSG_INTERVAL=" must between ",MSG_STARTDATE=" Start date ",MSG_ENDDATE=" End date ",MSG_INVALIDNUMBER=" is not a valid number",MSG_INVALIDDATE=" is not a valid date. Accepted format is ",MSG_MONTH="Month ",MSG_DAY="Day ",MSG_30DAY=" have only 30 days",MSG_29DAY="February have only 28 days in ",MSG_INVALIDEMAIL=" is not a valid email.";
function fn_checkthis(a,d,c,b,e,f){window.status="";if(c==1&&b.value=="")return fn_message(a+MSG_REQUIRED),!1;if(c!=1&&b.value=="")return!0;if(d==1)return b.value=b.value.toLowerCase(),!0;if(d==2)return b.value=b.value.toUpperCase(),!0;if(d==3){if(!fn_isValidNumber(b.value,a))return!1;if((fn_toFloat(b.value)<fn_toFloat(e)||fn_toFloat(b.value)>fn_toFloat(f))&&b.value!="")return fn_message(a+MSG_INTERVAL+e+" -- "+f),!1}if(d==4){if(!fn_isValidDate(b.value,a))return!1;if(fn_isValidDate(e,MSG_STARTDATE+
a)&&fn_isValidDate(f,MSG_ENDDATE+a))return fn_isValidRangeDate(a,e,f,b.value)}if(d==9){b.value=b.value.toUpperCase();for(c=0;c<=22;)j=b.value.indexOf("\u00c1\u00c0\u00c3\u00c2\u00c4\u00c9\u00c8\u00ca\u00cb\u00cd\u00cc\u00ce\u00cf\u00d3\u00d2\u00d4\u00d5\u00d6\u00da\u00d9\u00db\u00dc\u00c7".charAt(c)),j>-1?b.value=b.value.substring(0,j)+"AAAAAEEEEIIIIOOOOOUUUUC".charAt(c)+b.value.substring(j+1,b.value.length):c++}return d==10&&(emailPat=/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/,!emailPat.test(b.value))?
(fn_message(a+MSG_INVALIDEMAIL),!1):!0}function fn_isValidNumber(a,d){var c="0123456789"+SEPARADORDECIMAL,b=0,e=0,f=0;for(a.substring(0,1)=="-"&&(e=1);e<a.length;e++)if(temp=a.substring(e,e+1),f=c.indexOf(temp),f==10&&b++,f==-1||b>1)return fn_message(d+MSG_INVALIDNUMBER),!1;return!0}function fn_toFloat(a){return parseFloat(a.replace(SEPARADORDECIMAL,"."))}var datePat;datePat=FORMATODATA==2?/^(\d{4})(\/|-)(\d{2})(\/|-)(\d{2})$/:/^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/;
function fn_isValidDate(a,d){var c=a.match(datePat);if(a=="")return!0;if(c==null){switch(FORMATODATA){case 0:fn_message(d+MSG_INVALIDDATE+" dd/mm/aaaa!");break;case 1:fn_message(d+MSG_INVALIDDATE+" mm/dd/aaaa!");break;case 2:fn_message(d+MSG_INVALIDDATE+" aaaa/mm/dd!")}return!1}switch(FORMATODATA){case 0:day=c[1];month=c[3];year=c[5];break;case 1:day=c[3];month=c[1];year=c[5];break;case 2:day=c[5],month=c[3],year=c[1]}return month<1||month>12?(fn_message(MSG_MONTH+d+MSG_INTERVAL+" 01 -- 12."),!1):
day<1||day>31?(fn_message(MSG_DAY+d+MSG_INTERVAL+" 01 -- 31."),!1):(month==4||month==6||month==9||month==11)&&day==31?(fn_message(MSG_MONTH+month+", "+d+", "+MSG_30DAY),!1):month==2&&(day>29||day==29&&!(year%4==0&&(year%100!=0||year%400==0)))?(fn_message(MSG_29DAY+year),!1):!0}function fn_isValidRangeDate(a,d,c,b){var e,f;if(d==""||c==""||b=="")return!0;e=fn_toDate(d);f=fn_toDate(c);b=fn_toDate(b);return e<=b&&b<=f?!0:(fn_message(a+MSG_INTERVAL+d+" -- "+c),!1)}
function fn_toDate(a){a=a.match(datePat);switch(FORMATODATA){case 0:return a[5]+a[3]+a[1];case 1:return a[5]+a[1]+a[3];case 2:return a[1]+a[3]+a[5]}}function fn_message(a){alert(a)}function validaNumeros(a){var a=window.event?a.keyCode:a.which,d=String.fromCharCode(a);reg=/\d/;return reg.test(d)||a==8||a==0}
function enviaEmail(a){document.getElementById("campoEmail").value!=document.getElementById("campoConfirmaEmail").value?alert("O email n\u00e3o confere! Verifique os campos"):/^([\w]+)(.[\w]+)*@([\w]+)(.[\w]{2,3}){1,2}$/.test(document.getElementById("campoEmail").value)?a.submit():alert("O email digitado \u00e9 inv\u00e1lido!!!")};

