

/* ----------------------------------------------------------------------------
 * scripts.js
 * ----------------------------------------------------------------------------
 */
 
function mostraFlash(arquivo, width, height) {
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="' + width + '" height="' + height + '">');
	document.write('<param name="movie" value="' + arquivo + '">');
	document.write('<param name="quality" value="high">');
	document.write('<embed src="' + arquivo + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + width + '" height="' + height + '"></embed>');
	document.write('</object>');
}

function mostraFlashTransparente(arquivo, width, height) {
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="' + width + '" height="' + height + '">');
	document.write('<param name="movie" value="' + arquivo + '">');
	document.write('<param name="quality" value="high">');
	document.write('<param name="wmode" value="transparent">');
	document.write('<embed src="' + arquivo + '" quality="high" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + width + '" height="' + height + '"></embed>');
	document.write('</object>');
}

/* ----------------------------------------------------------------------------
 * validacoes.js
 * ----------------------------------------------------------------------------
 */

function validaFormLogon() {    

  var caDoc = document.getElementById("caDoc");
  var anSenha = document.getElementById("anSenha");

  if (isEmpty(caDoc) || !validaCpf(caDoc.value)) {
    caDoc.focus();
    mostraAlerta("CPF inv&aacute;lido.");
    return false;
  }	

  if (isEmpty(anSenha) || anSenha.value.length < 6) {
    anSenha.focus();
    mostraAlerta("Senha inv&aacute;lida.");
    return false;
  }	

  return true;
}


function validaFormAlterarSenha() {    

  var caDoc = document.getElementById("caDoc");
  var anSenhaAtual = document.getElementById("anSenhaAtual");
  var anSenhaNova = document.getElementById("anSenhaNova");
  var anSenhaNovaConfirma = document.getElementById("anSenhaNovaConfirma");

  if (isEmpty(anSenhaAtual) || anSenhaAtual.value.length < 6) {
    anSenhaAtual.focus();
    mostraAlerta("Senha atual inv&aacute;lida. [m&iacute;nimo de 06 caracteres]");
    return false;
  }	

  if (isEmpty(anSenhaNova) || anSenhaNova.value.length < 6) {
    anSenhaNova.focus();
    mostraAlerta("Nova senha inv&aacute;lida. [m&iacute;nimo de 06 caracteres]");
    return false;
  }	

  if (isEmpty(anSenhaNovaConfirma) || anSenhaNovaConfirma.value.length < 6) {
    anSenhaNovaConfirma.focus();
    mostraAlerta("Confirma&ccedil;&atilde;o de senha inv&aacute;lida. [m&iacute;nimo de 06 caracteres]");
    return false;
  }	

  if (anSenhaNovaConfirma.value != anSenhaNovaConfirma.value) {
    anSenhaNovaConfirma.focus();
    mostraAlerta("Confirma&ccedil;&atilde;o de senha inv&aacute;lida.");
    return false;
  }	


  return true;
}



function validaFormCadastroP1() {    

  var preCadastro_caDoc = document.getElementById("preCadastro.caDoc");
  var preCadastro_anEmail = document.getElementById("preCadastro.anEmail");
  var preCadastro_anEmailConf = document.getElementById("preCadastro.anEmailConf");
  var preCadastro_anSenha = document.getElementById("preCadastro.anSenha");
  var preCadastro_anSenhaConfirma = document.getElementById("preCadastro.anSenhaConfirma");
  var preCadastro_nmTelResDdd = document.getElementById("preCadastro.nmTelResDdd");
  var preCadastro_nmTelResNumero = document.getElementById("preCadastro.nmTelResNumero");
  var preCadastro_boParticiparProgrRelac = document.getElementById("preCadastro.boParticiparProgrRelac");

  
  if (!preCadastro_boParticiparProgrRelac.checked) {
		preCadastro_boParticiparProgrRelac.focus();
		mostraAlerta("Para prosseguir com o seu cadastramento, &eacute; necess&aacute;rio que leia o regulamento e aceite os crit&eacute;rios de participa&ccedil;&atilde;o do programa de relacionamento t vantagens.");
		return false;
  	
  }
  
  if (isEmpty(preCadastro_caDoc)) {
    preCadastro_caDoc.focus();
    mostraAlerta("Digite o seu CPF.");
    return false;
  }	

  if (!validaCpf(preCadastro_caDoc.value)) {
    preCadastro_caDoc.focus();
    mostraAlerta("Digite um CPF v&aacute;lido.");  
    return false;
  }
  
  if (isEmpty(preCadastro_anEmail) || preCadastro_anEmail.value.length < 4 || !isValidMail(preCadastro_anEmail.value)) {
      preCadastro_anEmail.focus();
      mostraAlerta("Endere&ccedil;o de e-mail inv&aacute;lido.");
      return false;
  }
  
  if (isEmpty(preCadastro_anEmailConf) || preCadastro_anEmailConf.value.length < 4 || !isValidMail(preCadastro_anEmailConf.value)) {
      preCadastro_anEmailConf.focus();
      mostraAlerta("Confirma&ccedil;&atilde;o do endere&ccedil;o de e-mail inv&aacute;lido.");
      return false;
  }

  if (preCadastro_anEmailConf.value != preCadastro_anEmail.value) {
      preCadastro_anEmailConf.focus();
      mostraAlerta("A confirma&ccedil;&atilde;o do seu e-mail est&aacute; incorreta.");
      return false;
  }


  if (isEmpty(preCadastro_anSenha) || preCadastro_anSenha.value.length < 6) {
    preCadastro_anSenha.focus();
    mostraAlerta("Digite uma senha com no m&iacute;nimo 06 caracteres.");
    return false;
  }	


  if (isEmpty(preCadastro_anSenhaConfirma) || preCadastro_anSenhaConfirma.value != preCadastro_anSenha.value ) {
    preCadastro_anSenhaConfirma.focus();
    mostraAlerta("A confirma&ccedil;&atilde;o da sua senha n&atilde;o confere com a senha digitada.");
    return false;
  }
  
	if (isEmpty(preCadastro_nmTelResDdd) || preCadastro_nmTelResDdd.value.length < 2) {
	  preCadastro_nmTelResDdd.focus();
	  mostraAlerta("Informe o DDD do n&uacute;mero de telefone residencial");
	  return false;
	}	
	
	if (isEmpty(preCadastro_nmTelResNumero) || preCadastro_nmTelResNumero.value.length < 6 ) {
	  preCadastro_nmTelResNumero.focus();
	  mostraAlerta("Informe o n&uacute;mero de telefone residencial");
	  return false;
	}	

  return true;
}
	
function validaFormCadastroP2Email() {    

  var preCadastro_anEmail = document.getElementById("anEmail");
  
  if (isEmpty(preCadastro_anEmail) || !isValidMail(preCadastro_anEmail.value)) {
      preCadastro_anEmail.focus();
      mostraAlerta("Endere&ccedil;o de e-mail inv&aacute;lido.");
      return false;
  }
    
  return true;
}



function validaFormCadastroP2Nass() { 

  var participante_anNome = document.getElementById("participante.anNome");
  var participante_anEmail = document.getElementById("participante.anEmail");
  var participante_caCep = document.getElementById("participante.caCep");
  var participante_anEndereco = document.getElementById("participante.anEndereco");
  var participante_nmEnderecoNumero = document.getElementById("participante.nmEnderecoNumero");
  var participante_anEnderecoBairro = document.getElementById("participante.anEnderecoBairro");
  var participante_anEnderecoCidade = document.getElementById("participante.anEnderecoCidade");
  var participante_anEnderecoUf = document.getElementById("participante.anEnderecoUf");
  var participante_caTvAssinatura = document.getElementById("participante.caTvAssinatura");

  if (isEmpty(participante_anNome) || participante_anNome.value.length < 6) {
    participante_anNome.focus();
    mostraAlerta("Digite o seu nome completo");
    return false;
  }	

  if (isEmpty(participante_anEmail) || !isValidMail(participante_anEmail.value)) {
      participante_anEmail.focus();
      mostraAlerta("Endere&ccedil;o de e-mail inv&aacute;lido.");
      return false;
  }


  if (isEmpty(participante_caCep) || participante_caCep.value.length < 8) {
    participante_caCep.focus();
    mostraAlerta("Digite um CEP v&aacute;lido");
    return false;
  }	

  if (isEmpty(participante_anEndereco) || participante_anEndereco.value.length < 3) {
    participante_anEndereco.focus();
    mostraAlerta("Digite um endere&ccedil;o v&aacute;lido");
    return false;
  }	

  if (isEmpty(participante_nmEnderecoNumero) || participante_nmEnderecoNumero.value.length == 0) {
    participante_nmEnderecoNumero.focus();
    mostraAlerta("Digite um n&uacute;mero v&aacute;lido para o endere&ccedil;o");
    return false;
  }	

  if (isEmpty(participante_anEnderecoBairro) || participante_anEnderecoBairro.value.length < 3) {
    participante_anEnderecoBairro.focus();
    mostraAlerta("Digite um bairro v&aacute;lido");
    return false;
  }	

  if (isEmpty(participante_anEnderecoCidade) || participante_anEnderecoCidade.value.length < 3) {
    participante_anEnderecoCidade.focus();
    mostraAlerta("Digite uma cidade v&aacute;lida");
    return false;
  }	

  if (isEmpty(participante_anEnderecoUf)) {
    participante_anEnderecoUf.focus();
    mostraAlerta("Selecione o Estado");
    return false;
  }	

  if (isEmpty(participante_caTvAssinatura)) {
    participante_caTvAssinatura.focus();
    mostraAlerta("Informe qual TV por assinatura voc&ecirc;e possui");
    return false;
  }	

  return true;
}


function validaFormAlteraCadastroNass() { 

  var participante_anEmail = document.getElementById("participante.anEmail");
  var participante_anRespostaPerguntaSecreta = document.getElementById("participante.anRespostaPerguntaSecreta");
  var participante_caCep = document.getElementById("participante.caCep");
  var participante_anEndereco = document.getElementById("participante.anEndereco");
  var participante_nmEnderecoNumero = document.getElementById("participante.nmEnderecoNumero");
  var participante_anEnderecoBairro = document.getElementById("participante.anEnderecoBairro");
  var participante_anEnderecoCidade = document.getElementById("participante.anEnderecoCidade");
  var participante_anEnderecoUf = document.getElementById("participante.anEnderecoUf");
  var participante_caTvAssinatura = document.getElementById("participante.caTvAssinatura");


  if (isEmpty(participante_anEmail) || !isValidMail(participante_anEmail.value)) {
      participante_anEmail.focus();
      mostraAlerta("Endere&ccedil;o de e-mail inv&aacute;lido.");
      return false;
  }
  
  
  if (isEmpty(participante_anRespostaPerguntaSecreta)) {
    participante_anRespostaPerguntaSecreta.focus();
    mostraAlerta("Digite uma resposta para a sua pergunta secreta.");
    return false;
  }	

  if (contemString(participante_anRespostaPerguntaSecreta, " ")) {
    participante_anRespostaPerguntaSecreta.value = "";
    participante_anRespostaPerguntaSecreta.focus();
    mostraAlerta("Responda com apenas uma palavra. Isso facilitar&aacute; a sua memoriza&ccedil;&atilde;o.");
    return false;
  }	

  if (isEmpty(participante_caCep) || participante_caCep.value.length < 8) {
    participante_caCep.focus();
    mostraAlerta("Digite um CEP v&aacute;lido");
    return false;
  }	

  if (isEmpty(participante_anEndereco) || participante_anEndereco.value.length < 3) {
    participante_anEndereco.focus();
    mostraAlerta("Digite um endere&ccedil;o v&aacute;lido");
    return false;
  }	

  if (isEmpty(participante_nmEnderecoNumero) || participante_nmEnderecoNumero.value.length == 0) {
    participante_nmEnderecoNumero.focus();
    mostraAlerta("Digite um n&uacute;mero v&aacute;lido para o endere&ccedil;o");
    return false;
  }	

  if (isEmpty(participante_anEnderecoBairro) || participante_anEnderecoBairro.value.length < 3) {
    participante_anEnderecoBairro.focus();
    mostraAlerta("Digite um bairro v&aacute;lido");
    return false;
  }	

  if (isEmpty(participante_anEnderecoCidade) || participante_anEnderecoCidade.value.length < 3) {
    participante_anEnderecoCidade.focus();
    mostraAlerta("Digite uma cidade v&aacute;lida");
    return false;
  }	

  if (isEmpty(participante_anEnderecoUf)) {
    participante_anEnderecoUf.focus();
    mostraAlerta("Selecione o Estado");
    return false;
  }	

  if (isEmpty(participante_caTvAssinatura)) {
    participante_caTvAssinatura.focus();
    mostraAlerta("Informe qual TV por assinatura voc&ecirc;e possui");
    return false;
  }	

  return true;
}



function validaFormAlteraCadastroAss() { 

  var participante_anEmail = document.getElementById("participante.anEmail");
  var participante_nmTelResDdd = document.getElementById("participante.nmTelResDdd");
  var participante_nmTelResNumero = document.getElementById("participante.nmTelResNumero");
  var participante_anRespostaPerguntaSecreta = document.getElementById("participante.anRespostaPerguntaSecreta");

  if (isEmpty(participante_anEmail) || !isValidMail(participante_anEmail.value)) {
      participante_anEmail.focus();
      mostraAlerta("Endere&ccedil;o de e-mail inv&aacute;lido.");
      return false;
  }
  
  if (isEmpty(participante_nmTelResDdd) || participante_nmTelResDdd.value.length == 0) {
    participante_nmTelResDdd.focus();
    mostraAlerta("Digite um DDD v&aacute;lido");
    return false;
  }	
  
  if (isEmpty(participante_nmTelResNumero) || participante_nmTelResNumero.value.length < 6 ) {
    participante_nmTelResNumero.focus();
    mostraAlerta("Digite um Telefone v&aacute;lido");
    return false;
  }	
  
  if (isEmpty(participante_anRespostaPerguntaSecreta)) {
    participante_anRespostaPerguntaSecreta.focus();
    mostraAlerta("Digite uma resposta para a sua pergunta secreta.");
    return false;
  }	

  if (contemString(participante_anRespostaPerguntaSecreta, " ")) {
    participante_anRespostaPerguntaSecreta.value = "";
    participante_anRespostaPerguntaSecreta.focus();
    mostraAlerta("Responda com apenas uma palavra. Isso facilitar&aacute; a sua memoriza&ccedil;&atilde;o.");
    return false;
  }	

  return true;
}



function validaFormObterLembreteSenha() {    

  var caDoc = document.getElementById("lembrete.caDoc");

  if (isEmpty(caDoc) || !validaCpf(caDoc.value)) {
    caDoc.focus();
    mostraAlerta("CPF inv&aacute;lido.");
    return false;
  }
  	
}
	
function validaFormObterNovaChaveAtivacao() {    

  var caDoc = document.getElementById("lembrete.caDoc");

  if (isEmpty(caDoc) || !validaCpf(caDoc.value)) {
    caDoc.focus();
    mostraAlerta("CPF inv&aacute;lido.");
    return false;
  }
  	
}



function validaFormObterLembreteSenha() {    

  var caDoc = document.getElementById("lembrete.caDoc");

  if (isEmpty(caDoc) || !validaCpf(caDoc.value)) {
    caDoc.focus();
    mostraAlerta("CPF inv&aacute;lido.");
    return false;
  }
  	
}


function validaFormCriarNovaSenha() {    

  var anRespostaPerguntaSecreta = document.getElementById("lembrete.anRespostaPerguntaSecreta");

  if (contemString(anRespostaPerguntaSecreta, " ")) {
    anRespostaPerguntaSecreta.value = "";
    anRespostaPerguntaSecreta.focus();
    mostraAlerta("Responda com apenas uma palavra.");
    return false;
  }	
  
  	
}

function validaFormFaleConoscoTfn() {    

	var contatoTfn_anNome = document.getElementById("contatoTfn.anNome");
	var contatoTfn_anEmail = document.getElementById("contatoTfn.anEmail");
	var contatoTfn_nmTelDdd = document.getElementById("contatoTfn.nmTelDdd");
	var contatoTfn_nmTelNumero = document.getElementById("contatoTfn.nmTelNumero");
	var contatoTfn_caAssunto = document.getElementById("contatoTfn.caAssunto");
	var contatoTfn_anMensagem = document.getElementById("contatoTfn.anMensagem");
  
  
	if (isEmpty(contatoTfn_anNome) || contatoTfn_anNome.value.length < 6) {
	  contatoTfn_anNome.focus();
	  mostraAlerta("Digite o seu nome completo");
	  return false;
	}	

	if (isEmpty(contatoTfn_anEmail) || !isValidMail(contatoTfn_anEmail.value)) {
      contatoTfn_anEmail.focus();
      mostraAlerta("Endere&ccedil;o de e-mail inv&aacute;lido.");
      return false;
	}

	if (isEmpty(contatoTfn_nmTelDdd) || contatoTfn_nmTelDdd.value.length == 0) {
	  contatoTfn_nmTelDdd.focus();
	  mostraAlerta("Selecione o DDD");
	  return false;
	}	
	
	if (isEmpty(contatoTfn_nmTelNumero) || contatoTfn_nmTelNumero.value.length < 6 ) {
	  contatoTfn_nmTelNumero.focus();
	  mostraAlerta("Digite um Telefone v&aacute;lido");
	  return false;
	}	

	if (isEmpty(contatoTfn_caAssunto) || contatoTfn_caAssunto.value.length == 0) {
	  contatoTfn_caAssunto.focus();
	  mostraAlerta("Selecione o Assunto");
	  return false;
	}	

	if (isEmpty(contatoTfn_anMensagem) || contatoTfn_anMensagem.value.length < 10 ) {
	  contatoTfn_anMensagem.focus();
	  mostraAlerta("Digite a sua mensagem");
	  return false;
	}	
    
  	
}


function validaFormFaleConoscoTva() {    

	var contatoTva_anNome = document.getElementById("contatoTva.anNome");
	var contatoTva_anEmail = document.getElementById("contatoTva.anEmail");
	var contatoTva_nmTelefone = document.getElementById("contatoTva.nmTelefone");
	var contatoTva_caAssunto = document.getElementById("contatoTva.caAssunto");
	var contatoTva_anMensagem = document.getElementById("contatoTva.anMensagem");
  
  
	if (isEmpty(contatoTva_anNome) || contatoTva_anNome.value.length < 6) {
	  contatoTva_anNome.focus();
	  mostraAlerta("Digite o seu nome completo");
	  return false;
	}	

	if (isEmpty(contatoTva_anEmail) || !isValidMail(contatoTva_anEmail.value)) {
      contatoTva_anEmail.focus();
      mostraAlerta("Endere&ccedil;o de e-mail inv&aacute;lido.");
      return false;
	}

	if (isEmpty(contatoTva_nmTelNumero) || contatoTva_nmTelNumero.value.length < 6 ) {
	  contatoTva_nmTelNumero.focus();
	  mostraAlerta("Digite um Telefone v&aacute;lido");
	  return false;
	}	

	if (isEmpty(contatoTva_caAssunto) || contatoTva_caAssunto.value.length == 0) {
	  contatoTva_caAssunto.focus();
	  mostraAlerta("Selecione o Assunto");
	  return false;
	}	

	if (isEmpty(contatoTva_anMensagem) || contatoTva_anMensagem.value.length < 10 ) {
	  contatoTva_anMensagem.focus();
	  mostraAlerta("Digite a sua mensagem");
	  return false;
	}	
  	
}


function validaFormFaleConoscoNao() {    

	var contatoNao_anNome = document.getElementById("contatoNao.anNome");
	var contatoNao_anEmail = document.getElementById("contatoNao.anEmail");
	var contatoNao_anMensagem = document.getElementById("contatoNao.anMensagem");
  
  
	if (isEmpty(contatoNao_anNome) || contatoNao_anNome.value.length < 6) {
	  contatoNao_anNome.focus();
	  mostraAlerta("Digite o seu nome completo");
	  return false;
	}	

	if (isEmpty(contatoNao_anEmail) || !isValidMail(contatoNao_anEmail.value)) {
      contatoNao_anEmail.focus();
      mostraAlerta("Endere&ccedil;o de e-mail inv&aacute;lido.");
      return false;
	}

	if (isEmpty(contatoNao_anMensagem) || contatoNao_anMensagem.value.length < 10 ) {
	  contatoNao_anMensagem.focus();
	  mostraAlerta("Digite a sua mensagem");
	  return false;
	}	
  	
}
	
// Scripts gerais

function isEmpty(objeto) {
  if (objeto.value.length == 0) {
    return true;
  }
  return false; 
}
	

function contemString(objeto, caractere) {
  if (objeto.value.indexOf(caractere,0) > -1) {
    return true;
  }
  return false; 
}


function contagemCaracte(objetoCampo, qtdMaxima) {
  qtdRestante = qtdMaxima - objetoCampo.value.length;
  if( qtdRestante <= 0 ) {
    objetoCampo.value=objetoCampo.value.substring(0,qtdMaxima);
  }
}


function apenasNumeroDigitado(evento) {
  var tecla = document.all ? evento.keyCode : evento.which;
  //alert(tecla);
  if (tecla == 0 || tecla == 8) {
     return true;
  } else if (!(tecla >= 48 && tecla <= 57)) {
     return false;
  } else {
     return true;
  }
}


function validaCpf(s) {  var i; 
  var c = s.substr(0,9);
  var dv = s.substr(9,2);
  var d1 = 0;

  for (i = 0; i < 9; i++) {
    d1 += c.charAt(i)*(10-i);
  }

  if (d1 == 0) {
    return false;
  }

  d1 = 11 - (d1 % 11);

  if (d1 > 9) d1 = 0;

  if (dv.charAt(0) != d1) {
    return false;
  }

  d1 *= 2;

  for (i = 0; i < 9; i++) {
    d1 += c.charAt(i)*(11-i);
  }

  d1 = 11 - (d1 % 11);

  if (d1 > 9) d1 = 0;

  if (dv.charAt(1) != d1) {
    return false;
  }

  return true;
}


// Mensagens de Alerta
function fechaAlerta(){
  document.getElementById("divAlerta").style.visibility = "hidden";
}


function mostraAlerta(mensagem, titulo){
  if (titulo != null) {	
  	document.getElementById("txtTituloAlerta").innerHTML=titulo;
  }	
  document.getElementById("txtAlertaNovo").innerHTML=mensagem;
  mostraAlertaNovo();
}

function mostraAlertaGrande(mensagem){
  document.getElementById("txtAlerta").innerHTML=mensagem;
  document.getElementById("divAlerta").style.visibility = "visible";
}

 
function isValidMail(stringNeeded) {
    if(stringNeeded.match(/^[0-9a-zA-Z-_\.]+@[0-9a-zA-Z-_\.~]+(\.[a-zA-Z]+)+$/)) return true;
    return false;
}

  
/* ----------------------------------------------------------------------------
 * funcoes.js
 * ----------------------------------------------------------------------------
 */
function createMask() {
	var bodyHeight = document.documentElement.clientHeight;
	if (jQuery.browser.msie) {
		if(parseInt(jQuery.browser.version) == 6) { 
          var docScroll = document.documentElement.scrollTop;
		  $('select').each(function(){$(this).hide()});
		  var hb = bodyHeight;
      } else {
	  	var docScroll = '0';
		var hb = '100%';
	  }
	} else {
		var docScroll = '0';
		var hb = '100%';
	}
	$('body').append('<div class="bg-modal"></div>');
	$('div.bg-modal').css({
		'top':docScroll+ "px",
		'height':hb
	});
	$('div.bg-modal').show();
	if (jQuery.browser.msie) {
		if(parseInt(jQuery.browser.version) == 6) { 
			$(window).scroll(function () {
				var docScroll = document.documentElement.scrollTop;
				$('div.bg-modal').css('top',docScroll+'px');
				var leftScroll = document.documentElement.scrollLeft;
				$('div.bg-modal').css('left',leftScroll+'px');
			});
		}
	} 
};
function closeBox(n) {
    $('div.bg-modal').fadeOut('fast');
    $('div.'+n+'').fadeOut('fast');
    if (jQuery.browser.msie) { 
      if(parseInt(jQuery.browser.version) == 6) {
          $('select').each(function(){$(this).show()});
      }
    }
	$('div.bg-modal').remove();
};
function createLightbox(n,width, height) {
	var bodyHeight = document.documentElement.clientHeight;
	var bodyWidth = document.documentElement.clientWidth;
	if (jQuery.browser.safari) {
		var docScroll = document.body.scrollTop;
	} else {
		var docScroll = document.documentElement.scrollTop;
	}
	var docScroll = parseInt(docScroll);
	var bodyHeight = parseInt(bodyHeight);
	var height = parseInt(height);
	
	if (bodyHeight < height ) { 
		var top = (15 + docScroll );
		$('div.'+n+'').css('position','absolute');
	} else {
		if (jQuery.browser.msie) {
			if(parseInt(jQuery.browser.version) == 6) { 
			  var top = (((bodyHeight /2) - (height /2)) + docScroll );
			  $('div.'+n+'').css('position','absolute');
		  } else {
			var top = ((bodyHeight /2) - (height /2));
			$('div.'+n+'').css('position','fixed');
		  }
		} else {
			var top = ((bodyHeight /2) - (height /2));
			$('div.'+n+'').css('position','fixed');
		}
	}
	var top = parseInt(top);
	
	if (bodyWidth < width ) {
		var left = (width /2)+ 10 +'px';
	} else {
		var left = '48%';
	}
	$('div.'+n+'').css({
		'left': left,
		'top': top + "px",
		'width': width + 'px',
		'height': height + 'px',
		'margin-left': -width / 2
	});
	$('div.'+n+'').fadeIn();
};
$(document).ready(function() {

});
function mostraLighbox()
{
   createMask();
   createLightbox('box-modal','416','209');
}
function fechaLighbox()
{
   closeBox('box-modal');
}
function mostraAlertaNovo()
{
   createMask();
   createLightbox('box-modal-alerta','319','209');
}
function fechaAlertaNovo()
{
   closeBox('box-modal-alerta');
}  
  
/* ----------------------------------------------------------------------------
 * cookie.js
 * ----------------------------------------------------------------------------
 */

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();		
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}
  
  
  
  
/* ----------------------------------------------------------------------------
 * tooltip.js
 * ----------------------------------------------------------------------------
 */


/***********************************************
* Fixed ToolTip script- � Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/
		
var tipwidth='150px' //default tooltip width
var tipbgcolor='#f5f5f5'  //tooltip bgcolor
var disappeardelay=150  //tooltip disappear speed onMouseout (in miliseconds)
var vertical_offset="10px" //horizontal offset of tooltip from anchor link
var horizontal_offset="80px" //horizontal offset of tooltip from anchor link

/////No further editting needed

var ie4=document.all
var ns6=document.getElementById&&!document.all

if (ie4||ns6)
document.write('<div id="fixedtipdiv" style="visibility:hidden;width:'+tipwidth+';background-color:'+tipbgcolor+'" ></div>')

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}


function showhide(obj, e, visible, hidden, tipwidth){
if (ie4||ns6)
dropmenuobj.style.left=dropmenuobj.style.top=-500
if (tipwidth!=""){
dropmenuobj.widthobj=dropmenuobj.style
dropmenuobj.widthobj.width=tipwidth
}
if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
obj.visibility=visible
else if (e.type=="click")
obj.visibility=hidden
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
var edgeoffset=(whichedge=="rightedge")? parseInt(horizontal_offset)*-1 : parseInt(vertical_offset)*-1
if (whichedge=="rightedge"){
var windowedge=ie4 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
}
else{
var windowedge=ie4 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
}
return edgeoffset
}

function fixedtooltip(menucontents, obj, e, tipwidth){
if (window.event) event.cancelBubble=true
else if (e.stopPropagation) e.stopPropagation()
clearhidetip()
dropmenuobj=document.getElementById? document.getElementById("fixedtipdiv") : fixedtipdiv
dropmenuobj.innerHTML=menucontents

if (ie4||ns6){
showhide(dropmenuobj.style, e, "visible", "hidden", tipwidth)
dropmenuobj.x=getposOffset(obj, "left")
dropmenuobj.y=getposOffset(obj, "top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"
}
}

function hidetip(e){
if (typeof dropmenuobj!="undefined"){
if (ie4||ns6)
dropmenuobj.style.visibility="hidden"
}
}

function delayhidetip(){
if (ie4||ns6)
delayhide=setTimeout("hidetip()",disappeardelay)
}

function clearhidetip(){
if (typeof delayhide!="undefined")
clearTimeout(delayhide)
}

function abrirPopup(url, largura, altura){
	var tmt_Move_WindowX = (screen.width - largura) / 2; 
	var tmt_Move_WindowY = (screen.height - altura) / 2; 
	var windowPopup = window.open(url, 'popup','width=' + largura +',height=' + altura);
	windowPopup.moveTo(tmt_Move_WindowX, tmt_Move_WindowY);
}
