  // JavasScript supporting popup help messages on mouse movement
  // Must be included in the source of the page, containing IFRAMEs. 
  //The page receives the mouse events from the IFRAMEs and positions 
  //the tooltip appropriately
  // Requires popup.css !!!

  xOffset = 10;
  yOffset = 10;

  var sknStyle;
  var sknDiv;
  
  var ns4=document.layers;
  var ns6=document.getElementById&&!document.all;
  var ie4=document.all;
  
  var hideTimerID;
  var showTimerID;

  function initMFramePopup() {
    if (ns4) {
      sknStyle=document.popupdiv;
    }  
    else if (ns6) {
      sknStyle=document.getElementById("popupdiv").style;
      sknDiv=document.getElementById("popupdiv");
    }  
    else if (ie4) {
      sknStyle=document.all.popupdiv.style;
      sknDiv=document.all.popupdiv;
    }  

    if(ns4) {
      document.captureEvents(Event.MOUSEMOVE);
    }  
    else {
      sknStyle.visibility="visible";
      sknStyle.display="none";
    }

    document.onmousemove=mframeMouseListener;
    sknDiv.onmousemove=mouse_move_div;
    sknDiv.onmouseout=mouse_out_div;
  }

  function popupMsg(msg) {
    var re = /\\n/g;
    var content="<TABLE class=\"popup\" ID=\"popuptable\" CELLPADDING=2 CELLSPACING=0><TR><TD>" + msg.replace(re, "<br>") + "</TD></TR></TABLE>";
    
    if (sknStyle == null) {
      initMFramePopup();
    }
    
    if(ns4) {
      sknStyle.document.write(content);
      sknStyle.document.close();
      sknStyle.visibility="visible";
    }
    if(ns6) {
      document.getElementById("popupdiv").innerHTML=content;
      sknStyle.display='';
      correctLocation();
    }
    if(ie4) {
      document.all("popupdiv").innerHTML=content;
      sknStyle.display='';      
      correctLocation();
    }
  }
  
  function correctLocation() {
     if (sknDiv==null) return;
     if (sknStyle==null) return;
     
     if (ns6) {
     
     }	
     else if (ns4) {
     
     }
     else if (ie4) {
        var divWidth=sknDiv.offsetWidth;
        var divHeight=sknDiv.offsetHeight;
        var divLeft=parseInt(sknStyle.left.replace("px",""));
        var divTop=parseInt(sknStyle.top.replace("px",""));
        var widthCorr=((document.body.scrollLeft+document.body.clientWidth)-(divLeft+divWidth));
        var heightCorr=((document.body.scrollTop+document.body.clientHeight)-(divTop+divHeight));
	
	//document.mouseForm.f1.value=divTop;
	//document.mouseForm.f3.value=heightCorr+divTop;
	
        if (widthCorr<0) {
           sknStyle.left=divLeft+widthCorr;
        }
      
        if (heightCorr<0) {
           sknStyle.top=divTop+heightCorr;
        }
     }
  }
  
  function popup(msg) {
    if (sknStyle == null) {
      initMFramePopup();
    }
    if (sknStyle == null) {
      return;
    }
    var re = /\\/g;
    var re2 = /\n/g;
    var re3 = /'/g;
    //alert("1:"+msg);
    
    msg=msg.replace(re,"\\\\");
    //alert("2:"+msg);
    msg=msg.replace(re2,"\\\\n");
    //alert("3:"+msg);
    msg=msg.replace(re3,"\\'");
    //alert("4:"+msg);

    showTimerID = setTimeout("popupMsg('" + msg+ "')", 1000);
  }
  
  function mouse_move_div(e) {
     if (sknStyle!=null) {
        sknStyle.display='';
     }
  
  }
  
  function mouse_out_div(e) {
     hidePopup();
  }
  
  
  function mframeMouseListener() {
     if (ie4) {
        //document.mouseForm.f5.value=event.y;
	
    var divX= event.screenX - screenLeft + document.body.scrollLeft + 11;
	var divY= event.screenY - screenTop + document.body.scrollTop + 11;
	if (sknStyle!=null) {
	   sknStyle.left=divX;
	   sknStyle.top=divY;
        }  
	correctLocation();
     }
  }
  
  function iframeMouseListener(mouseScreenX, mouseScreenY, winName, winScreenLeft, winScreenTop) {
     if (ie4) {
        var win=document.all(winName);
        if (win!=null) {
	   var divX = mouseScreenX - winScreenLeft + document.body.scrollLeft + 11;
	   var divY = mouseScreenY - winScreenTop + document.body.scrollTop + 11;
	   if (sknStyle!=null) {
	      sknStyle.left = divX;
	      sknStyle.top = divY;
           }  
	   correctLocation();
        }
     }	
	
  }
  

  function hidePopup() {
    if(ns4) {
      sknStyle.visibility="hidden";
    } 
    else if (ns6||ie4) {
      sknStyle.display="none";
    }
    clearTimeout(hideTimerID);
    clearTimeout(showTimerID);
  }

  function popupHelp(msg) {
    popup(msg);
    hideTimerID = setTimeout("hidePopup()", 4000);
  }
