function popupimg(img, width, height)
{
    var popup = window.open('', 'popup'+new Date().getTime(), 'width='+width+', height='+height+', toolbar=no,location=no,status=no,resizable=no,scrollbars=yes,left='+(screen.width / 2 - width / 2)+',top='+(screen.height / 2 - height / 2));
    if (popup)
    {
        var doc = popup.document;
        doc.write('<html><head><meta http-equiv="imagetoolbar" content="no"><title></title></head><body style="margin:0;padding:0;overflow:hidden"><img src="'+img+'" onclick="window.close()"><script type="text/javascript">onload = function() { window.resizeTo(document.images[0].width + 12, document.images[0].height + 50); }</script></body></html>');
    }
    doc.close();
    return false;
}

function addLoadEvent(func)
{
	var oldonload = window.onload;
	if (typeof window.onload != 'function')
	{
		window.onload = func;
	}
	else
	{
		window.onload = function()
		{
			if (oldonload)
			{
				oldonload();
			}
			func();
		}
	}
}

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

	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++)
	{
		var anchor = anchors[i];
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external")
			anchor.target = "_blank";                                               
	}
}

addLoadEvent (externalLinks);
