jQuery.noConflict();

jQuery(document).ready(function() {
	bluz_toggle();							
	bluz_engage();
	bluz_minor();
	bluz_social_footer();
	bluz_switch_view();
	bluz_complete();
});

function bluz_toggle(){
	jQuery('.toggle-content').hide();
	jQuery('.toggle').toggle(function () {
        jQuery(this).css({"background-position":"left bottom"});
		jQuery(this).next(".toggle-content").show("normal");
      },
      function () {
        jQuery(this).css({"background-position":"left top"});
		jQuery(this).next(".toggle-content").hide("normal");
	  });
}

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, .dropcap'); // 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
	jQuery("ul#box-list li:odd, .footer-widget:eq(3)").addClass('no-margin');

}

function bluz_social_footer(){
	jQuery('.footer-widget .social-links a:has(img)').fadeTo("fast","0.55");
	jQuery('.footer-widget .social-links a:has(img)').hover(function() {
		jQuery(this).stop().fadeTo("fast","1");
		}, function() {
		jQuery(this).stop().fadeTo("fast","0.55");
	});
}

function bluz_minor(){
	jQuery('.latest-posts li:last-child').css("border-bottom", "none");
	jQuery('.widget').wrapInner('<div class="inside" />');
	jQuery('span.close').click(function() {
		jQuery(this).parent().fadeOut(400);					   
	});
	jQuery('#content a.img-load 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('<div id="pagename-finish"></div>');
}


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 a.img-load 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 a.img-load img:hidden').eq(0).fadeIn(500);//fades in the hidden images one by one
	
	i++;//add 1 to the count
}