
/*
 * Image preload
 */
jQuery.preloadImages = function() {
	for(var i = 0; i<arguments.length; i++) {
		jQuery("<img>").attr("src", arguments[i]);
	}
}
$.preloadImages(
	'/images/nav-home-on.gif',
	'/images/nav-archives-on.gif',
	'/images/nav-work-on.gif',
	'/images/nav-about-on.gif',
	'/images/nav-contact-on.gif',
	'/images/brown-45.png'
);


$(document).ready(function() {

	// png fix
	$('.comment, .screen').pngfix({
		sizingMethod: "scale"
	});
	$('#footer, .more-link').pngfix();

	// main nav rollovers
	$('#nav_home').mouseover(function() {
		$(this).attr('src', '/images/nav-home-on.gif')
	}).mouseout(function() {
		$(this).attr('src', '/images/nav-home.gif')
	});
	$('#nav_archives').mouseover(function() {
		$(this).attr('src', '/images/nav-archives-on.gif')
	}).mouseout(function() {
		$(this).attr('src', '/images/nav-archives.gif')
	});
	$('#nav_work').mouseover(function() {
		$(this).attr('src', '/images/nav-work-on.gif')
	}).mouseout(function() {
		$(this).attr('src', '/images/nav-work.gif')
	});
	$('#nav_about').mouseover(function() {
		$(this).attr('src', '/images/nav-about-on.gif')
	}).mouseout(function() {
		$(this).attr('src', '/images/nav-about.gif')
	});
	$('#nav_contact').mouseover(function() {
		$(this).attr('src', '/images/nav-contact-on.gif')
	}).mouseout(function() {
		$(this).attr('src', '/images/nav-contact.gif')
	});

	// screenshot rollovers
	$('.screen a').mouseover(function() {
		$(this).parents('.screen').addClass('screen_over');
	}).mouseout(function() {
		$(this).parents('.screen').removeClass('screen_over');
	})

	// image replacement
	if($('#logo')[0].offsetWidth == 288) { // if images are enabled
		$('h2.img').each(function() {
			string = $(this).text();
			filename = string.toLowerCase().replace(/ /g, '-').replace(/([^0-9a-z-])/g,'');
			$(this).html('<img src="/images/' + filename + '.gif" height="38" alt="' + string + '" />');
		});
	}

});
