
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);
		distObj.style.display = "";
	}
}

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 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(globalBaseURL+'index.php?edit='+cls+'&'+params, 'editWin','scrollbars=yes,top='+tp+',left='+lft+',resizable=1,width='+width+',height='+height);
	editWin.focus();
}

var imgWin=null;
function openBigImage(smallSrc) {
	width = 600;
	height = 500;

	var lft = Math.floor((screen.availWidth - width)/2);
	var tp = Math.floor((screen.availHeight - height)/2)-20;
	
	var srcPath = smallSrc.replace(/[^\/]+$/, '') + 'big/';
	var url = globalBaseURL+srcPath+smallSrc.replace(/^.+\//, '');
	imgWin = open(url, 'imgWin','scrollbars=yes,status=yes,top='+tp+',left='+lft+',resizable=1,width='+width+',height='+height);
	imgWin.focus();
}

var popWin=null;
function openPop(width, height, url) {
	if (popWin != null) {
		popWin.close();
	}
	if (width > screen.availWidth) {
		width = screen.availWidth - 50;
	}
	if (height > screen.availHeight) {
		height = screen.availHeight - 50;
	}
	var lft = Math.floor((screen.availWidth - width)/2);
	var tp = Math.floor((screen.availHeight - height)/2);
	
	popWin = open(url, 'popWin','scrollbars=yes,status=yes,top='+tp+',left='+lft+',resizable=1,width='+width+',height='+height);
	popWin.focus();
}

function openNewWin(url, winName, params) {
	if (! url.match(/^(http:|ftp:|mailto:|news:|https:).+$/)) {
		if (! url.match(/^\/.+/)) {
			url = globalBaseURL + url;
		}
	}
	window.open(url, winName, params);
}

function form2uri(frm) {
	if (frm != null) {
		
		var curPath = globalBaseURL+globalCurrPath;
		var params='';
		var first=true;
		
		for(var i=0;i<frm.elements.length;i++) {
			if ((frm.elements[i] != null)) {
				if ((frm.elements[i].type != 'button')&&(frm.elements[i].type != 'submit')&&((frm.elements[i].type != 'radio')&&(frm.elements[i].type != 'checkbox') || frm.elements[i].checked)) {
				//alert("form field "+frm.elements[i].name);
					if (! first) {
						params += '/';	
					}
					first=false;
				
					var val = escape(frm.elements[i].value);
					//var val = frm.elements[i].value;
					val =  val.replace(/\-/g, "%2D");
					val =  val.replace(/\//g, "%2F");
					val = val.replace(/%/g, "^");
					params += frm.elements[i].name + '-' + val;
				}
			}
		}
		var newURL = curPath + globalUriDelimiter + '/' + params + '/' + globalCurrFile;
		//alert(newURL);
		window.location.href = newURL;
		return false;
	}
	return true;
}

function addbookmark(url, title){
if (document.all)
window.external.AddFavorite(url,title);
}
function setHome(ob) {
ob.style.behavior='url(#default#homepage)';
ob.setHomePage(document.location);
}
