
//  Options for the Toll tip
  

  //Offset of the tip
  var offX = 3;
  var offY = 4;
  //var TipBg;

var divName;

function tooltipX() {

  //Create the tipbody
  var tipBody = document.getElementsByTagName("body").item(0);
  
  //Tip wrap
	if(!document.getElementById('tipX')){
	  var tipWrap = document.createElement("div");
	  tipWrap.setAttribute('id','tipX');
	  tipWrap.style.display = "none";
	  //tipWrap.setAttribute('style','width:auto;min-width:60px;');
	  tipWrap.style.width = "75px";	
	  tipWrap.style.position = "absolute";
	  tipWrap.style.zIndex = "106";
	  //tipWrap.style.background = TipBg;
	  tipBody.appendChild(tipWrap);
	}

  //Output the tooltip
	var linkwithTip = document.getElementsByClassName('tooltipx');
	for(i = 0; i < linkwithTip.length; i++) {
		tipObj = linkwithTip[i];
		tipObj.onmouseover = function() {
		  var tipValue = this.getAttribute('title');
		  $('tipX').innerHTML = tipValue;
		  $('tipX').style.display = "block";
		  divName = "tipX";
		  this.onmousemove = follow;
		  this.setAttribute('title', '');
		}
		tipObj.onmouseout = function() {
		  var title= $('tipX').innerHTML;
		  $('tipX').innerHTML = null;
		  $('tipX').style.display = "none";
		  this.setAttribute('title', title);
		}
	}
}

function mouseX(evt) {
  if (!evt) evt = window.event;
  if (evt.pageX) return evt.pageX;
  else if (evt.clientX) return evt.clientX + (document.documentElement.scrollLeft ?  document.documentElement.scrollLeft : document.body.scrollLeft);
  else return 0;
}
	
function mouseY(evt) {
  if (!evt) evt = window.event;
  if (evt.pageY) return evt.pageY;
  else if (evt.clientY)return evt.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
  else return 0;
}

function follow(evt) {
  if (document.getElementById) {
    var obj = document.getElementById(divName).style; obj.visibility = 'visible';
    
    var tleft = parseInt(mouseX(evt)); //Determine left with no offset
    var ttop = parseInt(mouseY(evt)); //Determine top with no offset
    
    //Determine max left so that could not come near right edge
    var swidth = screen.width;
    var limitx = swidth - 350;
            
    //Determine Distance to edge
    var iebody=(document.compatMode && document.compatMode != "BackCompat")? document.documentElement : document.body;
    var hiddentop=document.all? iebody.scrollTop : pageYOffset;
    
    if (ttop<(hiddentop+145)) offY = 5; //Rest offset if near top edge
    if (tleft>limitx) tleft = limitx; //Reset left postion if near with right edge
    
    obj.left = [tleft+offX] + 'px';
    obj.top =  [ttop+offY] + 'px';
  }
}
