/*
Script: Status Bar Decrypter v1.0 
Author: Anarchos [http://i.am/Anarchos] 
Modified by Option-line! [http://www.option-line.com/webmasters]
*/

function ObjDecrypt(id, data, delay)
{
	this.id = id;
	this.data = data ? data : "|| | ||| |";
	this.delay = delay ? delay : 3000;
	this.done = 1;
	this.msglist = new Array;
	this.msgix = -1;
	this.timer = null;
	this.mensagem = function(m) {
		this.msglist[this.msglist.length] = m;
	}
	this.iniciar = function() {
		if(this.msglist.length > 0) {
			this.msgix++;
			if(this.msgix >= this.msglist.length) this.msgix = 0;
			this.scheduler();
		}
		else
			window.status = 'Nenhuma mensagem definida!';
		return true;
	}
	this.scheduler = function() {
		window.setTimeout(this.id + ".decrypt('" + this.msglist[this.msgix] + "',2,3)", this.delay);
	}
	this.decrypt = function(text, max, delay) {
		if(this.done) {
		    this.done = 0;
    		this.decrypt_helper(text, max, delay, 0, max);
		}
	}
	this.decrypt_helper = function(text, runs_left, delay, charvar, max) {
		if(!this.done) {
			runs_left = runs_left - 1;
			var status = text.substring(0,charvar);
			for(var current_char = charvar; current_char < text.length; current_char++)
				status += this.data.charAt(Math.round(Math.random()*this.data.length));
			window.status = status;
			var rerun = this.id + ".decrypt_helper('" + text + "'," + runs_left + "," + delay + "," + charvar + "," + max + ");"
			var new_char = charvar + 1;
			var next_char = this.id + ".decrypt_helper('" + text + "'," + max + "," + delay + "," + new_char + "," + max + ");"
			if(runs_left > 0)
				window.setTimeout(rerun, delay);
			else {
				if (charvar < text.length)
					window.setTimeout(next_char, Math.round(delay*(charvar+3)/(charvar+1)));
				else {
					this.done = 1;
					this.iniciar();
				}
			}
		}
	}
	return this;
}

