
d = document;

function gE(k)
{
	return d.getElementById(k);
}

function gEs(k)
{
	var o=gE(k);
	if (!o) 
		return null;
	return o.style;
}

function setVisibility(o,f)
{
	if (!o) 
		return;
	o.visibility=f?"inherit":"hidden";
}

function setInnerHTML(k,h)
{
	var o=gE(k);
	if (o) o.innerHTML=h; 
	return h;
}

//=======================================================================================
function jzMeOv(e)
{
	jzPop(e.id);
}

// The popup choose the puzzle cut menu 
var idPop=0,idMouseExitTimeout=0;

// Show / Hide a popup panel.
function jzPop(id)
{	
	// if a different menu is already visible, hide it.
	if (idPop !=0 && idPop != id)
	{
		// Hide the popup
		setVisibility(gEs(idPop+"R"),0);
		gE(idPop).className="jzMeLeft";
		idPop=0;
	}
	
	if (id)
	{
		// Display the popup
		setVisibility(gEs(id+"R"),1);
		gE(id).className="jzMeLeftHi";		
		idPop=id;
	}
}

// Called by onmousemove for window.
function mMove(e)
{	   
    // If the cut-pop-menu is open, test if the mouse has moved out of the panel. 
    if (idPop)
    {
    	if (!e) 
	  		var e = window.event;

		// Get the element which was moved over on	(in netscape OR IE)
   	var z=e["target"] || e.srcElement;
    	   
	   // Test if the mouse is inside or outside the cut-pop-menu panel
	   if (!nodeGetAncestorById(z, idPop+"R") && z.id != idPop)
	   {
	  	   // The mouse has moved out of the cut-pop-menu, set a timer to close the popup after a grace period.
	       if (!idMouseExitTimeout)
	  	      idMouseExitTimeout=setTimeout('jzPop(0)',250);
	   }
	   else
	   {
	  	   if (idMouseExitTimeout)
		   {  
		   		// The mouse has moved back into the cut-pop-menu after it has been scheduled for closure.
					// Cancel the closure timer to keep the cut-pop-menu visible.
	  	   		clearTimeout(idMouseExitTimeout);
		   		idMouseExitTimeout=0;
	  	   }
	   }
   }
}


// Used to test if the mouse is over the pop-cut-menu panel components.
function nodeGetAncestorById(o, id)
{	
	while (o && o.id != id)
	{
		o = o.parentNode;
	}
	return o;
}

// Catch the page mouse moves for the pop-cut-menu mouse out auto closure 
d.onmousemove=mMove;

//=======================================================================================
function mecm(o,c){o.innerHTML=c+'cm';o.className="o";}
function mein(o,i){o.innerHTML=i+'&quot;';o.className="";}
function jzShowExtraImg(path, w, h)
{
	var o = document.getElementById('jzPIEX'); 
	var i = '<img src="'+path+'" style="width:"'+w+'px;height:'+h+'px;"/>';
	
	if (!o.innerHTML)
		o.innerHTML=i;
	o.style.display="block";
}

function jzShowExtraHTML(html)
{
	var o = document.getElementById('jzPIEX'); 
	
	if (!o.innerHTML)
		o.innerHTML=html;
	
	o.style.display="block";
}

function jzHideExtra(html)
{
	var o = document.getElementById('jzPIEX'); 

	o.style.display="none";
}
