var imgBigGreenArrowLink_Over = new Image();
var imgBigGreenArrowLink = new Image();
var imgArrowLink_Over = new Image();
var imgArrowLink = new Image();
var imgHelp = new Image();
var imgHelp_Over = new Image();
var imgHelpLarge = new Image();
var imgHelpLarge_Over = new Image();
var imgClose = new Image();
var imgClose_Over = new Image();
var detect = navigator.userAgent.toLowerCase();
var OS,browser,version,total,thestring;

imgBigGreenArrowLink_Over.src = "http://" + window.location.host + "/img/action_over.gif";
imgBigGreenArrowLink.src = "http://" + window.location.host + "/img/action.gif";
imgArrowLink_Over.src = "http://" + window.location.host + "/img/arrowSubmitOver.png";
imgArrowLink.src = "http://" + window.location.host + "/img/arrowSubmit.png";
imgHelp.src = "http://" + window.location.host + "/img/help-icon.png";
imgHelp_Over.src = "http://" + window.location.host + "/img/help-icon_over.png";
imgHelpLarge.src = "http://" + window.location.host + "/img/help-icon-large.png";
imgHelpLarge_Over.src = "http://" + window.location.host + "/img/help-icon-large_over.png";
imgClose.src = "http://" + window.location.host + "/img/close.png";
imgClose_Over.src = "http://" + window.location.host + "/img/close_over.png";

if (checkIt('konqueror'))
{
	browser = "Konqueror";
	OS = "Linux";
}
else if (checkIt('safari')) browser = "Safari"
else if (checkIt('omniweb')) browser = "OmniWeb"
else if (checkIt('opera')) browser = "Opera"
else if (checkIt('webtv')) browser = "WebTV";
else if (checkIt('icab')) browser = "iCab"
else if (checkIt('msie')) browser = "Internet Explorer"
else if (!checkIt('compatible'))
{
	browser = "Netscape Navigator"
	version = detect.charAt(8);
}
else browser = "An unknown browser";

if (!version) version = detect.charAt(place + thestring.length);

if (!OS)
{
	if (checkIt('linux')) OS = "Linux";
	else if (checkIt('x11')) OS = "Unix";
	else if (checkIt('mac')) OS = "Mac"
	else if (checkIt('win')) OS = "Windows"
	else OS = "an unknown operating system";
}

function checkIt(string)
{
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}

var oPopup = (browser == "Internet Explorer") ? window.createPopup() : null;

function showPopUp(oReference, sText, x, y){
	insertHelpTable();
	if(browser == "Internet Explorer"){
		var oPopupBody = oPopup.document.body;
		var oTable = document.getElementById('HelpTable');
		var oCell = document.getElementById('HelpCell');
		oCell.innerHTML = sText;
		oPopupBody.style.backgroundColor = "#2C5086";
		oPopupBody.style.border = "solid LightSteelBlue 1px";
		oPopupBody.style.color = "White";
		oTable.style.fontFamily = "Arial";
		oTable.style.fontSize = "8pt";
		oPopupBody.style.filter = "progid:DXImageTransform.Microsoft.Fade(duration=0.35)"
		oPopupBody.filters.item(0).Apply();
		oPopupBody.filters.item(0).Play();
		oTable.style.top = -1000;
		oTable.style.left = -1000;
		oPopupBody.innerHTML = oTable.outerHTML;
		oPopup.show(14, 16, oTable.offsetWidth, oTable.offsetHeight, oReference);
	} else if(document.getElementById('HelpTable')){
		var oTable = document.getElementById('HelpTable');
		var oCell = document.getElementById('HelpCell');
		oCell.innerHTML = sText;
		oTable.style.position = "absolute";
		oTable.style.top = findPosY(oReference) + 10;
		oTable.style.left = findPosX(oReference) + 10;
		oTable.style.display = "inline";
		oTable.style.zIndex = "100";
	}
}

function hidePopUp(){
	if(oPopup && oPopup.isOpen){
		oPopup.hide();
	}else if(document.getElementById('HelpTable')){
		document.getElementById('HelpTable').style.display = "none";
	}
}

function insertHelpTable(){
	if(browser == "Internet Explorer"){
		if(document.body){
			var oBody = document.body;
			var sTable = "<table class='tblHelp' id='HelpTable'><tr><td id='HelpCell'></td></tr></table>";
			oBody.insertAdjacentHTML("afterBegin", sTable);
		}
	}else{		
		var oBody = document.getElementsByTagName("body").item(0);
		var oTable = document.createElement("TABLE");
		var oTableBody = document.createElement("TBODY");
		var oTableRow = document.createElement("TR");
		var oTableCell = document.createElement("TD");
		
		oTableRow.appendChild(oTableCell);
		oTableBody.appendChild(oTableRow);
		oTable.appendChild(oTableBody);
		oBody.appendChild(oTable);
		
		oTable.setAttribute("id", "HelpTable");
		oTable.setAttribute("class", "tblHelp");
		oTableCell.setAttribute("id", "HelpCell");
	}
}

function findPosX(obj)
{
	var curleft = 0;
	alert(obj.offsetLeft);
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}