var moz_fudgeArray, moz_fudgeCount;

moz_fudgeInit();

  function moz_fudgeInit()
  {
    if (navigator.appName!='Netscape' || parseInt(navigator.appVersion) <= 4)
      return;

    moz_fudgeCount=1;
    moz_fudgeArray = new Array( moz_fudgeCount );
    moz_fudgeArray[0]='a';

    var parent, child;

    // Add a <div> to <body>
    parent = document.getElementsByTagName('body')[0];
    child = document.createElement('div');
    parent.appendChild(child);

    // Add onLoad= and onUnload= to <body>, and id= to the <div>
    moz_fudgeAddAttribute(parent, 'onLoad', 'moz_fudgeLoop(1);');
    moz_fudgeAddAttribute(parent, 'onUnload', 'moz_fudgeLoop(0);');
    moz_fudgeAddAttribute(child, 'id', 'moz_fudgeDiv');

    var sheets=document.styleSheets, rules;
    var sheet=0, rule, hasStyle=0;

    while (sheet < sheets.length && hasStyle == 0)
    {
      rule=0;
      rules = sheets[sheet].cssRules;

      while (rule < rules.length && hasStyle == 0)
      {
        if ( rules[rule].selectorText == '#moz_fudgeDiv' )
        {
          hasStyle=1;
        }
        rule++;
      }
      sheet++;
    }

    if (hasStyle == 0)
    {
      parent = document.getElementsByTagName('head')[0];
      child = document.createElement('style');
      parent.appendChild(child);

      moz_fudgeAddAttribute(child, 'type', 'text/css');

      parent=child;
      child=document.createTextNode('#moz_fudgeDiv { display:none; position:absolute; top:-50px; width:auto; border:1px solid black; padding:2px; margin:0px; color:black; background-color:#FFFFE7; font:9pt Tahoma}');
      parent.appendChild(child);
    }
  }

  function moz_fudgeAddAttribute(element, attribute, value)
  {
    if ( element.hasAttribute(attribute) )
      value += ' '+element.getAttribute(attribute);
    
    element.setAttribute(attribute, value);
  }

  function moz_fudgeLoop(add)
  {
    var element=0;
    while (element < moz_fudgeArray.length)
    {
      moz_fudgeInnerLoop(moz_fudgeArray[element], add);
      element++;
    }
  }

  function moz_fudgeInnerLoop(element, add)
  {
    var elements = document.getElementsByTagName(element);
    var position=0;

    while (position < elements.length)
    {
      if (elements[position].title && elements[position].title.length)
      {
        if (add) {
          elements[position].addEventListener('mouseover', moz_fudgeOver, false);
          elements[position].addEventListener('mouseout', moz_fudgeOut, false);
        } else {
          elements[position].removeEventListener('mouseover', moz_fudgeOver, false);
          elements[position].removeEventListener('mouseout', moz_fudgeOut, false);
        }
      }
      position++;
    }
  }
  
  function moz_fudgeOver(e)
  {
    var theDiv=document.getElementById('moz_fudgeDiv');
    if (theDiv.style.display=='inline') return;

    theDiv.innerHTML=e.currentTarget.title;
    theDiv.style.display='inline';

    var width=parseInt( getComputedStyle(theDiv, '').getPropertyValue('width') );

    if (width>300) { theDiv.style.width='300px'; width=300; }
    if (e.clientX+width>window.innerWidth-30) {
      theDiv.style.left=(window.innerWidth-width-30)+'px';
    } else {
      theDiv.style.left=(e.pageX+5)+'px';
    }

    var height=parseInt( getComputedStyle(theDiv, '').getPropertyValue('height') );

    if (e.clientY+height+20>window.innerHeight) {
      theDiv.style.top=(e.pageY-10-height)+'px';
    } else {
      theDiv.style.top=(e.pageY+20)+'px';
    }

    e.currentTarget.title='';
  }

  function moz_fudgeOut(e)
  {
    var theDiv=document.getElementById('moz_fudgeDiv');

    theDiv.style.display='none';
    theDiv.style.left=theDiv.style.top='-50px';
    theDiv.style.width=theDiv.style.height='auto';

    e.currentTarget.title=theDiv.innerHTML;
  }

