var DomLoaded =
{
	onload: [],
	loaded: function()
	{
		if (arguments.callee.done) return;
		arguments.callee.done = true;
		for (i = 0;i < DomLoaded.onload.length;i++) DomLoaded.onload[i]();
	},
	load: function(fireThis)
	{
		this.onload.push(fireThis);
		if (document.addEventListener) 
			document.addEventListener("DOMContentLoaded", DomLoaded.loaded, null);
		if (/KHTML|WebKit/i.test(navigator.userAgent))
		{ 
			var _timer = setInterval(function()
			{
				if (/loaded|complete/.test(document.readyState))
				{
					clearInterval(_timer);
					delete _timer;
					DomLoaded.loaded();
				}
			}, 10);
		}
		/*@cc_on @*/
		/*@if (@_win32)
		var proto = "javascript:void(0)";
		if (location.protocol == "https:") proto = "src=//0";
		document.write("<scr"+"ipt id=__ie_onload defer src=" + proto + "><\/scr"+"ipt>");
		var script = document.getElementById("__ie_onload");
		script.onreadystatechange = function() {
		    if (this.readyState == "complete") {
		        DomLoaded.loaded();
		    }
		};
		/*@end @*/
	   window.onload = DomLoaded.loaded;
	}
};


var setupLinks = function() {
	if(!document.getElementsByTagName) return;
	var links = document.getElementsByTagName("a");
	for(var i=0;i<links.length;i++) {
		var link = links[i];
		if(link.getAttribute("href") && link.getAttribute("rel") == "external") {
			link.onclick = function() { window.open(this.getAttribute("href")); return false; };
		}
		if(link.getAttribute("href") && link.getAttribute("rel") == "pdf") {
			link.onclick = function() { window.open(this.getAttribute("href"),"popup","height=500,width=750,toolbar=no"); return false; };
		} 
	}
}


DomLoaded.load(setupLinks);