/*
+--------------------------------------------------------
+	Marquee group
+--------------------------------------------------------
*/

function marqueer_object(){
	this.height = new Array();
	this.percent = new Array();
	this.scrolls = new Array();
	this.process = new Array();
	this.nextops = new Array();
	this.limitime1 = 12;//0;
	this.limitime2 = 3000;
	this.up = function(id,percent,height){
		if ($(id)){
			this.height[id] = isNaN(height) ? 270 : parseInt(height);
			this.percent[id] = isNaN(percent) ? 135 : parseInt(percent);
			$(id).style.height = this.height[id] + 'px';
			this.scrolls[id] = $(id).scrollHeight - this.height[id];
			this.nextops[id] = 0;
			this.starter(id);
		}
	}
	this.stoper = function(id){
		clearTimeout(this.process[id]);
		this.process[id] = false;
	}
	this.starter = function(id){
		if ($(id)){
			if (!this.process[id]){
				this.process[id] = setTimeout('marqueer.starter("' + id + '")',this.limitime2);
			} else {
				if (this.limitime1 == 0){
					if (this.nextops[id] == -1){
						this.nextops[id] = 0;
					} else {
						this.nextops[id] += this.percent[id];
					}
					$(id).scrollTop = this.nextops[id] >= this.scrolls[id] ? this.scrolls[id] : this.nextops[id];
					if (this.nextops[id] >= this.scrolls[id]){
						this.nextops[id] = -1;
					}
					this.process[id] = setTimeout('marqueer.starter("' + id + '")',this.limitime2);
				} else {
					this.nextops[id] += 1;
					$(id).scrollTop = this.nextops[id];
					if (this.nextops[id] == 0){
						this.process[id] = setTimeout('marqueer.starter("' + id + '")',this.limitime2);
					} else if (this.nextops[id] >= this.scrolls[id]){
						this.process[id] = setTimeout('marqueer.starter("' + id + '")',this.limitime2);
						this.nextops[id] = -1;
					} else if (this.nextops[id] % this.percent[id] == 0) {
						this.process[id] = setTimeout('marqueer.starter("' + id + '")',this.limitime2);
					} else {
						this.process[id] = setTimeout('marqueer.starter("' + id + '")',this.limitime1);
					}
				}
			}
		}
	}
}

marqueer = new marqueer_object();
