// "AltTxt" script by Brian Gosselin  / version 1.2
// Created: 8/7/00.
// Modified: 2/16/01.
// www.scriptasylum.com
// E-mail: scriptasylum@hotmail.com
// Comments and suggestions are ALWAYS welcome at the above email address.

var txtcolor="black";                        //COLOR OF THE TEXT
var boxcolor="ivory";                    //BACKGROUND COLOR OF THE BOX
var boxbordercolor="gold";   //COLOR OF THE BORDER
var boxborderstyle="outset";       //BORDERSTYLE. SEE A STYLE SHEET GUIDE.
var boxborderthickness="4";         //THICKNESS OF BORDER IN PIXELS
var boxwidth=150;                          //WIDTH OF THE BOX IN PIXELS

var ishover=false, offset,w_y,navtxt, boxheight, scrolly;
var isloaded=false;

document.write('<div id="navtxt" style="position:absolute; top:0px; left:0px; width:'+boxwidth+'; visibility:hidden; font-size:12pt; border-width:'+boxborderthickness+'px; border-style:'+boxborderstyle+'; border-color:'+boxbordercolor+'; padding:4px; background-color:'+boxcolor+'; color:'+txtcolor+'; layer-background-color:'+boxcolor+'; text-align:center; z-index:1000000;"></div>');

//**** SOME OF THESE UTILITY FUNCTIONS BASED ON THE dhtmllib.js FILE FROM BRAINJAR.COM ****//

var isMinNS4 = (navigator.appName.indexOf("Netscape")>=0 && parseFloat(navigator.appVersion) >= 4 && parseFloat(navigator.appVersion) < 5)? true : false;
var isMinIE4 = (document.all)? true : false;
var isMinIE5 = (isMinIE4 && navigator.appVersion.indexOf("5.") >= 0)? true : false;
var isMinNS6 = (parseFloat(navigator.appVersion) >= 5 && navigator.appName.indexOf("Netscape")>=0 )? true: false;

function getlayer(name){
if(isMinNS4)return findlayer(name,document);
if(isMinIE4)return eval('document.all.'+name);
if(isMinNS6)return document.getElementById(name);
return null;
}

function findlayer(name,doc){
var i,layer;
for(i=0;i<doc.layers.length;i++){
layer=doc.layers[i];
if(layer.name==name)return layer;
if(layer.document.layers.length>0)
if((layer=findlayer(name,layer.document))!=null)
return layer;
}
return null;
}

function getwindowheight(){
if(isMinNS4 || isMinNS6)return window.innerHeight;
if(isMinIE4)return document.body.clientHeight;
return -1;
}

function getlayerheight(layer){
if(isMinNS4){
if(layer.document.height)return layer.document.height;
else return layer.clip.height;
}
if(isMinIE4){
if(layer.style.pixelHeight)
return layer.style.pixelHeight;
else return layer.offsetHeight;
}
if(isMinNS6) return parseInt(layer.offsetHeight);
return -1;
}

function getmousex(evt){
if(isMinNS4 || isMinNS6) return evt.pageX;
if(isMinIE4)  return event.clientX+document.body.scrollLeft;
return -1;
}

function getmousey(evt){
if(isMinNS4 || isMinNS6) return evt.pageY;
if(isMinIE4) return event.clientY+document.body.scrollTop;
return -1;
}

function hidelayer(layer){
if(isMinNS4)layer.visibility = "hide";
if(isMinIE4 || isMinNS6)layer.style.visibility = "hidden";
}

function showlayer(layer){
if(isMinNS4)layer.visibility = "show";
if(isMinIE4 || isMinNS6)layer.style.visibility = "visible";
}

function movelayerto(layer,x,y){
if(isMinNS4)layer.moveTo(x,y);
if(isMinIE4 || isMinNS6){
layer.style.left=x+'px';
layer.style.top=y+'px';
}}

function getpagescrollx(){
if(isMinNS4 || isMinNS6)return window.pageXOffset;
if(isMinIE4)return document.body.scrollLeft;
return -1;
}

function getpagescrolly(){
if(isMinNS4 || isMinNS6)return window.pageYOffset;
if(isMinIE4)return document.body.scrollTop;
return -1;
}

function writelayer(layer,text){
if(isMinNS4){
layer.document.open();
layer.document.write(text);
layer.document.close();
}
if(isMinIE4||isMinNS6)layer.innerHTML=text;
}

//**** END UTILITY FUNCTIONS ****//

function init(){
navtxt=getlayer('navtxt');
boxheight=getlayerheight(navtxt);
w_y=getwindowheight();
isloaded=true;
}

function getwindowsize(){
(isMinNS4)? setTimeout('history.go(0)',200) : w_y=getwindowheight();
}

function writetxt(text){
if(isloaded){
if(text!=0){
ishover=true;
if(isMinNS4)text='<div style="width:'+boxwidth+'px; border-width:'+boxborderthickness+'px; border-style:'+boxborderstyle+'; border-color:'+boxbordercolor+';"><font style="font-size:12pt; color:'+txtcolor+'"><center>'+text+'</center></font></div>';
writelayer(navtxt,text);
}else{
hidelayer(navtxt);
ishover=false;
}
boxheight=getlayerheight(navtxt);
}}

function moveobj(evt){
if(isloaded){
if(ishover){
offset=(getmousey(evt)+boxheight+45-getpagescrolly()>=w_y)? -15-boxheight : 30;
movelayerto(navtxt, Math.max(2+getpagescrollx() , getmousex(evt)-boxwidth/2), getmousey(evt)+offset);
showlayer(navtxt);
}}}

if(isMinNS4)document.captureEvents(Event.MOUSEMOVE);
document.onmousemove=moveobj;
window.onload=init;
window.onresize=getwindowsize;


