// Tooltip program by Dominic Wormald
$(document).ready(function() {
	var msx = 0; 
	var msy = 0;
 	var flip = 0;
	var temp;
	$("body").append('<div id="tip"></div');
   	$().mousemove(function(e){
		msx=e.pageX; msy =  e.pageY;
		if ((msx +120) > posRight()) 
		{
			tooltip_left=msx-125;
		} 
		else
		{
			tooltip_left=msx+15;
		}

		if ((msy +70) > posBottom()) 
		{
			tooltip_top=msy-60;
		} 
		else
		{
			tooltip_top=msy+15;
		}
	
		$("#tip").css({left:tooltip_left});
		$("#tip").css({top:tooltip_top});
	}); 
	
    
    


	
	
	 $("a").hover(
      function () {
		 
//        temp = this.innerHTML +' - '+this.title;
        temp = this.title;
		if(this.title !='')
		{
			this.title='';
			$("#tip").stop();  
		 	$("#tip").show();
		 	$("#tip").html(temp);
		}
      }, 
      function () {
		$("#tip").stop();  
		$("#tip").hide();
		this.title = temp;
		temp = '';
		$("#tip").html('');
      }
    );

 });



function tooltip_pageWidth() 
{return window.innerWidth != null? window.innerWidth : document.documentElement && document.documentElement.clientWidth ?       document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null;} 

function tooltip_pageHeight() {return  window.innerHeight != null? window.innerHeight : document.documentElement && document.documentElement.clientHeight ?  document.documentElement.clientHeight : document.body != null? document.body.clientHeight : null;} 

function posLeft() {return typeof window.pageXOffset != 'undefined' ? window.pageXOffset :document.documentElement && document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ? document.body.scrollLeft : 0;} 

function posTop() {return typeof window.pageYOffset != 'undefined' ?  window.pageYOffset : document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ? document.body.scrollTop : 0;} 

function posRight() {return posLeft()+tooltip_pageWidth();} 

function posBottom() {return posTop()+tooltip_pageHeight();}
                    