﻿
//////////////////////////
//   Window Variables   //
//////////////////////////
var distanceFromMouse = 20;
var windowColor = "#eeeeee";
var windowWidth = 425;
var windowHeight = 250;
var windowBorder = "solid 1px silver";
var windowBackgroundImage = "";
var displayWindowInSeconds = 1;

var tempX;
var tempY;
var timer;
document.onmouseover = getMouseXY;
var IE = document.all?true:false
if (!IE) document.captureEvents(Event.MOUSEMOVE)

function getMouseXY(e) {
    if (IE) 
    { // grab the x-y pos.s if browser is IE
        tempX = event.clientX + document.documentElement.scrollLeft;
        tempY = event.clientY + document.documentElement.scrollTop;
    }
    else 
    {  // grab the x-y pos.s if browser is NS
        tempX = e.pageX;
        tempY = e.pageY;
    }  
    // catch possible negative values in NS4
    if (tempX < 0){tempX = 0}
    if (tempY < 0){tempY = 0}  
   // return true
}
function showWindow(HTML)
{    
    clearTimeout(timer);
    document.onmousemove = getMouseXY;
    templateHTML = '<a href=javascript:hide() style=float:right >Close</a><br />';
    document.getElementById("divcontent").innerHTML = templateHTML + HTML;
    document.getElementById("hiddenDiv").style.position = "absolute"
    if(tempY > document.documentElement.clientHeight - windowHeight)
    {
        document.getElementById("hiddenDiv").style.top = tempY - windowHeight - distanceFromMouse + 'px';
    }
    else
    {
        document.getElementById("hiddenDiv").style.top = distanceFromMouse + tempY + 'px';
    }
    if(tempX > document.documentElement.clientWidth / 2)
    {
        document.getElementById("hiddenDiv").style.left = tempX - windowWidth - distanceFromMouse + 'px';
    }
    else
    {
        document.getElementById("hiddenDiv").style.left = distanceFromMouse + tempX + 'px';
    }
    document.getElementById("hiddenDiv").style.backgroundColor = windowColor;
    document.getElementById("hiddenDiv").style.backgroundImage = windowBackgroundImage;
    document.getElementById("hiddenDiv").style.width = windowWidth + "px";
    document.getElementById("hiddenDiv").style.height = windowHeight + "px";
    document.getElementById("hiddenDiv").style.border = windowBorder;
    document.getElementById("hiddenDiv").style.padding = "5px";
    document.getElementById("hiddenDiv").style.overflow = "auto";
    document.getElementById("hiddenDiv").style.font = "normal 12px arial";
    document.getElementById("hiddenDiv").style.visibility = "visible";   
    document.getElementById("hiddenDiv").style.zIndex = 40;
}

function hideWindow()
{
    clearTimeout(timer);
    timer = setTimeout('hide()',displayWindowInSeconds * 1000);    
}
function hide()
{
    document.getElementById("hiddenDiv").style.visibility = "hidden";
}
