﻿function AdRotator(){
	this.images = new Array();
	this.timer;
	this.imageIndex;
	this.rotateSpeed = 5000;
	this.imagePlaceholder = document.getElementById("adRotator");
}
AdRotator.prototype.addImage = addImage;
AdRotator.prototype.invoke = function (){
	var me = this;
	
	if(this.imageIndex == null){
		this.imageIndex = Math.floor(Math.random()*aRotator.images.length);
	}
	else if(this.imageIndex >= this.images.length){
		this.imageIndex = 0;
	}
	this.imagePlaceholder.src = this.images[this.imageIndex++].src;
	this.timer = setTimeout(function(){me.invoke()}, this.rotateSpeed);
}

function addImage(imageUrl){
	var image = new Image();
	image.src = imageUrl;
	this.images[this.images.length] = image;
}


function ImagePreview(){
	this.images = new Array();
	this.imagePlaceholder = document.getElementById("menuImage");
}
ImagePreview.prototype.addImage = addImage;
ImagePreview.prototype.showImage = function(imageIndex){
	this.imagePlaceholder.src = this.images[imageIndex].src;
}
