/*** 
	BASIC HEADER SLIDESHOW
    Released by Jon Raasch (jonraasch.com) under FreeBSD license
***/

function slideSwitch() {
    var $active = $('#headerSlides img.active');

    if ( $active.length == 0 ) $active = $('#headerSlides img:last');

    // use this to pull the images in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('#headerSlides img:first');

    // uncomment the 3 lines below to pull the images in random order
    
    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = $( $sibs[ rndNum ] );

    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 2000, function() {
            $active.removeClass('active last-active');
        });
}

$(function() {
    setInterval( "slideSwitch()", 6000 );
});

/*** 
	SCROLLERS
    Released by Jon Raasch (jonraasch.com) under FreeBSD license
***/



$(function() {

	// initialize scrollable
	$(".scrollable").scrollable({ circular: true });
});

$(function() {

$(".scroll").scrollable({circular:true}).autoscroll({autoplay: false});

$(".thumbs img").click(function() {

	if ($(this).hasClass("active")) { return; }

	var url = $(this).attr("src").replace("thumb_", "");
	var wrap = $("#theBigSlide").fadeTo("slow", 1);
	var img = new Image();


	img.onload = function() {
		wrap.fadeTo("fast", 1);
		wrap.find("img").attr("src", url);
	};

	img.src = url;
	$(".thumbs img").removeClass("active");
	$(this).addClass("active");

}).filter(":first").click();
});
