var fedingInOutSpeed	= 500;

var fedingInOutDuration	= 7000;

var shownItem			= 0;

var nextItem			= 1;

var maxItemNo			= 0;

		jQuery(function (){

	jQuery('#adsContainer a').each(function(i){

		jQuery(this).css({ zIndex : 9999-i , opacity : 0 })

		maxItemNo++

	})

	

	maxItemNo--

	

	jQuery('#adsContainer a:first').animate( {opacity : 1}, fedingInOutSpeed)

	

	setInterval('startAutoAdShowing()',fedingInOutDuration)

	

})

function startAutoAdShowing(){

	if( nextItem < maxItemNo ){

		jQuery('#adsContainer a').eq(nextItem).animate( {opacity : 1}, fedingInOutSpeed, function(){

			jQuery(this).css({ zIndex : 9999 })

		})

		jQuery('#adsContainer a').eq(shownItem).animate( {opacity : 0}, fedingInOutSpeed, function(){

			jQuery(this).css({ zIndex : 9000 })

		})

		shownItem = nextItem

		nextItem++

	}

	else{

		jQuery('#adsContainer a').eq(nextItem).animate( {opacity : 1}, fedingInOutSpeed, function(){

			jQuery(this).css({ zIndex : 9999 })

		})

		jQuery('#adsContainer a').eq(shownItem).animate( {opacity : 0}, fedingInOutSpeed, function(){

			jQuery(this).css({ zIndex : 9000 })

		})

		shownItem = nextItem

		nextItem = 0

	}

}
