var $j = jQuery.noConflict();

if (!Array.indexOf) {
	Array.prototype.indexOf = function (obj, start) {
		for (var i = (start || 0); i < this.length; i++) {
			if (this[i] == obj) {
				return i;
			}
		}
		return -1;
	}
}


$j(function() {
	
	if ($j("body").attr("class") == 'whats_happening') {
		
		// set active page's link to on state
		var el = "img#side_nav_" + $j("body").attr("id");
		if ($j(el).length > 0) {
			var new_src = $j(el).attr("src").replace("_off.", "_on.");
			$j(el).removeClass("rollover").attr("src", new_src);
		}
	}
	
	
	
	// preload images and turn rollovers on
	
	var images = [];
	
	$j("img.rollover").each(function() {
		
		if (images.indexOf($j(this).attr("src")) === -1) {
		
			images.push($j(this).attr("src"));
			
			$j("<img />").appendTo('body')
				.css({ display: "none" })
				.attr("src", $j(this).attr("src").replace("_off.", "_on."));
		}
		
	}).hover(
		function() {
			$j(this).attr("src", $j(this).attr("src").replace("_off.", "_on."));
		},
		function() {
			$j(this).attr("src", $j(this).attr("src").replace("_on.", "_off."));
		}
	);
	
	/*
	$j(".article_text").find('img').each(function() {
		$j(this).attr("src", "../../../" + $j(this).attr("src"));
	});
	*/
	
	$j("table[width], col[width], tr[width], th[width], td[width]", $j(".article_text")).attr("width", "auto");
	
});


