var isIE=navigator.userAgent.indexOf('MSIE ')!=-1;

// Javascript Smart ToolTip  Ferra' srl 2007
var STT={
fTip:false, // T/F
fHide:false,
iStatus:0,
xOfs:10,yOfs:10, // Offset dal cursore del mouse
fArrow:true, // T/F per la freccia
xArrow:0,yArrow:14, // Posizione della freccia
iDelay:800,
ndp:false,
objTip:null,objArrow:null,

Show:function (e,thetext, thewidth, thecolor, posx, posy)
{
if (_dom>1){
if (typeof thewidth!="undefined") STT.objTip.style.width=thewidth+"px";
if (typeof thecolor!="undefined" && thecolor!="") STT.objTip.style.backgroundColor=thecolor;
STT.objTip.innerHTML=thetext;
if (!STT.fTip&&STT.iDelay) {STT.fHide=true; setTimeout('ShowTipTime()',STT.iDelay);}
STT.fTip=true;
positiontip(e,posx,posy);
return false;}
},

Hide: function (){
if (_dom>1){
STT.fTip=false;
STT.objTip.style.visibility="hidden"
STT.objArrow.style.visibility="hidden"
STT.objTip.style.left="-1000px"
STT.objTip.style.backgroundColor=''
STT.objTip.style.width=''}
STT.fHide=false;
},

View: function () {
STT.objTip.style.visibility="visible";
if (!STT.snp&&STT.fArrow) STT.objArrow.style.visibility="visible"; else STT.objArrow.style.visibility="hidden";
}

};

function ShowTipTime() 
{if (!STT.fTip) return;
 STT.fHide=false; 
 STT.View();
}

document.write('<div id="dhtmltooltip"></div>') 
document.write('<img id="dhtmlpointer" src="/js/tt/arrow2.gif">') 

if (_dom>1)
{
 STT.objTip=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : "";
 STT.objArrow=document.all? document.all["dhtmlpointer"] : document.getElementById? document.getElementById("dhtmlpointer") : "";
}

function positiontip(e,posx,posy){
STT.snp=false;
var ms={x:0,y:0};
if (!e) ms={x:0,y:0}; else ms=GetCursor(e); 
if (posx) {ms.x=posx; ms.y=posy;}

// Find out how close the mouse is to the corner of the window 
var winwidth=isIE&&!window.opera? ietb().clientWidth : window.innerWidth-20;
var winheight=isIE&&!window.opera? ietb().clientHeight : window.innerHeight-20;
var rightedge=isIE&&!window.opera? winwidth-event.clientX-STT.xOfs : winwidth-e.clientX-STT.xOfs;
var bottomedge=isIE&&!window.opera? winheight-event.clientY-STT.yOfs : winheight-e.clientY-STT.yOfs;
var leftedge=(STT.xOfs<0)? STT.xOfs*(-1) : -1000;
// if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<STT.objTip.offsetWidth)
{
 //move the horizontal position of the menu to the left by it's width
 STT.objTip.style.left=ms.x-STT.objTip.offsetWidth+"px";
 STT.snp=true;
}
else if (ms.x<leftedge)
 STT.objTip.style.left="5px";
else
{
//position the horizontal position of the menu where the mouse is positioned
STT.objTip.style.left=ms.x+STT.xOfs-STT.xArrow+"px";
STT.objArrow.style.left=ms.x+STT.xOfs+"px";
}

if (bottomedge<STT.objTip.offsetHeight)
{STT.objTip.style.top=ms.y-STT.objTip.offsetHeight-STT.yOfs+"px"; STT.snp=true;}
else
{STT.objTip.style.top=ms.y+STT.yOfs+STT.yArrow+"px";STT.objArrow.style.top=ms.y+STT.yOfs+"px";}

if (!STT.fHide) STT.View();
}


