/* written by FUNK <http://serber.n3.net> */

	var CurrentMsg = '';
	function update(msg)
	{
		pad_str+=' ';
		CurrentMsg = pad_str + msg;
		window.status = CurrentMsg;
	}

	var data = '';
	var done = 3;
	function walkIn(CurrentMsg)
	{
		decrypt(CurrentMsg, 2, 1);
	}

	function walkOut()
	{
		self.description = '';
		done = 1;
	}

	function decrypt(CurrentMsg, max, delay)
	{
		if (done)
		{
			done = 0;
			decrypt_helper(CurrentMsg, max, delay,  0, max);
		}
	}

	function decrypt_helper(CurrentMsg, runs_left, delay, charvar, max)
	{
		if (!done)
		{
			runs_left = runs_left - 1;
			var description = CurrentMsg.substring(0, charvar);
			for (var current_char = charvar; current_char < CurrentMsg.length; current_char++)
			{
				description += data.charAt(Math.round(Math.random()*data.length));
			}

			window.status = description;
			var rerun = "decrypt_helper('" + CurrentMsg + "'," + runs_left + "," + delay + "," + charvar + "," + max + ");"
			var new_char = charvar + 1;
			var next_char = "decrypt_helper('" + CurrentMsg + "'," + max + "," + delay + "," + new_char + "," + max + ");"
			if(runs_left > 0)
			{
				setTimeout(rerun, delay);
			}
			else
			{
				if (charvar < CurrentMsg.length)
				{
					setTimeout(next_char, Math.round(delay*(charvar+3)/(charvar+1)));
				}
				else
				{
					done = 1;
				}
			}
		}
	}
