/* makes links with attribute rel="external" open in a new window */
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"; 
		}
	}
}

if (window.addEventListener) {
	window.addEventListener('load', externalLinks, false); 
} else if (window.attachEvent) { 
	window.attachEvent('onload', externalLinks);
}

String.prototype.trim = function () {
    return this.replace(/^\s*/,'')
                     .replace(/\s*$/,'');
};

		$(document).ready(function() {
			var curLocation = document.location.toString().split("/");
			var realLocation = "";
			for (var i=3; i < curLocation.length && i <= 3; i++) { // strip away http://..../
				realLocation += "/" + curLocation[i];
			};

			$('div#menu ul li a[href=' + realLocation + ']').parent().addClass('selected');
			// window.status = "We are here: " + realLocation;
		});
