
/*
 * Image preload
 */
jQuery.preloadImages = function() {
	for(var i = 0; i<arguments.length; i++) {
		jQuery("<img>").attr("src", arguments[i]);
	}
}
$.preloadImages(
	'/images/home.png',
	'/images/bridal-party.png',
	'/images/events.png',
	'/images/blog.png',
	'/images/contact.png'
);


$(document).ready(function() {

	// image replacement
	if($('#img_check')[0].offsetWidth == 1) { // 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 + '.png" height="16" alt="' + string + '" />');
		});
	}

	// png fix
	$(document).pngFix();

	// main nav rollovers
	$('#home').mouseover(function() {
		$(this).attr('src', '/images/home.png')
	}).mouseout(function() {
		$(this).attr('src', '/images/nav-home.png')
	});
	$('#bridal_party').mouseover(function() {
		$(this).attr('src', '/images/bridal-party.png')
	}).mouseout(function() {
		$(this).attr('src', '/images/nav-bridal-party.png')
	});
	$('#events').mouseover(function() {
		$(this).attr('src', '/images/events.png')
	}).mouseout(function() {
		$(this).attr('src', '/images/nav-events.png')
	});
	$('#blog').mouseover(function() {
		$(this).attr('src', '/images/blog.png')
	}).mouseout(function() {
		$(this).attr('src', '/images/nav-blog.png')
	});
	$('#contact').mouseover(function() {
		$(this).attr('src', '/images/contact.png')
	}).mouseout(function() {
		$(this).attr('src', '/images/nav-contact.png')
	});

	// no margin on blog comments
	$('.comment_text').each(function() {
		$(this).children('p:last').css('margin-bottom', '0');
	});


	$('a[rel*=facebox]').facebox();

});
