// JavaScript Document

/*---- FUNCAO DATA ------------------------------------------------------------------------------------------------------*/
function PrintDate(){
	var now = new Date();
	var mName = now.getMonth() + 1;
	var dayNr = now.getDate();
	var yearNr=now.getYear();
	var daynow = now.getDay();
	if(mName==1) Month = "Janeiro";
	if(mName==2) Month = "Fevereiro";
	if(mName==3) Month = "Mar&ccedil;o";
	if(mName==4) Month = "Abril";
	if(mName==5) Month = "Maio";
	if(mName==6) Month = "Junho";
	if(mName==7) Month = "Julho";
	if(mName==8) Month = "Agosto";
	if(mName==9) Month = "Setembro";
	if(mName==10) Month = "Outubro";
	if(mName==11) Month = "Novembro";
	if(mName==12) Month = "Dezembro";
	
	if(daynow==0) semana = "Domingo";
	if(daynow==1) semana = "Segunda-Feira";
	if(daynow==2) semana = "Ter&ccedil;a-Feira";
	if(daynow==3) semana = "Quarta-Feira";
	if(daynow==4) semana = "Quinta-Feira";
	if(daynow==5) semana = "Sexta-Feira";
	if(daynow==6) semana = "S&aacute;bado";
	if(yearNr < 2000) Year = 1900 + yearNr;
	else Year = yearNr;
	
	// String to display current date.
	var todaysDate =(semana+", " + dayNr + " de " + Month + " de " + Year + ".");
	document.write(todaysDate);
}

/*---- FORMULARIO ------------------------------------------------------------------------------------------------------*/
/*PREENCHIMENTO PADRAO*/
	//Entrada do campos
	function padraoIn(id, conteudo) {
		if(document.getElementById(id).value == conteudo) {
			document.getElementById(id).value = '';
			return true;
		}
	}
	
	//Saindo do campos
	function padraoOut(id, conteudo) {
		if(document.getElementById(id).value == '') {
			document.getElementById(id).value = conteudo;
			return true;
		}
	}


/*CAMPOS OBRIGATORIOS*/
	//Funcao para destacar campos
	function camposObrigatorios(form, total) {
		for (var i=1; i<=total; i++) {
			document.getElementById('Obrig'+ form + i).style.color="#EE0000";
		}
	}
	
	//Funcao para ofuscar campos
	function limpaCamposObrig(form, total) {
		for (var i=1; i<=total; i++) {
			document.getElementById('Obrig'+ form + i).style.color="#000000";
		}
	}

/*CAMPOS RESET*/
	function camposReset(form, total){
		// Chama função ZERA CAMPOS OBRIGATORIOS
		limpaCamposObrig(form, total);
		
		// LIMPA CAMPOS E DEFINE FOCUS
		document.getElementById(form).reset();
		document.getElementById('empresa'+form).focus();
	}
	
	// Limpa campos da pagina anterior
		function ParentCamposReset(form, total){
			window.opener.camposReset(form, total);
		}
	
/*VALIDA FORMULARIOS*/

	//Form INFORMACOES
	function validaFormContato(form, total) {
		
		// Função de validação do campo
			var contato = document.getElementById('contato'+form).value;
			
			if ( contato == null || contato == '' || contato.length<3){
				//Obrigatorios
				limpaCamposObrig(form, total);
				document.getElementById('Obrig'+ form + '1').style.color="#EE0000";
				//Alerta
				alert("Preencha o CONTATO corretamente");
				document.getElementById('contato'+form).focus();
				
				return false;
			}

		// Função de validação do campo
			var email = document.getElementById('email'+form).value;
			
			parte1 = email.indexOf("@");
			parte2 = email.indexOf(".");
			parte3 = email.length;
			
			if ( email == null || email == '' || !(parte1 >= 3 && parte2 >= 6 && parte3 >= 9)) {
				//Obrigatorios
				limpaCamposObrig(form, total);
				document.getElementById('Obrig'+ form + '2').style.color="#EE0000";
				//Alerta
				alert("Preencha o E-MAIL corretamente");
				document.getElementById('email'+form).focus();
				
				return false;
			}

		// Função de validação do campo
			var mensagem = document.getElementById('mensagem'+form).value;
			
			if ( mensagem == null || mensagem == "" || mensagem.length<3) {
				//Obrigatorios
				limpaCamposObrig(form, total);
				document.getElementById('Obrig'+ form + '3').style.color="#EE0000";
				//Alerta
				alert("Preencha a MENSAGEM corretamente.");
				document.getElementById('mensagem'+form).focus();
				
				return false;
			}
		
		return true;
	}

