jQuery.fn.cpSwapImg = function(num, state){
	var img = "<img src='wp-content/themes/cheeseplus.com/images/nav/nav_"+state+"_"+num+".gif'>";
	return jQuery(this).html(img);
};

$(document).ready(function(){
	$('#nav li')
		.not($('#nav li:last'))
			.after("<li><img src='wp-content/themes/cheeseplus.com/images/nav/dot.gif'></li>")
		.end()
		.children('a')
			.each(function(){
				var tc = $(this).parent('li').attr('class');
				var num = tc.match(/\d+/);
				var state = 'off';
				if (tc.match(/current_page_item/)) state = 'on';
				$(this)
					.cpSwapImg(num, state)
					.css({
						backgroundImage: "url(wp-content/themes/cheeseplus.com/images/nav/nav_on_"+num+".gif)"
					})
					.hover(function(){
						$(this).children('img').css({visibility: 'hidden'});
					}, function(){
						$(this).children('img').css({visibility: 'visible'});
					});
			});
	
	$('h1').each(function(){
		var src = $(this).text().match(/^\w+/);
		var img = "<img src='wp-content/themes/cheeseplus.com/images/h_"+src+".gif'>"
		$(this).html(img);
	});
});