var threshold = 160;
var priorCoords;
var hasUserFocus = 'no';

function sliverlightControlHostMouseMove(obj)
{
  var coords = getOffsetXY(obj);
 
  //document.getElementById('testOutput').innerHTML='the relative mouse position within<br>' + obj.id + ' is: X=' + coords.x + ' Y=' + coords.y + '<br>hasUserFocus=' + hasUserFocus;
 
  //from all prior states, if in left side, raise to top
  if (coords.x < threshold){
    hasUserFocus = 'yes';
    obj.style.zIndex = 1000;
  }
 
  //if not coming from main area (not user has moused over widget counters)
  if (hasUserFocus == 'no'){
    if (coords.x >= threshold){
      //it appears Chrome does not like negative z-orders
      obj.style.zIndex = 0;
    }
  }
  priorCoords = coords;
}

function sliverlightControlHostMouseOut(obj){
  if (priorCoords.x >= threshold){
    hasUserFocus = 'no';
  }
}
 
 
//the following is lifted from http://www.codingforums.com/showthread.php?t=65686 and my work with all browsers
var mX;
var mY; 
 
function checkS(e)
{
  mX = 0;
  mY = 0; 

  if (!e){ //IE 
    var e = window.event
  };

  if (e.pageX || e.pageY){ //Moz 
    mX = e.pageX;
    mY = e.pageY;
  } 
  else if (e.clientX || e.clientY){ //IE 
    //IE correction 
    mX = e.clientX-2; 
    mY = e.clientY-2;
  }
  //document.getElementById('testPreOutput0').innerHTML='docX:' + mX + ', docY:' + mY;
} 

function getOffsetXY(obj)
{ 
  var oX = obj.offsetLeft;
  var oY = obj.offsetTop; 
 
  //document.getElementById('testPreOutput1').innerHTML='docX:' + oX + ', docY:' + oY;
 
  //NOTE: this nesting calculation does not add anything for IE, Firefox and Chrome. Is it necessary for some other browser?
  //while(obj.parentNode)
  //{// finds the absolute position of the object 
  //oX=oX+obj.parentNode.offsetLeft; 
  //oY=oY+obj.parentNode.offsetTop; 
  //
  //if(obj==document.getElementsByTagName('body')[0])
  //{
  //break;
  //} 
  //else
  //{
  //obj=obj.parentNode;
  //} 
  //}
 
  //document.getElementById('testPreOutput2').innerHTML='docX:' + oX + ', docY:' + oY;
 
  var rX=mX-oX;//relative X 
  var rY=mY-oY;//relative Y 
 
  coords = new Object();
  coords.x = rX;
  coords.y = rY;
  return coords;
} 
