// Common Tools 

////////////////////////////////////////////////////////////////////
// Expandable menus script
function initMenus() {
	if (!document.getElementsByTagName) return;
	
	var aMenus = document.getElementsByTagName("LI");
	for (var i = 0; i < aMenus.length; i++) {
		var mclass = aMenus[i].className;
		if (mclass.indexOf("treenode") > -1) {
			var submenu = aMenus[i].childNodes;
			for (var j = 0; j < submenu.length; j++) {
				if (submenu[j].tagName == "A") {
					submenu[j].onclick = function() {
						var node = this.nextSibling;
											
						while (1) {
							if (node != null) {
								if ((node.tagName == "UL") || (node.tagName == "OL")) {
									var d = (node.style.display == "none")
									node.style.display = (d) ? "block" : "none";
									this.className = (d) ? "treeopen" : "treeclosed";
									return false;
								}
								node = node.nextSibling;
							} else {
								return false;
							}
						}
						return false;
					}
					
					submenu[j].className = (mclass.indexOf("open") > -1) ? "treeopen" : "treeclosed";
				}
				
				if (submenu[j].tagName == "UL")
					submenu[j].style.display = (mclass.indexOf("open") > -1) ? "block" : "none";
			}
		}
	}
}



////////////////////////////////////////////////////////////////////
// startUp: starts everything listed (binded to the <BODY ...onload="startUp(); ...>"
function startUp() {
	// Funstions list...
	initMenus();

	// Preload Images
//	MM_preloadImages('images/feedb1.gif','images/labs1.gif','images/lab0.gif','images/libr0.gif','images/nw0.gif','images/fb0.gif','images/dsc0.gif','images/do.gif','images/ch.gif','images/re.gif','images/ki1.gif','images/ch3.gif','images/f.gif','images/x.gif');
	
	// Load 
	
}

// Starts Any function
function Evaluate(prm) {
	var result = eval(prm);      				

// var a=Evaluate('alert("Hi");');
}

////////////////////////////////////////////////////////////////////
// Open Popup window andcenters it

function opendemo(popW,popH,doc,prms)
{
var rnum=Math.round(Math.random()*4);
	
	if (prms == null) {
		prms='resizable=no,scrollbars=no,status=no';
	}

	if (document.all || document.layers) {
   		var w = screen.availWidth;
   		var h = screen.availHeight;
	}


	var leftPos = (w-popW)/2, topPos = (h-popH)/2;


	window.open (doc, rnum, prms + ',width=' + popW + ',height=' + popH + ',top=' + topPos + ',left=' + leftPos)
}

////////////////////////////////////////////////////////////////////
// Changes StatuBar Text

function StatusBar(txt) {
	self.status = txt;
}

////////////////////////////////////////////////////////////////////
// Repeats specified character <c> , n - times

function repeatChar(c,n) {
var str = "";

	for(var i=0;i<n;i++) {
		str=str+c;
	}
	return str;	
}
