// Image Rotating Web 2.0 style
// Dat Chu - CBL Lab
SplashImages = [
{
	src:"http://shikiok.com/images/banner/banner.jpg",
	link:"http://shikiok.com/",
	target:""
},
{
	src:"http://shikiok.com/images/banner/banner2.jpg",
	link:"http://shikiok.com/",
	target:""
},
{
	src:"http://shikiok.com/images/banner/banner3.jpg",
	link:"http://shikiok.com/",
	target:""
},
{
	src:"http://shikiok.com/images/banner/banner4.jpg",
	link:"http://shikiok.com/",
	target:""
},
{
	src:"http://shikiok.com/images/banner/banners1.jpg",
	link:"http://shikiok.com/",
	target:"parent"
},
{
	src:"http://shikiok.com/images/banner/banners2.jpg",
	link:"http://shikiok.com/",
	target:""
},
{
	src:"http://shikiok.com/images/banner/shikifuji.jpg",
	link:"http://shikiok.com/",
	target:""
},
{
	src:"http://shikiok.com/images/banner/banners3.jpg",
	link:"http://shikiok.com/",
	target:""
}];

ImageRotator = {
	images: SplashImages,
	prevIndex: "",
	nextIndex: "",
	targetDivs:"",
	effects:"",
	delay:12000,
	writeDivs:function(){
            //this should not even exists, these things suppose to be handled by the server (not client)
			for(i=0;i< this.images.length;i++)
			{
				if(!this.images[i].link) document.writeln('<img src="'+this.images[i].src+'" target="'+this.images[i].target+'" border="0" />');
				else document.writeln('<div class="index_image"><a href="'+this.images[i].link+'"><img src="'+this.images[i].src+'" target="'+this.images[i].target+'" /></a></div>');
			}
			this.targetDivs = document.getElementsByClassName('index_image');
			this.buildEffects();
		},
	buildEffects:function(){
			this.prevIndex = Math.floor(Math.random() * this.images.length);
			this.nextIndex = (this.prevIndex+1) % this.images.length;
			eff = new Array;
			for(i=0;i<this.targetDivs.length;i++)
			{
				eff[i] = new Fx.Opacity(this.targetDivs[i],{duration:1000});
				if (i!=this.prevIndex) eff[i].hide();
			}
			this.effects = eff;
		},
	rotate: function(){
			this.effects[this.prevIndex].toggle(); //hide prev
			this.effects[this.nextIndex].toggle(); //show next
			//repeat
			this.prevIndex = this.nextIndex;
			this.nextIndex = (this.nextIndex +1) % this.effects.length;
			setTimeout("ImageRotator.rotate();",this.delay);
		}
};
