// JavaScript Document

function CheckForm () {

	var errorMsg = "";

	var ok = true;

	if (document.form.nome.value == ""){
		errorMsg += "\t* Seu Nome - Digite um nome \n";
	}

	if (document.form.email.value.search("@") == -1) {
		errorMsg += "\t* E-mail - E-mail inválido. \n";
	}

	if (errorMsg != ""){
		msg = "Os seguintes campos não foram preenchidos, ou estão incorretos\n\n";
		errorMsg += alert(msg + errorMsg + "\n");
		return false;
	}
	return true;

}


	function MM_reloadPage(init) {  //reloads the window if Nav4 resized
	  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
		document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
	  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
	}
	MM_reloadPage(true);
	
	function MM_findObj(n, d) { //v4.01
	  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	  if(!x && d.getElementById) x=d.getElementById(n); return x;
	}
	
		function isCpf(sCpf) 
	{
		sCpf = pegaNumeros(sCpf)
		if (sCpf.length != 11 || sCpf == "00000000000" || sCpf == "11111111111" ||	sCpf == "22222222222" ||	sCpf == "33333333333" || sCpf == "44444444444" ||	sCpf == "55555555555" || sCpf == "66666666666" || sCpf == "77777777777" ||		sCpf == "88888888888" || sCpf == "99999999999")
			return false;
		soma = 0;
		for (i=0; i < 9; i ++)
			soma += parseInt(sCpf.charAt(i)) * (10 - i);
		resto = 11 - (soma % 11);
		if (resto == 10 || resto == 11)
			resto = 0;
		if (resto != parseInt(sCpf.charAt(9)))
			return false;
		soma = 0;
		for (i = 0; i < 10; i ++)
			soma += parseInt(sCpf.charAt(i)) * (11 - i);
		resto = 11 - (soma % 11);
		if (resto == 10 || resto == 11)
			resto = 0;
		if (resto != parseInt(sCpf.charAt(10)))
			return false;
		return true;
	}
	
		// recebe uma string e retorna somente os números que ela contém
	function pegaNumeros(sValor)
	{
		var sValida = "0123456789", i = 0;
		while (i < sValor.length) 
		{
			if (sValida.indexOf(sValor.charAt(i)) < 0) 
			{
				sValor = sValor.substring(0,i) + sValor.substring(i+1,sValor.length)
			} else i++;	
		}
		return sValor
	}
	
	
		// ************ Validação de Data **********************
	function isDate(strData)
	{
		//verifica se a data foi digitada corretamente
		strData = retiraEspaco(strData);
		if (isEmpty(strData)) 
			return false;
		var strNum = "0123456789/";
		var Size = strData.length;
		//testa a validade dos caracteres que formam a data
		for (var i=0; i<Size; i++) {
			if (strNum.indexOf(strData.charAt(i)) < 0)
				return false;
		}
			
		var Pos1 = strData.indexOf("/");
		var Pos2 = strData.lastIndexOf("/");
		if (!(Pos1==2 && Pos2==5)) return false;
						
		a = strData.split("/");
		if (a.length == 3 && a[2].length==4 && a[2]>0) {
			if ((a[1]<1) || (a[1]>12)) 
				return false;
			else if ((a[0]<1) || (a[0]>numDias(a[1], a[2])))
					return false;
		} else return false;
			
		return true;
	}
	
		function numDias(intMes,intAno)	{
		//retorna o número de dias de um mês em um ano qualquer
		var Dias;
		intMes = parseInt(intMes, 10);
		intAno = parseInt(intAno, 10);
			
		switch(intMes) {
			case 1: 
			case 3:
			case 5:
			case 7:
			case 8:
			case 10:
			case 12: Dias = 31; break;
			case 4:
			case 6:
			case 9:
			case 11: Dias = 30;	break;
			case 2:
				Dias = 28;
				if (((intAno%400)==0) || ((intAno%100)!=0 && (intAno%4)==0)) 
					Dias++; 
				break;
			default:
				Dias = 0;
				alert("DATA DESCONHECIDA");
		}
		return Dias;
	}
	
	
		function retiraEspaco(theString) {
		//retira todos os espaços de uma string
		if (theString.indexOf(" ") >= 0) {
			var i = 0;
			while (theString.indexOf(" ") >= 0) {
				if (theString.charAt(i) == " ") 
					theString = theString.substring(0,i) + theString.substring(i+1,theString.length);
				else i++
			}
			newString = theString;
		} 
		else newString = theString;
		return newString;
	}
	
	//-->