$(document).ready(function() {
    setInterval( "startBannerRotation()", 4000 );
	
	$(".buy a.popup").fancybox({
		ajax : {
		    type	: "POST"
		},
		'onComplete'	:	function() {
			initPopup();
		},
		'autoDimensions': false,
		'height' : 514,
		'width'  : 450
	});
});

function startBannerRotation() {
	var $active = $('.banners .active');
	if ( $active.length == 0 ) $active = $('.banners :last');
	var $next =  $active.next().length ? $active.next()
		: $('.banners :first');
	$active.addClass('last-active');
	$next.css({opacity: 0.0})
		.addClass('active')
		.animate({opacity: 1.0}, 1000, function() {
			$active.removeClass('active last-active');
		});
}
