function setupButtons() {
	$("img.button").each(function() {
		$(this).css("cursor", "pointer");

		var button_re = /(.*)_(normal|over|down)\.(png|gif)$/;

		// Preload
		jQuery("<img>").attr("src", $(this).attr("src").match(button_re)[1] + "_normal." + $(this).attr("src").match(button_re)[3]);
		jQuery("<img>").attr("src", $(this).attr("src").match(button_re)[1] + "_over." + $(this).attr("src").match(button_re)[3]);
		//jQuery("<img>").attr("src", $(this).attr("src").match(button_re)[1] + "_down." + $(this).attr("src").match(button_re)[3]);

		$(this).bind("mouseover", function() { 
			if ($(this).attr("default_over"))
				$(this).attr("src", ($(this).attr("src").match(button_re)[1]) + "_" + $(this).attr("default_over") + "." + $(this).attr("src").match(button_re)[3]); 
			else
				$(this).attr("src", ($(this).attr("src").match(button_re)[1]) + "_over." + $(this).attr("src").match(button_re)[3]); 
		});
		$(this).bind("mouseout",  function() { 
			if ($(this).attr("default"))
				$(this).attr("src", ($(this).attr("src").match(button_re)[1]) + "_" + $(this).attr("default") + "." + $(this).attr("src").match(button_re)[3]); 
			else
				$(this).attr("src", ($(this).attr("src").match(button_re)[1]) + "_normal." + $(this).attr("src").match(button_re)[3]); 
		});
		//$(this).bind("mousedown", function() { $(this).attr("src", ($(this).attr("src").match(button_re)[1]) + "_down." + $(this).attr("src").match(button_re)[3]); });
		$(this).bind("mouseup",   function() { $(this).attr("src", ($(this).attr("src").match(button_re)[1]) + "_normal." + $(this).attr("src").match(button_re)[3]); });

	});

	$("a.nav_button").each(function() {
		// Preload
		jQuery("<img>").attr("src", img_base + "images/nav/btn_" + $(this).attr("type") + "_back.png");

		$(this).bind("mouseover", function() {
			if (!$(this).hasClass("current")) {
				$(this).css("background", "url(" + img_base + "images/nav/btn_" + $(this).attr("type") + "_back.png)");
				$(this).addClass("over");
			}
		});

		$(this).bind("mouseout", function() {
			if (!$(this).hasClass("current")) {
				$(this).css("background", "none");
				$(this).removeClass("over");
			}
		});

	});

	$("a.nav_current").each(function() {
		$(this).css("background", "url(" + img_base + "images/nav/btn_" + $(this).attr("type") + "_back.png)");
		$(this).addClass("over");
	});

}

$(document).ready(function() {
	setupButtons();
});
