var statusMsg = "";

function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

var dacPath = Array();
dacPath.push(1);
dacMenuId = "";


function hideSubMenus(node)
{
   normalizeMenus(node);
   if (node.className == "dacmenuHover") node.className = "dacmenuNormal";
   return ;
   for (var itemi=0;itemi<node.childNodes.length;itemi++) {
      var subNode = node.childNodes[itemi];
      if (subNode.childNodes.length) hideSubMenus(subNode);
      else subNode.className = "dacmenuNormal";
   }
}

function normalizeMenus(node)
{
   var nodes = node.getElementsByTagName("a");
   for (var itemi=0;itemi<nodes.length;itemi++) {
      if (nodes[itemi].className == "dacmenuHover") nodes[itemi].className = "dacmenuNormal";  
   }
   nodes = node.getElementsByTagName("td");
   for (var itemi=0;itemi<nodes.length;itemi++) {
      if (nodes[itemi].className == "dacmenuHover") nodes[itemi].className = "dacmenuNormal";  
   }
   nodes = node.getElementsByTagName("table");
   for (var itemi=0;itemi<nodes.length;itemi++) {
      if (nodes[itemi].className == "dacmenuHover") nodes[itemi].className = "dacmenuNormal";  
   }
}

var closeTimer = 0;

function dacmenuenter(menuId, divId)
{
	clearTimeout(closeTimer);
  if (dacMenuId != "" && dacMenuId != menuId) {
	  // new menu close previous menu
		dachideandnormalizesubmenues(dacMenuId, 1);  
  }
  dacMenuId = menuId;
  
	
   return true;
}


function dachideandnormalizesubmenues(menuId, parentDivId)
{
	  while (true) {
     var head = dacPath.pop();
     if (head) {
        if (head == parentDivId) {
           dacPath.push(parentDivId);
           normalizeMenus(document.getElementById("dacmenu"+menuId+parentDivId));
           break;
        } else {
           var subMenu = document.getElementById("dacmenu"+menuId+head);
           hideSubMenus(subMenu);
        }
     } else {
        break;
     }
  }
}

function dacclosetimeout(menuId, parentDivId)
{
	dachideandnormalizesubmenues(menuId, 1); // 1= close all parentDivId= close 1 level
}


function dacmenuexit(menuId, divId)
{
		if (closeTimer) clearTimeout(closeTimer);
		closeTimer = setTimeout("dacclosetimeout('"+menuId+"',"+divId+");",750);
		return true;

}

function dacmenuclick(menuId, divId)
{
		if (closeTimer) clearTimeout(closeTimer);
		dacclosetimeout(menuId, divId);
		return true;

}

function dacmenuexpand(menuId, s, parentDivId, divId)
{
  clearTimeout(closeTimer);
  if (dacMenuId != "" && dacMenuId != menuId) {
	  // new menu close previous menu
		dachideandnormalizesubmenues(dacMenuId, 1);  
  }
  dacMenuId = menuId;

  var td = s;
  var d = document.getElementById("dacmenu"+menuId+divId);
  var aList = td.getElementsByTagName("a");

  dachideandnormalizesubmenues(menuId, parentDivId);

  if (aList.length == 0) return ;
  var a = aList.item(0);
  
  td.className = "dacmenuHover";
  a.className = "dacmenuHover";

  if (d) {
     d.className = "dacmenuHover";
     dacPath.push(divId);
	  var parentDiv = document.getElementById("dacmenu"+menuId+parentDivId);
	  var parentTable = parentDiv.getElementsByTagName("table");
/*
	  var s = "";
	  for (key in td)   {
		  if (key.substring(0,2) != "on") {
			  var val = ""+td[key];
		  if (val.length < 8 || val.substring(0,8) != "function") {
			  s += key + ": " + td[key] + "; ";
		  }	
		}
	  }
	  alert(s);
*/	  

	  d.style.left = findPosX(td)+0+"px";
     //d.style.left = td.offsetLeft+0+"px"; //td.clientWidth+0+"px"; //findPosX(td)+td.clientWidth-5+"px";
     d.style.top = findPosY(td)+td.clientHeight+"px"; //td.offsetTop+0+"px";
     //d.style.top = td.clientHeight+5+"px" //td.offsetTop+0+"px";
     //d.style.width = 219;
  }

}

function dacmenucollapse(menuId, s, parentDivId, divId)
{
}


function printpage() {
	var url = ''+self.location;
	if (url.indexOf("?") < 0) {
	   window.open(url+'?dac_preview=print', '');
	} else {
	   window.open(url+'&dac_preview=print', '');
	}
}

