// Copyright 2000 dearbiz.com All rights reserved.

function turnlist() {
	//---------------   GLOBAL VARIABLES   ---------------
	this.name = "turnlist";
	this.item = new Array();
	this.itemcount = 0;
	this.itemoffset = 0;
	this.currentspeed = 0;
	this.scrollspeed = 50;
	this.pausemouseover = false;
	this.stop = 0;
	this.count=0;
	this.pausedelay = 5000;
	this.itemtop = 0;
	this.itemheight = 230;
	this.height = 230;
	this.width = 479;
	this.scroltype = '1';
	this.scrolheight = 30;

	//---------------     API FUNCTIONS    ---------------
	this.add = function () {
		var text = arguments[0];
		this.item[this.itemcount] = text;
		this.itemcount = this.itemcount + 1;
	};

	this.start = function () {
		if ( this.scrolltype=='1' ) {
			this.display();
			this.currentspeed = this.scrollspeed;
			obj = document.getElementById(this.name+'item0').style;
			obj.display='block';
			this.count++;
			this.scroll();
		}else
		if ( this.scrolltype=='2' ) {
			this.display();
			this.currentspeed = this.scrollspeed;
			this.up();
		}else
		if ( this.scrolltype=='3' ) {
			this.display();
			this.currentspeed = this.scrollspeed;
			this.itemup();
		}
	};

	//---------------    LOCAL FUNCTIONS   ---------------
	this.display = function () {
		if ( this.scrolltype=='1' ) {
			document.write('<div id="'+this.name+'" style="" OnMouseOver="'+this.name+'.onmouseover();" OnMouseOut="'+this.name+'.onmouseout();">');
			for(var i = 0; i < this.itemcount; i++) {
				document.write('<div id="'+this.name+'item'+i+'"style="display:none;">');
				document.write(this.item[i]);
				document.write('</div>');
			}
			document.write('</div>');
		}else
		if ( this.scrolltype=='2' ) {

			//document.write('<div id="'+this.name+'" style="height:100;width:500;position:absolute;overflow:hidden;" OnMouseOver="'+this.name+'.onmouseover();" OnMouseOut="'+this.name+'.onmouseout();">');
			document.write('<div id="'+this.name+'" style="height:'+this.height+';width:'+this.width+';overflow:hidden;" OnMouseOver="'+this.name+'.onmouseover();" OnMouseOut="'+this.name+'.onmouseout();">');
			for(var i = 0; i < this.itemcount; i++) {
				document.write('<div id="'+this.name+'item'+i+'"style="left:0px; width:'+this.width+';position:absolute; display:none; ">');
				document.write(this.item[i]);
				document.write('</div>');
			}
			document.write('</div>');
		}else
		if ( this.scrolltype=='3' ) {
			document.write('<div id="'+this.name+'" style="height:'+this.height+';width:'+this.width+';overflow:hidden;" OnMouseOver="'+this.name+'.onmouseover();" OnMouseOut="'+this.name+'.onmouseout();">');
			for(var i = 0; i < this.itemcount; i++) {
				document.write('<div id="'+this.name+'item'+i+'"style="left:0px; width:'+this.width+';position:absolute; display:none; ">');
				document.write(this.item[i]);
				document.write('</div>');
			}
			document.write('</div>');
		}
	};

	this.scroll = function () {
		this.currentspeed = this.scrollspeed;
		if ( !this.stop ) {
			this.imageChange();
		}
		window.setTimeout(this.name+".scroll()",this.currentspeed);
	};

	this.imageChange = function ()
	{
		for (k = 0; k < this.itemcount; k++) {
			obj = document.getElementById(this.name+'item'+k).style;
			if (this.count % this.itemcount == k) {
				obj.display = 'block';
			} else {
				obj.display = 'none';
			}
		}
		this.count++;
	};

	this.onmouseover = function ()
	{
		if ( this.pausemouseover ) {
			this.stop = 1;
		}
	};

	this.onmouseout = function ()
	{
		if ( this.pausemouseover ) {
			this.stop = 0;
		}
	};

	this.up = function ()
	{
		var nextitem;

		if (!this.stop) {

			if ( this.itemoffset >= this.itemcount ) {
				this.itemoffset = 0;
			}
			
			obj = document.getElementById(this.name+'item'+this.itemoffset).style;
			obj.display = 'block';
			obj.top = this.itemtop;
			this.itemtop--;

			nextitem = this.itemoffset + 1;
			if ( nextitem >= this.itemcount ) {
				nextitem = 0;
			}

			obj = document.getElementById(this.name+'item'+nextitem).style;
			obj.display = 'block';
			obj.top = this.itemtop + this.itemheight;

			for (i = 0; i < this.itemcount; i++) {
				if ( i!=nextitem && i!=this.itemoffset) {
					obj = document.getElementById(this.name+'item'+i).style;
					if ( obj.display == "block" ) {this.itemoffset = i+1;obj.display="none";}
				}
			}
		}
		if( this.itemtop * -1 >= this.itemheight )
		{
			obj = document.getElementById(this.name+'item'+this.itemoffset).style;
			obj.display = 'none';
			this.itemtop = 0;
			this.itemoffset = nextitem;
			window.setTimeout(this.name + ".up();",this.pausedelay);
		}else {
			window.setTimeout(this.name + ".up();",this.scrollspeed);
		}
	}

	this.itemup = function ()
	{
		var nextitem;

		if (!this.stop) {

			if ( this.itemoffset >= this.itemcount ) {
				this.itemoffset = 0;
			}
			
			obj = document.getElementById(this.name+'item'+this.itemoffset).style;
			obj.display = 'block';
			obj.top = this.itemtop;
			this.itemtop--;

			nextitem = this.itemoffset + 1;
			if ( nextitem >= this.itemcount ) {
				nextitem = 0;
			}

			obj = document.getElementById(this.name+'item'+nextitem).style;
			obj.display = 'block';
			obj.top = this.itemtop + this.itemheight;

			for (i = 0; i < this.itemcount; i++) {
				if ( i!=nextitem && i!=this.itemoffset) {
					obj = document.getElementById(this.name+'item'+i).style;
					if ( obj.display == "block" ) {this.itemoffset = i+1;obj.display="none";}
				}
			}
		}
		if( this.itemtop * -1 >= this.itemheight )
		{
			obj = document.getElementById(this.name+'item'+this.itemoffset).style;
			obj.display = 'none';
			this.itemtop = 0;
			this.itemoffset = nextitem;
		}
		if( !((this.itemtop * -1 ) % this.scrolheight) )
		{
			window.setTimeout(this.name + ".itemup();",this.pausedelay);
		}else {
			window.setTimeout(this.name + ".itemup();",this.scrollspeed);
		}

	}

}

//---------------   SAMPLE CODE   ---------------
/*
tbl_scelist = new turnlist();
tbl_scelist.name = "tbl_scelist";

if(0){
tbl_scelist.scrolltype = '1';
tbl_scelist.scrollspeed = 5000;
}else if(0){
tbl_scelist.scrollspeed = 5;
tbl_scelist.pausedelay = 5000;
tbl_scelist.height = 230;
tbl_scelist.width = 479;
tbl_scelist.scrolltype = '2';
tbl_scelist.itemheight = 230;
}else if(0){
tbl_scelist.scrollspeed = 5;
tbl_scelist.pausedelay = 5000;
tbl_scelist.height = 196;
tbl_scelist.width = 479;
tbl_scelist.itemheight = 196;
tbl_scelist.scrolheight = 28;
tbl_scelist.scrolltype = '3';
}

tbl_scelist.pausemouseover = true;
tbl_scelist.add('html');
tbl_scelist.start();
*/
