if (typeof encodeURIComponent != 'function') {
	function encodeURIComponent(str) {
		var output = [];
		
		for (var i = 0, sl = str.length; i < sl; i++) {
			var c = str.charAt(i);
			
			if (/[\w\d]/.test(c) || "-_.!~*'()".indexOf(c) != -1)
				output.push(c);
			else
				output.push("%" + c.charCodeAt(0).toString(16));
		}
		
		return output.join("");
	}
}

/*var debug = false && /debug/.test(location.href);

function $(id) {
	if (document.all)
		return document.all(id);
	return document.getElementById(id);
}

function debug_msg(msg) {
	if (!debug)
		return;
		
	var div = document.createElement("div");
		
	div.innerHTML = msg + "\n<br />";
	
	for (var i = 0; i < div.childNodes.length; i++)
		$("jsdebug").appendChild(div.childNodes[i]);
	$("jsdebug").style.whiteSpace = "pre";
}*/

var debug = /debug/.test(location.href);

//window.onload = 
function external_links() {
	var links = document.body.getElementsByTagName("a");
	
	for (var i = 0; i < links.length; i++) {
		var l = links[i];
		
		/*debug_msg((/^http[s]?:\/\//.test(l.href) && !/^http[s]?:\/\/(linode.)?nafc.(org|com)/.test(l.href)) + " " + l.href);*/
		
		if (/^http[s]?:\/\//.test(l.href) && !/^http[s]?:\/\/(www.)?nafc.(org|com)/.test(l.href) && 
		    typeof l.onclick != 'function') {
			l.target = "_blank";
			l.href = '/jump.php?link=' + encodeURIComponent(l.href);
		}
	}
}
