/*<![CDATA[*/
// ToolTip tt2Part1 (07-08-2005)
// by Vic Phillips http://www.vicsjavascripts.org.uk/

// Display a simple Tool Tip popup on a mouse over event.
// The position can be relative the object instigating the event or to an anchor.
// Mouseover the Tool Tip to maintain the ToolTip in view.
// The delay in hiding the Tool Tip may be defined for mouseout of the object and ToolTip
// Optional Code allows:
// One Tool Tip can be 'Sticky' - Re-Appear when other tool tips close.
// The tool tip will reposition to be visible if positioned 'off screen'

// Application Notes

// tt2Part1 contains the Main Functional code.
// The optional tt2Part2 contains the 'Sticky' and 'RePositioning'  code.

// Each Tool Tip popup is defined in HTML Code
// and must be contained in a block element allocated with a unique id.
// This block element can contain any HTML code including links.
// e.g
//  <div id="B" class="text" style="position:absolute;visibility:hidden;z-index:2;width:100px;border:solid black 1px;text-Align:center;">
//   <div style="background-Color:white;" ><a href="http://www.vicsjavascripts.org.uk" >Topic 6</a></div>
//   <div style="background-Color:red;" >Topic 7</div>
//   <div style="background-Color:white;" >Topic 8</div>
//   <div style="background-Color:red;" >Topic 9</div>
//  </div>

// The Tool Tip popup must have a style
// position:absolute,  visibility:hidden; and a z-Index greater than other page elements.

// Each element to activate a ToolTip must have an onmouseover event call
// e.g.
// <span onmouseover="tt2ToolTip(event,this,'*TTID*',*XOffset*,*YOffset*,*ItemDelay*,*TTDDelay*,'*HTMLCode*');" >Some Text</span>
// where:
// event        = do not change
// this         = for standard applications, identifies the activating element
// *TTID*       = the unique id of the Tool Tip to display.                  (string)
// *XOffset*    = the horizonal(X) relative to the activating element.       (digits)
// *YOffset*    = the vertical(Y)  relative to the activating element.       (digits)
// *ItemDelay* = the delay in hiding the ToolTip on object mouse out.       (digits)
// *TTDelay*   = the delay in hiding the ToolTip on ToolTip mouse out.      (digits)
// *HTMLCode*   = optional -  the HTMLCode to be used in the Tool Tip PopUp. (string)

// The Tool Tip may also appear at a position relative to a specified element.
// This is usefull if a number of Tool Tips are to be displayed a single location.
// This 'anchor' element must be given a unique id.
// eg <a id="*AnchorID*" ></a>
// where*
// *AnchorID*  = the unique id of the anchor (string)
//
// The *AnchorID* must be specified in the Tool Tip call
// e.g.
// <span onmouseover='tt_ToolTip(event,'*AnchorID*','*TTID*',*XOffset*,*YOffset*,*OpenDelay*,*CloseDelay*);" >Some Text</span>

// All variable and function etc names are prefixed with 'tt2' to minimise conflicts with other JavaScripts

// The tt2Part1 the main functional code is about 2.5K (Less Notes)
// The optional tt2Part2 containing the 'Sticky' and 'RePositioning' code is less than 1.5k.

// Tested with IE6 and Mozilla FoxFire

// Functional Code - No Need to Change

var tt2Ary=new Array();
var tt2TO,tt2New,tt2S,tt2D1,tt2D2,tt2P;

function TheWidth(){
var myWidth = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
  }
  return myWidth
  }


function tt2ToolTip(tt2e,tt2obj,tt2id,tt2x,tt2y,tt2d1,tt2d2,tt2t){
 clearTimeout(tt2TO);
 if (tt2S){ tt2S.style.visibility='hidden'; }
 if (!tt2e) var tt2e=window.event;
 if (tt2e.target) tt2eobj=tt2e.target;
 else if (tt2e.srcElement) tt2eobj=tt2e.srcElement;
 if (tt2eobj.nodeType==3) tt2eobj=tt_eobj.parentNode;
 if ( typeof(tt2obj)!='object'){
  tt2obj=document.getElementById(tt2obj);
  if (!tt2obj){ return; }
 }
 tt2D1=tt2d1;tt2D2=tt2d2;
 tt2id=document.getElementById(tt2id);
 if (tt2t){ tt2id.innerHTML=tt2t; }

 if (((tt2Pos(tt2obj)[0])+tt2x+tt2id.offsetWidth)>TheWidth())
  {tt2id.style.left=(tt2Pos(tt2obj)[0]-tt2id.offsetWidth)+'px';}
 else
  {tt2id.style.left=(tt2Pos(tt2obj)[0]+tt2x)+'px';}
 tt2id.style.top=(tt2Pos(tt2obj)[1]+tt2y)+'px';
 tt2id.style.visibility='visible';
 tt2obj.pu=tt2id;
 tt2AddHideTO1(tt2eobj);
 tt2AddHideTO2(tt2id);
 tt2AddClearTO(tt2id);
 if (!tt2id.set){
  tt2id.set=1;
  tt2Ary[tt2Ary.length]=tt2id;
 }
 tt2New=tt2id;
 tt2HideOld();
 if (tt2P){ tt2TTPos(tt2id); }
}


function tt2Hide(){
 for(tt20=0;tt20<tt2Ary.length;tt20++){
  tt2Ary[tt20].style.visibility='hidden';
 }
 if (tt2S){ tt2StickyShow(); }
}

function tt2ClearTO(){
 clearTimeout(tt2TO);
}
function tt2HideTO1(){
 tt2TO=setTimeout('tt2Hide();',tt2D1);
}

function tt2HideTO2(){
 tt2TO=setTimeout('tt2Hide();',tt2D2);
}

function tt2HideOld(){
 for(tt20=0;tt20<tt2Ary.length;tt20++){
  if (tt2Ary[tt20]!=tt2New){
   tt2Ary[tt20].style.visibility='hidden';
  }
 }
}
function tt2Pos(tt2){
 tt2ObjLeft = tt2.offsetLeft;
 tt2ObjTop = tt2.offsetTop;
 while(tt2.offsetParent!=null){
  tt2ObjParent=tt2.offsetParent;
  tt2ObjLeft+=tt2ObjParent.offsetLeft;
  tt2ObjTop+=tt2ObjParent.offsetTop;
  tt2=tt2ObjParent;
 }
 return [tt2ObjLeft,tt2ObjTop];
}

function tt2EventAdd(tt2o,tt2t,tt2f) {
 if ( tt2o.addEventListener ){ tt2o.addEventListener(tt2t, function(e){ tt2o[tt2f](e);}, false); }
 else if ( tt2o.attachEvent ){ tt2o.attachEvent('on'+tt2t,function(e){ tt2o[tt2f](e); }); }
 else {
  var tt2Prev=tt2o["on" + tt2t];
  if (tt2Prev){ tt2o['on'+tt2t]=function(e){ tt2Prev(e); tt2o[tt2f](e); }; }
  else { tt2o['on'+tt2t]=tt2o[tt2f]; }
 }
}

function tt2AddClearTO(tt2){
 if (tt2.addclearTO){ return; }
 tt2.addclearTO=tt2ClearTO;
 tt2EventAdd(tt2,'mouseover','addclearTO');
}

function tt2AddHideTO1(tt2){
 if (tt2.addhideto1){ return; }
 tt2.addhideto1=tt2HideTO1;
 tt2EventAdd(tt2,'mouseout','addhideto1');
}

function tt2AddHideTO2(tt2){
 if (tt2.addhideto2){ return; }
 tt2.addhideto2=tt2HideTO2;
 tt2EventAdd(tt2,'mouseout','addhideto2');
}

/*]]>*/


