function slideSwitch1() {
    var $active = $('#slideshow1 IMG.active');

    if ( $active.length == 0 ) $active = $('#slideshow1 IMG:last');

    // use this to pull the images in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('#slideshow1 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}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

function slideSwitch2() {
    var $active = $('#slideshow2 IMG.active');

    if ( $active.length == 0 ) $active = $('#slideshow2 IMG:last');

    // use this to pull the images in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('#slideshow2 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}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

function slideSwitch3() {
    var $active = $('#slideshow3 IMG.active');

    if ( $active.length == 0 ) $active = $('#slideshow3 IMG:last');

    // use this to pull the images in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('#slideshow3 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}, 1000, function() {
            $active.removeClass('active last-active');
        });
}


$(document).ready(function() {
						   
	$('ul#topnav li a.navOn').next().show();
	
	$("ul#topnav li").hover(function() { //Hover over event on list item
		$(this).css({ 'background' : 'url(../images/background_navhover.png) no-repeat bottom center'}); //Add background color + image on hovered list item
		$(this).find("span").show(); //Show the subnav
	} , function() { //on hover out...
		$(this).css({ 'background' : 'none'}); //Ditch the background
		$(this).find("span").hide(); //Hide the subnav
	});
	
	$("#slider").easySlider({
		auto: false,
		continuous: true 
	});
	
	
	$(".teamText").hide();
	
	$(".teamBlock").click(function() { 
		
		$(this).find(".teamIcon").toggleClass("active");
		$(this).find(".teamText").slideToggle("slow");
	
	});
	
	
	$(function() {
    setInterval( "slideSwitch1('')", 5000 );
	setInterval( "slideSwitch2('')", 5000 );
	setInterval( "slideSwitch3('')", 5000 );
	});
	
	$(function() {
		$("#quotes").jCarouselLite({
			auto: 8000,
			visible: 1,
			speed: 1200
		});
		
	});
	
});
