  var __emc = {x:0, y:0};
  function _md(event) {
	  __emc.x = event.clientX;
	  __emc.y = event.clientY;
  }
  function _mu(event, elem) {
    if (event.button != 2 && Math.abs(__emc.x - event.clientX) < 5 && Math.abs(__emc.y - event.clientY) < 5) {
      eval(elem.getAttribute('act'));
    }
  }
  // do nothing
  function noop() {}
  // trim whitespace from beginning and end of string v.
  function trim(v) {
      if (v.match(/^\s+$/)) {
          return "";
      } else {
          return v.replace(/^(\s+)?(.*\S)(\s+)?$/, '$2'); 
      }
  }
  // true if string v is null or the empty string.
  function isEmpty(v) { return (null == v || "" == trim(v));            }

  // get all elements that are assigned a particular class.
  // don't pass a node arg to get all elements in the document.
  // http://ejohn.org/blog/getelementsbyclassname-speed-comparison/
  //
  function getElementsByClassName(searchClass, node, tag) {
    var classElements = new Array();
    if ( node == null )
      node = document;
    if ( tag == null )
      tag = '*';
    var els = node.getElementsByTagName(tag);
    var elsLen = els.length;
    var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
    for (i = 0, j = 0; i < elsLen; i++) {
      if ( pattern.test(els[i].className) ) {
        classElements[j] = els[i];
        j++;
      }
    }
    return classElements;
  }
  // Get a cookie for the current document by name.
  //
  function getCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for (var i=0; i < ca.length; i++) {
	  var c = ca[i];
	  while (c.charAt(0)==' ') { c = c.substring(1,c.length); }
	  if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
  }

  // Write a cookie with the specified path, name, value, and "# of days cookie should last".
  // path should usually be /bhc/PortletName
  // Pass "" for days to create a session cookie.
  // Pass -1 for days to erase a cookie.
  //
  function writeCookie(path, name, value, days) {
	if (days) {
	  var date = new Date();
	  date.setTime(date.getTime()+(days*24*60*60*1000));
	  var expires = "; expires="+date.toGMTString();
	} else {
	  var expires = "";
	}
	document.cookie = name + "=" + value + expires + "; path=" + path;
  }

  // Show the "pleasewait" popup div at the current click event location.
  // To use this function, create a div like the following (text in the <p> can be anything you want): 
  //     <div id="pleasewait"><p>Please wait... </p></div>
  // Then, add an onClick="showPleaseWait(event);" handler to whatever DOM obj you desire.
  //
  function showPleaseWait(event, offsetVert, offsetHoriz) {
    if (null == offsetVert) offsetVert = 0;
    if (null == offsetHoriz) offsetHoriz = 0;
    
    var p = document.getElementById("pleasewait");
	p.style.top = (event.clientY + offsetVert) + ((document.all) ? "" : "px");
    p.style.left = (event.clientX + offsetHoriz) + ((document.all) ? "" : "px");
    p.style.display = "block";
  }


  // Toggle all items in array "fields" enabled or disabled.
  // This dis/enables the fields and changes the bg color to gray, like FF does by default.
  // @param d true to mark all fields disabled, false to mark them all enabled.
  // @param fields array of form input fields to mark disabled
  //
  function toggleDisabled(d, fields) {
    var c = ((d) ? "silver" : "white");
    for (var i=0; i < fields.length; i++) {
      if (fields[i] != null) {
        if (fields[i][1]) {
          for (var j=0; j < fields[i].length; j++) {
            fields[i][j].disabled = d;
            fields[i][j].style.backgroundColor = c;
          }
        } 
        fields[i].disabled = d;
        if (fields[i].style) { fields[i].style.backgroundColor = c; }
      }
    }
  }


  // For IE versions less than 7, define a function called XMLHttpRequest; we call this in asyncGET.
  /*@cc_on 
    @if (@_win32 && @_jscript_version >= 5) 
      if (! window.XMLHttpRequest) function XMLHttpRequest () {return new ActiveXObject ("Microsoft.XMLHTTP")} 
    @end 
  @*/

  // Submit an http GET or POST request for the given url.  
  // On _complete_ retrieval of URL contents, call function 'callback'.
  // The first parameter to 'callback' will be the xmlhttp object used in the request.
  // Any additional parameters after the 'callback' parameter will be passed along to 'callback' itself.
  //
  function asyncGET(url, callback) {
    sendRequest('', url, callback, arguments, 2);
  }
  
  function asyncPOST(content, url, callback) {
    sendRequest(content, url, callback, arguments, 3);
  }
  
  function sendRequest(content, url, callback, a, offset) {
    var xmlhttp = new XMLHttpRequest;
    xmlhttp.open("POST", url, true);
    xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    var args = 'callback(xmlhttp';
    for (var i=offset; i < a.length; i++) args += ',a['+i+']';
    args += ')';
    xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState == 4) { eval(args); } } ;
    xmlhttp.send(content);
  
  }
  // Gets the number of pixels of vertical scroll the document has, if any.
  //
  function getVerticalScrollOffset() {
    var scroll = 0;
    if (typeof( window.pageYOffset ) == 'number' ) {
      //Netscape compliant
      scroll = window.pageYOffset;
    } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
      //DOM compliant
      scroll = document.body.scrollTop;
    } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
      //IE6 standards compliant mode
      scroll = document.documentElement.scrollTop;
    }
    return scroll;
  }
  
  // Closes the ebiz notice and marks it as seen for this user.
  //
  function closeEbizNotice(hideForGood) {
    document.getElementById("ebizNotice").style.display = "none";
    asyncGET("/bhc/Notifications/?__doIgnoreNotice=1&hide=" + hideForGood, noop);
    return false;
  }