function getPosition() 
{
	var top, left, height, width;
	
	if (window.pageYOffset)
	{
		top = window.pageYOffset;
		left = window.pageXOffset;
	}
	else if (document.documentElement && document.documentElement.scrollTop)
	{
		top = document.documentElement.scrollTop;
		left = document.documentElement.scrollLeft;
	}
	else if (document.body)
	{
		top = document.body.scrollTop;
		left = document.body.scrollLeft;
	}

	if (window.innerWidth)
	{
		width = window.innerWidth;
		height= window.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientWidth)
	{
		width = document.documentElement.clientWidth;
		height = document.documentElement.clientHeight;
	}
	else if (document.body)
	{
		width = document.body.clientWidth;
		height = document.body.clientHeight;			
	}

	return {top:top, left:left, height:height, width:width};
}

function pngDlg(container_id, caption, x, y, w, h, content_url) 
{
	var container = document.getElementById(container_id);
	var bg_layer = document.getElementById('pngdialog');
	var fg_layer;

	if (bg_layer) 
		hidePngDlg();
	
	bg_layer = document.createElement('div');
	bg_layer.setAttribute('id', 'pngdialog');
	bg_layer.style.position = 'absolute';
	bg_layer.style.left = x + 'px';
	bg_layer.style.top = y + 'px';
	bg_layer.style.width = w;
	bg_layer.style.height = h;
	bg_layer.style.zIndex = 2;
	container.appendChild(bg_layer);
	
	fg_layer = document.createElement('div');
	fg_layer.setAttribute('id', 'fg_layer');
	fg_layer.style.position = "absolute";
	fg_layer.style.left = x + 20 + 'px';
	fg_layer.style.top = y + 20 + 'px';
	fg_layer.style.width = w;
	fg_layer.style.height = h;
	fg_layer.style.zIndex = 3;

	fg_layer.innerHTML =
		"<div style='height:30px; font-family:Arial;font-size:20px;font-weight:bold;color:#040;padding-left:10px;padding-top:0px;'>" +
		caption + 
		"</div>" + 
		"<div style='position:absolute;top:-5px;left:450px;'>" +
		"<img src='images/closeico.gif' style='CURSOR:pointer' onclick='hidePngDlg();' alt='Close' />" +
		"</div>" +
		"<iframe sytle='top:42px;left:20px;' height='470px' width='470px' frameborder='0' scrolling='auto' src='" + content_url + "' id='content-if'></iframe>";
	container.appendChild(fg_layer);
}

function hidePngDlg()
{
	var bg_layer = document.getElementById('pngdialog');
	var fg_layer = document.getElementById('fg_layer');
	if (bg_layer && fg_layer) 
	{
		var pnode = bg_layer.parentNode;

		pnode.removeChild(fg_layer);
		pnode.removeChild(bg_layer);
	}
}

function addLoadEvent(func)
{
	var	oldonload = window.onload;
	
	if (typeof window.onload != 'function')
	{
		window.onload = func;
	}
	else
	{
		window.onload = function() 
		{
			oldonload();
			func();
		}
	}
}																      
	
function insertAfter(newElement, targetElement)
{
	var	parent = targetElement.parentNode;
	if (parent.lastChild == targetElement)
		parent.appendChild(newElement);
	else
		parent.insertBefore(newElement, targetElement.nextSibling);
}

function addClass(element, class_name)
{
	if (!element.className)
		element.className = class_name;
	else
	{
		var newClassName = element.className;
		newClassName += ' ';
		newClassName += class_name;
		element.className = newClassName;
	}
}

function focusLabels()
{
	if (!document.getElementByTagName)	return false;
	
	var labels = document.getElementByTagName("label");
	for (var i = 0; i < labels.length; i++)
	{
		if (!labels[i].getAttribute("for"))	continue;
		labels[i].onclick = function()
		{
			var id = this.getAttribute("for");
			if (!document.getElementById("id")) return false;
			var element = document.getElementById(id);
			element.focus();
		}
	}
}

function stripeTable(table_id)
{
	if (!document.getElementsByTagName)	return false;
	
	var table = document.getElementById(table_id);
	if (table)
	{
		var	odd = false;
		var	rows = table.getElementByTagName("tr");
		for (var i = 0; i < rows.length; i++)
		{
			if (odd == true)
			{
				addClass(rows[i], "odd");
				odd = false;
			}
			else
				odd = true;
		}
	}
}

function highlightRow(table_id)
{
	if (!document.getElementById)	return false;

	var table = document.getElementById(table_id);
	if (table)
	{
		var rows = table.getElementByTagName("tr");
		for (var i = 0; i < rows.length; i++)
		{
			rows[i].oldClassName = rows[i].className;
			rows[i].onmouseover = function()
			{
				addClass(this, "highlight");
			}
			rows[i].onmouseout = function()
			{
				this.className = this.oldClassName;
			}
		}
	}
}