function openPopUp(URL, NAME, OPTIONS) {
  window.open(URL, NAME, OPTIONS)
}

function ValidaEmail(sEmail) {
  var regex=/^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/;
  return regex.test(sEmail);
}

function ValidaCampo(campo,msg,minimo){
  if(campo.value==''){alert('Informe '+msg+'.');return false;}
  else{if(campo.value.length<minimo){alert('Preencha '+msg+' corretamente.');return false;}}
  return true;
}

function LimitaTexto(CampoTexto,MaxChars,iIdioma){
//Limita a quantidade de caracteres de CampoTexto a MaxChars
  if(CampoTexto.value.length>MaxChars){
    CampoTexto.value=CampoTexto.value.substring(0,MaxChars);
    if(iIdioma==0)alert('Este campo pode conter até '+MaxChars+' caracteres.');
    else if(iIdioma==1)alert('Maximum capacity is '+MaxChars+' characters.');
    else if(iIdioma==2)alert('Este campo puede contener hasta '+MaxChars+' caracteres.');
    else if(iIdioma==3)alert('Este campo pode conter até '+MaxChars+' caracteres.');
    CampoTexto.focus();
    }
}

function ValidaCEP(campo) {
  var validos="0123456789-";
  var NumHifens=0;
  if (campo.length<8)return false;
  for (var i=0;i<campo.length;i++) {
    temp=""+campo.substring(i,i+1);
    if(temp=="-") NumHifens++;
    if(validos.indexOf(temp)=="-1")return false;
    if(NumHifens>0 && ""+campo.charAt(5)!="-")return false;
  }
  return true;
}

function ValidaFaleConosco(theForm){
  if (theForm.remetente.value=="") {
    alert("Informe seu nome.");
    theForm.remetente.focus();
    return(false);
  }
  if (theForm.email_remetente.value==""){
    alert("Informe seu e-mail.");
    theForm.email_remetente.focus();
    return(false);
  }
  if (theForm.assunto.value==""){
    alert("Informe um assunto.");
    theForm.assunto.focus();
    return(false);
  }
  if (theForm.mensagem.value==""){
    alert("Digite sua mensagem.");
    theForm.mensagem.focus();
    return(false);
  }
  if (!ValidaEmail(theForm.email_remetente.value)){
    alert("E-mail inválido.");
    theForm.email_remetente.focus();
    return(false);
  }
  theForm.submit();
}

function ValidaPergunta(theForm){
  if (theForm.nome.value=="") {
    alert("Informe seu nome.");
    theForm.nome.focus();
    return(false);
  }
  if (theForm.email.value==""){
    alert("Informe seu e-mail.");
    theForm.email.focus();
    return(false);
  }
  if (theForm.pergunta.value==""){
    alert("Informe sua pergunta.");
    theForm.pergunta.focus();
    return(false);
  }
  if (!ValidaEmail(theForm.email.value)){
    alert("E-mail inválido.");
    theForm.email.focus();
    return(false);
  }
  return (true);
}

function ValidaFranquias(theForm){
  if (theForm.nome.value=="") {
    alert("Informe seu nome.");
    theForm.nome.focus();
    return(false);
  }
  if (theForm.email.value==""){
    alert("Informe seu e-mail.");
    theForm.email.focus();
    return(false);
  }
  if (theForm.cidadeestado.value==""){
    alert("Informe sua cidade e estado.");
    theForm.cidadeestado.focus();
    return(false);
  }
  if (theForm.mensagem.value==""){
    alert("Digite sua mensagem.");
    theForm.mensagem.focus();
    return(false);
  }
  if (!ValidaEmail(theForm.email.value)){
    alert("E-mail inválido.");
    theForm.email.focus();
    return(false);
  }
  theForm.submit();
}

function ValidaModelos(theForm){
  if (theForm.nome.value=="") {
    alert("Informe seu nome.");
    theForm.nome.focus();
    return(false);
  }
  if (theForm.email.value==""){
    alert("Informe seu e-mail.");
    theForm.email.focus();
    return(false);
  }
  if (theForm.idade.value==""){
    alert("Informe sua idade.");
    theForm.idade.focus();
    return(false);
  }
  if (theForm.cidadeestado.value==""){
    alert("Informe sua cidade e estado.");
    theForm.cidadeestado.focus();
    return(false);
  }
  if (theForm.opcao.value==""){
    alert("Informe a opção desejada.");
    theForm.opcao.focus();
    return(false);
  }
  if (theForm.mensagem.value==""){
    alert("Digite sua mensagem.");
    theForm.mensagem.focus();
    return(false);
  }
  if (!ValidaEmail(theForm.email.value)){
    alert("E-mail inválido.");
    theForm.email.focus();
    return(false);
  }
  theForm.submit();
}

function ValidaInscricao(theForm){
  if (theForm.id_turma.value==0) {
    alert("Informe uma turma de interesse.");
    theForm.id_turma.focus();
    return(false);
  }	
  if (theForm.nome.value=="") {
    alert("Informe seu nome.");
    theForm.nome.focus();
    return(false);
  }
  if (theForm.email.value==""){
    alert("Informe seu e-mail.");
    theForm.email.focus();
    return(false);
  }
  if (theForm.telefone.value==""){
    alert("Informe seu telefone.");
    theForm.telefone.focus();
    return(false);
  }
  if (!ValidaEmail(theForm.email.value)){
    alert("E-mail inválido.");
    theForm.email.focus();
    return(false);
  }
  theForm.submit();
}

function PopupPic(url, img)
{ 
	window.open(url +"?img="+ img, "", "resizable=1,HEIGHT=200,WIDTH=200,top=100,left=100");
}

function sw_abrir(elem)
{
	var aberto = document.getElementById(elem).style.display;
	if (aberto == '') {
		document.getElementById(elem).style.display = 'none';
		aberto = 'none';
	} else {
		document.getElementById(elem).style.display = '';
		aberto = '';
	}
}