if(window.navigator.appName.toLowerCase().indexOf("netscape") == -1)
{
	window.attachEvent("onload", InitPopUpInfo);
}
else
{
	// Netscape
	window.addEventListener("load", InitPopUpInfo, true); 
}

var selectBoxes;

function InitPopUpInfo()
{
	var documentLinks = document.links;
	var documentImages = document.images;
	var popupLinks = new Array();

	selectBoxes = document.getElementsByTagName("select");

	for(i=0; i<documentLinks.length; i++)
	{
		if(documentLinks[i].className.indexOf("popupInfo") != -1)
			popupLinks.push(documentLinks[i]);
	}

	for(i=0; i<documentImages.length; i++)
	{
		if(documentImages[i].className.indexOf("popupInfo") != -1)
			popupLinks.push(documentImages[i]);
	}
	
	if(popupLinks.length > 0)
	{
		CreatePopupLayer();
	}
	else
	{
		return;
	}
	
	for(i=0; i<popupLinks.length; i++)
	{
		var popupInfoLayer = document.getElementById("popupInfoLayer");
		
		popupLinks[i].onmousemove = function(e)
		{
			var leftOffset = 0;
			if(rightPopup)
			{
				leftOffset = 200;
			}

			if(this.active != true)
			{
				CreatePopupLayer(e);
			
				popupInfoLayer.style.visibility = "visible";
				var popupContent = document.getElementById("popupInfoText");
				
				popupContent.innerHTML = this.title;
				this.title = "";
			}
			
			if(window.navigator.appName.toLowerCase().indexOf("internet explorer") == -1)
			{
				popupInfoLayer.style.left = (e.pageX - leftOffset - 40) + "px";
				popupInfoLayer.style.top = (e.pageY - popupInfoLayer.clientHeight) + "px"; 
			}
			else
			{
				getMouseXY(e);
			
				// Lokalt?
				//popupInfoLayer.style.left = (window.event.x - 40 + window.parent.document.documentElement.scrollLeft) + "px";
				//popupInfoLayer.style.top = (window.event.y - 5 + window.parent.document.documentElement.scrollTop - popupInfoLayer.clientHeight) + "px";
				//popupInfoLayer.style.left = (window.event.x - 40 + document.body.scrollLeft) + "px";
				//popupInfoLayer.style.top = (window.event.y - 5 + document.body.scrollTop - popupInfoLayer.clientHeight) + "px";

				//popupInfoLayer.style.left = (mousex - 40 + window.parent.document.documentElement.scrollLeft) + "px";
				//popupInfoLayer.style.top = (mousey - 5 - popupInfoLayer.clientHeight + window.parent.document.documentElement.scrollTop) + "px";
				
				var scrollTop = 0;
				var scrollLeft = 0;
				
				//window.alert(document.body.scrollTop);
				
				/*
				if(document.body.scrollTop)
				{
					scrollTop = document.body.scrollTop;
					scrollLeft = document.body.scrollLeft;
				}
				
				else if(window.parent.document.documentElement.scrollTop != 0)
				{
					scrollTop = window.parent.document.documentElement.scrollTop;
					scrollLeft = window.parent.document.documentElement.scrollLeft;
				}
				*/
				
				popupInfoLayer.style.left = (mousex - 40 - leftOffset + scrollLeft) + "px";
				popupInfoLayer.style.top = (mousey - 5 + scrollTop - popupInfoLayer.clientHeight) + "px";
			}	
			
			
			if(window.navigator.appVersion.indexOf("MSIE 6.0") != -1)
			{
				for(j=0; j<selectBoxes.length; j++)
				{
					selectBoxes[j].style.visibility = "hidden";
				}
			}
			//selectBoxes
		
		this.active = true;
		}

		popupLinks[i].onmouseout = function()
		{
			var popupContent = document.getElementById("popupInfoText");
			this.title = popupContent.innerHTML;
			popupInfoLayer.style.visibility = "hidden";
			this.active = false;
			
			if(window.navigator.appVersion.indexOf("MSIE 6.0") != -1)
			{
				for(j=0; j<selectBoxes.length; j++)
				{
					selectBoxes[j].style.visibility = "visible";
				}
			}
			
		}
		
		popupLinks[i].onclick = function()
		{
			return false;
		}
	}
	
}

var rightPopup = false;
var currentPos = "right";

function CreatePopupLayer(e)
{
	var popupInfoLayer = document.getElementById("popupInfoLayer");
	
	if(rightPopup)
		currentPoss = "left";
	
	if(!popupInfoLayer)
	{
//		popupInfoLayer = document.createElement("div");
//		popupInfoLayer.id = "popupInfoLayer";
//		document.body.appendChild(popupInfoLayer);
//		popupInfoLayer.style.position = "absolute"; 
//		popupInfoLayer.style.visibility = "hidden"; 
//		popupInfoLayer.style.width = "272px"; 
//		popupInfoLayer.innerHTML = "<img src=\"images/popuplefttop.png\" style=\"width:272px; height:10px;\" class=\"pngfix\"/><div id=\"popupInfoText\" style=\"background-image:url(images/popupleftmiddle.png); color:#ffffff; padding-left:11px; padding-right:14px; font-size:11px; width:247px\" class=\"pngfix\"></div><img src=\"images/popupleftbottom.png\" style=\"width:272px; height:42px;\" class=\"pngfix\" />";
		currentPos = "right";		
	}
	
	getMouseXY(e);
	
	if((mousex + 272) >= document.body.clientWidth)
		rightPopup = true;
	else
		rightPopup = false;
	
rightPopup = true;

	//window.alert(document.body.clientWidth + " " + mousex);	
	if(rightPopup && currentPos == "left")
	{
    popupInfoLayer.className = "popupInfoLeft";	
//		popupInfoLayer.style.position = "absolute"; 
//		popupInfoLayer.style.visibility = "hidden"; 
//		popupInfoLayer.style.width = "272px"; 
//		popupInfoLayer.innerHTML = "<img src=\"images/popuplefttop.png\" style=\"width:272px; height:10px;\" class=\"pngfix\"/><div id=\"popupInfoText\" style=\"background-image:url(images/popupleftmiddle.png); color:#ffffff; padding-left:11px; padding-right:14px; font-size:11px; width:247px\" class=\"pngfix\"></div><img src=\"images/popupleftbottom.png\" style=\"width:272px; height:42px;\" class=\"pngfix\" />";
		currentPos = "right";
	}
	else if(currentPos == "right" && rightPopup == false)
	{
	  popupInfoLayer.className = "popupInfoRight";
//		popupInfoLayer.style.position = "absolute"; 
//		popupInfoLayer.style.visibility = "hidden"; 
//		popupInfoLayer.style.width = "272px"; 
//		popupInfoLayer.innerHTML = "<img src=\"images/popuptop.png\" style=\"width:272px; height:10px;\" class=\"pngfix\"/><div id=\"popupInfoText\" style=\"background-image:url(images/popupmiddle.png); color:#ffffff; padding-left:11px; padding-right:14px; font-size:11px; width:247px\" class=\"pngfix\"></div><img src=\"images/popupbottom.png\" style=\"width:272px; height:42px;\" class=\"pngfix\" />";
		currentPos = "left";
	}

}

var mousex = 0;
var mousey = 0;
var algor = 0;

function getMouseXY(e) // works on IE6,FF,Moz,Opera7
{ 
  if (!e) e = window.event; // works on IE, but not NS (we rely on NS passing us the event)

  if (e)
  { 
    if (e.pageX || e.pageY)
    { // this doesn't work on IE6!! (works on FF,Moz,Opera7)
      mousex = e.pageX;
      mousey = e.pageY;
      algor = '[e.pageX]';
      if (e.clientX || e.clientY) algor += ' [e.clientX] ';
    }
    else if (e.clientX || e.clientY)
    { // works on IE6,FF,Moz,Opera7
			// Lokalt?
      mousex = e.clientX + document.body.scrollLeft;
      mousey = e.clientY + document.body.scrollTop;
      algor = '[e.clientX]';
      if (e.pageX || e.pageY) algor += ' [e.pageX] ';
    }  
  }
}

