/*
@version $Revision: 1.7 $

inspiration from:  http://inspire.server101.com/js/m/ 
for functions mSet, mBlur, mShow, mHide

*/

var mItem = [];
var mTime = [];
var mWait = 500;
var curShown = "";




function mClear(){
    if (mTime[curShown]) {
      clearTimeout(mTime[curShown]);
      mTime[curShown] = null;
    }
}

function mHide() {
    if(""!=curShown){
      mClear();
      toggleLayer(curShown,"none",0,0);
    }
}


function mBlur(id) {
    if(id==null){
        return;
    }
	mTime[id] = setTimeout('toggleLayer(\'' + id + '\',"none",0,0);', mWait);
}

/*
Best regards to
http://www.netlobo.com/div_hiding.html
*/

function toggleLayer(whichLayer,value,x,y)
{
    if(whichLayer==null || ''==whichLayer){
        alert('bad data');
        return;
    }

    if(value=="none"){
        curShown = "";
    }
    else{
        mHide();
        curShown = whichLayer;
    }

	if (document.getElementById && document.getElementById(whichLayer))
	{
		// this is the way the standards work
        var parent = document.getElementById(whichLayer).parentNode;
        var y2 = getPageOffsetTop(parent);
        var x2 = getPageOffsetLeft(parent)+116;
		var style2 = document.getElementById(whichLayer).style;
        style2.display = value;
        style2.top=y2;
        style2.left=x2;
	}
	else if (document.all && document.all[whichLayer])
	{
		// this is the way old msie versions work
        var parent = document.all[whichLayer].parentNode;
        var y2 = getPageOffsetTop(parent);
        var x2 = getPageOffsetLeft(parent)+116;
		var style2 = document.all[whichLayer].style;
        style2.display = value;
        style2.top=y2;
        style2.left=x2;
	}
	else if (document.layers && document.layers[whichLayer])
	{
		// this is the way nn4 works
        var parent = document.layers[whichLayer].parentNode;
        var y2 = getPageOffsetTop(parent);
        var x2 = getPageOffsetLeft(parent)+116;
		var style2 = document.layers[whichLayer].style;
        style2.display = value;
        style2.top=y2;
        style2.left=x2;
	}
}


// www.brainjar.com
function getPageOffsetLeft(el) {

  var x;

  // Return the x coordinate of an element relative to the page.

  x = el.offsetLeft;
  if (el.offsetParent != null)
    x += getPageOffsetLeft(el.offsetParent);

  return x;
}

function getPageOffsetTop(el) {

  var y;

  // Return the y coordinate of an element relative to the page.

  y = el.offsetTop;
  if (el.offsetParent != null)
    y += getPageOffsetTop(el.offsetParent);

  return y;
}


