function sequence(refreshTime, width, height){
	this.objName = "sequenceimage" + (sequence.count++);
	eval(this.objName + "=this");
	this.refreshTime = refreshTime*1000;
	this.width = width;
	this.height = height;
	this.seqs = [];
	this.mySize = 0;

	this.seq = function(src) {
		var tempImage = new Image();
		tempImage.src = src;
		this.seqs[this.mySize] = new Object();
		var seq = this.seqs[this.mySize];
		seq.src = src;
		this.mySize++;
	}

	this.randomSeq = function(){
		var n;
		do { n = Math.floor(Math.random() * (this.mySize)); } 
		while(n == this.currentSeq);
		this.currentSeq = n;
	}

	this.output = function(){
		var tempCode = "";
		if (this.mySize > 1){
			if (this.currentSeq == null) this.randomSeq();
			if (this.currentSeq >= this.mySize) this.currentSeq = this.mySize - 1;
			tempCode = '<img src="' + this.seqs[this.currentSeq].src + '" width="' + this.width;
			tempCode += '" name="' + this.objName + 'Img" height="' + this.height + '" ';
			tempCode += 'border="0" />';
			document.write(tempCode);
			this.nextSeq();
		} else document.write("Error: two sequences must be defined for the script to work.");
	}

	this.newSeq = function(){
		this.currentSeq++;
		if (this.currentSeq >= this.mySize) this.currentSeq = 0;
		this.nextSeq();
	}

	this.nextSeq = function(){
		document.images[this.objName+ 'Img'].src = this.seqs[this.currentSeq].src;
		setTimeout(this.objName+'.newSeq()',this.refreshTime)
	}
}
sequence.count = 0;
