/*****************************************
JavaScript For Dropdown Menu Items
*****************************************/
function setdd(){
	var cntctrl = document.getElementById("rowcount");
	var cnt = cntctrl.value;
	var subctrl, menuctrl;
	for (var i=1;i<=cnt;i++){
		subctrl = document.getElementById("sub"+i);
		menuctrl = document.getElementById("menu"+i);
		if (subctrl != null && menuctrl != null){
			subctrl.style.position = "absolute";
			var loc = getLocation(menuctrl);
			setLocation(subctrl, loc.x, loc.y + menuctrl.offsetHeight - 2);
		}
	}
}
function showsubmenu(i){
	var sub = document.getElementById("sub" + i);
	if (sub != null){
		var octrl = document.getElementById("isopen" + i);
		var isopen = octrl.value;
		if (isopen == "0"){
			sub.style.visibility = "visible";
			octrl.value = "1";
			var ocnt = document.getElementById("sub" + i);
			var cnt = eval(ocnt.offsetHeight) + 25;
			var ocol = document.getElementById("col" + i);
			ocol.style.height = cnt;
			ocol = document.getElementById("xpander" + i);
			ocol.innerHTML = "-";
			setdd();
		}else{
			sub.style.visibility = "hidden";
			octrl.value = "0";
			var ocol = document.getElementById("col" + i);
			ocol.style.height = "25";
			ocol = document.getElementById("xpander" + i);
			ocol.innerHTML = "+";
			setdd();
		}
	}
}
function checksubmenu(i){
	var octrl = document.getElementById("isopen" + i);
	if (octrl != null){
		if (octrl.value == "0"){
			showsubmenu(i);
		}
	}
}
function hidesubmenu(i){
	var sub = document.getElementById("sub" + i);
	if (sub != null){
		sub.style.visibility = "hidden";
	}
}
function getLocation(el) {
	var elLoc = {x:0,y:0};
	//the offsetLeft & offsetTop return the left and top position
	//of the element relative to the parent container.  
	while(el) {
		elLoc.x += el.offsetLeft;
		elLoc.y += el.offsetTop;
		el = el.offsetParent;
	}
	return elLoc;	
}//end of getLocation
function setLocation(el, x, y) {
	var parentLoc = {x:0, y:0};
	if(el.offsetParent) {
		parentLoc = getLocation(el.offsetParent);
	}
	//set element location
	el.style.left = (x - parentLoc.x) + 'px';
	el.style.top = (y - parentLoc.y) + 'px';
}//end of setLocation
function setdark(ctrl) {
	ctrl.style.backgroundColor = "#330033";
	ctrl.style.color = "#FFFFFF";
}
function setlite(ctrl) {
	ctrl.style.backgroundColor = "#CCCCCC";
}
