	
	var invalid, s;
	invalid = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;

	var cp = new cpaint();
	cp.set_response_type('text');
	cp.set_debug(false);

	
	function cad_news() {
		cp.call('newsletter.php', 'cad_news', resposta, document.getElementById('news_nome').value, document.getElementById('news_email').value);
		return false;
	}
	
	function resposta(resultado) {
		document.all.newsletterBox.style.display = 'none';
		document.all.resp_newsletter.style.display = '';
		document.getElementById('resp_newsletter').innerHTML = resultado;
	}
		
	function back_news() {
		document.all.newsletterBox.style.display = '';
		document.all.resp_newsletter.style.display = 'none';
	}
		  
		
	function doSubmit(src) {
		window.location = src;
	}

	function valida_contato() {
	
		var src = document.contato;
		
		if (src.nome.value == "") {
			alert("Portal UNIPACS\n\nO campo nome deve ser preenchido.");
			src.nome.focus();	
			return false;	
		}
		
		if (src.email.value.length == 0)	{
			alert("Portal UNIPACS\n\nO Campo Email é obrigatório.");
			src.email.focus();
			return false;	
		}
	
		if (invalid.test(src.email.value) == false) {
			alert("Portal UNIPACS\n\nO endereço de e-mail é inválido!");
			src.email.focus();
			return false; 
		}
		
		if (src.assunto.value == "") {
			alert("Portal UNIPACS\n\nO campo Assunto deve ser preenchido.");
			src.assunto.focus();		
			return false;	
		}
		if (src.mensagem.value == "") {
			alert("Portal UNIPACS\n\nO campo Mensagem deve ser preenchido.");
			src.mensagem.focus();		
			return false;	
		}
		
		src.action = "main.php?tipo=1&cod=6";
		src.submit();
	
	}
	
	function valida_curriculo() {
	
		var src = document.curric;
		
		if (src.nome.value == "") {
			alert("Portal UNIPACS\n\nO campo nome deve ser preenchido.");
			src.nome.focus();	
			return false;	
		}
		
		if (src.email.value.length == 0)	{
			alert("Portal UNIPACS\n\nO Campo Email é obrigatório.");
			src.email.focus();
			return false;	
		}
	
		if (invalid.test(src.email.value) == false) {
			alert("Portal UNIPACS\n\nO endereço de e-mail é inválido!");
			src.email.focus();
			return false; 
		}
		
		if (src.curriculo.value == "") {
			alert("Portal UNIPACS\n\nO campo Curriculo deve conter seu curriculo em anexo.");
			src.curriculo.focus();		
			return false;	
		}
		if (src.mensagem.value == "") {
			alert("Portal UNIPACS\n\nO campo Mensagem deve ser preenchido.");
			src.mensagem.focus();		
			return false;	
		}
		
		src.action = "main.php?tipo=1&cod=7&enviar=1";
		src.submit();
	
	}

	
	//função de validação de cadastro de novos usuários
	function valida_interesse(tipo) {
	
		var src = document.interesse;
		if (src.nome.value == "") {
			alert("Portal UNIPACS\n\nO campo nome deve ser preenchido.");
			src.nome.focus();	
			return false;	
		}
	
		if (src.telefone.value == "") {
			alert("Portal UNIPACS\n\nO campo Telefone deve ser preenchido.");
			src.telefone.focus();		
			return false;	
		}

		if (src.email.value.length == 0)	{
			alert("Portal UNIPACS\n\nO Campo Email deve ser preecnchido.");
			src.email.focus();
			return false;	
		}
	
		if (invalid.test(src.email.value) == false) {
			alert("Portal UNIPACS\n\nO endereço de e-mail é inválido!");
			src.email.focus();
			return false; 
		}

		if (src.curso.value == "") {
			alert("Portal UNIPACS\n\nO campo Curso deve ser preenchido.");
			src.curso.focus();		
			return false;	
		}

		
		if (src.turno[0].checked == false && src.turno[1].checked == false && src.turno[2].checked == false) {
			alert("Portal UNIPACS\n\nVocê deve marcar o turno do curso.");
			src.turno[0].focus();
			return false;
		}

		src.action = "main.php?tipo=5&cod=1&tp="+tipo+"&enviar=1";
		src.submit();
	
	}
	
	//função de validação de cadastro na newsletter
	function valida_newsletter(src) {
		if (src.news_nome.value.length == 0) {
			alert("Portal UNIPACS\n\nO preenchimento do campo Nome é obrigatório.");
			src.news_nome.focus();
			return false;
		}

		if (src.news_email.value.length == 0) {
			alert("Portal UNIPACS\n\nO preenchimento do campo E-mail é obrigatório.");
			src.news_email.focus();
			return false;
		}
		
		if (invalid.test(src.news_email.value) == false) {
			alert("Portal UNIPACS\n\nO endereço de e-mail é inválido.");
			src.news_email.focus();
			return false; 
		}
		cad_news();
	}
	

	
		//função de formatação de números de telefone	
	function TelefoneFormat(Campo, e) { 
		var key = ''; 
		var len = 0; 
		var strCheck = '0123456789'; 
		var aux = ''; 
		var whichCode = (window.Event) ? e.which : e.keyCode; 
		 
			if (whichCode == 13 || whichCode == 8 || whichCode == 0) { 
				return true;  // Enter backspace ou FN qualquer um que não seja alfa numerico 
			} 
			key = String.fromCharCode(whichCode); 
			if (strCheck.indexOf(key) == -1) { 
				return false;  //NÃO E VALIDO 
			} 
		 
			aux =  Telefone_Remove_Format(Campo.value); 
			len = aux.length; 
	
			if(len>=10) { 
				return false;    //impede de digitar um telefone maior que 10 
			} 
	   
			aux += key; 
			Campo.value = Telefone_Mont_Format(aux); 
			return false; 
	} 

	function  Telefone_Mont_Format(Telefone) { 
		var aux = len = ''; 
		 
		len = Telefone.length; 
			if(len<=9) { 
				tmp = 5; 
			} else { 
				tmp = 6; 
			} 
		 
		aux = ''; 
		for(i = 0; i < len; i++) { 
			if (i==0) { 
				aux = '('; 
			} 
			
			aux += Telefone.charAt(i); 
			if (i+1==2) { 
				aux += ')'; 
			} 
			 
			if (i+1==tmp) { 
				aux += '-'; 
			} 
		} 
		return aux ; 
	} 

	function  Telefone_Remove_Format(Telefone) { 
		var strCheck = '0123456789'; 
		var len = i = aux = ''; 
		len = Telefone.length; 
		for(i = 0; i < len; i++) { 
			if (strCheck.indexOf(Telefone.charAt(i))!=-1) { 
				aux += Telefone.charAt(i); 
			} 
		} 
		return aux; 
	} 
	
	function limpa_string(S){
		var Digitos = "0123456789";
		var temp = "";
		var digito = "";
	
		for (var i=0; i<S.length; i++)	{
			digito = S.charAt(i);
			if (Digitos.indexOf(digito)>=0)	{
				temp=temp+digito	}
		} 
	
		return temp
	}
	
// script para validação de datas existentes
	function ValidaData(objeto) 
	{ 
	
		var DataString    = objeto.value; 
		var DataArray    = DataString.split("/");   
		var Flag=true; 
	
		if (DataArray.length != 3) 
			Flag=false; 
		else 
			{ 
				if (DataArray.length==3) 
				{ 
					var dia = DataArray[0], mes = DataArray[1], ano = DataArray[2]; 
	
					if (((Flag) && (ano<1000) || ano.length>4)) 
						Flag=false; 
					 
					if (Flag) 
					{ 
						verifica_mes = new Date(mes+"/"+dia+"/"+ano); 
						if (verifica_mes.getMonth() != (mes - 1)) 
							Flag=false; 
					} 
				} 
				else 
					Flag=false; 
			} 
	return Flag; 
	} 

	
	function FormataData(objeto,teclapress) 
	{ 
		var tecla = teclapress.keyCode; 
	
		if(((window.event.keyCode == 13) || (window.event.keyCode == 9))&&objeto.value != "") 
		{ 
			if(!(ValidaData(objeto))) 
				{ 
					window.event.cancelBubble = true; 
					window.event.returnValue = false; 
					alert("Poa Produções\n\nData digitada é inválida."); 
					objeto.value = ""; 
					objeto.focus(); 
				} 
		} 
	
		if (( tecla == 8 || tecla == 88 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 )&& objeto.value.length < (10)) 
		{ 
			vr = objeto.value; 
			vr = vr.replace( "/", "" ); 
			vr = vr.replace( "/", "" ); 
			tam = vr.length; 
	
			if (tam < 8) 
				{ 
					if (tecla != 8) {tam = vr.length + 1 ;} 
				} 
			else 
				{ 
					window.event.cancelBubble = true; 
					window.event.returnValue = false; 
				} 
			 
			if ((tecla == 8) && (tam > 1)) 
				{ 
					tam = tam - 1 ; 
					objeto.value = vr.substr(0,tam); 
					window.event.cancelBubble = true; 
					window.event.returnValue = false; 
				} 
					if ( tam <= 4 && tecla != 8){ 
						 objeto.value = vr ; } 
	
					if ( (tam >= 4) && (tam <= 6) ){ 
						 objeto.value = vr.substr(0, tam - 4) + '/' + vr.substr( tam - 4, 4 ); } 
	
					if ( (tam >= 6) && (tam <= 8) ){ 
						objeto.value = vr.substr(0, tam - 6 ) + '/' + vr.substr( tam - 6, 2 ) + '/' + vr.substr( tam - 4, 4 ); } 
	
					if ((tam == (8)) && tecla != 8) 
						{ 
							if(tecla >=96 && tecla <=105) 
								{ 
									tecla = tecla - 48; 
								} 
	
							objeto.value = objeto.value + (String.fromCharCode(tecla)); 
							window.event.cancelBubble = true; 
							window.event.returnValue = false; 
	
							if (!(ValidaData(objeto))) 
								{ 
									alert("Poa Produções\n\nData digitada é inválida."); 
									objeto.value = ""; 
									objeto.focus(); 
								} 
						} 
		} 
		else if((window.event.keyCode != 8) && (window.event.keyCode != 9) && (window.event.keyCode != 13) && (window.event.keyCode != 35) && (window.event.keyCode != 36) && (window.event.keyCode != 46)) 
			{ 
				event.returnValue = false; 
			} 
	} 


