/*
This tooltip library was created by Mukul Kumar; http://codeeazy.com
It has been modified for specific-case use by VoiceThread.
*/
function showtip(e,message) {
  var x=0;var y=0;var m;var h;
  // Get window sizes
  // Thanks to: http://www.howtocreate.co.uk/tutorials/javascript/browserwindow
  var windowWidth = 0, windowHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    windowWidth = window.innerWidth;
    windowHeight = window.innerHeight;
  }
  else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    windowWidth = document.documentElement.clientWidth;
    windowHeight = document.documentElement.clientHeight;
  }
  else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    windowWidth = document.body.clientWidth;
    windowHeight = document.body.clientHeight;
  }

  if(!e) var e=window.event;
  if(e.pageX||e.pageY){
    x=e.pageX;y=e.pageY;
  }
  else if(e.clientX||e.clientY)
  {
    x=e.clientX+document.body.scrollLeft+document.documentElement.scrollLeft;
    y=e.clientY+document.body.scrollTop+document.documentElement.scrollTop;
  }
  m=document.getElementById('mktipmsg');
  if((y>10)&&(y<450)) {
    m.style.top=y-4+"px";
  }
  else { m.style.top=y+4+"px"; }
  var messageHeigth=(message.length/20)*10+25;
  if(messageHeigth > 400) {
    m.style.top=(y-(messageHeigth/2))+"px";
  }
  // Determine left or right of cursor
  // If room to the right won't go off the screen, show on the right of cursor
  //alert ((x+400)+" "+windowWidth);
  if((x+400)<windowWidth) { m.style.left=x+20+"px"; }
  // Otherwise, show tool-tip on the left of cursor
  else { m.style.left=x-400+"px"; }
  
  m.innerHTML=message;
  m.style.display="block";
  m.style.zIndex=203;
}

function showtipmanage(e,message) {
  var x=0;var y=0;var m;var h;
  // Get window sizes
  // Thanks to: http://www.howtocreate.co.uk/tutorials/javascript/browserwindow
  var windowWidth = 0, windowHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    windowWidth = window.innerWidth;
    windowHeight = window.innerHeight;
  }
  else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    windowWidth = document.documentElement.clientWidth;
    windowHeight = document.documentElement.clientHeight;
  }
  else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    windowWidth = document.body.clientWidth;
    windowHeight = document.body.clientHeight;
  }

  if(!e) var e=window.event;
  if(e.pageX||e.pageY){
    x=e.pageX;y=e.pageY;
  }
  else if(e.clientX||e.clientY)
  {
    x=e.clientX+document.body.scrollLeft+document.documentElement.scrollLeft;
    y=e.clientY+document.body.scrollTop+document.documentElement.scrollTop;
  }
  m=document.getElementById('mktipmsg');
  if((y>10)&&(y<250)) {
    //alert(y);
    m.style.top=y+15+"px";
  }
  else { m.style.top=y+15+"px"; }
  var messageHeigth=(message.length/20)*10+25;
  if(messageHeigth > 330) {
    m.style.top=(y-(messageHeigth/2))+"px";
  }
  // Determine left or right of cursor
  // If room to the right won't go off the screen, show on the right of cursor
  //alert ((x+400)+" "+windowWidth);
  if((x+300)<windowWidth) { m.style.left=x+15+"px"; }
  // Otherwise, show tool-tip on the left of cursor
  else { m.style.left=x-330+"px"; }
  
  m.innerHTML=message;
  m.style.display="block";
  m.style.zIndex=203;
}

function hidetip() {
  var m;
  m=document.getElementById('mktipmsg');
  m.style.display="none";
}
