﻿
function setPopup()
{
	if (!document.getElementsByTagName) return false;
	var linkNode = document.getElementsByTagName('a');
	for (var i in linkNode)
	{
		if(linkNode[i].className == 'popup')
		{
			linkNode[i].onclick = function()
			{
				return doWindowOpen(this.href, this.rel);
			};
		}
	}
}

function doWindowOpen(url, rel)
{
	var split = rel.split(',');
	var width  = (split[0] != undefined) ? split[0] : "470";
	var height = (split[1] != undefined) ? split[1] : "600";
	var x = (screen.width - width) / 2;
	var y = (screen.height - height) / 2; 
	var win = window.open(url + "&w=" + width + "&h=" + height, 'popup', 'top=' + x + ',left=' + y + ',width=' + width + ',height=' + height + ',toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no');
	win.moveTo( x, y );
	win.focus();
	return false;
}

window.onload = setPopup;
