$(document).ready(function() {
		// Preload all rollovers
		$("#nav img, #subnav img").each(function() {
			// Set the original src
			rollsrc = $(this).attr("src");
			rollON = rollsrc.replace(/.gif$/ig,"_over.gif");
			$("<img>").attr("src", rollON);
		});
		
		// Navigation rollovers
		$("#nav a, #subnav a").mouseover(function(){
			imgsrc = $(this).children("img").attr("src");
			if(imgsrc) {
				matches = imgsrc.match(/_over/);
			
				// don't do the rollover if state is already ON
				if (!matches) {
				imgsrcON = imgsrc.replace(/.gif$/ig,"_over.gif"); // strip off extension
				$(this).children("img").attr("src", imgsrcON);
				}
			}
			
		});
		$("#nav a, #subnav a").mouseout(function(){
			if(imgsrc) {
				$(this).children("img").attr("src", imgsrc);
			}
		});
		
		// Determine the active section button
		if (location.pathname.substring(1)) {
			// get the path
			thePath = location.pathname.substring(1);
			thePath = thePath.match(/^\/?([a-z0-9_\.-]+)/); // only get the first part of the path

			thePath = '/' + thePath[0];

			navLink = $('#nav a[@href$="' + thePath + '"], #subnav a[@href$="' + thePath + '"]');
			imgsrc = $(navLink).children("img").attr("src");
			if (imgsrc) {
			imgsrcON = imgsrc.replace(/.gif$/ig,"_over.gif"); // strip off .gif
			$(navLink).children("img").attr("src", imgsrcON);
			}
		}

	$("form.vote").submit(function() {
		var vote = $("input[name='items[vote]']");
		return vote.val() != "null";
	});
});