//-------------------------------   TV - EFILME  ---------------------------------------------------------
  var anteriorMenuBotao = "";
  var linkFlash ;
  
	function carregaFlash(posFlash){
		try{
			var urlFlash  = arr_url_banner_flash[(posFlash-1)];
			linkFlash = arr_link_banner_flash[(posFlash-1)];

			if (urlFlash != ''){
				if(urlFlash.indexOf('.swf') != -1 || urlFlash.indexOf('.SWF') != -1){
					jQuery('#divTvflash').html(utlizarBannerFlash(linkFlash,urlFlash));
				}else {
					jQuery('#divTvflash').html('<img src="' + urlFlash + '" width="366px" height="276px" />');
				}
				jQuery('#tvMenuBotao' + posFlash).addClass('divTvmenuBotaoOn').removeClass('divTvmenuBotaoOff');
				if(anteriorMenuBotao != ""){
					jQuery('#tvMenuBotao' + anteriorMenuBotao).addClass('divTvmenuBotaoOff').removeClass('divTvmenuBotaoOn');
				}
				anteriorMenuBotao = posFlash;
			}         
		}catch(e){}	
	}

	function utlizarBannerFlash(linkFlash,urlFlash) {
		var js_h = 276;
		var js_w = 366;
		var js_flash = "<p style='cursor:pointer;'>";
		js_flash += "<object class='myObject'  classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'  ";
		js_flash += " codebase='HTTP://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0'  width='"+ js_w + "' height='"+ js_h +"' > <param name=movie value='";
		js_flash =  js_flash + urlFlash; 
		js_flash =  js_flash + "' width='"+ js_w + "' height='"+ js_h +"'>";
		js_flash += "<param name='wmode' value='transparent' />";
		js_flash += "<param name='quality' value='high'>";
		js_flash += "<embed src='" + urlFlash + "'";             
		js_flash += "width='"+ js_w + "' height='"+ js_h +"' wmode='transparent'></embed>";
		js_flash +=	"</object>";
		js_flash += "</p>";
	
		return js_flash;
	}
	
	
	jQuery(function() {	
		jQuery("#divTvflash").click(function(){
			window.location=linkFlash;
		});
	});
  
//-------------------------------   DHTML ---------------------------------------------------------


	//Monta o Flash na página
	function GerarSWF($arquivo,$largura,$altura,$idNome){
            //controle para ver se é a primeira vez q. entrou na pagina (sessao)
         //   if (readCookie('dhtmlHome') != 'OK'){
		document.writeln('<object id="globalnav-object" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="' + $largura + '" height="' + $altura + '" id="' + $idNome + '" name="' + $idNome + '">');
		document.writeln('<param name="movie" value="' + $arquivo + '" />');
		document.writeln('<param name="FlashVars" value="loc=en_US&htmlApp=false&gatewayURL=gwurl" />');
		document.writeln('<param name="bgcolor" value="#ffffff" />');
		document.writeln('<param name="menu" value="false" />');
		document.writeln('<param name="quality" value="high" />');
		document.writeln('<param name="salign" value="tl" />');
		document.writeln('<param name="scale" value="noscale" />');
		document.writeln('<param name="wmode" value="transparent" />');
		document.writeln('<embed id="globalnav-embed" src="' + $arquivo + '" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" wmode="transparent" flashvars="loc=en_US&htmlApp=false&gatewayURL=gwurl" bgcolor="#ffffff" menu="false" quality="high" salign="tl" scale="noscale" id="' + $idNome + '" width="' + $largura + '" height="' + $altura + '"></embed>');
		document.writeln('</object>');
		              //marca que já exibiu o dhtml na sessao 
                createCookie('dhtmlHome','OK','');
          //  }
	}	

function Browser() {
  var ua, s, i;
  this.isIE    = false;  // Internet Explorer
  this.isOP    = false;  // Opera
  this.isNS    = false;  // Netscape
  this.version = null;
  ua = navigator.userAgent;
  s = "Opera";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isOP = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }
  s = "Netscape6/";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = 6.1;
    return;
  }
  s = "MSIE";
  if ((i = ua.indexOf(s))) {
    this.isIE = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }
}

var browser = new Browser();

var botaoAtivo = null;

var divFrame = null;

function clicaBotao(event, menuId) {  
/*
  var botao;
  if (browser.isIE){
    botao = window.event.srcElement;
  }
  else{
    botao = event.currentTarget;
  }  
  if (botao.divDhtml == null) {
    botao.divDhtml = document.getElementById('arquivoMenu');
  }
    
  if (botaoAtivo != null)
    fechaMenu(botaoAtivo);

  if (botao != botaoAtivo) {
    abreMenu(botao);
    botaoAtivo = botao;
  } else {
    botaoAtivo = null;
  }  
  return false;
*/
}
function abreMenu() {
  if (browser.isIE) {
    x =  document.getElementById("arquivoMenu").style.left;
    y =  document.getElementById("arquivoMenu").style.top;    
    w =  document.getElementById("arquivoMenu").style.width;
    h =  document.getElementById("arquivoMenu").style.height;
    frameM = document.getElementById("iFrameMenu");
    frameM.style.left    = x;
    frameM.style.top     = y;
    frameM.style.width   = w;
    frameM.style.height  = h;
    frameM.style.zIndex = document.getElementById("arquivoMenu").style.zIndex-1;
    frameM.style.visibility = "visible";
  }
  document.getElementById("arquivoMenu").className = "menuButtonActive";
  document.getElementById("arquivoMenu").style.visibility = "visible";
}

function fechaMenu(botao) {
  botao.className = "menuButton";
  if (botao.divDhtml != null) {
    if (browser.isIE) {
        frameM = document.getElementById("iFrameMenu");
        frameM.style.visibility = "hidden";
      }
    botao.divDhtml.style.visibility = "hidden";
  }
}


function getPageOffsetLeft(el) {
  var x;
  x = el.offsetLeft;
  if (el.offsetParent != null)
    x += getPageOffsetLeft(el.offsetParent);
  return x;
}

function getPageOffsetTop(el) {
  var y;
  y = el.offsetTop;
  if (el.offsetParent != null)
    y += getPageOffsetTop(el.offsetParent);
  return y;
}

