var advCurrentShow = 0;
var timeOut = 5000; // milisekundy
var rotatorActive = true;
var advNo = 1;

$(document).ready(function() {
	$("#topAdv_"+advCurrentShow).show();
	advNo = $('div#topAdv_0').children('div.contentAdvertMenu').children('div.contentAdvertMenuLeft').children('img').length;
	advNo = advNo-1;
});

function adv( banner ) {
	if( banner != advCurrentShow ) {
		switch( banner ) {
			case 'next':
				next = advCurrentShow + 1;
				banner = 0;
				$("#topAdv_"+next).each(function(){
					banner = next;
				});
				if( !rotatorActive ) {
					rotatorActive = setTimeout("autoAdv();", timeOut);
				}
			break;
			case 'prev':
				next = advCurrentShow - 1;
				banner = advNo;
				$("#topAdv_"+next).each(function(){
					banner = next;
				});	
				if( !rotatorActive ) {
					rotatorActive = setTimeout("autoAdv();", timeOut);
				}	
			break;
			default:
				rotatorActive = false;
				clearTimeout( rotatorActive );
			break;
		}

		if( banner != advCurrentShow ){
			$("#topAdv_"+banner).show( );
			$("#topAdv_"+advCurrentShow).hide( );
			advCurrentShow = banner;
		}
	}
}
function autoAdv() {
	if( rotatorActive ) {
		adv( 'next' );
		rotatorActive = setTimeout("autoAdv();", timeOut);
	}
}

setTimeout("autoAdv();", timeOut);
