/***********************************************
* Cool DHTML tooltip script II- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
*
* Modified by Camille SCHOELL for TENNIS ACADEMY
***********************************************/


var xOffset=8
var yOffset=20

var ie=document.all
var w3c=document.getElementById && !document.all
var enabletip=false
if (ie||w3c) {
	var tipobj
}


function ietruebody(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

/*------------------------------------------------------------------------
SHOW TOOLTIP
------------------------------------------------------------------------*/
function showTip(txt, title, info){

	if (w3c||ie){
		txt = txt.replace(/##apo/g,"'");
		title = title.replace(/##apo/g,"'");
		info = info.replace(/##apo/g,"'");


		var content = "<p>"+txt+"</p>"

		tipobj = document.all? document.all["tooltip"] : document.getElementById? document.getElementById("tooltip") : ""
		tipcontent = document.all? document.all["tooltipContent"] : document.getElementById? document.getElementById("tooltipContent") : ""

		if (title!="") {
			if ( txt!="" ) {
				content='<div class="title">'+title+'</div>'+content
			}
			else {
				content='<div class="titleOnly">'+title+'</div>'+content
			}
		}
		
		if (info!="") {
			content=content+'<div class="tipInfo"><i>'+info+'</i></div>'
		}
		

		tipcontent.innerHTML = content
		enabletip=true

		return false
	}
}


/*------------------------------------------------------------------------
HIDE THE TOOLTIP
------------------------------------------------------------------------*/
function hideTip(){
	if (w3c||ie){
		enabletip=false
//        tipobj.style.visibility="hidden" // avoid the IE6 cache optimisation with hidden blocks
		tipobj.style.top="-1000px"
		tipobj.style.backgroundColor=''
		tipobj.style.width=''
	}
}


/*------------------------------------------------------------------------
ONMOVE EVENT
------------------------------------------------------------------------*/
function moveTip(e){
	if (enabletip){
	
		var nondefaultpos=false
		// IE Fix by xam
		if (!e)
		{
		var e = window.event
		}
		
		// IE Fix by xam
		if (e.pageX || e.pageY)
		{
		curX = e.pageX;
		curY = e.pageY;
		}
		else if (e.clientX || e.clientY)
		{
		curX = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
		curY = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
		}
		//Find out how close the mouse is to the corner of the window
		var winwidth=ie&&!window.opera? ietruebody().clientWidth : window.innerWidth-20
		var winheight=ie&&!window.opera? ietruebody().clientHeight : window.innerHeight-20

		var rightedge=ie&&!window.opera? winwidth-event.clientX-xOffset : winwidth-e.clientX-xOffset
		var bottomedge=ie&&!window.opera? winheight-event.clientY-yOffset : winheight-e.clientY-yOffset

		var leftedge=(xOffset<0)? xOffset*(-1) : -1000

		//if the horizontal distance isn't enough to accomodate the width of the context menu
		if (rightedge<tipobj.offsetWidth){
			//move the horizontal position of the menu to the left by it's width
			tipobj.style.left=curX-tipobj.offsetWidth+"px"
			nondefaultpos=true
		}
		else {
			if (curX<leftedge) {
				tipobj.style.left="5px"
			}
			else{
				//position the horizontal position of the menu where the mouse is positioned
				tipobj.style.left=curX+xOffset+"px"
			}
		}

		//same concept with the vertical position
		if (bottomedge<tipobj.offsetHeight) {
			tipobj.style.top=curY-tipobj.offsetHeight-yOffset+"px"
			nondefaultpos=true
		}
		else{
			tipobj.style.top=curY+yOffset+"px"
		}
	}
}
function showVignette(i){

	if (w3c||ie){
		
		tipobj = document.all? document.all["vignette_popup"+i] : document.getElementById? document.getElementById("vignette_popup"+i) : ""
		

		
		enabletip=true

		return false
	}
}


document.onmousemove=moveTip



