/*
#**********************************
#   file:    help-lib.js          *
#   HTML-Helptext-functions       *
#   Author: Thomas Hippchen       *
#   WWW:    www.hippchen.de       *
#   eMail:  th@hippchen.de        *
#   Dezember 1999                 *
#**********************************
*/
var d=this.window.document;  // only needed for lasy typing
var Clip=new Array();
var WindowClip=new Array();

/* the following "Intial()" is called when the loading of the document 
   has finished ("onLoad=" in the body-Tag).
*/   

							   
function Initial() 
{
	ReleaseMouse();
	CatchMouse();
}	


//******************************** the MouseEvents
//Get the Mouse-Event(s) needed
var Mdown=0;
var MouseX;
var MouseY;


function CatchMouse()
{
	if(isNetscape)
	{
		window.captureEvents(Event.MOUSEMOVE);
   		window.onmousemove=MouseMove;
	}
	if(isMSIE)	{document.onmousemove=MouseMove;}
}//eCatchMouse



function ReleaseMouse()
{
	if(isNetscape){	window.releaseEvents(Event.MOUSEMOVE);}
	if(isMSIE)	{document.onmousemove="";}

}//eReleaseMouse



function MouseMove(e)
{
	if(isNetscape)
	{
		MouseX=e.layerX;
		MouseY=e.layerY;
	}
	if(isMSIE)
	{
		MouseX=event.clientX;
		MouseY=event.clientY;
	}
}//eMouseMove




/* now some functions to manipulate "Layers" */

function ShowLayer(LayerName)
{
	if(isNetscape){d[LayerName].visibility="show";}
	if(isMSIE){d.all[LayerName].style.visibility="visible";}
}

function HideLayer(LayerName)
{					
	if(isNetscape){d[LayerName].visibility="hide";}
	if(isMSIE){d.all[LayerName].style.visibility="hidden";}
}

function LayerIsVisible(LayerName)
{					
	if(isNetscape)
	{
		return( d[LayerName].visibility=="show")
	}
	if(isMSIE)
	{
		return(d.all[LayerName].style.visibility=="visible")
	}
}
	

function MoveLayerTo(LayerName,x,y,pos)
{
         
	if(isNetscape){L=d[LayerName];}
	if(isMSIE){L=d.all[LayerName].style;}
	
        WindowClip=GetWindowRegion();
	Clip=GetLayerRegion("HelpLayer");
	if (Clip.right>=WindowClip.width){x=WindowClip.width-Clip.width-20;}
            

        var ylinkabstand=10
        if (pos==1)
          { 
            var grenze=parseInt(y+Clip.height+ylinkabstand+20-(window.pageYOffset+WindowClip.height))
            if (grenze>=0)
              {
               window.scrollBy(0,grenze)}
               y=y+ylinkabstand 
          
          }
        if (pos==2)
           { 
             var grenze=(y-Clip.height-ylinkabstand-20)-window.pageYOffset
             if (grenze<0) { window.scrollBy(0,grenze) }
             y=y-Clip.height-ylinkabstand 
           } 
        if (x<=0){x=0;}
	if (y<=0){y=0;}
        if (Clip.right>=WindowClip.width){x=WindowClip.width-Clip.width-20;}
        L.top=y;
	L.left=x;
                
}

function SetContent(LayerName,Content)
{					
	if(isNetscape)
	{
		d[LayerName].document.open();
		d[LayerName].document.write(Content);
		d[LayerName].document.close();
	}
	if(isMSIE)
	{
		d.all[LayerName].innerHTML=Content;
	}
}//eSetContent


function GetLayerRegion(LayerName) //returns .left, .right, .top, .down, .height, .width
{
	c=new Array();
	if(isNetscape)
	{
		c.left=d[LayerName].left;
		c.right=c.left+d[LayerName].clip.width;
		c.top=d[LayerName].top;
		c.down=c.top+d[LayerName].clip.height;
		c.height=d[LayerName].clip.height;
		c.width=d[LayerName].clip.width;
	}
	if(isMSIE)
	{
		//c.left=d.all[LayerName].offsetLeft;
                c.left=parseInt(d.all[LayerName].style.left);
		c.right=c.left+d.all[LayerName].offsetWidth;
		//c.top=d.all[LayerName].offsetTop;
		c.top=parseInt(d.all[LayerName].style.top);
                c.down=c.top+d.all[LayerName].offsetHeight;
		c.width=d.all[LayerName].offsetWidth;
		c.height=d.all[LayerName].offsetHeight;
	}
	return c;
}//eGetLayerRegion


function GetWindowRegion() //returns .height, .width
{
	c=new Array();
	if(isNetscape)
	{
		c.height=this.innerHeight;
		c.width=this.innerWidth;
	}
	if(isMSIE)
	{
		c.width=d.body.clientWidth;
		c.height=d.body.clientHeight;
	}
	return c;
}//eGetWindowRegion


function GetYScroll() 
{
	if(isNetscape)
	{
		return window.pageYOffset;
               
	}
	if(isMSIE)
	{
		return document.body.scrollTop;
	}
}//eGetYScroll

function GetXScroll() 
{
	if(isNetscape)
	{
		return window.pageXOffset;
	}
	if(isMSIE)
	{
		return document.body.scrollLeft;
	}
}//eGetXScroll


function AddHelp(thekey,thepos,thewidth,theheigth,thecolor,thetext)
{
			HelpArray[thekey]=new Array();
			HelpArray[thekey]['text']=thetext;
			HelpArray[thekey]['bgcolor']=thecolor;
			HelpArray[thekey]['width']=thewidth;
			HelpArray[thekey]['height']=theheigth;
                        HelpArray[thekey]['pos']=thepos 
}

function Help(theKey)
{
	if (LayerIsVisible("HelpLayer")){HideLayer("HelpLayer");}
	theText=HelpArray[theKey]['text'];
	theBgColor=HelpArray[theKey]['bgcolor'];
	theWidth=HelpArray[theKey]['width'];
	theHeight=HelpArray[theKey]['height'];
	theLayerContent="<table border=\"1\" cellspacing=\"0\" cellpadding=\"2\" bgcolor=\"" +theBgColor+"\"width=\""+theWidth+"\">";
	theLayerContent+="<tr><td height=\""+theHeight+"\">" + theText+"</td></tr></table>";
	SetContent("HelpLayer",theLayerContent);
	//correction of position
	thepos=HelpArray[theKey]['pos'];
        var X=MouseX;
	var Y=MouseY;
        
	//Coords Correction for MSIE
	if(isMSIE)
	{       
               
		Y+=GetYScroll();
        	X+=GetXScroll();
            
	}
	 
	MoveLayerTo("HelpLayer",X,Y,thepos);        
	ShowLayer("HelpLayer");

}//eHelp


function CloseHelp()
{
	HideLayer("HelpLayer");	
}



