//help table
var mem = new Array();
//---------------------------
function doSome(){
	if (ie4) { var e = window.event; e.cancelBubble = true;}//solve the bubbling problem
}
//sniff
var ie4 = false;
if(document.all) { ie4 = true; }
function getObject(id) {
	if (ie4) { return document.all[id]; }
	else { return document.getElementById(id); }
}
//-------------------------
//set + get content
function setContent(name, value) {
	var d = getObject(name);
	d.innerHTML = value;    
}
function getContent(name) {
	var d = getObject(name);
	return d.innerHTML;
}
function setColor(name, value) {
	var d = getObject(name);
	d.style.color = value;  
}
function getColor(name) {
	var d = getObject(name);
	return d.style.color;
}
function ParentCl (name, col) {
	var d = getObject(name);
	d.style.color = col;
}
//------------------------------
//function make the menu with -span class letter-
function makeMenu (a, b, col) {
	for (z=0; z<b; z++) {
		var name = a + z;
		var value = getContent(name);
		mem[z]=value;//put in memory the primary value
		toDo(name, value, col,z);
	}
}
function toDo (name, value, col,z) {
	if (value.indexOf('<span') >= 0) { return; }//if begin with span jump
	var length = 0;
	var str = '';
	var ch;
	var token = '';
	var htmltag = false;
	ParentCl(name, 'white');//change the parent span/style
	for (i = 0; i < value.length; i++) {//do loop until the end of the word=value
		ch = value.substring(i, i+1);//one letter of the word
		if (i < value.length - 1) { nextch = value.substring(i+1, i+2); } else { nextch = ' '; }
		token += ch;
		if (ch == '<' && nextch.indexOf('/aAbBpPhHiIoOuUlLtT') >= 0) { htmltag = true; }//begin of tag
		if (ch == '>' && htmltag) { htmltag = false; }
		if (!htmltag && ch.charCodeAt(0) > 30 && ch != ' ' && ch != '\n') {
			str += '<span id="' + name + '_' + length + '" style="color:white">' + token + '</span>';//create span
			token = '';
			length++;
		}
	}
	setContent(name, str);//put span letter with color white
	anima(name, length, -1, col,z);
}
function anima(name, length, ind, col,z) {
	var next = ind + 1;
	if (next >= length) { 
		setContent(name, mem[z]);
		ParentCl(name, 'black');
		return; 
	}
	setColor(name + '_' + next, col);
	command = 'anima(\'' + name + '\', ' + length + ',' + next + ', \'' + col + '\','+z+')';
	setTimeout(command , 50);
}

function display(elm,mnu) {
	doSome();
	var d = getObject(elm);
if(d.className=="open") { 
	d.className="closed";
	} else { 
	d.className="open";
	if(mnu=="zz2") {makeMenu('ma',1,'black');}
	else if(mnu=="zz3") {makeMenu('s',14,'black');}
	else if(mnu=="zz1") {makeMenu('k',3,'black');}
	} 
}
