var mousex = 0;
var mousey = 0;
var grabx = 0;
var graby = 0;
var orix = 0;
var oriy = 0;
var elex = 0;
var eley = 0;
var algor = 0;

var dragobj = null;





var bw		=	null;


function lib_bwcheck(){ //Browsercheck (needed)
	this.ver=navigator.appVersion
	this.agent=navigator.userAgent
	this.dom=document.getElementById?1:0
	this.opera5=this.agent.indexOf("Opera 5")>-1
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0; 
	this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;
	this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
	this.ie=this.ie4||this.ie5||this.ie6
	this.mac=this.agent.indexOf("Mac")>-1
	this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0; 
	this.ns4=(document.layers && !this.dom)?1:0;
	this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5)
	return this
}

bw	=	new lib_bwcheck();











function getMouseXY(e) // works on IE6,FF,Moz,Opera7
{ 



  if (!e) 
  	e = window.e; // works on IE, but not NS (we rely on NS passing us the e)
 
  
  if (e)
  { 
    if (e.pageX || e.pageY)
    { // this doesn't work on IE6!! (works on FF,Moz,Opera7)
      mousex = e.pageX;
      mousey = e.pageY;
      algor = '[e.pageX]';
      if (e.clientX || e.clientY) algor += ' [e.clientX] '
    }
    else if (e.clientX || e.clientY)
    { // works on IE6,FF,Moz,Opera7
      // Note: I am adding together both the "body" and "documentElement" scroll positions
      //       this lets me cover for the quirks that happen based on the "doctype" of the html page.
      //         (example: IE6 in compatibility mode or strict)
      //       Based on the different ways that IE,FF,Moz,Opera use these ScrollValues for body and documentElement
      //       it looks like they will fill EITHER ONE SCROLL VALUE OR THE OTHER, NOT BOTH 
      //         (from info at http://www.quirksmode.org/js/doctypes.html)
      mousex = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
      mousey = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
      algor = '[e.clientX]';
      if (e.pageX || e.pageY) algor += ' [e.pageX] '
    }
  }
}


function grab(context)
{
  dragobj = context;
  grabx = mousex;
  graby = mousey;
  elex = orix = dragobj.offsetLeft;
  eley = oriy = dragobj.offsetTop;
}



function moveToPosition() // parameter passing is important for NS family 
{
  if (dragobj)
  {
    elex = orix + (mousex-grabx);
    eley = oriy + (mousey-graby);
    dragobj.style.left = (mousex-210).toString(10) + 'px';
    dragobj.style.top  = (mousey-120).toString(10) + 'px';
  }
  return false; // in IE this prevents cascading of events, thus text selection is disabled
}




function b_newsWrite(obj,textWritten)	{
	if (bw.ns4){
		obj.write(textWritten)
		obj.close()
	}
	else 
		obj.innerHTML = textWritten
}




function	openDivHelp(e,text,showORhide)	{
	
	objDiv	=	document.getElementById("objDivHelp");
 
	
	getMouseXY(e);
	//alert(defPosition(event));
	//alert(e+' '+mousex+' '+mousey);
	grab(objDiv);
	moveToPosition();
	
	 
	
	if (showORhide)	{
		b_newsWrite(objDiv,text);
		objDiv.style.display	=	'block';
	}
	else if (!showORhide)
		objDiv.style.display	=	'none';
}


function	openDivHelpAtPos(e,text,showORhide)	{
	
	objDiv	=	document.getElementById("objDivHelp");
 
	
	getMouseXY(e);
	//alert(defPosition(event));
	//alert(e+' '+mousex+' '+mousey);
	grab(objDiv);
	//moveToPosition();

    objDiv.style.left = (76).toString(10) + 'px';
    objDiv.style.top  = (262).toString(10) + 'px';
	
	 
	
	if (showORhide)	{
		b_newsWrite(objDiv,text);
		objDiv.style.display	=	'block';
	}
	else if (!showORhide)
		objDiv.style.display	=	'none';
}

