
var iTime = 6000;

var iCurrentItem = 1;
var periodical;
var iShow;

window.addEvent('domready', function(){
	
	//alert('rotatingbanner');
	
	initItems();
	
	$('rotatingBanner'+ iCurrentItem).style.display = 'block';
	
	setTimeout(function(){
		
		change();
		periodical = change.periodical(iTime);
		
	}, iTime);
	
});




var change = function() {
	
	if(iCurrentItem >= iTotalItems) {
		iChange = 1;
	} else {
		iChange = iCurrentItem + 1;
	}
	
	$('rotatingBanner'+ iCurrentItem).style.display = 'none';
	$('rotatingBanner'+ iChange).style.display = 'block';
	
	//console.log('show: '+ iChange +' hide: '+ iCurrentItem);
	
	if(iCurrentItem == iTotalItems) {
		iCurrentItem = 1;
	} else {
		iCurrentItem++;
	}
	
	
	
};


function initItems(){
	
	$('headerBanner').addEvents({
		'mouseenter': function() {
			
			$clear(periodical);
			
		},
		'mouseleave': function() {
			
		
				change();
				periodical = change.periodical(iTime);
				
			
		}
	});
	
}






