// JavaScript Document

//  text trimming

//  locations

function get_left(obj) {
  var result = 0;
  if (typeof(obj) == 'string')
    obj = get_element(obj);
  if (obj) {
    if (obj.offsetParent)
      while (true) {
        result += obj.offsetLeft;
        if (!obj.offsetParent)
          break;
        obj = obj.offsetParent;
      }
    else if (obj.x)
      result += obj.x;
  }
  return result;
}
function get_top(obj) {
  var result = 0;
  if (typeof(obj) == 'string')
    obj = get_element(obj);
  if (obj) {
    if(obj.offsetParent)
      while (true) {
        result += obj.offsetTop;
        if (!obj.offsetParent)
          break;
        obj = obj.offsetParent;
      }
    else if(obj.y)
      result += obj.y;
  }
  return result;
}



// addClass and removeClas

function addClass(objElement, strClass, blnMayAlreadyExist) {
   if ( objElement.className ) {
      var arrList = objElement.className.split(' ');
      if ( blnMayAlreadyExist ) {
         var strClassUpper = strClass.toUpperCase();

         for ( var i = 0; i < arrList.length; i++ ) {
            if ( arrList[i].toUpperCase() == strClassUpper ) {
               arrList.splice(i, 1);
               i--;
               }
            }
         }
      arrList[arrList.length] = strClass;
      objElement.className = arrList.join(' ');
      }
   else objElement.className = strClass;
}

function removeClass(objElement, strClass) {
   if ( objElement.className ) {
      var arrList = objElement.className.split(' ');
      var strClassUpper = strClass.toUpperCase();
      for ( var i = 0; i < arrList.length; i++ ) {
         if ( arrList[i].toUpperCase() == strClassUpper ) {
            arrList.splice(i, 1);
            i--;
            }
         }
      objElement.className = arrList.join(' ');
      }
}


// popover menus - suckerfish style
var visible = null;
function sfHover() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	var subNav = document.getElementById("nav").getElementsByTagName("UL");
	visible = document.getElementById("visible");
	for (var i=0; i<sfEls.length; i++) {
	  if (sfEls[i].parentNode.id != "visible") {
		  sfEls[i].onmouseover=function() {
				addClass(this,"sfhover");
				if (this.className.indexOf("current") == -1) {
				if (this.lastChild.id != "visible")
	  		      if (visible) visible.style.display = "none";
				if (this.lastChild.id == "visible")
				  this.lastChild.style.display = "block";
			}
		  }
		  sfEls[i].onmouseout=function() {
			removeClass(this,"sfhover");
			if (this.className.indexOf("current") == -1) {
				if (this.lastChild.id != "visible")
				  if (visible) visible.style.display = "block";
				if (this.lastChild.id == "visible")
				  this.lastChild.style.display = "none";
			}
		  }
	  } else {
		sfEls[i].onmouseover=function()
			{addClass(this,"sfhover"); came_from_here = 1;}
		sfEls[i].onmouseout=function()
			{removeClass(this,"sfhover"); came_from_here = 0;}
	}
}
}
var came_from_here = 0;

//if (window.attachEvent) window.attachEvent("onload", sfHover);

