// JavaScript Document
var xmlHttp;
var toHide = 0;
var etype;

function getPopUp(url)
{    
    xmlHttp=GetXmlHttpObject();
    
    if (xmlHttp==null)
    {
        alert ("Browser does not support HTTP Request");
        return;
    } 
    
    xmlHttp.onreadystatechange=displayPage;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
} 

function displayPage() 
{ 
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    {
        document.getElementById("popup").innerHTML = xmlHttp.responseText;
	    document.getElementById("popupDisplay").style.display = "block";
	}		
} 

function GetXmlHttpObject(handler)
{ 
    var objXMLHttp=null;
    
    if (window.XMLHttpRequest)
    {
        objXMLHttp=new XMLHttpRequest();
    }
    else if (window.ActiveXObject)
    {
        objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    
    return objXMLHttp;
}

function showProductInfo(url, e)
{
	getPopUp(url);
	
	toHide = 0;

	var elSrc;
		
   	if (!e)
	{
		e = window.event;				
	}
   	if (e.target) 
	{
		elSrc = e.target;
	} 
	else if (e.srcElement) 
	{
	    elSrc = e.srcElement;
	}
	etype = e.type;    
	var x, y, obj;
	
	x = y = 0;
	obj = elSrc;
	    
	if(obj.offsetParent) 
	{
	while (obj) 
		{
		    x += obj.offsetLeft;
		    y += obj.offsetTop;
	    	obj = obj.offsetParent;
	    }
    } 
	else 
	{
	   	x = obj.x;
	    y = obj.y;
    }
		
	if (document.layers || document.getElementById && !document.all) 
	{
		y = e.pageY - 140; //40;
		x = e.pageX - 40;
		w = window.innerWidth;
		h = window.innerHeight;		
	}
	//IE
	else if (document.all) 
	{
		y = (window.event.clientY + document.body.scrollTop) - 140;//40;
		x = (window.event.clientX + document.body.scrollLeft) - 40;
		w = document.body.clientWidth;
		h = document.body.clientHeight;		
	}
    if (y > h - 30) y = y - 50;
	if (y < 30) y = 30;
	if (x+300 > w) x = w-300;	
	document.getElementById("popupDisplay").style.top = y + "px";
	document.getElementById("popupDisplay").style.left = x + "px";
	document.getElementById("popupDisplay").style.width = 300;
}
	  
function hideDiv(layer)
{
	toHide = 1;		
	if (etype == 'mouseover') setTimeout("closeDiv()", 2000);
}	
	
function closeDiv()
{		
	if(toHide == 1)
	{
		document.getElementById("popupDisplay").style.display = "none";
	}
}
	
function closeDivNOW()
{
	document.getElementById("popupDisplay").style.display = "none";
}
	
function cancelClose()
{
	toHide = 0;
}