$(window).load(function () {
	prepareLinks();
});

function prepareLinks()
{

	var links = document.getElementsByTagName("a");
	for (var i=0; i<links.length; i++)
	{
		if (links[i].getAttribute("className"))
		{
			if (links[i].getAttribute("classname") == "external") 
			{
				if (links[i].getAttribute('title') == '' || links[i].getAttribute('title') == null)
					links[i].setAttribute("title","(opens in a new window)");
			}
			else if (links[i].getAttribute('classname').substring(0,6) == 'popup_')
				links[i].setAttribute('title','this is a popup');
		}
		else if (links[i].getAttribute("class"))
		{
			if (links[i].getAttribute("class") == "external")
			{
				if (links[i].getAttribute('title') == '' || links[i].getAttribute('title') == null)
					links[i].setAttribute("title","(opens in a new window)");
			}
			else if (links[i].getAttribute('class').substring(0,6) == 'popup_')
				links[i].setAttribute('title','this is a popup');
		}
	}
	
	$('a.external').click(function()
	{
	     window.open(this.href);
    	 return false;
    });

	$("a[class^='popup_']").click(function(event)
	{
    	var prop = event.target.className;
        var w = prop.split('_')[1];
        var h = prop.split('_')[2];
        window.open(this.href,'','menubar=0,location=0,scrollbars=1,toolbar=0,status=0,directories=0,titlebar=0,width='+w+',height='+h);
        return false;
    });
}

