sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

jQuery.preloadImages = function() {
	for(var i = 0; i<arguments.length; i++) {
		jQuery("<img>").attr("src", arguments[i]);
	}
}
	
$(window).bind('load', function() {
	$('#nav img').each(function(elm) { 
		$.preloadImages($(this).attr("src").replace(".png", "-on.gif"));
	});
	$("a.rollover img").each(function(elm) {
		if ($(this).attr("src").indexOf(".jpg") != -1) {
			$.preloadImages($(this).attr("src").replace(".jpg", "-on.jpg"));			
		} else {
			$.preloadImages($(this).attr("src").replace(".gif", "-on.gif"));
		}
	});
});

$(document).ready(function(){
	$("#nav li a img").hover(
		function(){
			if($(this).attr("src").indexOf("-on") == -1) {
				var newSrc = $(this).attr("src").replace(".png", "-on.gif");
				$(this).attr("src",newSrc);
			}
		},
		function(){
			if($(this).attr("src").indexOf("-on.gif") != -1) {
				var oldSrc = $(this).attr("src").replace("-on.gif", ".png");
				$(this).attr("src",oldSrc);
			}
		}
	);
	$("a.rollover img").hover(
		function(){
			if($(this).attr("src").indexOf("-on") == -1) {
				if ($(this).attr("src").indexOf(".jpg") != -1) {
					var newSrc = $(this).attr("src").replace(".jpg", "-on.jpg");
				} else {
					var newSrc = $(this).attr("src").replace(".gif", "-on.gif");
				}
				if ($(this).attr("src").indexOf(".png") != -1) {
					var newSrc = $(this).attr("src").replace(".png", "-on.png");			
				}
				$(this).attr("src",newSrc);
			}
		},
		function(){
			if($(this).attr("src").indexOf("-on.") != -1) {
				if ($(this).attr("src").indexOf(".jpg") != -1) {
					var oldSrc = $(this).attr("src").replace("-on.jpg", ".jpg");
				} else {
					var oldSrc = $(this).attr("src").replace("-on.gif", ".gif");
				}
				if ($(this).attr("src").indexOf(".png") != -1) {
					var oldSrc = $(this).attr("src").replace("-on.png", ".png");			
				}
				$(this).attr("src",oldSrc);
			}
		}
	);
});
jQuery(function($) {
    $("img[@src$=png], #image-one, #image-two").pngfix();
});