// JAVASCRIPT

var objStatus = new Array();
var divContent = new Array();

function toggle(objId) {

//	debugText(objId);

	if (objStatus[objId] == "down") {
		up(objId);
	} else {
		if (objStatus[objId] == "up") {
			down(objId);
		} else {
			// objStatus[objId] has not been defined
			this.obj = document.getElementById(objId);
			divContent[objId] = this.obj.innerHTML;
//			debugText("yo1");
// debugText("<br>" + divContent[objId].replace(/</g, "&lt;") + "end text<br><br>");
			objStatus[objId] = "down";
			up(objId);
		}
	}
}

function up(objId) {
	this.obj = document.getElementById(objId);
	this.text1 = this.obj.innerHTML;
	this.text = this.text1.toLowerCase();
	this.mark = this.text.indexOf("</div>");
	if (this.mark > 0) { 
		this.mark = this.mark + 6;
		this.newText = this.text1.substr(this.mark);
		this.obj.innerHTML = this.newText;
		window.setTimeout("up('"+objId+"');", 50);
	} else {
		this.obj.style.display = 'none';
		objStatus[objId] = "up";
	}
}

function down(objId) {
	this.obj = document.getElementById(objId);
	this.obj.style.display = 'block'; 				// make visible again
	this.obj.innerHTML = divContent[objId];
	// divContent[objId];
	objStatus[objId] = "down";
}

function debugText(oPut) {
	this.debug = document.getElementById("debug");
//	var newText = oPut.replace(/</g, "&lt;");
//	newtext = newText.replace(/>/g, "&gt;");
	this.debug.innerHTML += oPut + "<br>";
}

