// Função somente para tecla de números e backspace (das idades)
function desabilitateclas_OLD()
{
	var tecla = event.keyCode;
	if ((tecla >= 0 && tecla <= 7)||(tecla >= 9 && tecla <= 12)||(tecla >= 14 && tecla <= 43)||(tecla >= 58 && tecla <= 127))
	{ return false; }
	return tecla;
}

// Desabilita todas as teclas exceto números
function desabilitateclas()
{
	// Detectando diferenças de browsers
	if( document.all && ! navigator.userAgent.match(/opera/gi) ) { // somente IE 
		var tecla = event.keyCode;
	} 
	else { // atende  no mínimo o Firefox, Netscape 6+,  e Opera 
		var tecla = evento.which;
	}
	/*
	0: TAB
	8: BACKSPACE
	13: ENTER
	48 - 57: Númeris de 0 a 9
	*/
	if ((tecla == 0)||(tecla == 8)||(tecla == 13)||(tecla >=48 && tecla <= 57))
		return tecla;
	return false;
}
/******************************************************/


// Muda o focus do telefone
function muda_focus(a,b)
{
	if(a.length==2)
		b.focus();
}

// Função mascara de FONE
function mascaraFONE(objeto)
{
	campo = eval (objeto);
	separacao1 = '-';
	conjunto1 = 4;
	conjunto2 = 9;
	if (desabilitateclas())
	{
			if (campo.value.length < (conjunto2))
			{
			  if (campo.value.length == conjunto1)
					campo.value = campo.value + separacao1;
			}
	}
	else
		event.returnValue = false;
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function favoritos() {
var name=confirm("Convenios Médicos Convida você a incluir nosso site em seus Favoritos!")
if (name==true)
{
	var url      = "http://www.conveniosmedicos.com";
    var title    = "Convenios Médicos - Planos de Saúde - Central de Vendas e Promoções !";
    if (window.sidebar) window.sidebar.addPanel(title, url,"");
    else if(window.opera && window.print){
        var mbm = document.createElement('a');
        mbm.setAttribute('rel','sidebar');
        mbm.setAttribute('href',url);
        mbm.setAttribute('title',title);
        mbm.click();
    }
    else if(document.all){window.external.AddFavorite(url, title);}
}
}

function piscar(x) {
   x = (x == null) ? 0 : x;
   var objLinks = document.getElementsByTagName("a");

   for (var i = 0; i < objLinks.length; i++) {
       if (objLinks[i].className == "piscar") {
           var objStyle = objLinks[i].style;
           objStyle.color = (x % 2 == 1)  ?  ""  :  "#cc0000";
           //objStyle.color = (objStyle.color == "#cc0000")  ?  ""  :  "#cc0000";
       }
   }

   setTimeout("piscar("+ (x+1) +")", 500);
}
piscar();  


function esconde(id,id_img)
{
	
	if(document.getElementById(id).style.display == 'none')
	{
		document.getElementById(id).style.display='block';
		document.getElementById(id_img).src='imagens/site/seta_cima.jpg';
	}
	else
	{
		document.getElementById(id).style.display='none';
		document.getElementById(id_img).src='imagens/site/seta_baixo.jpg';
	}
}

function tira_duvidas(id)
{
	
	if(document.getElementById(id).style.display == 'none')
	{
		document.getElementById(id).style.display='block';
	}
	else
	{
		document.getElementById(id).style.display='none';
	}
}

function mar(pos, speed)
{
 obj = document.getElementById('marquee');
 obj.direction = pos;
 obj.scrollAmount = speed;
}

function comparativo(id)
{													  	
	
	if(id=='reduzir')
	{
		document.getElementById('mostrar_reduz').style.display='block';
		document.getElementById('mostrar_melhora').style.display='none';
		document.getElementById('imagem_lado').src='imagens/site/comparativo_reduz.jpg';
	}
	else
	{
		document.getElementById('mostrar_melhora').style.display='block';
		document.getElementById('mostrar_reduz').style.display='none';
		document.getElementById('imagem_lado').src='imagens/site/comparativo_melhor.jpg';
	}
	document.getElementById('mostrar_resto').style.display='block';
}


function submitFormTxtDominio(idForm, idBotao, campoValidar) {
	b = document.getElementById(idBotao);
	f = document.getElementById(idForm);
	v = document.getElementById(campoValidar);
	if (v.value != "" && v.value != "meudominio" && v.value.indexOf("www.") == -1) {
		b.style.backgroundPosition= "0px -30px";
		b.setAttribute("onClick","alert('Aguarde enquanto sua solicitação é processada!')")
		f.setAttribute("action","/searchb.html")
		f.submit();
	} else if (v.value.indexOf("www.") > -1) {
		alert("Não é necessário digitar nome do domínios com 'www.'!");
		return false;
	} else {
		alert("É necessário digitar pelo menos um domínio para pesquisa!");
		return false;
	}
}

function Onload_botao(idForm, idBotao, campoValidar){
	b = document.getElementById(idBotao);
	f = document.getElementById(idForm);
	v = document.getElementById(campoValidar);
	if (v.value != "" && v.value != "0")
	{
		b.style.backgroundPosition= "0px -30px";
		b.setAttribute("onClick","alert('Aguarde enquanto sua pesquisa é processada !')");
	}
	else
	{
		//alert('Complete as Informações para finalizar a pesquisa !!!');
		return false;
	}
}

function troca_botao()
{
	document.getElementById('imageField').style.backgroundPosition= "0px -30px";
	document.getElementById('imageField').setAttribute("onClick","alert('Aguarde enquanto sua pesquisa é processada !')");
}

// Para rede credenciada
function ir_rede_credenciada(n,plId)
{
	if(n==0) // Hospital TODOS
	{
		document.ordenacao.plId.value = plId;
		document.ordenacao.action="dt_rede_hospital_all.php";
	}
	if(n==1) // Hospital ZC
	{
		document.ordenacao.plId.value = plId;
		document.ordenacao.action="dt_rede_hospital_zc.php";
		document.ordenacao.regiao.value=5;
	}
	if(n==2) // Hospital ZN
	{
		document.ordenacao.plId.value = plId;
		document.ordenacao.action="dt_rede_hospital_zc.php";
		document.ordenacao.regiao.value=2;		
	}
	if(n==3) // Hospital ZS
	{
		document.ordenacao.plId.value = plId;
		document.ordenacao.action="dt_rede_hospital_zc.php";
		document.ordenacao.regiao.value=1;
	}
	if(n==4) // Hospital ZL
	{
		document.ordenacao.plId.value = plId;
		document.ordenacao.action="dt_rede_hospital_zc.php";
		document.ordenacao.regiao.value=3;		
	}
	if(n==5) // Hospital ZO
	{
		document.ordenacao.plId.value = plId;
		document.ordenacao.action="dt_rede_hospital_zc.php";	
		document.ordenacao.regiao.value=4;
	}
	if(n==6) // Hospital ZR
	{
		document.ordenacao.plId.value = plId;
		document.ordenacao.action="dt_rede_hospital_zc.php";	
	}
	if(n==7) // LABORATÓRIO
	{
		document.ordenacao.plId.value = plId;
		document.ordenacao.action="dt_rede_laboratorio.php";	
	}
	if(n==8) // CARÊNCIA
	{
		document.ordenacao.plId.value = plId;
		document.ordenacao.action="dt_carencia.php";	
	}
	if(n==9) // ADESÃO: QUEM PODE ADQUIRIR
	{
		document.ordenacao.plId.value = plId;
		document.ordenacao.action="dt_quem_pode_aderir.php";	
	}
	if(n==10) // ADESÃO: SAIBA MAIS
	{
		document.ordenacao.plId.value = plId;
		document.ordenacao.action="dt_maisinfo.php";	
	}
	if(n==11) // ODONTO: DOCUMENTAÇÃO NECESSÁRIA
	{
		document.ordenacao.plId.value = plId;
		document.ordenacao.action="dt_documentacao.php";	
	}
	if(n==12) // ODONTO: PROCEDIMENTOS
	{
		document.ordenacao.plId.value = plId;
		document.ordenacao.action="dt_procedimentos.php";	
	}
	if(n==13) // PME: DETALHES PLANOS
	{
		document.ordenacao.plId.value = plId;
		document.ordenacao.action="dt_plano.php";	
	}
	if(n==14) // REEMBOLSO
	{
		document.ordenacao.plId.value = plId;
		document.ordenacao.action="dt_reembolso.php";	
	}
	if(n==15) // ENDEREÇO
	{
		document.ordenacao.plId.value = plId;
		document.ordenacao.action="dt_endereco.php";	
	}
	document.ordenacao.submit();
}
