/****************
 (c) 2006 by Forger
 ----------------------
 open 'external' links
 in a separate window
 ****************/

addEV(window, 'load', externalLinks);

function externalLinks()
{
	if (!document.getElementsByTagName)
		return;

	var anchors = document.getElementsByTagName("a");
	var sw = window.screen.width;
	var sh = window.screen.height;

	var width = 805;
	var height = 660;

	//calc center window position
	var sx = (sw / 2) - (width / 2);
	var sy = (sh / 2) - (height / 2);

	var winopts =
	{
		width:	width,
		height:	height,
		left:	sx,
		top:	sy,
		menubar:	"no",
		toolbar:	"no",
		location:	"no",
		directories:	"no",
		status:	"no",
		resizable:	"yes",
		scrollbars:	"yes"
	};

	//create options string
	var popts_a = [];

	for (var pname in winopts)
	{
		popts_a.push(pname + "=" + winopts[pname]);
	}

	var popts = popts_a.join(",");

	for (var i = 0; i < anchors.length; i++)
	{
		var anchor = anchors[i];
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external")
		{
			addEV(anchor, 'click', function() {window.open(anchor.getAttribute("href"), "Fraczek", popts);});
			anchor.target = "Fraczek";
		}
	}
}

function addEV(obj, name, method)
{
	if (obj.addEventListener)
	{
		obj.addEventListener(name, method, false);
	}
	else if (obj.attachEvent)
	{
		obj.attachEvent('on' + name, method);
	}
}
