// JavaScript Document

function exibir(id) {
document.getElementById(id).style.display = "";
}
function ocultar(id) {
document.getElementById(id).style.display = "none";
}

/*abrir nova janela*/
function OpenWindowA(url) {
  window.open(url,"_blank");
}

/*abrir nova janela com parâmetros*/
function NewWindow(url,w,h) {
  window.open(url,"_blank","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width="+w+", height="+h);
}

/*retira os espaços do início e fim de uma string*/
function trim(str){
   return str.replace(/^\s*|\s*$/g,"");
}

/*verifica se é um e-mail válido*/
function ValidaEmail(email) {
  var padrao = '^([0-9,a-z,A-Z]+)([.,_,-]([0-9,a-z,A-Z]+))*[@]([0-9,a-z,A-Z]+)([.,_,-]([0-9,a-z,A-Z]+))*[.]([a-z,A-Z]){2,3}([0-9,a-z,A-Z])?$';
  var reg = new RegExp(padrao);
  var result = reg.exec(email);
	if(result != null)
	  return true;
	else
	  return false;
}

/*validação dos campos do formulário*/
function ValidaForm(form) {
  var erros = Array();
  var foco = null;
  var nomeform = form;

    if (nomeform.nome) {
	  nomeform.nome.value = trim(nomeform.nome.value);
	    if(nomeform.nome.value == "") {
		  erros.push('Le champs "nom" est obligatoire.');
		if (foco == null)
		  foco = nomeform.nome;
		}
	}

	if (nomeform.email) {
	  nomeform.email.value = trim(nomeform.email.value);
	    if (!ValidaEmail(nomeform.email.value)) {
		  erros.push('Email invalide.');
		if (foco == null)
		  foco = nomeform.email;
		}
	}

	if (nomeform.mensagem) {
	  nomeform.mensagem.value = trim(nomeform.mensagem.value);
	    if (nomeform.mensagem.value == "") {
		  erros.push('Ecrire un message, S´il vous plait.');
		if (foco == null)
		  foco = nomeform.mensagem;
		}
	}

	if (nomeform.tel) {
	  nomeform.tel.value = trim(nomeform.tel.value);
	    if (nomeform.tel.value == "") {
		  erros.push('Favor preencher um telefone.');
		if (foco == null)
		  foco = nomeform.tel;
		}
	}

	numErros = erros.length;
	if (numErros > 0) {
	  msg = 'Attention:';
	  for (i = 0; i < numErros; i++) {
	    msg += '\n » ' + erros[i];
	  }
	  alert(msg);
	  foco.focus();
	  return false;
	} else {
	  nomeform.submit();
	  return true;
	}
}