// Copyright © 2000 by Apple Computer, Inc., All Rights Reserved.
//
// You may incorporate this Apple sample code into your own code
// without restriction. This Apple sample code has been provided "AS IS"
// and the responsibility for its operation is yours. You may redistribute
// this code, but you are not permitted to redistribute it as
// "Apple sample code" after having made changes.
// ********************************
// application-specific functions *
// ********************************

// initialize hacks whenever the page loads
window.onload = initializeHacks;


function initializeHacks() 
{
    // this ugly little hack resizes a blank div to make sure you can click
    // anywhere in the window for Mac MSIE 5
    if ((navigator.appVersion.indexOf('MSIE 5') != -1) 
	&& (navigator.platform.indexOf('Mac') != -1)
	&& getStyleObject('blankDiv')) {
	window.onresize = explorerMacResizeFix;
    }
    resizeBlankDiv();
    // this next function creates a placeholder object for older browsers
    createFakeEventObj();
}

function createFakeEventObj() 
{
    // create a fake event object for older browsers to avoid errors in function call
    // when we need to pass the event object to functions
    if (!window.event) {
	window.event = false;
    }
} // createFakeEventObj

function resizeBlankDiv() 
{
    // resize blank placeholder div so IE 5 on mac will get all clicks in window
    if ((navigator.appVersion.indexOf('MSIE 5') != -1) 
	&& (navigator.platform.indexOf('Mac') != -1)
	&& getStyleObject('blankDiv')) {
	getStyleObject('blankDiv').width = document.body.clientWidth - 20;
	getStyleObject('blankDiv').height = document.body.clientHeight - 20;
    }
}

function explorerMacResizeFix () 
{
    location.reload(false);
}


/***********************************************
* Cool DHTML tooltip script 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
***********************************************/

var offsetxpoint=-60 //Customize x offset of tooltip
var offsetypoint=20 //Customize y offset of tooltip
var ie=document.all
var ns6=document.getElementById && !document.all
var enabletip=false

function ietruebody()
{
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function ddtip(thetext, thewidth)
{
if (ns6||ie)
{
var tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : ""
if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
tipobj.innerHTML=thetext
if (ns6)
{	
	tipobj.style.position="fixed"
	if(!window.event && window.captureEvents) 
	{
	  // set up event capturing for mouse events (add or subtract as desired)
	  window.captureEvents(Event.MOUSEOVER);
	  window.onmouseover = WM_getCursorHandler;
	  window.event = new Object;
	}
}
enabletip=true
tipobj.style.visibility="visible"
positiontip();
return false
}
}

function WM_getCursorHandler(e) 
{
  // set event properties to global vars (add or subtract as desired)
  window.event.clientX = e.pageX;
  window.event.clientY = e.pageY;
  window.event.x = e.layerX;
  window.event.y = e.layerY;
  window.event.screenX = e.screenX;
  window.event.screenY = e.screenY;
  // route the event back to the intended function
  if ( routeEvent(e) == false ) {
    return false;
  } else {
    return true;
  }
}


function positiontip()
{
if (enabletip)
{
if (document.all)
{
	var tipobj= document.all["dhtmltooltip"];
	var curX= event.x+ietruebody().scrollLeft;
	var curY= event.y+ietruebody().scrollTop;
	//Find out how close the mouse is to the corner of the window
	var rightedge= !window.opera ? ietruebody().clientWidth-event.clientX-offsetxpoint : window.innerWidth-tipobj.clientX-offsetxpoint-20
	var bottomedge= !window.opera ? ietruebody().clientHeight-event.clientY-offsetypoint : window.innerHeight-tipobj.clientY-offsetypoint-20

	var leftedge=(offsetxpoint<0) ? offsetxpoint*(-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= ietruebody().scrollLeft+event.clientX-tipobj.offsetWidth+"px" 
	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+offsetxpoint+"px"

	//same concept with the vertical position
	if (bottomedge<tipobj.offsetHeight)
		tipobj.style.top= ietruebody().scrollTop+event.clientY-tipobj.offsetHeight-offsetypoint+"px"
	else
		tipobj.style.top=curY+offsetypoint+"px"
}
else
{
	// For Netscape we used a Fixed position
	var tipobj= document.getElementById ? document.getElementById("dhtmltooltip") : ""
	tipobj.style.top=window.event.clientY+offsetypoint-window.pageYOffset+"px"
	tipobj.style.left=window.event.clientX+offsetxpoint-window.pageXOffset+"px"
}
}
}

function ddhide()
{
if (ns6||ie)
{
var tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : ""
enabletip=false
tipobj.style.visibility="hidden"
}
}


