<!--
/*
This code is from Dynamic Web Coding 
www.dyn-web.com 
Copyright 2002 by Sharon Paine 
Permission granted to use this code as long as this 
entire notice is included.

Idea and math for time-based animation from 
Aaron Boodman at www.youngpup.net
*/
dom = (document.getElementById) ? true : false;
ns5 = ((navigator.userAgent.indexOf("Gecko")>-1) && dom) ? true: false;
ie5 = ((navigator.userAgent.indexOf("MSIE")>-1) && dom) ? true : false;
ns4 = (document.layers && !dom) ? true : false;
ie4 = (document.all && !dom) ? true : false;
nodyn = (!ns5 && !ns4 && !ie4 && !ie5) ? true : false;

// resize fix for ns4
var origWidth, origHeight;
if (ns4) {
	origWidth = window.innerWidth; origHeight = window.innerHeight;
	window.onresize = function() { if (window.innerWidth != origWidth || window.innerHeight != origHeight) history.go(0); }
}

// avoid error of passing event object in older browsers
if (nodyn) event = "nope";

// settings for tooltip 
var tipWidth 			 	= 170;
var tipOffX				 	= 18;	// how far from mouse to show tip
var tipOffY				 	= 12; 
var tipFontFamily 	= "Verdana, arial, helvetica, sans-serif";
var tipFontSize			= "7pt";
var tipFontColor		= "#66FF66";
var tipBgColor 			= "#666666";
var tipBorderColor 	= "#999966";
var tipBorderWidth 	= 1;
var tipBorderStyle 	= "solid";
var tipPadding		 	= 4;
var tipAniLen				= 300;	// time allotted for slideOut/In

// messages for links
var msg1 = "Realizing your full life\'s potential.";
var msg2 = "Celebrating the wonders of science.";
var msg3 = "Astronomy - a look at space, our universe and beyond.";
var msg4 = "Our planet, our environment.";
var msg5 = "Or they might not...";
var msg6 = "What is Edible Brain about and who does this site?";
var msg7 = "Is my glass half happy or half sad?";
var msg8 = "Oops!";

var tooltip, tipcss, tipMult, startTime;
function initTip() {
	if (nodyn) return;
	tooltip = (ns4)? document.tipDiv.document: (ie4)? document.all['tipDiv']: (ie5||ns5)? document.getElementById('tipDiv'): null;
	tipcss = (ns4)? document.tipDiv: tooltip.style;
	if (ie4||ie5||ns5) {	// ns4 would lose all this on rewrites
		tipcss.width = tipWidth+"px";
		tipcss.fontFamily = tipFontFamily;
		tipcss.fontSize = tipFontSize;
		tipcss.color = tipFontColor;
		tipcss.backgroundColor = tipBgColor;
		tipcss.borderColor = tipBorderColor;
		tipcss.borderWidth = tipBorderWidth+"px";
		tipcss.padding = tipPadding+"px";
		tipcss.borderStyle = tipBorderStyle;
	}
	if (ns5) tipWidth += 2*(tipBorderWidth+tipPadding);
	clipTo(tipcss,0,0,300,0);	// sets bottom to 300 
	tipMult = tipWidth/tipAniLen/tipAniLen;	// used for slideIn/Out
}
window.onload=initTip;

function doTip(txt,e) {
	if (!tooltip) return;
	if (t1) clearTimeout(t1); if (t2) clearTimeout(t2);
	var y = (ns4||ns5)? e.pageY+tipOffY: window.event.clientY + document.body.scrollTop+tipOffY;
	var x = (ns4||ns5)? e.pageX+tipOffX: window.event.clientX + document.body.scrollLeft+tipOffX;
	if (ns4) {
		// styles need to be reapplied each time for ns4
		var cntnt = '<table bgcolor="' + tipBorderColor + '" width="' + tipWidth + '" cellspacing="0" cellpadding="' + tipBorderWidth + '" border="0"><tr><td><table bgcolor="' + tipBgColor + '" width="100%" cellspacing="0" cellpadding="' + tipPadding + '" border="0"><tr><td><span style="font-family:' + tipFontFamily + '; font-size:' + tipFontSize + '; color:' + tipFontColor + ';">' + txt  + '</span></td></tr></table></td></tr></table>';
  	tooltip.write(cntnt);
		tooltip.close();
  	tipcss.moveTo(x,y);				
  } else {
		tooltip.innerHTML = txt;
		tooltip.style.top =  y+"px";
		tooltip.style.left =  x+"px";
	}
	startTime = (new Date()).getTime();
	slideOut();
}

var t1, t2;	// for setTimeout's
function slideOut() {
	var clipVal = getClipValues(tipcss);
	var elapsed = (new Date()).getTime()-startTime;
	if (elapsed<tipAniLen) {
		var cv = tipWidth - Math.round(Math.pow(tipAniLen-elapsed,2)*tipMult);
		clipTo(tipcss,0,cv,clipVal[2],0);
		t1 = setTimeout("slideOut()",35);
	} else clipTo(tipcss,0,tipWidth,clipVal[2],0);
}

function slideIn() {
	var clipVal = getClipValues(tipcss);
	var elapsed = (new Date()).getTime()-startTime;
	if (elapsed<tipAniLen) {
		var cv = Math.round(Math.pow(tipAniLen-elapsed,2)*tipMult);
		clipTo(tipcss,0,cv,clipVal[2],0);
		t2 = setTimeout("slideIn()",35);
	} else clipTo(tipcss,0,0,clipVal[2],0);
}

function shrink() {
	if (!tooltip) return;
	if (t1) clearTimeout(t1);
	if (t2) clearTimeout(t2);
	startTime = (new Date()).getTime();
	slideIn();
}

// ideas from dynduo, brainjar and bratta
function getClipValues(lyr) {
	if (ns4) {
  	var clipVal = new Array();
		clipVal[0] = lyr.clip.top;
		clipVal[1] = lyr.clip.right;
		clipVal[2] = lyr.clip.bottom;
		clipVal[3] = lyr.clip.left;
  } else if (ie4 || ie5 || ns5) {
		var clipVal = lyr.clip.substring(5,lyr.clip.length-1).split(' ');
			for (var i=0; i<4; i++) {
				clipVal[i] = parseInt(clipVal[i]);
			}
  }
	return clipVal;
}

function clipTo(lyr,top,rt,btm,lft) {
	if (ns4) {
  	lyr.clip.top = top;
		lyr.clip.right = rt;
		lyr.clip.bottom = btm;
		lyr.clip.left = lft;
  } else if (ie4 || ie5 || ns5) {
  	lyr.clip = "rect("+top+"px "+rt+"px "+btm+"px "+lft+"px)";
  }
}
//-->