//<!--

/* Copyright 2006 Sysformance AG - Dirk Manske */
/* $Id: mouse_pop.js,v 1.7 2006/06/01 16:04:59 manske Exp $ */

// create or remove image if s is unset
var xo = null;
function x( i, s ) {
  var p = document.getElementById(i);
  if( p ) {
    if( s ) {
      xo = document.createElement('img');
      xo.src = p.src.replace(/\.png$/, s + '.png');
      xo.border = '0px';
      xo.style.position = 'absolute';
      xo.style.left = '0px';
      xo.style.top = '0px';
      p.parentNode.appendChild( xo );
    } else if( xo ) {
      xo.parentNode.removeChild( xo );
      xo = null;
    }
  }
}

var ie = document.all ? 1 : 0;

function move( ev, obj ) {
  if( obj )  {
    var tempX;
    var tempY;
    if (ie) {
       tempX = window.event.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft);
       tempY = window.event.clientY + (document.documentElement.scrollTop || document.body.scrollTop)
    } else {
       tempX = ev.pageX;
       tempY = ev.pageY;
    }
    obj.style.left = tempX+5 + "px";
    obj.style.top  = tempY + "px";
    return true;
  }
}


/* tooltip */

var tpElement = null;
var tpTarget = null;
var tpData = new Array();

// create or remove tool tip if num is unset
function tp( obj, ev, num ) {
    document.onmousemove = null;
    if( tpElement ) {
        tpElement.parentNode.removeChild( tpElement );
        tpElement = null;
    }
    if( num==undefined ) return;
    var data = tpData[num];
    if( !data ) return;
    tpElement = document.createElement('table');
    tpElement.className = 'tp';
    var tbody = document.createElement('tbody');
    tpElement.appendChild( tbody );
    for( var ri=0; ri<data.length; ri++ ) {
        var tr = document.createElement('tr');
        var row = data[ri];
        var align = 'left';
        for( var ci=0; ci<row.length; ci++ ) {
            switch( row[ci] ) {
                case '_AR_': align = 'right'; continue;
                case '_AL_': align = 'left'; continue;
            }
            var cell = document.createElement( ci==0 ? 'th' : 'td' );
            cell.style.textAlign = align;
            cell.innerHTML = row[ci];
            tr.appendChild( cell );
        }
        tbody.appendChild( tr );
    }
    tpmove( ev );
    document.body.appendChild( tpElement );
    document.onmousemove = tpmove;
}

// move tool tip
function tpmove( ev ) {
    move( ev, tpElement );
}

// create or remove image if s is unset
var showImg = null;
var showName = null;
function show( name, obj, id ) {
    
  if( name ) {
      if( showImg ) {
         if(  name!=showName ) {
             showName = name;
             showImg.src = name;
         } else {
             hideCnt--;
         }
      } else {
        if( !id ) id = 'main';  
        var p = document.getElementById(id);
        if( !p ) return;
        showImg = document.createElement('img');
        showImg.src = name;
        showImg.border = '0px';
        showImg.style.position = 'absolute';
        showImg.style.left = '12px';
        showImg.style.top = '8px';
        obj.style.position = 'relative';
        obj.style.zIndex = 500;
        showObj = obj;
        p.appendChild( showImg );
      }
  } else {
      if( showImg ) {
          showImg.parentNode.removeChild( showImg );
          showImg = null;
          showCnt = 0;
          hideCnt = 0;
          showObj.style.zIndex = '';
      }
  }
}

//-->
