jQuery(document).ready(function() {
	bluz_engage();
	bluz_minor();
	bluz_social_footer();
	bluz_switch_view();
	bluz_complete();
});

function bluz_switch_view(){
	jQuery("a.switch_thumb").toggle(function(){
        jQuery(this).addClass("swap");
        jQuery("ul.grid").fadeOut("fast", function() {
			jQuery(this).removeClass("grid");
            jQuery(this).fadeIn("fast").addClass("list");
        });
    }, function () {
        jQuery(this).removeClass("swap");
        jQuery("ul.list").fadeOut("fast", function() {
			jQuery(this).removeClass("list");
            jQuery(this).fadeIn("fast").addClass("grid");
        });
    });
}

function bluz_engage(){
	Cufon.replace('h1, h2, h3, h4, h5, h6, p.tagline'); // enabling cufon
	jQuery('#tabs').tabs({ fx: { opacity: 'toggle', height: 'toggle' } }); // make the tabs work
	jQuery('ul.sf-menu').superfish({
        delay:       250                          // one second delay on mouseout 
	});
	jQuery("a[rel^='prettyPhoto']").prettyPhoto(); // makes lightbox work
}

function bluz_social_footer(){
	jQuery('.footer-widget .social-links a:has(img)').fadeTo("fast","0.7");
	jQuery('.footer-widget .social-links a:has(img)').hover(function() {
		jQuery(this).stop().fadeTo("fast","1");
		}, function() {
		jQuery(this).stop().fadeTo("fast","0.7");
	});
}

function bluz_minor(){
	jQuery('span.close').click(function() {
		jQuery(this).parent().fadeOut(400);
	});
	jQuery('#content img').hide();//hide all the images on the page
}

function bluz_complete(){
	jQuery('ul.sf-menu').before('<div id="nav-finish"></div>');
	jQuery('#pagename h2 span').after('<img src="images/pagename-right.png" alt="" id="pagename-finish" />');
}


var i = 0;//initialize
var int=0;//Internet Explorer Fix
jQuery(window).bind("load", function() {//The load event will only fire if the entire page or document is fully loaded
	var int = setInterval("preload(i)",300);//500 is the fade in speed in milliseconds
});	

function preload() {
	var images = jQuery('#content img').length;//count the number of images on the page
	if (i >= images) {// Loop the images
		clearInterval(int);//When it reaches the last image the loop ends
	}
	jQuery('#content img:hidden').eq(0).fadeIn(500);//fades in the hidden images one by one
	
	i++;//add 1 to the count
}
