// MNB
// 3/25/09
// used to load the hover options of the browse by products on:
// http://www.panasonic.com/business/provideo/support/

function displayProductHover(object)
{
    var currentProductHover = document.getElementById(object.id + "-hover");
    
    clearCurrentHovers(object);
    
    currentProductHover.style.display = 'block'; 
}

function hideProductHover(e, object)
{
    //declare full product hover as well as just the links section
    var currentProductHover = document.getElementById(object.id);
    var currentProductHoverLinks = document.getElementById(object.id + "-links");
    
    //get the mouse coordinates
    var mouseX = Event.pointerX(e);
    var mouseY = Event.pointerY(e);

    //get the scroll bar offsets incase the scroll bar is at the very top and far left
    var scrollLeftOffset = document.documentElement.scrollLeft;
    var scrollTopOffset = document.documentElement.scrollTop;
    
    //see if the cursor is in the hover links section above the image
    
    //get the position of the current hoverLinks
    //uses prototype.js
    var currentProductHoverLinksLeft = Position.page(currentProductHoverLinks)[0];
    var currentProductHoverLinksTop = Position.page(currentProductHoverLinks)[1];
    
    //use prototypes function to get the dimension
	//Usefull because it also checks for borders
	//uses prototype.js
    var containerDimensions = currentProductHoverLinks.getDimensions();
    var height   = containerDimensions.height;
    var width = containerDimensions.width;
    
//    alert("x-" + mouseX);
//    alert("right-" + (width + currentProductHoverLinksLeft));
//    alert("left-" + (currentProductHoverLinksLeft));

//    alert("y-" + mouseY);
//    alert("top-" + (currentProductHoverLinksTop));
//    alert("offset-" + (scrollTopOffset));
//    alert("bottom-" + (height + currentProductHoverLinksTop));
    
    //checks to see if the cursor is outside of the div
    if(mouseX >= (width + (currentProductHoverLinksLeft) + scrollLeftOffset) || mouseY >= (height + (currentProductHoverLinksTop) + scrollTopOffset) || (mouseX - 1) <= (currentProductHoverLinksLeft + scrollLeftOffset) || (mouseY - 1) <= (currentProductHoverLinksTop + scrollTopOffset))
    {
        currentProductHover.style.display = 'none'; 
    }
}

function clearCurrentHovers(object)
{
    var currentHoverId = object.id;
    var tempHoverId;
    
    for (var i = 1; i < 6; i++)
    {
        tempHoverId = document.getElementById("product-" + i + "-hover");

        if (tempHoverId != currentHoverId)
        {
            tempHoverId.style.display = 'none';
        }
    }
}