/*function banners(){
	
	if(this.count || this.count == 0){
		this.count++;
	} else {
		this.count = 0;
	}
	
	var all = $("#indexBanners .curBanner").size();
	
	var sel = $("#indexBanners .selected")[0];
	
	if(this.count == all){
		this.count = 0;
	}
	
	var next = $("#indexBanners .curBanner")[this.count];
	
	$(sel).removeClass('selected');
	$(next).addClass('selected');
	
	$(sel).fadeOut();
	$(next).fadeIn();
}

$(window).load(function(){
	
	$("#indexBanners").at_intervals(banners, { delay: 5000, name: "banners" });
	
})
*/

function slideSwitch() {
    var $active = $('#hdr_banners .selected');
	var $activeDot = $('.fuckDots .activeDot').first();
	
    if ( $active.length == 0 ) $active = $('#hdr_banners .block:last');
	if ( $activeDot.length == 0 ) $activeDot = $('.fuckDots a:last');

    // use this to pull the divs in the order they appear in the markup
    var $next =  $active.next().length ? $active.next() : $('#hdr_banners .block:first');
	var $nextDot =  $activeDot.next().length ? $activeDot.next() : $('.fuckDots a:first');
	
    // uncomment below to pull the divs randomly
    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = $( $sibs[ rndNum ] );


    $active.addClass('last-selected');
	$nextDot.addClass('activeDot');
	$activeDot.removeClass('activeDot');

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

$(function() {
	if($('#hdr_banners .block').length > 1){
		setInterval( "slideSwitch()", 5000 );
	}
});
