/* 
 *  NCBOWD
 *  Site by New Media Campaigns
 */

$(document).ready(function() {
    
    // Open external links in a new window
	//$('a[href^="http://"]').attr("target", "_blank");
	
	// Rotate homepage images
	$('#featurePhoto').rotate();
    
	// Setup the nav drop-downs
	
	
});


// Fades from one image to another
(function($) {
 
    $.fn.rotate = function(time) {	
        return this.each(function() {
            list = $(this);
            items = list.children();
            
            items.css('position', 'absolute').not(':first').hide();

            // Set a timer for the next fade
            var t = setTimeout('$.fn.rotate.startFade()', 500);
        });
    };
    
    $.fn.rotate.startFade = function() {
        // Get the current and the next image
        var current = items.filter(':visible');
        var next = current.next()
        var next = (next.length) ? next : items.filter(':first');
        
        // Do the fade
        current.fadeOut(1200);
        next.fadeIn(1200);
        
        // Set a timer for the next fade
        var t = setTimeout('$.fn.rotate.startFade()', 5000);
    }
	
})(jQuery);


