
function atualizaIframee(tamanho){	
	top.document.getElementById("cont-central").height = top.frames['conteudo-central'].document.getElementById("conteudo-central2").scrollHeight + tamanho;
	
}
function submitTypePost(action, conteudo1) {
	var form = document.createElement('form');
	form.action = action;
	form.method = "post";
	form.target="_top";
	var hdd_conteudo1 = document.createElement("input");
	hdd_conteudo1.setAttribute("type", "hidden");
	hdd_conteudo1.setAttribute("id", "conteudo1");
	hdd_conteudo1.setAttribute("name","conteudo1");
	hdd_conteudo1.setAttribute("value", conteudo1);
	form.appendChild(hdd_conteudo1);
	document.body.appendChild(form);
	form.submit();
}
function addToFavorites() {
	var url      = "http://www.bradescosaude.com.br/saude/home.do";
	var title    = "Bradesco Saúde";
	
	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(window.ActiveXObject){
		
		// Nao funciona no IE8, deve ser chamado a partir de um evento ex: onclick...
		window.external.AddFavorite(url, title);
		
		//var element = document.getElementById('favoritos');
		//var evt = document.createEventObject();
		//return element.fireEvent('onclick',evt);

	} 
}


function atualizaIframe() {
	    //var iFrames = parent.document.getElementsByTagName(window.name);
		var iFrames = parent.document.getElementsByTagName('iframe');
		if (iFrames != undefined) {
			for (var i = 0, j = iFrames.length; i < j; i++)	{
				var frame = iFrames[i];
				try { // deve tentar em todos os documentos.
					if(window.ActiveXObject){
						if ((frame.contentWindow.document != undefined) && (frame.contentWindow.document.body == document.body)) {
							frame.height = document.body.scrollHeight;
							break;
						}
					} else {
						if ((frame.contentDocument != undefined) && (frame.contentDocument == document)) {
							if (document.body.scrollHeight > 0) {
								frame.height  = document.body.scrollHeight;
							} else {
								frame.height = document.documentElement.scrollHeight;	
							}
							break;
						}
					}
				} catch (e) {
				alert(e);
				// se for erro de permissao entre servidores voc� j� n�o poderia
				// fazer nada a n�o ser definir igualmente o domain de ambos.
				// Defina o domain do hospedeiro.
				// document.domain = '[your domain]';
			}
		}
	}		
}

function mostraEsconde(object) {
	obj = document.getElementById(object);
	obj.style.display = obj.style.display == "block" ? "none" : "block";	
}

// Troca classe para ativar e desativar o menu (sinais de "+" e "-")
function trocaBotao(object) {
	obj = document.getElementById(object);
	if (object.className == "fechado") {
		obj.className = obj.className == "aberto" ? "fechado" : "aberto";
	} else {
		obj.className = obj.className == "fechado" ? "aberto" : "fechado";
	}
		
}



function ativaClasse(object,classe) { 
    obj = document.getElementById(object);
    obj.className = classe;
}

function sL(object) {

	obj = document.getElementById(object).style;
	obj.display = "block";
	 
	/*var ver = getInternetExplorerVersion();
	 if ( ver > -1 ){
		 if ( (ver >= 5.0) && (ver < 7.0) && (object=='menu-empresas')){
			obj.top="116px";
		  	obj.left="250px";
	 	}
	 }
	*/
    
}
function hL(object) {
    obj = document.getElementById(object).style;
    obj.display = "none";
}

function geraFlash($arquivo,$largura,$altura){
    document.writeln('    <object type="application/x-shockwave-flash" data="'+ $arquivo +'" width="'+ $largura +'" height="'+ $altura +'" style="float:left;">');
    document.writeln('        <param name="movie" value="' + $arquivo + '?date=' + new Date() + '" />');
    document.writeln('        <param name="menu" value="false" />');
    document.writeln('        <param name="quality" value="high" />');
	document.writeln('        <param name="wmode" value="transparent" />');
    document.writeln('    </object>');
}

function abreCanalsaude() {window.location.href = "/saude/canal-saude.do";}

//banner hotsite do Ipad Iphone
function abreHotsiteIphoneIpad(){
	window.open(hotsiteIphoneIpad, "_blank"	);
}

// Vitrine Institucional
function quemsomos() {window.location.href = quemSomos;}
function ogrupo() {window.location.href = oGrupo;}
function demofinanceiras() {window.location.href = demoFinanceiras;}
function balanpromocional() {window.location.href = balanPromocional;}
function histseguro() {window.open(histSeguro, "_blank");}
function conhecaDestaquesSWF() {window.location.href = conhecaDestaques;}

function privacidade() {window.location.href = privaCidade;}
function instDiferenciais() {window.location.href = bradDiferenciais;}
function medReferenciamento() {window.location.href = colicReferenciamento;}

// Vitrine Pequenas Empresas
function peqEntrada() {window.location.href = peqEmpEntrada;}
function peqPlanos() {window.location.href = peqEmpPlanos;}
function peqVantagens() {window.location.href = peqEmpVantagens;}
function peqPerguntas() {window.location.href = peqEmpPerguntas;}
function peqProposta() {
	//PCBS
	top.document.getElementById("cont-central").height = document.getElementById("conteudo-central").scrollHeight + 200;
	top.frames['conteudo-central'].location.href = '../../../../PCBS-Propostas/iniciarSolicitarPropostaEmpresas.do?empresa=1&portal=S';
}

// Vitrine SPG
function spg() {window.location.href = spgentrada;}
function spg0549() {window.location.href = SPG0549;}
function spgperfil0549() {window.location.href = SPGperfil0549;}
function spg5099() {window.location.href = SPG5099;}
function spgperfil5099() {window.location.href = SPGperfil5049;}

// Vitrine Sa�de Empresarial
function empresarial() {window.location.href = Empresarial;}
function bsemp100() {window.location.href = bsEmp100;}
function bsperfilemp100() {window.location.href = bsPerfilemp100;}


// Vitrine M�dias Empresas
function medEntrada() {window.location.href = medEmpEntrada;}
function medPlanos() {window.location.href = medEmpPlanos;}
function medVantagens() {window.location.href = medEmpVantagens;}
function medPerguntas() {window.location.href = medEmpPerguntas;}   
function medProposta() {
	window.location.href = '/saude/produto-saude-spg.do?conteudo1=PCBS-Propostas/iniciarSolicitarPropostaEmpresas.do?empresa=2&portal=S';
	//window.location.href = '/saude/pequenas-empresas-proposta.do?conteudo1=2';
	
	
}  

// Vitrine Grandes Empresas
function empresarial() {window.location.href = grdEmpEntrada;}
function gdPlanos() {window.location.href = grdEmpPlanos;}
function gdVantagens() {window.location.href = grdEmpVantagens;}
function gdPerguntas() {window.location.href = grdEmpPerguntas;}

function gdProposta() {
	window.location.href = '/saude/produto-saude-spg.do?conteudo1=PCBS-Propostas/iniciarSolicitarPropostaEmpresas.do?empresa=3&portal=S';
	//window.location.href = '/saude/pequenas-empresas-proposta.do?conteudo1=2';
		
}

// Vitrine Segurados
function seguradosEntrada() {window.location.href = segEntrada;}
function seguradosVantagens() {window.location.href = segVantagens;}
function seguradosPerguntas() {window.location.href = segPerguntas;}
function seguradosPlanos() {window.location.href = segPlanos;} 

// vitrine poptour
function popupTour() {window.location.href = popTour;}

// Vitrine Dentistas
function dentistasEntrada() {
	window.location.href = dentEntrada;
}
function dentistasVantagens() {
	window.location.href = dentVantagens;
}
function dentistasPerguntas() {window.location.href = dentPerguntas;}
function referenciamentoPF() {
	// atualizaIframee(1000);
	top.frames['conteudo-central'].location.href = dentReferenciamentoPF;
}
function referenciamentoPJ() {
	// atualizaIframee(1300);
	top.frames['conteudo-central'].location.href = dentReferenciamentoPJ;
	
}

// Vitrine Corretores
function corretoresEntrada() {
	window.location.href = corEntrada;
	}
function corretoresVantagens() {window.location.href = corVantagens;}
function corretoresPerguntas() {window.location.href = corPerguntas;}
function corretoresSite() {
	var url = corSiteCorretor;
	
	var width = 765;
	var height = 585;
	
	var left = 100;
	var top = 100;
	
	window.open(url, 'AcessoExclusivo', 'width=' + width + ',height=' + height + ',left=' + left + ',top=' + top + ',scrollbars=no,status=no,toolbar=no,location=no');
}

function sejaCorretor() {
	atualizaIframee(550);
}

function canalSaude() {window.location.href = canalSaude0;}
function canalSaudeCancer() {window.location.href = canalSaude1;}
function canalSaudeCancerColo() {window.location.href = canalSaude2;}
function canalSaudeCancerProstota() {window.location.href = canalSaude3;}
function canalSaudeDengue() {window.location.href = canalSaude4;}


function Abre_odontoprev(){
  window.open('html/pop_assoc_odontoprev.html', "BradescoDental", "left=0, top=0, status=no, menubar=no, toolbar=no,scrollbars=no,resizable=no, width=624, height=634");
} 

function Abre_video(){

	// Versao Popup
	verificaURL("video_bradesco/video-tour-portaldental.html", "_blank", "v")
	
  }
  
 function openShadowbox(content, player, title){
    Shadowbox.open({
        content:    content,
        player:     player,
        title:      title,
		width:		640,
		height:		400
    });
}

//Returns the version of Internet Explorer or a -1
//(indicating the use of another browser).
function getInternetExplorerVersion(){
	var rv = -1; // Return value assumes failure.
	if (navigator.appName == 'Microsoft Internet Explorer')
	{
	  var ua = navigator.userAgent;
	  var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
	  if (re.exec(ua) != null)
	    rv = parseFloat( RegExp.$1 );
	}
	return rv;
}

/**
* Redimensiona de acordo com o tamanho do frame de conteúdo.
* @param moreSize - Mais tamanho - incluído para tratar diferenças de tamanhos entre layouts iguais.
* @return true;
*/
function reSize(moreSize){
	var	oFrame	=	document.getElementById("conteudoCentral");
	var	oBody;
	var altura;
	
	if (moreSize == undefined) {
		moreSize = 0;
	}
	
	if (oFrame != undefined) {
		if(window.ActiveXObject){
			try {
				oBody =	oFrame.document.body;
				oFrame.contentWindow.document.body.onclick = function() {timeout_state= setTimeout('reSize(100)',1000);};
				//oFrame.contentWindow.document.body.scrollHeight é a propriedade que deve ser usada para o IE7 e IE8 (testada);
				altura = (oFrame.contentWindow.document.body.scrollHeight);
				oFrame.style.height = (altura + 50) + "px";
				document.getElementById("divPrincipal").style.height = (moreSize + altura + document.getElementById("divMenuFlash").clientHeight +  document.getElementById("divMenu").clientHeight) + 'px';
			} catch (e) {
				return reSizeWidthParam(moreSize);
			}
		}else {
			try {
				oBody =	oFrame.contentDocument.body;
				oBody.onclick = function() {timeout_state= setTimeout('reSize(100)',1000);};
				if (oBody.scrollHeight > 0) {
					altura = oBody.scrollHeight;
				} else {
					altura = oFrame.contentDocument.documentElement.scrollHeight;	
				}
				oFrame.style.height = (altura + 50) +"px"; 
				document.getElementById("divPrincipal").style.height = (moreSize + altura + document.getElementById("divMenuFlash").scrollHeight +  document.getElementById("divMenu").clientHeight) + 'px';  
			} catch (e) {
				return reSizeWidthParam(moreSize);
			}
		}
	}
	return true;
}

/*
* Abre outra aplica��o dentro da DIV Iframe
* @param pontoDoOrigem - Action de onde a chamada a aplica��o.
* @param pontoDoDestino - Action da aplica��o para onde sera redirecionada.
*/
function openApp(pontoDoOrigem, pontoDoDestino){
	var url = '/acessibilidade/'+pontoDoOrigem+'?conteudo1='+ pontoDoDestino;
	window.location.href = url;
}

	
/**
* Fun��o para abrir PopUp de acordo com as regras de acessibilidade.
* @param nomepagina - P�gina que deve ser exibida no popUp.<b> 
* @param titulopagina - T�tulo do popUp.<b> 
* @param w - Largura do popUp.
* @param h - Altura do popUp.
* @param scroll - Barra scroll.
*/
function PopUpCentralizado(nomepagina, titulopagina, w, h, scroll, app) {
	 var winl = (screen.width - w) / 2;
	 var wint = (screen.height - h) / 2;
	 winprops = 'height=' + h + ', width = ' + w + ', top = ' + wint + ', left = ' + winl + ', scrollbars = ' + scroll + ', location=no, status=no';
	 //colocando action
	 
	 if (app == null){
		 if(nomepagina.substring(0,5) == "/PCBS"){
			 nomepagina = nomepagina.replace("/PCBS","PCBS");
		 }
		 nomepagina = "abreAppExterna.do?width="+w+"&height="+h+"&conteudo1="+nomepagina;
	 }
	 
	 
	 win = window.open(nomepagina, titulopagina, winprops);
	 if(win && parseInt(navigator.appVersion)  >= 4){
		 	 win.window.focus();		 
	 }else{
		 window.open(nomepagina, titulopagina, winprops);
	 }
	 
}

function noNumbers(e){
	var keynum
	var keychar
	var numcheck
	
	if(window.event){ // IE	
		keynum = e.keyCode
	}
	else if(e.which){ // Netscape/Firefox/Opera
		keynum = e.which
	}
	/*keychar = String.fromCharCode(keynum)
	
	numcheck = /\d/
	alert(!numcheck.test(keychar));
	alert(keynum);
	alert(keychar);
	*/
	if(keynum == "38"){
		location.hash="#Amenu";
	}else if (keynum == "42"){
		location.hash="#Ainicio";
	}else if (keynum == "40"){
		location.hash="#Aconteudo";
	}else if (keynum == "41"){
		location.hash="#Abusca";
	}
	
}

//Menu Drop Down Acessível
//Alexandre Junqueira
//cont...@alexandrejunqueira.com
//http://www.alexandrejunqueira.com/projetos/menu-drop-down-acessivel/
var dropdown_intervalId;
var dropdown_ulId = (!dropdown_ulId) ? 'menu-principal' : dropdown_ulId;
var dropdown_delay = (!dropdown_delay) ? 0 : dropdown_delay;

function dropdown_init(){
	try{
		var as = document.getElementById(dropdown_ulId).getElementsByTagName('a');

		for (var a = 0; a < as.length; a++){
			as[a].onfocus = function() { dropdown_expand(this) }
			as[a].onmouseover = function() { dropdown_expand(this) }
			as[a].onblur = function() { dropdown_colapse(dropdown_delay) }
			as[a].onmouseout = function() { dropdown_colapse(dropdown_delay) }
		}

		dropdown_colapse(0);

	} catch(e){}

}

function dropdown_expand(caller){
	try{
		clearInterval(dropdown_intervalId);

		var uls = caller.parentNode.parentNode.getElementsByTagName('ul');

		for (var ul = 0; ul < uls.length; ul++){
			uls[ul].style.left = "-1000em";			
		}


		caller.parentNode.getElementsByTagName('ul')[0].style.left = "auto";

	} catch(e){}

}

function dropdown_colapse(milliseconds){
	try{
		clearInterval(dropdown_intervalId);

		dropdown_intervalId = setInterval(function(){    
			var uls = document.getElementById(dropdown_ulId).getElementsByTagName('ul');

			for (var ul = 0; ul < uls.length; ul++){
				uls[ul].style.left = "-1000em";				
			}
 

			clearInterval(dropdown_intervalId);

		}, milliseconds, null);

	} catch(e){}

}

//window.onload = dropdown_init;

