// ********** Monta Barra  ********** //

var txtBarra = "";

txtBarra += "<div class=\"RedeRelTittle\" id=\"RedeRelTittle\">\n";
txtBarra += "	<ul>\n";
txtBarra += "		<li class=\"esquerda\">&nbsp;</li>\n";
txtBarra += "		<li class=\"meio\"><span id=\"RedeRelTittleTxt\">&nbsp;</span></li>\n";
txtBarra += "		<li class=\"direita\">&nbsp;</li>\n";
txtBarra += "	</ul>\n";
txtBarra += "</div>\n";

txtBarra += "<div class=\"RedeRel\" id=\"RedeRel\">\n";
txtBarra += "	<img id=\"RedeRelImg\" height=\"30\" alt=\"\" width=\"949\" usemap=\"#m_redes\" border=\"0\" name=\"redes\" src=\"../../custom/client/images/Site2008/redes.png\" />\n";
txtBarra += "	<map name=\"m_redes\" id=\"m_redes\">\n";
txtBarra += "		<area id=\"fTeste\" onMouseOver=\"MostraTittle('Minimizar', '942', 'RedeRel');\" onMouseOut=\"EscondeTittle();\" onClick=\"MenuRedesOff()\" style=\"cursor: pointer\" href=\"javascript:;\" shape=\"poly\" coords=\"912,0,942,0,942,30,912,30,912,0\" />\n";
txtBarra += "		<area target=\"_blank\" onMouseOver=\"MostraTittle('Download gratuito do aplicativo Meu Carro', '907', 'RedeRel');\" onMouseOut=\"EscondeTittle();\" href=\"http://itunes.apple.com/us/app/meu-carro/id335221034?mt=8\" coords=\"837,0,907,30\" shape=\"rect\" />\n";
txtBarra += "		<area target=\"_blank\" onMouseOver=\"MostraTittle('Acompanhe o BB Seguro Auto no YouTube', '828', 'RedeRel');\" onMouseOut=\"EscondeTittle();\" href=\"http://www.youtube.com/bbseguroautovideos\" coords=\"778,0,828,30\"shape=\"rect\" />\n";
txtBarra += "		<area target=\"_blank\" onMouseOver=\"MostraTittle('Adicione o BB Seguro Auto no Orkut', '769', 'RedeRel');\" onMouseOut=\"EscondeTittle();\" href=\"http://www.orkut.com.br/Main#Profile?uid=14074647968104201288\" shape=\"rect\" coords=\"729,0,769,30\" />\n";
txtBarra += "		<area target=\"_blank\" onMouseOver=\"MostraTittle('Adicione o BB Seguro Auto no Facebook', '720', 'RedeRel');\" onMouseOut=\"EscondeTittle();\" href=\"http://www.facebook.com/home.php?sk=lf#!/pages/BB-Seguro-Auto/115615055125856?ref=ts\" coords=\"662,0,720,30\" shape=\"rect\" />\n";
txtBarra += "		<area target=\"_blank\" onMouseOver=\"MostraTittle('Acompanhe o BB Seguro Auto no Twitter', '654', 'RedeRel');\" onMouseOut=\"EscondeTittle();\" href=\"http://twitter.com/bbseguroauto\" coords=\"599,0,654,30\" shape=\"rect\" />\n";
txtBarra += "	</map>\n";
txtBarra += "</div>\n";

txtBarra += "<div class=\"RedeRel_Off\" id=\"RedeRel_Off\">\n";
txtBarra += "	<a onMouseOver=\"MostraTittle('Maximizar', '990', 'RedeRel_Off');\" onMouseOut=\"EscondeTittle();\" onClick=\"MenuRedesOn()\" style=\"cursor: pointer\" href=\"javascript:;\">\n";
txtBarra += "		<img id=\"RedeRelImg_Off\" height=\"30\" alt=\"\" width=\"50\" border=\"0\" name=\"redes\" src=\"../../custom/client/images/Site2008/redes_off.png\" />\n";
txtBarra += "	</a>\n";
txtBarra += "</div>\n";

document.write(txtBarra);



// ********** Funções Redes de Relacionamento  ********** //

function getPosicaoElemento(elemID){
    var offsetTrail = document.getElementById(elemID);
    var offsetLeft = 0;
    var offsetTop = 0;
    while (offsetTrail) {
        offsetLeft += offsetTrail.offsetLeft;
        offsetTop += offsetTrail.offsetTop;
        offsetTrail = offsetTrail.offsetParent;
    }
    if (navigator.userAgent.indexOf("Mac") != -1 && 
        typeof document.body.leftMargin != "undefined") {
        offsetLeft += document.body.leftMargin;
        offsetTop += document.body.topMargin;
    }
    return {left:offsetLeft, top:offsetTop};
}



function MostraTittle(txt, pos, dvMenu)
{
	
	var divRedeRelTittle 	= document.getElementById("RedeRelTittle");
	var divRedeRelTittleTxt = document.getElementById("RedeRelTittleTxt");
	
	divRedeRelTittleTxt.innerHTML=txt;
	divRedeRelTittle.style.display='block';
	
	//var tamDivTittle = 20;
	//var divTamanho = 20;
	
	var tamDivTittle 		= divRedeRelTittle.clientWidth;
	var divTamanho 			= parseInt(getPosicaoElemento(dvMenu).left) + parseInt(pos) - parseInt(tamDivTittle);
	
	var tempX = 0;
	var tempY = 0;
	
	
	tempY = $(window).height() + $(window).scrollTop() - 54;
	tempX = divTamanho;
	
	if (tempX < 0){tempX = 0;}
	if (tempY < 0){tempY = 0;}
	
	divRedeRelTittle.style.top=tempY+"px";
	divRedeRelTittle.style.left=tempX+"px"; 	
		
}

function EscondeTittle(){document.getElementById("RedeRelTittle").style.display='none';}




//if(LerCookie('cooMenuRedes')!=null)
//	MenuRedesOff();
//else
//	alert(LerCookie('cooMenuRedes'));


function MenuRedesOff()
{
	if(LerCookie('cooMenuRedes')==null)
		GerarCookie('cooMenuRedes', '1', 0);

	EscondeTittle();
	
	var left_top = 'Top';
	var directionOfTopMovement = '+=';
	var movementAmount = '30px';
	var props = {};
	props["margin" + left_top] = directionOfTopMovement + movementAmount;
	$(".RedeRel").animate(props, 1000, "swing");
	
	window.setTimeout(function(){
							   directionOfTopMovement = '-=';
							   props["margin" + left_top] = directionOfTopMovement + movementAmount;
							   $(".RedeRel_Off").animate(props, 1000, "swing");
							   },1000);
		 
			
			
}



function MenuRedesOn()
{
	
	if(LerCookie('cooMenuRedes')!=null)
		ExcluirCookie('cooMenuRedes');
	
	EscondeTittle();
	
	var left_top = 'Top';
	var directionOfTopMovement = '+=';
	var movementAmount = '30px';
	var props = {};
	
	
	props["margin" + left_top] = directionOfTopMovement + movementAmount;
	$(".RedeRel_Off").animate(props, 1000, "swing");
	
	directionOfTopMovement = '-=';
	window.setTimeout(function(){
								props["margin" + left_top] = directionOfTopMovement + movementAmount;
								$(".RedeRel").animate(props, 1000, "swing");
								},1000);
	
								
}




function iframeAutoHeight(ifr){

quem = document.getElementById(ifr)
     if(navigator.appName.indexOf("Internet Explorer")>-1) { 
          var func_temp = function(){
               var val_temp = quem.contentWindow.document.body.scrollHeight + 5
               quem.style.height = val_temp + "px";
               var iframe=document.getElementById(ifr)
               iframe.attachEvent("onload", iframeAutoHeight)
          }
     setTimeout(function() { func_temp() },100) 
     }
     else {
          var val = quem.contentWindow.document.body.parentNode.offsetHeight + 5
          quem.style.height= val + "px";
          var iframe=document.getElementById(ifr)
    }    
}