//------------------------------------------------------------//
//DATA: 06/06/2011
//PROGR.: Carlos Alberto Vettorato
//FUNÇÃO: Arquivo Genérico de Funções JavaScript
//------------------------------------------------------------//

//------------------------------------------------------------//
// Funções JQuery
//------------------------------------------------------------/
function enviar(url) {
//loading
   $(document).ready(function() {
   $().ajaxStart(function() {
   $('#loading').show(); });
   $().ajaxStop(function() {
   $('#loading').hide(); });
  });
//fim loading
   $.ajax({
   url: url,
   type: 'post',
   complete: function(xml) {
   $('#pagina').html( xml.responseText);
  }
 });
}

//------------------------------------------------------------//
// VALIDA LOGIN
//------------------------------------------------------------//
function validaLogin(form)
{

	if(form.login.value == "") {
		 alert("Favor colocar o seu LOGIN !!!");
		 form.login.focus();
		 return(false);
	}
	if(form.senha.value == "") {
		 alert("Coloque a sua SENHA !!!");
		 form.senha.focus();
		 return(false);
	}

	return (true);

}

//------------------------------------------------------------//
// VALIDAR CAMPOS FORMULÁRIO CONTATO
//------------------------------------------------------------//
function validaFormContato(theForm)
{

	if(theForm.nome.value == "") {
		 alert("Você não colocou o seu nome!!!");
		 theForm.nome.focus();
		 return(false);
	}

	if(theForm.email.value == "") {
		 alert("Favor colocar um e-mail válido!!!");
		 theForm.email.focus();
		 return(false);
	}

	if(theForm.area.value == "") {
		 alert("Favor colocar código de área!!!");
		 theForm.area.focus();
		 return(false);
	}

	if(theForm.fone.value == "") {
		 alert("Favor colocar o fone!!!");
		 theForm.fone.focus();
		 return(false);
	}

	if(theForm.assunto.value == "") {
		 alert("Você não preencheu o assunto!!!");
		 theForm.assunto.focus();
		 return(false);
	}

	if(theForm.mensagem.value == "") {
		 alert("Você não colocou a sua mensagem!!!");
		 theForm.mensagem.focus();
		 return(false);
	}

	return (true);
}
//------------------------------------------------------------//
// VALIDAR CAMPOS FORMULÁRIO CONSULTA
//------------------------------------------------------------//
function validaFormConsulta(theForm)
{

	if(theForm.nome.value == "") {
		 alert("Você não colocou o seu nome!!!");
		 theForm.nome.focus();
		 return(false);
	}

	if(theForm.email.value == "") {
		 alert("Favor colocar um e-mail válido!!!");
		 theForm.email.focus();
		 return(false);
	}
	
	if(theForm.cpf.value == "") {
		 alert("Favor colocar o CPF!!!");
		 theForm.cpf.focus();
		 return(false);
	}

	if(theForm.area.value == "") {
		 alert("Favor colocar código de área!!!");
		 theForm.area.focus();
		 return(false);
	}

	if(theForm.fone.value == "") {
		 alert("Favor colocar o fone!!!");
		 theForm.fone.focus();
		 return(false);
	}

	if(theForm.assunto.value == "") {
		 alert("Você não preencheu o assunto!!!");
		 theForm.assunto.focus();
		 return(false);
	}

	if(theForm.mensagem.value == "") {
		 alert("Você não colocou a sua mensagem!!!");
		 theForm.mensagem.focus();
		 return(false);
	}

	return (true);
}

//------------------------------------------------------------//
// SAUDAÇÃO - DATA
//------------------------------------------------------------//
{
  var now = new Date();
  var mName = now.getMonth() + 1;
  var dName = now.getDay() + 1;
  var dayNr = now.getDate();
  var yearNr=now.getYear();
  var nHours = now.getHours();
  if(dName==1) Day = "Domingo";
  if(dName==2) Day = "Segunda-feira";
  if(dName==3) Day = "Ter&ccedil;a-feira";
  if(dName==4) Day = "Quarta-feira";
  if(dName==5) Day = "Quinta-feira";
  if(dName==6) Day = "Sexta-feira";
  if(dName==7) Day = "S&aacute;bado";
  if(yearNr < 2000) Year = 1900 + yearNr;
  else Year = yearNr;
  if((nHours < 12) && (nHours >= 5)) {Saudacao = "Bom dia.";}
  if((nHours >= 12) && (nHours < 19)) {Saudacao = "Boa tarde.";}
  if((nHours >= 19) && (nHours < 24)) {Saudacao = "Boa noite.";}
  if((nHours >= 0) && (nHours < 5)) {Saudacao = "Boa madrugada.";}

  	if(dayNr < 10) {
  		var dia =(" " + Day + ", 0" + dayNr); } else {var dia =(" " + Day + ", " + dayNr) ;
	}
  	if(mName < 10) {
  		var mes =("/0" + mName + "/" + Year); } else {var mes =("/" + mName + "/" + Year) ;
	}
	var todaysDate =(dia + mes) ;
	var saudar =(Saudacao + " Seja bem-vindo");
}


