// FUNCAO DO MENU 
var IdMenu;
function overMenu(id,op){
	if(op == 'e'){
		if (typeof(timeMenu) != 'undefined'){
			clearTimeout(timeMenu);
		}
		if(IdMenu != undefined){ outMenu(IdMenu); }
		inMenu(id);
	}
	else{
		timeMenu = setTimeout('outMenu("'+id+'")',1);
	}
}
function inMenu(id){
	mudadivcont("none");
	document.getElementById("s"+id).style.display = "block";
}
function outMenu(id){
	mudadivcont("block");
	document.getElementById("s"+id).style.display = "none";
}
// oculta ou exibe os selects para não dar conflito com o menu
function mudadivcont(ativo){
    var divs = document.getElementsByTagName('SELECT');
    for(var no=0;no<divs.length;no++){
        if(divs[no].className=='frmSelect oculta'){
            divs[no].style.display = ativo;
        }}}
// função para as abas com conteudo simples
function abas(id){
	for(i=0; i<txtAbas.length; i++){
		document.getElementById("aba_"+i).className = "excecaoTamanhoTexto";
	}
	document.getElementById("aba_"+id).className = "on excecaoTamanhoTexto";
	document.getElementById("contAbas").innerHTML = txtAbas[id];
}
// função para as abas do resultado da simulação. parametros: id do que vai ser ativo e o numero de abas.
function abas_res(id,num)
{
	for(i=0; i<num; i++)
	{
		document.getElementById("contAba_"+i).style.display = "none";
		document.getElementById("aba_"+i).className = "excecaoTamanhoTexto";
	}
	document.getElementById("contAba_"+id).style.display = "block";
	document.getElementById("aba_"+id).className = "on excecaoTamanhoTexto";
}
// função para os abre e fecha do resultado da simulação
function openCloseCar(id,ini,num)
{
	for(i=ini; i<num; i++)
	{
		if(id != i)
		{
			document.getElementById("cont_"+i).style.display = "none";
			document.getElementById("blt_"+i).className = "lnk";
		}
	}
	if(document.getElementById("cont_"+id).style.display == "none")
	{
		document.getElementById("cont_"+id).style.display = "block";
		document.getElementById("blt_"+id).className = "lnkOn";
	}
	else
	{
		document.getElementById("cont_"+id).style.display = "none";
		document.getElementById("blt_"+id).className = "lnk";
	}
}
// Popup: <a href="arquivo.ext" onclick="popup(this.href,'360','535','1'); return false;"></a>
function popup(url,w,h,s) {
	var oW=window.open(url,'popup_'+w,'width='+w+',height='+h+',directories=0,location=0,menubar=0,resizable=1,scrollbars='+s+',status=0,toolbar=0,marginleft=0,margintop=0,left=0,top=0');
}
// SELECIONA O TIPO DE SIMULAÇÃO 
function selTipoSimulador(id,num){
	for(i=0; i<num ; i++){
		document.getElementById("simulador_"+i).style.display = "none";
	}
	document.getElementById("simulador_"+id).style.display = "block";
}
// FUNÇÃO PARA PERMITIR SOMENTE NÚMEROS NOS TEXTBOX
function soNumeros(e){
 //Caso Internet Explorer(IE) outros (Other)
 if (navigator.appName.indexOf('Microsoft') != -1){
 	clientNavigator = "IE";
 }else{
 	clientNavigator = "Other";
 }
 //Função permite digitação de números
 	if (clientNavigator == "IE"){
 		if (e.keyCode < 48 || e.keyCode > 57){
 			return false
 		}
 	}else{
 		if ((e.charCode < 48 || e.charCode > 57) && e.keyCode == 0){
 			return false
 		}}
}
// Função para aceitar apenas números e letras em campos texto
function soNumerosLetras(e){
     var key;
     var keychar;

     if (window.event) {
        key = window.event.keyCode;
     } else if (e) {
        key = e.which;
     } else {
        return true;
     }	

     keychar = String.fromCharCode(key);

     // teclas de controle
     if ((key==null) || (key==0) || (key==8) ||
          (key==9) || (key==13) || (key==27) ) {
        return true;
     } else if ((("0123456789qwertyuiopasdfghjklçzxcvbnmQWERTYUIOPASDFGHJKLÇZXCVBNMéèêáàãâíìîóòõôúùûüïäëÉÈÊÁÀÃÂÍÌÎÓÒÕÔÚÙÛÜÏÄË ").indexOf(keychar) > -1)) {
        return true;     
     } else {
        return false;
     }
}
function soNumerosLetrasBusca(e){
	if (window.event) {
		key = window.event.keyCode;
	} else if (e) {
		key = e.which;
	} else {
		return true;
	}
	if (!(key == 13)) {
		return soNumerosLetras(e);
	} else {
		objBtn = document.getElementById("ctl00_ctBusca_btnOk");
		if (objBtn) {
			objBtn.click();
		} else {
			objBtn = document.getElementById("ctBusca_btnOk");
			if (objBtn) {
				objBtn.click();
			}
		}
		return false;
	}
}
// FUNÇÃO PARA ABRIR E FECHAR AS DIV DO CALENDARIO DE ASSEMBLEIAS 
function abreDivCalendario(div)
{
    var divGrupo = document.getElementById(div);
    var bltMais_divgrupo = document.getElementById('bltMais_' + div);
    var bltMenos_divgrupo = document.getElementById('bltMenos_' + div);
    var divs, i;
    divs = document.getElementsByTagName('div');
    if(divGrupo.style.display=='none')
    {
        divGrupo.style.display='block';
        bltMais_divgrupo.style.display='none';
        bltMenos_divgrupo.style.display='block';
    }
    else
    {
        divGrupo.style.display='none';
        bltMais_divgrupo.style.display='block';
        bltMenos_divgrupo.style.display='none';
    }
    for (i in divs)
    {
        if(divs[i].id != undefined)
        {
            if(divs[i].id.indexOf('divgrupo') != -1)
            {
                //alert(divs[i].id + " = " + divGrupo.id);
                if(divs[i].id != divGrupo.id)
                {
                    var imgMais = document.getElementById('bltMais_' + divs[i].id);
                    var imgMenos = document.getElementById('bltMenos_' + divs[i].id);
                    divs[i].style.display='none';
                    imgMais.style.display='block';
                    imgMenos.style.display='none';
                }
            }
        }
    }
}
//   FUNÇÃO PARA SELECIONAR SIMULADOR NA HOME E TROCAR CONTEÚDO DOS BLOCOS   
var lnkPlanoAnterior = "";
var lnkPlanoAtivo = "";
var strId = "";
function selecionaSimuladorHome(id) {
	if (lnkPlanoAtivo != "" ) {
		lnkPlanoAnterior = lnkPlanoAtivo;
	}
	lnkPlanoAtivo = "lnkPlano" + id;
	if (lnkPlanoAnterior != "") {
		document.getElementById(lnkPlanoAnterior).className = "desmarcado";
	}
	document.getElementById(lnkPlanoAtivo).className = "marcado";
	strId = id;
}
function mostraPlanoSimuladores() {
	if (strId == "") {
		alert ("Escolha um simulador.");
	} else {
		document.getElementById("divSelecionaSimulador").style.display = "none";
		document.getElementById("boxTesteAbasSimuladores").style.display = "block";
		var strTemporizador = setTimeout("mostraPlanoSimuladores2();", 1);
	}
}
function mostraPlanoSimuladores2() {
	if (strId == "2") { 
		abas_home('imoveis');
	}
	if (strId == "3") { 
		abas_home('caminhoes');
	}
	if (strId == "4") { 
		abas_home('tratores');
	}
	document.getElementById("cmbSimulacao"+strId).options[document.getElementById("cmbSimulacao").value].selected = true;
	carregaPasso2(document.getElementById("cmbSimulacao"+strId).value);
}
//VISTORIA
function MontaCidades(comboEstado)
{
    var comboCidade = document.getElementById("ctl00_ContentPlaceHolder1_dlCidade");
    comboCidade.options.length = 0;
    eval(vistoriaMethods.LoadXMLCidadeAjax(comboEstado.value).value);
}

//AJUSTA TAMANHO DO TEXTO
tamanhoTexto = 10; // mantem o tamanho do texto
function ajustaTexto(acao) {

	elementos = new Array("p","li","a","strong","font","div","span");

	if (acao == 1) { // aumenta texto
		if (tamanhoTexto < 12) {
			tamanhoTexto++;
		}	
	} else { // diminui texto
		if (tamanhoTexto > 10) {
			tamanhoTexto--;
		}
	}
	for(var e in elementos){ // varre os elementos mudando o tamanho do texto
		$(".conteudo "+elementos[e]).css("font-size",tamanhoTexto + "px");
		$(".colDest "+elementos[e]).css("font-size", "10px");
	}
	$(".excecaoTamanhoTexto").css("font-size", "10px");

}
var nomesf = new Array();
nomesf[0] = "barra";
nomesf[1] = "conteudo";

var nframes = 2;
var endsite = "http://www.bradescoconsorcios.com.br/";
if (document.URL.indexOf('vistorias') == -1){
	try
	{
		if (parent.frames.length > 0)
		{
			if (parent.frames.length != nframes)
			 {
			   //Quantidade de frames diferente do permitido.
			   top.location.href=endsite;
			 }	
			for(x=0;x<parent.frames.length;x++)
			 {
			  if (nomesf[x] != parent.frames[x].name)
			    {
				//Nome dos Frames
				top.location.href=endsite;
				}
			 }
		}
	}
	catch(e)
	{
		  var detect = navigator.userAgent.toLowerCase();
		  if (detect.indexOf('mac') < 1)
		  {
		   //Catch caso carrege de um iframe
		   top.location.href=endsite;
		  }
	}
}

