var log = function(txt) {
	(console || console.log) ? console.log(txt) : alert(txt);
};

var coverFader = function(){
	clearInterval(coverTabTimer);
	var index = $(".cover-img img.active").index();
	var next = index+1;
	next = next < $('.cover-img img').length ? next : 0;
	var nextItem = $('.cover-img img')[next];

	$(".cover-img img.active").fadeOut(800, function(){
		$(this).removeClass('active');
	});

	$(nextItem).fadeIn(1200, function(){
		$(nextItem).addClass('active');
	});
	coverTabTimer = setInterval(coverFader, 5000);
}



var __init__ = function() {
	$(".cover-img img:first-child").addClass('active');
	if ($('.cover-img').length>0) {
		coverTabTimer = setInterval(coverFader, 8000);
	}

};

$(document).ready(function(){
	__init__();
});
