var path_prefix = _ABS_PATH;

function toggleSelectBoxes(arg) {
	var e = document.getElementsByTagName('select');
	for(var i=0; i<e.length; i++) {
		e[i].style.visibility = (arg=='hide') ? 'hidden' : 'visible';
	}
}

function load(new_location) {
	if (new_location == -1 || !new_location) return false;
	if(new_location.indexOf("http://") < 0) new_location = path_prefix + new_location;
	window.location = new_location;
	return false;
}

var menuLayers = {
  timer: null,
  timer_pulldowns: null,
  activeMenuID: null,
  offX: 4,   // horizontal offset 
  offY: 6,  // vertical offset 
  show: function(id, e) {
    var mnu = document.getElementById? document.getElementById(id): null;
    if (!mnu) return;
    this.activeMenuID = id;
    if ( mnu.onmouseout == null ) mnu.onmouseout = this.mouseoutCheck;
    if ( mnu.onmouseover == null ) mnu.onmouseover = this.clearTimer;
    this.position(mnu);
  },
  
  hide: function() {
    this.clearTimer();
    if (this.activeMenuID && document.getElementById) {
      this.timer = setTimeout("hideMenu('"+menuLayers.activeMenuID+"')", 300);
    }
  },

  position: function(mnu) {
    this.timer = setTimeout("showMenu('"+menuLayers.activeMenuID+"')", 100);
  },

  mouseoutCheck: function(e) {
    e = e? e: window.event;
    var mnu = document.getElementById(menuLayers.activeMenuID);
    var toEl = e.relatedTarget? e.relatedTarget: e.toElement;
    if ( mnu != toEl && !menuLayers.contained(toEl, mnu) ) menuLayers.hide();
  },
  

  contained: function(oNode, oCont) {
    if (!oNode) return;
    while ( oNode.parentNode ) {
      oNode = oNode.parentNode;
      if ( oNode == oCont ) return true;
    }
    return false;
  },

  clearTimer: function() {
    if (menuLayers.timer) clearTimeout(menuLayers.timer);
    if (menuLayers.timer_pulldowns) clearTimeout(menuLayers.timer_pulldowns);
    if (menuLayers.activeMenuID) showMenu(menuLayers.activeMenuID);
  }

}



function showMenu(id) {
	document.getElementById(id).style.visibility = "visible";
	if(document.getElementById(id+"_img").onmouseover) document.getElementById(id+"_img").onmouseover.call();
	//toggleSelectBoxes("hide");
}

function hideMenu(id) {
	document.getElementById(id).style.visibility = "hidden";
	if(document.getElementById(id+"_img").onmouseout) document.getElementById(id+"_img").onmouseout.call();
	//toggleSelectBoxes("show");
}

var preloadFlag = false;
var loadedImages;

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function preloadImages(imageArr) {
	if (document.images && imageArr!=null) {
		loadedImages = new Array(imageArr.length);
		for (var i=0; i<imageArr.length; i++) {
			loadedImages[i] = newImage(imageArr[i]);
		}
		preloadFlag = true;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}


function popUp(name,w,h) {
	window.open("",name,"height="+h+",width="+w+",scrollbars=yes,resizable=yes,toolbar=no,status=no,location=no,menubar=no");
}