function slideSwitch() {
    var $active = $('#homepageRotator DIV.active');

    if ( $active.length == 0 ) $active = $('#homepageRotator DIV:last');

    // use this to pull the images in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('#homepageRotator DIV: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 productsLink() {
	$('html, body').animate({scrollTop:0}, 'fast', function() {
		if( $("#subnav").is(":visible") ){
		}
		else{
			$("#subnav").slideDown(200);
			$("#bProducts").parent().addClass("current");
		}
	});
}

$(function(){

	$("#bProducts").bind("click", function(){
		
		
		if( $("#subnav").is(":visible") ){
			$("#subnav").slideUp(200);
			if( $(this).parent().hasClass("active") ){
				
			}
			else{
				$(this).parent().removeClass("current");
			}	
		}
		else{
			$("#subnav").slideDown(200);
			$(this).parent().addClass("current");
		}
	});
});

jQuery(document).ready(function($) {
	setInterval( "slideSwitch()", 7000 );
      
      $('a[rel*=facebox]').facebox({
        loadingImage : '/assets/facebox/loading.gif',
        closeImage   : '/assets/facebox/closelabel.png'
      })
      
      
      
    })

