window.addEvent('domready', function() {

	var ad_idx = 0;
	var ads = $$('div#secondary_ad img');
	//console.log(ads);
	ads.set('opacity', 0);
	//alert(slides);


	for(var i = 0;i< ads.length;i++) {
		ads[i].store('imgfx', new Fx.Morph(ads[i],{duration: 500}));					
	}


	function adOut(ad) {
		ad.retrieve('imgfx').start({opacity:0});

	}

	function adIn(ad) {
		ad.retrieve('imgfx').start({opacity:1})
	}

	function swapAd() {
		adOut(ads[ad_idx]);
		ad_idx = ad_idx + 1 >= ads.length ? 0 : ad_idx + 1;
		setTimeout(function() { adIn(ads[ad_idx]); }, 300);
	}
	ad_idx = 0;
	setInterval(swapAd,7000);
	setTimeout(function() { adIn(ads[0]); }, 300);


});
