
function DL_GetElementLeft(eElement)
{
   if (!eElement && this)                    // if argument is invalid
   {                                         // (not specified, is null or is 0)
      eElement = this;                       // and function is a method
   }                                         // identify the element as the method owner

   var DL_bIE = document.all ? true : false; // initialize var to identify IE

   var nLeftPos = eElement.offsetLeft;       // initialize var to store calculations
   var eParElement = eElement.offsetParent;  // identify first offset parent element

   while (eParElement != null)
   {                                         // move up through element hierarchy

      if(DL_bIE)                             // if browser is IE, then...
      {
         if( (eParElement.tagName != "TABLE") && (eParElement.tagName != "BODY") )
         {                                   // if parent is not a table or the body, then...
            nLeftPos += eParElement.clientLeft; // append cell border width to calcs
         }
      }
      else                                   // if browser is Gecko, then...
      {
         if(eParElement.tagName == "TABLE")  // if parent is a table, then...
         {                                   // get its border as a number
            var nParBorder = parseInt(eParElement.border);
            if(isNaN(nParBorder))            // if no valid border attribute, then...
            {                                // check the table's frame attribute
               var nParFrame = eParElement.getAttribute('frame');
               if(nParFrame != null)         // if frame has ANY value, then...
               {
                  nLeftPos += 1;             // append one pixel to counter
               }
            }
            else if(nParBorder > 0)          // if a border width is specified, then...
            {
               nLeftPos += nParBorder;       // append the border width to counter
            }
         }
      }
      nLeftPos += eParElement.offsetLeft;    // append left offset of parent
      eParElement = eParElement.offsetParent; // and move up the element hierarchy
   }                                         // until no more offset parents exist
   return nLeftPos;                          // return the number calculated
}

function DL_GetElementTop(eElement)
{
   if (!eElement && this)                    // if argument is invalid
   {                                         // (not specified, is null or is 0)
      eElement = this;                       // and function is a method
   }                                         // identify the element as the method owner

   var DL_bIE = document.all ? true : false; // initialize var to identify IE

   var nTopPos = eElement.offsetTop;         // initialize var to store calculations
   var eParElement = eElement.offsetParent;  // identify first offset parent element

   while (eParElement != null)
   {                                         // move up through element hierarchy
      if(DL_bIE)                             // if browser is IE, then...
      {
         if( (eParElement.tagName != "TABLE") && (eParElement.tagName != "BODY") )
         {                                   // if parent a table cell, then...
            nTopPos += eParElement.clientTop; // append cell border width to calcs
         }
      }
      else                                   // if browser is Gecko, then...
      {
         if(eParElement.tagName == "TABLE")  // if parent is a table, then...
         {                                   // get its border as a number
            var nParBorder = parseInt(eParElement.border);
            if(isNaN(nParBorder))            // if no valid border attribute, then...
            {                                // check the table's frame attribute
               var nParFrame = eParElement.getAttribute('frame');
               if(nParFrame != null)         // if frame has ANY value, then...
               {
                  nTopPos += 1;              // append one pixel to counter
               }
            }
            else if(nParBorder > 0)          // if a border width is specified, then...
            {
               nTopPos += nParBorder;        // append the border width to counter
            }
         }
      }

      nTopPos += eParElement.offsetTop;      // append top offset of parent
      eParElement = eParElement.offsetParent; // and move up the element hierarchy
   }                                         // until no more offset parents exist
   return nTopPos;                           // return the number calculated
}
var time_id = null;
var curElm = null;

function showPositionElm(obj, name, dx, dy) {
	if (document.getElementById && document.getElementById(name)) {

		distObj = document.getElementById(name);
		x= DL_GetElementLeft(obj);
		y= DL_GetElementTop(obj);
		distObj.style.left = x + dx;
		distObj.style.top = y + dy;
		clearTimeout(time_id);
		if (curElm != null) {curElm.style.display = "none";}
		distObj.style.display = "";
		curElm = distObj;
	}
}

function hideCurElm() {
	if (curElm != null) {
		time_id = setTimeout("hideElm()", 500);
	}
}

function undoHideElm() {
	clearTimeout(time_id);
}
function hideElm() {
	if (curElm != null) {
		curElm.style.display = "none";
	}
}

function sh_h_class(tag_name, class_name, show) {
	//if (show) { alert("Show on"); }
	//else { alert("Show off"); }
if(document.getElementsByTagName){
   var els = document.getElementsByTagName(tag_name);
   //alert("Length: " + els.length);
   var cl_names = "";
    for(var i=0; i<els.length; i++){
		if (els[i].className == class_name) {
			cl_names += els[i].className + "; ";
			els[i].style.display = (show) ? "" : "none";
		}
	}
	//alert("Classes: " + cl_names);
}
}
var toolWin=null;
function openTool(width, height, type, params) {
	if (toolWin != null) {
		toolWin.close();
	}
	toolWin = open('index.php?get='+type+'&'+params, 'toolWin','scrollbars=yes,resizable=1,width=780,height=540');
	toolWin.focus();
}

var editWin=null;
function openEdit(width, height, cls, params) {
	if (editWin != null) {
		editWin.close();
	}
	var lft = Math.floor((screen.availWidth - width)/2);
	var tp = Math.floor((screen.availHeight - height)/2);
	
	editWin = open('index.php?edit='+cls+'&'+params, 'editWin','scrollbars=yes,top='+tp+',left='+lft+',resizable=1,width='+width+',height='+height);
	editWin.focus();
}