
	/*********************************************************************************************

	ALTTXT V1.6
	BY: BRIAN GOSSELIN OF SCRIPTASYLUM.COM

	EXAMPLE: <a href="scriptasylum.com" onmouseover="writetxt('Popup text')" onmouseout="writetxt(0)">Link text</a>

	NOTES:

	  > YOU CAN CAUSE A BOX *NOT* TO DISAPPEAR ONCE THE MOUSE LEAVES THE LINK BY SIMPLY OMITTING THE
	    onmouseout="writetxt(0)" PART. THIS WILL CAUSE THE CURRENT BOX TO REMAIN VISIBLE. THIS IS BEST
	    USED WHEN mousefollow MODE IS DISABLED (SET TO false).

	  > YOU CAN SET THE PADDING STYLE ATTRIBUTE *ONLY* IN THE navtxt DIV ITSELF AND *NOT* IN THE STYLE
	    SHEET AT THE TOP OF THE PAGE. OTHERWISE NS4 DISPLAYS SOME WEIRD BEHAVIOR. ALSO, THE PADDING ATTRIBUTE
	    ONLY HAS AN EFFECT IN IE4+ AND NS6+.

	UPDATES BY EHOSTER:
	- window.onload=function() => function loadAT() since window.onload conflicts with the BODY onload event.
	- Support for IE4, NS4, NS6 (and possibly IE5/IE6) ditched to save space/performance and increase readability.
	  Please note that: this.ie5 => IE, this.ns6 => FF + Webkit (safari + chrome)
	- Nasty scroll-y bug for IE6/IE7/IE8 fixed
	- Support for Opera added (this.opera)
	- Modern opacity methods (CSS3) is now used for all browser except... IE!
	- The filter function (used for opacity) for IE has been blocked because of problems with ClearType in IE7/IE8
	  More info: http://blogs.msdn.com/ie/archive/2006/08/31/730887.aspx

	*********************************************************************************************/

	var dofade=true;       // ENABLES FADE-IN EFFECT (FOR IE4+ AND NS6 ONLY)

	var centertext=false;  // CENTERS THE TEXT INSIDE THE BOX. YOU CAN'T SIMPLY DO THIS VIA "STYLE" BECAUSE OF NS4.
	                       // OTHERWISE, TEXT IS LEFT-JUSTIFIED.

	var xoffset=9;         // HORIZONTAL PIXEL COUNT FROM CURSOR

	var yoffset=20;        // VERTICAL PIXEL COUNT FROM CURSOR

	var mousefollow=false; // ENABLES MOUSE FOLLOW MODE WHERE THE BOX CONTINUES TO FOLLOW THE MOUSE. SET TO false TO
	                       // LOCK THE BOX WHEREVER IT INITIALLY APPEARS.

	var hideDelay=300;     // DELAY IN MILLISECONDS ( 1 SECOND = 1000 MILLISECONDS) FROM WHEN YOU HOVER OUT OF LINK
	                       // AND THE BOX DISAPPEARS ONLY WHEN "mousefollow" IS SET TO "false".
	                       // THIS WILL GIVE THE USER TIME TO CLICK A LINK OR WHATEVER IN THE BOX BEFORE IT DISAPPEARS.

	////////////////////////////// NO NEED TO EDIT BEYOND THIS POINT //////////////////////////////////////

	function altProps(){
	this.w3c=(document.getElementById)?true:false;
	this.ie5=(document.all && this.w3c)?true:false;
	this.ns6=(this.w3c && navigator.appName.indexOf("Netscape")>=0 )?true:false;
	this.opera=(navigator.appName=='Opera')?true:false;
	//alert('W3C:'+this.w3c+' IE5:'+this.ie5+' NS6:'+this.ns6+' Opera:'+this.opera);
	//alert(navigator.appName);
	this.w_y=0;
	this.w_x=0;
	this.navtxt=null;
	this.boxheight=0;
	this.boxwidth=0;
	this.ishover=false;
	this.ieop=0;
	this.op_id=0;
	this.oktomove=false;
	this.dy=0;
	}

	var AT=new altProps();

	function toggle_centertext(){
	centertext=!centertext;
	}

	function toggle_mousefollow(){
	mousefollow=!mousefollow;
	}

	function toggle_dofade(){
	dofade=!dofade;
	if(!dofade)AT.ieop=100;
	}


	function getwindowdims(){
	AT.w_y=(AT.ie5)?document.body.clientHeight:window.innerHeight;
	AT.w_x=(AT.ie5)?document.body.clientWidth:window.innerWidth;
	}

	function getboxwidth(){
	AT.boxwidth=(AT.navtxt.style.width)? parseInt(AT.navtxt.style.width) : parseInt(AT.navtxt.offsetWidth);
	}

	function getboxheight(){
	AT.boxheight=parseInt(AT.navtxt.offsetHeight);
	}

	function movenavtxt(x,y){
	AT.navtxt.style.left=x+'px';
	AT.navtxt.style.top=y+'px';
	}

	function getpagescrolly(){
	if(AT.ie5) return document.documentElement.scrollTop;
	else return window.pageYOffset;
	}

	function getpagescrollx(){
	if(AT.ie5)return document.documentElement.scrollLeft;
	else return window.pageXOffset;
	}

	function writeindiv(text){
	AT.navtxt.innerHTML=text;
	}

	function writetxt(text, aaa){
	if(dofade && AT.w3c)clearInterval(AT.op_id);
	if(text!=0){
	if(!mousefollow)clearTimeout(AT.dy);
	AT.oktomove=true;
	AT.ishover=true;
	if(AT.w3c)AT.navtxt.style.textAlign=(centertext)?"center":"left";
	writeindiv(text);
	AT.navtxt.style.visibility="visible";
	AT.navtxt.style.display="block";
	getboxheight();
	if(AT.w3c && dofade){
	if(AT.ie5&&false)AT.navtxt.style.filter="alpha(opacity=0)";
	else AT.navtxt.style.opacity = 0;
	AT.ieop=0;
	AT.op_id=setInterval('incropacity()',50);
	}}else{
	if(mousefollow)hideAlttxt();
	else AT.dy=setTimeout('hideAlttxt()',hideDelay);
	}}

	function hideAlttxt(){
	AT.navtxt.style.display="none";
	AT.navtxt.style.visibility="hidden";
	movenavtxt(-AT.boxwidth-10,0);
	writeindiv('');
	}

	function incropacity(){
	if(AT.ieop<=100){
	AT.ieop+=15;
	if(AT.ie5&&false)AT.navtxt.style.filter="alpha(opacity="+AT.ieop+")";
	else AT.navtxt.style.opacity = AT.ieop/100;
	}else clearInterval(AT.op_id);
	}

	function moveobj(evt){
	mx=(AT.ie5)?event.clientX:evt.pageX;
	my=(AT.ie5)?event.clientY:evt.pageY;
	if(AT.ishover && AT.oktomove){
	margin=(AT.ie5)?5:25;
	xoff=mx+xoffset;
	
	yoff=(my+AT.boxheight+yoffset-((AT.ns6||AT.opera)?getpagescrolly():0)>=AT.w_y)? -5-AT.boxheight-yoffset: yoffset;
	movenavtxt( Math.min(AT.w_x-AT.boxwidth-margin , Math.max(2,xoff))+getpagescrollx(), my+yoff+((!AT.ns6&&!AT.opera)?getpagescrolly():0));
	if(!mousefollow)AT.oktomove=false;
	}}


	function loadAT(){
	  AT.navtxt=(AT.w3c)?document.getElementById('navtxt'):null;
	  getboxwidth();
	  getboxheight();
	  getwindowdims();
	  if(AT.ie5&&dofade&&false)AT.navtxt.style.filter="alpha(opacity=100)";
	  AT.navtxt.onmouseover=function(){
	  if(!mousefollow)clearTimeout(AT.dy);
	  }
	  AT.navtxt.onmouseout=function(){
	  if(!mousefollow)AT.dy=setTimeout('hideAlttxt()',hideDelay);
	  }
	  document.onmousemove=moveobj;
	  window.onresize=getwindowdims;
	}


