// JavaScript Document
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * Pop - it menu - © Dynamic Drive (www.dynamicdrive.com)
 * This notice MUST stay intact for legal use
 * Visit http : // www.dynamicdrive.com / for full source code
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

var defaultMenuWidth = "350px" // set default menu width.
var linkset = new Array()
var followMouseInterval; 
var menuobj; 
var lastLink; 

//// No need to edit beyond here

var ie5 = document.all && ! window.opera
var ns6 = document.getElementById

if (ie5 || ns6)document.write('<div id="popitmenu" onMouseover="clearhidemenu();" onMouseout="dynamichide(event)"></div>')

function iecompattest()
{
   return (document.compatMode && document.compatMode.indexOf("CSS") != - 1) ? document.documentElement : document.body
}

function showmenu(e, which, lnk)
{
   if ( ! document.all && ! document.getElementById) return;
   if (!menuobj) menuobj = document.getElementById("popitmenu"); 
   if((a=document.getElementById("combo_busca")))
   {
		a.style.display = "none";    
		document.getElementById("combo_fake").style.display="block";
   }
   
   clearhidemenu();
   // for(i in lnk) alert(i + ">>" + lnk[i]);
   if(lastLink) lastLink.className = 'a12cinzabold';
   lastLink = lnk; 
   lnk.className = "a12pretoTop";
   menuobj.innerHTML = document.getElementById(which).innerHTML; 
   menuobj.contentwidth = menuobj.offsetWidth;
   menuobj.contentheight = menuobj.offsetHeight;
   mousemove(e,lnk);  
   menuobj.style.visibility = "visible"
   
  
   return false; 
}



function mousemove(e,obj)
{
  
   pos = findPos(obj); 
   eventX = pos[0]; 
   
   if(ie5) 
   {
   	eventY = pos[1] + obj.offsetHeight - 10;
   } else 
   {
	eventY = pos[1] + obj.offsetHeight - 2;
   }
   // Find out how close the mouse is to the corner of the window
	var rightedge = ie5 ? iecompattest().clientWidth - eventX : window.innerWidth - eventX;
	var bottomedge = ie5 ? iecompattest().clientHeight - eventY : window.innerHeight - eventY;
	var temp = eventX;
	menuobj.style.left = temp + "px";   
	menuobj.style.top = eventY + "px"; 
}

function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}


function contains_ns6(a, b)
{
   // Determines if 1 element in contained in another - by Brainjar.com
   var b; 
   
   while (b.parentNode)
   if ((b = b.parentNode) == a)
   return true;

   return false;
}

function hidemenu()
{
   if (window.menuobj)
   {
	lastLink.className = 'a12cinzabold';
    menuobj.style.visibility = "hidden"
	if((a=document.getElementById("combo_busca")))
    {
		a.style.display = "block";    
		document.getElementById("combo_fake").style.display="none";
    }
	clearhidemenu()
    //document.onmousemove = function(){}; 
   }
}

function dynamichide(e)
{
   if (ie5 && ! menuobj.contains(e.toElement))
   {
      hidemenu()
   }
   else if (ns6 && e.currentTarget != e.relatedTarget && ! contains_ns6(e.currentTarget, e.relatedTarget))
   {
      hidemenu()
   }
}

function delayhidemenu()
{
   delayhide = setInterval("hidemenu()", 10)
}

function clearhidemenu()
{
   if (window.delayhide) 
   {
       clearInterval(delayhide)
       //document.onmousemove = function(){};
   }
}

if (ie5 || ns6) 
{
    document.onclick = hidemenu
}
