var $j = jQuery;
$j(document).ready(function () {
	externalLinks();
	randomHeaderBgImg();
	stripeTableRows();
});

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";
	}
}

function randomHeaderBgImg() {
	var imgNum = 3; // Number of images in the random image folder
	var elementId = "#masthead_inner"; // The element in which to apply the random bg image
	var randomNum = Math.ceil(Math.random() * imgNum);
	$j(elementId).css({ backgroundImage: "url(/images/header_img_" + randomNum + ".jpg)"});
}

function stripeTableRows() {
	$j("tbody tr:even").addClass("alt");
}