	function ValidarFormatoData(source, arguments) {
		arguments.IsValid = ValidarData(arguments.Value);
	}
								
	function ValidarData(theDate) {
		var theFormat = 'dd-mm-aaaa';
		var dtTemp,ano='',mes='',dia='',dtOK=0;
		var msg = false;
		var totalOK;
							
		dtTemp = theDate;
		if (dtTemp.length == 8) { totalOK = 3 } else { totalOK = 5 };
				
		for(i=0; i<(dtTemp.length);i++) {
			if (dtTemp.charAt(i) == theFormat.charAt(i)) { dtOK = dtOK/1 + 1 }
			if (theFormat.charAt(i) == 'd') { dia += dtTemp.charAt(i) }
			if (theFormat.charAt(i) == 'm') { mes += dtTemp.charAt(i) }
			if (theFormat.charAt(i) == 'a') { ano += dtTemp.charAt(i) }
		}
				
		if (dia.charAt(0) == '0') { diaZero = '0' } else { diaZero = '' }
		if (mes.charAt(0) == '0') { mesZero = '0' } else { mesZero = '' }
	
		if (dia!=diaZero+parseInt(dia,10)) { return msg } else { dia = eval(dia) };
		if (mes!=mesZero+parseInt(mes,10)) { return msg } else { mes = eval(mes) };
		if (ano!=''+parseInt(ano,10)) { return msg } else { ano = eval(ano) };
	
		switch (mes) {
		  case  2: if (ano % 4 == 0) { diasmes = 29} else { diasmes = 28 }; break;
		  case  4: diasmes = 30; break;
		  case  6: diasmes = 30; break;
		  case  9: diasmes = 30; break;
		  case 11: diasmes = 30; break;
		  default: diasmes = 31; break;
		};
 
		if ((dia > 0) && (dia <= diasmes)) { dtOK = dtOK/1 + 1 }
		if ((mes > 0) && (mes < 13)) { dtOK = dtOK/1 + 1 }
		if ((ano > 1800) && (ano < 9999)) { dtOK = dtOK/1 + 1 }
	
		if (dtOK == totalOK) { msg = true }	
		return msg;
	}
	
	function ValidarCodigoPostal(source, arguments) {	
		if (document.HtmlForm.txtCodigoPostal1.value.length==0 && document.HtmlForm.txtCodigoPostal2.value.length==0) {		
			arguments.IsValid=true
		}		
		else {
			if (ValidarInteiro(document.HtmlForm.txtCodigoPostal1.value, 4, 4))		
				if (document.HtmlForm.txtCodigoPostal2.value.length==0) {
					arguments.IsValid=true					
				}
				else {
					arguments.IsValid = ValidarInteiro(document.HtmlForm.txtCodigoPostal2.value, 3, 3)
				}
			else {
				arguments.IsValid=false
			}
		}						
	}
		
	function ValidarInteiro(sCampo, iMin, iMax) {
		var inicio = 0;
		if (sCampo.length<iMin || sCampo.length>iMax) {
			return false;
		}
		else {
			if (sCampo.charCodeAt(0)==45) {
				inicio = 1;
			}
			for (var i = inicio; i < sCampo.length; i++) {
				if (sCampo.charCodeAt(i)<48 || sCampo.charCodeAt(i)>57) {
					return false;
				}
			}
			return true;
		}
	}
	
	function ValidarTelefone(source, arguments) {
		var numTelefone=arguments.Value;
		
		if (ValidarInteiro(numTelefone, 9, 9)) {
			if ((numTelefone.substring(0,1) == '2') || (numTelefone.substring(0,2) == '91') || (numTelefone.substring(0,2) == '93') || (numTelefone.substring(0,2) == '96')) {
				arguments.IsValid = true
			}
			else {
				arguments.IsValid = false
			}
		}
		else {
				arguments.IsValid = false
		}
	}
