/***********************************************
* AnyLink Drop Down Menu- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

//Contents for menu
var menuCinema=new Array()
menuCinema[0]='<a href="/filmes/ranking/">Filmes</a>';
menuCinema[1]='<a href="/seriados-e-tv/ranking/">Seriados e TV</a>';
menuCinema[2]='<a href="/astros-e-estrelas/ranking/">Astros e Estrelas</a>';

var menuMusica=new Array()
menuMusica[0]='<a href="/musicas/ranking/">Músicas</a>';
menuMusica[1]='<a href="/artistas/ranking/">Artistas</a>';

//Contents for menu 1
var menuLeitura=new Array()
menuLeitura[0]='<a href="/livros/ranking/">Livros</a>';
menuLeitura[1]='<a href="/autores/ranking/">Autores</a>';

//Contents for menu 1
var menuGastronomia=new Array()
menuGastronomia[0]='<a href="/restaurantes/ranking/">Restaurantes</a>';
menuGastronomia[1]='<a href="/bares-cafes-e-cia/ranking/">Bares, Cafés e Cia</a>';

//Contents for menu 1
var menuViagem=new Array()
menuViagem[0]='<a href="/atracoes/ranking/">Atrações Turísticas</a>';
menuViagem[1]='<a href="/praias/ranking/">Praias</a>';
menuViagem[2]='<a href="/cidades/ranking/">Cidades</a>';
menuViagem[3]='<a href="/hoteis/ranking/">Hotéis</a>';

//Contents for menu 1
var menuInternet=new Array()
menuInternet[0]='<a href="/videos/ranking/">Vídeos</a>';
menuInternet[1]='<a href="/blogs/ranking/">Blogs</a>';

var menuwidth='180px' //default menu width
var menubgcolor=''  //menu bgcolor
var disappeardelay=250  //menu disappear speed onMouseout (in miliseconds)
var hidemenu_onclick="no" //hide menu when user clicks within menu?

/////No further editting needed

var ie4=document.all
var ns6=document.getElementById&&!document.all

if (ie4||ns6)
document.write('<div id="dropmenudiv" style="visibility:hidden;width:'+menuwidth+';" onMouseover="clearhidemenu()" onMouseout="dynamichide(event)"></div>')

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}


function showhide(obj, e, visible, hidden, menuwidth){
if (ie4||ns6)
dropmenuobj.style.left=dropmenuobj.style.top="-500px"
if (menuwidth!=""){
dropmenuobj.widthobj=dropmenuobj.style
dropmenuobj.widthobj.width=menuwidth
}
if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
obj.visibility=visible
else if (e.type=="click")
obj.visibility=hidden
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
var edgeoffset=0
if (whichedge=="rightedge"){
var windowedge=ie4 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
}
else{
var topedge=ie4 && !window.opera? iecompattest().scrollTop : window.pageYOffset
var windowedge=ie4 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure){ //move up?
edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) //up no good either?
edgeoffset=dropmenuobj.y+obj.offsetHeight-topedge
}
}
return edgeoffset
}

function populatemenu(what){
if (ie4||ns6)
//dropmenuobj.innerHTML=what.join("");
dropmenuobj.innerHTML='<div class="sombra">'+
	what.join("")+
	'</div><div class="sombra_bottom">&nbsp;</div>';
}

function dropdownmenu(obj, e, menucontents, menuwidth){
if (window.event) event.cancelBubble=true
else if (e.stopPropagation) e.stopPropagation()
clearhidemenu()
dropmenuobj=document.getElementById? document.getElementById("dropmenudiv") : dropmenudiv
populatemenu(menucontents)

if (ie4||ns6){
showhide(dropmenuobj.style, e, "visible", "hidden", menuwidth)
dropmenuobj.x=(getposOffset(obj, "left")-6)
dropmenuobj.y=getposOffset(obj, "top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"
}

return clickreturnvalue()
}

function clickreturnvalue(){
if (ie4||ns6) return false
else return true
}

function contains_ns6(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function dynamichide(e){
if (ie4&&!dropmenuobj.contains(e.toElement))
delayhidemenu()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
delayhidemenu()
}

function hidemenu(e){
if (typeof dropmenuobj!="undefined"){
if (ie4||ns6)
dropmenuobj.style.visibility="hidden"
}
}

function delayhidemenu(){
if (ie4||ns6)
delayhide=setTimeout("hidemenu()",disappeardelay)
}

function clearhidemenu(){
if (typeof delayhide!="undefined")
clearTimeout(delayhide)
}

if (hidemenu_onclick=="yes")
document.onclick=hidemenu

// RANDOMIZER //
function getId(id){ return document.getElementById(id) }

function getIdNext(id,posicao)
{
    var i;
    
    for (i=0;i<random.idMax;i++)
    {
        if ($('hot_items_'+id) == null)
        {
            if (posicao == ">")
            {
                id++;
                if (id > random.idMax)
                    id = 1;
            }
            else
            {
                id--;
                if (id < 1)
                    id = random.idMax;
            }   
        }
        else
        {
            return id;
            break;
        }
    }
}

var random = {
  idMax:13,
  idAtual:1,
  prefix:'hot_items_',
  intervalId:'',
  show:'',
  play:function(obj){
  	//this.idMax = obj.numDestaques;
  	this.idAtual = getIdNext(this.idAtual,'>');
  	getId(this.prefix+this.idAtual).style.display = 'block';
  	this.show = (obj.show == 'play') ? 'play' : 'pause';
    this.intervalId = setInterval('random.next()',12000);
    this.showPlayPause('pause');
    return false;
  },
  pause:function(){
    clearInterval(this.intervalId);
    this.show = 'play';
    this.showPlayPause();
    return false;
  },
  previous:function(act){
    getId(this.prefix+this.idAtual).style.display = 'none';
    //if (this.idAtual > 1)
    //  this.idAtual -= 1;
    //else
    //  this.idAtual = this.idMax;
    this.idAtual = getIdNext(this.idAtual-1,'<');
    getId(this.prefix+this.idAtual).style.display = 'block';
    this.show = 'play';
    this.showPlayPause(act);
    return false;
  },
  next:function(act){
    getId(this.prefix+this.idAtual).style.display = 'none';
    //if (this.idAtual+1 > this.idMax)
    //	this.idAtual = 1;
    //else
    //	this.idAtual += 1;
    	this.idAtual = getIdNext(this.idAtual+1,'>');
    getId(this.prefix+this.idAtual).style.display = 'block';
    if (act == 'play')
    	this.show = 'play';
    this.showPlayPause(act);
    return false;
  },
  showPlayPause:function(action){
    var obj = getId(this.prefix+this.idAtual);
    var links = obj.getElementsByTagName('a');
    for (i=0; i<links.length; i++){
      if (links[i].className == 'play' || links[i].className == 'pause'){
	      if (links[i].className == this.show)
      		links[i].style.display = 'block';
	      else
      		links[i].style.display = 'none';
			}
    }
  }
}

function CloseBox(){
  document.getElementById('especialistaDescription').style.display = 'none';
}

function onytplayerStateChange(newState) {
  if (newState == 1 || newState == 3)
  {
    random.pause();
  }
}

function onYouTubePlayerReady(playerId) {
  ytplayerMusica = document.getElementById(playerId);
  ytplayerMusica.addEventListener("onStateChange", "onytplayerStateChange");
}

///// PRELOAD IMAGES //////
var _imgPP = 'http://www.oyo.com.br/img2.0/';
function preloadImages() { //v3.0
    var d=document;
    if(d.images){
      if(!d._p)
        d._p=new Array();
      var i, j=d._p.length, a=preloadImages.arguments;
      for(i=0; i<a.length; i++){
        //if (a[i].indexOf("#")!=0){
          d._p[j]=new Image;
          d._p[j].src=a[i];
          //document.write( '<img src="'+d._p[j].src+'" />' );
          //alert(d._p[j].src);
          j++;
        //}
      }
    }
}
preloadImages(
  _imgPP+'bg_dropdown.png',
  _imgPP+'bg_dropdown_7.png',
  _imgPP+'bg_dropdown_bottom.png'
);
///// PRELOAD IMAGES //////
