// <![CDATA[
// tooltip.js
// September 14, 2007
// tooltip("absolute positioned div", "appearing/disappearing div", "show or hide", "change in x", "change in y", "type of effect", "length of effect")



function tooltip(parentid, childid, todo, xChange, yChange, myEffect, myEffectDuration, checkChildHover) {
	// The variables below may be modified to suit the needs of your current application
// 	var xChange = 25;
//	var yChange = 140;
	
	// We need to find the positioning of the parent id so we can position the child appropriately
	workingElem = document.getElementById(parentid);
	var curleft = 0;
	var curtop = 0;
	var xScroll, yScroll;
	var windowWidth, windowHeight;
	
	
	if(workingElem.offsetParent) {
		curleft = workingElem.offsetLeft;
		curtop = workingElem.offsetTop;
		while (workingElem = workingElem.offsetParent) {
			curleft += workingElem.offsetLeft;
			curtop += workingElem.offsetTop;
		}
	}
	
	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
		xScroll = self.pageXOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
		xScroll = document.documentElement.scrollLeft;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
		xScroll = document.body.scrollLeft;	
	}

	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	if(xChange == "center") {
		xChange = windowWidth/2 - 180;	
	}
	
	switch(todo) {
		case "showoverlay":
			document.getElementById(childid).style.top = parseInt(yScroll) + parseInt(yChange) + "px";
			document.getElementById(childid).style.left = parseInt(xScroll) + parseInt(xChange) + "px";
			// Check if any effects are wanted
			if(myEffect == "Appear") {
				new Effect.Appear(childid, { duration: myEffectDuration });
			} else {
				// No effect, just display
				document.getElementById(childid).style.display = "block";
			}
			break;
		case "hideoverlay":
			document.getElementById(childid).style.top = -6000 + "px";
			document.getElementById(childid).style.display = "none";
			break;
		case "show":
			document.getElementById(childid).style.top = parseInt(curtop) - parseInt(yChange) + "px";
			document.getElementById(childid).style.left = parseInt(curleft) - parseInt(xChange) + "px";
			// Check if any effects are wanted
			if(myEffect == "Appear") {
				new Effect.Appear(childid, { duration: myEffectDuration });
			} else {
				// No effect, just display
				document.getElementById(childid).style.display = "block";
			}
			break;
		case "hide":
				document.getElementById(childid).style.top = -6000 + "px";
				document.getElementById(childid).style.display = "none";
			break;
	}
}



// ]]>
