// Image Rotating Web 2.0 style
// Dat Chu - CBL Lab
SplashImages = [
{
	src:"/images/picbox/physlearningcenter.jpg",
	link:"physicslearningcenter.htm",
	target:""
},
{
	src:"/images/picbox/didyouknow_students.jpg",
	link:"/didyouknow/",
	target:""
},
{
	src:"/images/picbox/vclass2.jpg",
	link:"https://vnet.uh.edu/about.lasso",
	target:"parent"
},
{
	src:"/images/picbox/web.jpg",
	link:"/services/web.htm",
	target:""
},
{
	src:"/images/picbox/videoconf.jpg",
	link:"/services/videoconf.htm",
	target:""
},
{
	src:"/images/picbox/vcalendar.jpg",
	link:"http://www.apple.com/education/profiles/houston/",
	target:"parent"
},
{
	src:"/images/picbox/appleprofile.jpg",
	link:"http://www.apple.com/education/profiles/houston/",
	target:""
},
{
	src:"/images/picbox/vnetbigplans.jpg",
	link:"vtcvideo.htm",
	target:"parent"
},
{
	src:"/images/picbox/vstation.jpg",
	link:"/services/vstation.htm",
	target:""
}];

ImageRotator = {
	images: SplashImages,
	prevIndex: "",
	nextIndex: "",
	targetDivs:"",
	effects:"",
	delay:4000,
	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);
		}
};
