/*
** : : : : : :  How to use the Show Help  : : : : : :
** For each interesting page element you can put the
** attribute help. The help attribute can be any string
** text (scaped to not distroy the html) or some html id.
** The help for each element will be showed automaticaly
** when the mouse is over that. Yeah... we can turn on
** this help system calling the function showMouseHelpOn()
** and turn off calling the function showMouseHelpOff().
**
** Examples:
**
** my link
**
** 
** 
**   This is a 
loooong help. 
**   You can put 
HTML here too!
** 
"+ pageHelp.myFrame.src +" x:"+ mX +" y:"+ mY;
      var txt = el.getAttribute("help");
      if ( txt != box.txt ) {
        if ( txt ) {
          helpWow(true);
          box.style.display = "block";
          if ( txt != "FALSE" ) {
            var realTxt = txt;
            if ( /^#.+/.test( txt ) ) {
              var txtEl = el.ownerDocument.getElementById( txt.replace(/#/,"") );
              if ( txtEl ) realTxt = txtEl.innerHTML;
            }
            box.content.innerHTML = ''+ realTxt +'
'+
                                    '
'+
                                    '';
          }
        } else {
          box.style.display = "none";
        }
      }
      box.txt = txt;
      box.style.left = ( mX + helpInfo.incPos.x ) +"px";
      box.style.top  = ( mY + helpInfo.incPos.y ) +"px";
    }
  }
}
pageHelp.getPos = function (obj) {
  var x = y = 0;
  if (obj.offsetParent) {
    do {
      x += obj.offsetLeft;
      y += obj.offsetTop;
    } while (obj = obj.offsetParent);
  }
  return { x:x, y:y };
}
function movePageHelpToTheLeftMouseSide() {
  clearTimeout( movePageHelpToTheRightMouseSide.timeout )
  clearTimeout( movePageHelpToTheLeftMouseSide.timeout )
  if ( pageHelp.info.incPos.x > -( pageHelp.info.helpBox.clientWidth + 20 ) ) {
    pageHelp.info.incPos.x -= 10;
    if ( ( pageHelp.info.mX + pageHelp.info.incPos.x + pageHelp.info.helpBox.clientWidth ) >
         pageHelp.info.myDoc.body.clientWidth ) {
      pageHelp.info.incPos.x =
        pageHelp.info.myDoc.body.clientWidth - pageHelp.info.helpBox.clientWidth - pageHelp.info.mX - 10;
    }
    pageHelp.info.helpBox.style.left = ( pageHelp.info.mX + pageHelp.info.incPos.x ) +"px";
    movePageHelpToTheLeftMouseSide.timeout =
    setTimeout( "movePageHelpToTheLeftMouseSide()", 20 );
  }
}
function movePageHelpToTheRightMouseSide() {
  clearTimeout( movePageHelpToTheRightMouseSide.timeout )
  clearTimeout( movePageHelpToTheLeftMouseSide.timeout )
  if ( pageHelp.info.incPos.x < 20 ) {
    pageHelp.info.incPos.x += 10;
    pageHelp.info.helpBox.style.left = ( pageHelp.info.mX + pageHelp.info.incPos.x ) +"px";
    movePageHelpToTheRightMouseSide.timeout =
    setTimeout( "movePageHelpToTheRightMouseSide()", 20 );
  }
}
if( window.addEventListener ) { // Standard
  document.body.addEventListener( "mousemove", getHelp, false );
}
if( window.attachEvent ) { // IE
  document.body.attachEvent( "onmousemove", getHelp );
}
function helpWow( start ) {
  var bg = pageHelp.info.bg;
  var box = pageHelp.info.helpBox.style;
  var change = false;
  if ( start ) {
    box.backgroundColor = "rgb("+ bg.r.wow +","+ bg.g.wow +","+ bg.b.wow +")";
    bg.r.cur = bg.r.wow;
    bg.g.cur = bg.g.wow;
    bg.b.cur = bg.b.wow;
    change = true;
  } else {
    for ( c in bg ) {
      if ( bg[c].cur != bg[c].orig ) {
        bg[c].cur += bg[c].inc;
        if ( ( bg[c].inc > 0 ) && ( bg[c].cur > bg[c].orig ) ) bg[c].cur = bg[c].orig
        if ( ( bg[c].inc < 0 ) && ( bg[c].cur < bg[c].orig ) ) bg[c].cur = bg[c].orig
        change = true;
      }
    }
  }
  if ( change ) {
    box.backgroundColor = "rgb("+ Math.round(bg.r.cur) +","+
                                  Math.round(bg.g.cur) +","+
                                  Math.round(bg.b.cur) +")";
    setTimeout( "helpWow()", 20 )
  }
}
function showMouseHelpOn() {
  pageHelp.info.helpBox = document.getElementById("helpBox");
  pageHelp.info.helpBox.content = document.getElementById("helpBoxContent");
  pageHelp.info.helpBox.setAttribute( "help", "FALSE" ); 
  pageHelp.info.updateBox = true;
  pageHelp.info.myDoc.body.style.cursor = "help";
  if ( window.getComputedStyle ) {
    var bg = window.getComputedStyle( pageHelp.info.helpBox, "" ).backgroundColor;
  } else {
    var bg = pageHelp.info.helpBox.currentStyle.backgroundColor;
  }
  if ( /^#/.test(bg) ) {
    var r = parseInt( bg.replace(/^#(..)..../,"$1"), 16 );
    var g = parseInt( bg.replace(/^#..(..)../,"$1"), 16 );
    var b = parseInt( bg.replace(/^#....(..)/,"$1"), 16 );
  } else {
    bg = bg.replace(/\s/g, "");
    var r = parseInt( bg.replace(/^rgb\(([0-9]+),[0-9]+,[0-9]+\)/,"$1") );
    var g = parseInt( bg.replace(/^rgb\([0-9]+,([0-9]+),[0-9]+\)/,"$1") );
    var b = parseInt( bg.replace(/^rgb\([0-9]+,[0-9]+,([0-9]+)\)/,"$1") );
  }
  bg = { r:{orig:r,wow:255}, g:{orig:g,wow:250}, b:{orig:b,wow:100} }
  for ( c in bg ) {
    bg[c].inc = ( bg[c].orig -  bg[c].wow ) / 20;
  }
  pageHelp.info.bg = bg;
}
function showMouseHelpOff() {
  pageHelp.info.helpBox.style.display = "none";
  pageHelp.info.updateBox = false;
  pageHelp.info.myDoc.body.style.cursor = "default";
}