var globalX;
var globalY;
var firefox=document.getElementById&&!document.all;

function Position(e)
{
	if(firefox)
	{
		globalX=e.clientX;
		globalY=e.clientY;
	}
	else
	{
		globalX = event.clientX;
		globalY = event.clientY;
	}
}
document.onmousemove = Position;
var defaultMenuWidth="150px" //setdefault menu width.

var ie5=document.all && !window.opera
var ns6=document.getElementById

if (ie5||ns6)
document.write('<div id="produtoPop" onMouseover="clearhidemenu();" onMouseout="dynamichide(event)" style="position:absolute;" ></div>')

function iecompattest(){
return (document.compatMode && document.compatMode.indexOf("CSS")!=-1)? document.documentElement : document.body
}

function produtoPop(e, cod, capa, artista, nome, valor, valorfaixa, valoralbum, tipoMedia){

if (!document.all&&!document.getElementById)
return

clearhidemenu();
quadro= document.getElementById('produtoPop'); <!--ie5? document.all.produtoPop : document.getElementById("produtoPop")-->
quadro.innerHTML="<div><center><img src=\"templates/images/wait.gif\"></center></div>";

if (tipoMedia=='DVD')
{
	var w = '70';
	var h = '94';
}else{
	var w = '94';
	var h = '94';

}

if(valor=='' && valorfaixa=='')
	var valorfaixa = "";
	//var valorfaixa = "<p><b>produto indispon�vel</b></p>";
else
{
	bla = "R$ "+valor;
	//valor = bla;
	
if (valoralbum=='')
{
	var valoralbum = '';
}else{

	//var valoralbum = "<p>Album Digital: <b>R$ "+ valoralbum +"</b></p>";
	var valoralbum = '';

}

if (valorfaixa=='')
{
	var valorfaixa = '';
}else{

	var valorfaixa = "<p>Faixa Digital: <b>R$ "+ valorfaixa + "</b></p>";

}
	var valor="";
}
	

eventX=globalX; <!--ie5? event.clientX : e.clientX;-->

eventX = eventX + 30;
eventY= globalY;<!--ie5? event.clientY : e.clientY;-->

eventY = eventY + 30;


	
	

//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
//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<quadro.contentwidth)
//move the horizontal position of the menu to the left by it's width
quadro.style.left=ie5? iecompattest().scrollLeft+eventX-quadro.contentwidth+"px" : window.pageXOffset+eventX-quadro.contentwidth+"px"
else
//position the horizontal position of the menu where the mouse was clicked
quadro.style.left=ie5? iecompattest().scrollLeft+eventX+"px" : window.pageXOffset+eventX+"px"
//same concept with the vertical position
if (bottomedge<quadro.contentheight)
quadro.style.top=ie5? iecompattest().scrollTop+eventY-quadro.contentheight+"px" : window.pageYOffset+eventY-quadro.contentheight+"px"
else
quadro.style.top=ie5? iecompattest().scrollTop+event.clientY+"px" : window.pageYOffset+eventY+"px"
quadro.style.visibility="visible"

quadro.innerHTML = "<div id='produtoPop-img'><img src='gallery/produtos/imagens/2-"+ capa +"' height='"+ h +"' width='"+ w +"' align='left'></div><div id='produtoPop-info'><p><b>"+ tipoMedia +" - "+ nome +"</b><BR>"+ artista +"</p><p><B><font size='2'> "+ valor +"</font></B></p>"+ valorfaixa +""+ valoralbum +"</div>";

return false
}



function textPop(e, texto){

if (!document.all&&!document.getElementById)
return
clearhidemenu()
quadro=ie5? document.all.produtoPop : document.getElementById("produtoPop")
quadro.innerHTML="<div><center><img src=\"templates/images/wait.gif\"></center></div>"

eventX=ie5? event.clientX : e.clientX

eventX = eventX + 30;
eventY=ie5? event.clientY : e.clientY

eventY = eventY + 30;

//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
//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<quadro.contentwidth)
//move the horizontal position of the menu to the left by it's width
quadro.style.left=ie5? iecompattest().scrollLeft+eventX-quadro.contentwidth+"px" : window.pageXOffset+eventX-quadro.contentwidth+"px"
else
//position the horizontal position of the menu where the mouse was clicked
quadro.style.left=ie5? iecompattest().scrollLeft+eventX+"px" : window.pageXOffset+eventX+"px"
//same concept with the vertical position
if (bottomedge<quadro.contentheight)
quadro.style.top=ie5? iecompattest().scrollTop+eventY-quadro.contentheight+"px" : window.pageYOffset+eventY-quadro.contentheight+"px"
else
quadro.style.top=ie5? iecompattest().scrollTop+event.clientY+"px" : window.pageYOffset+eventY+"px"
quadro.style.visibility="visible"
//Decodificando
texto = texto.replace(/\+/g," ")
quadro.innerHTML = '<div id="text-info" align="center">'+ unescape(texto) +'</div>';

return false
}
function contains_ns6(a, b) {
//Determines if 1 element in contained in another- by Brainjar.com
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function hidemenu(){
if (window.quadro)
quadro.style.visibility="hidden"
}

function dynamichide(e){
if (ie5&&!quadro.contains(e.toElement))
hidemenu()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
hidemenu()
}

function delayhidemenu(){
delayhide=setTimeout("hidemenu()",500)
}

function clearhidemenu(){
if (window.delayhide)
clearTimeout(delayhide)
}