var MouseX=0;
var MouseY=0;
var ScrollX=0;
var ScrollY=0;
var Browser=GetBrowser();
//alert (Browser);
function GetBrowser()
{
	var BrowserName=navigator.appName;
	var BrowserVersion=navigator.appVersion;
	var BrowserVersion=parseInt(BrowserVersion.substr(0,1));
	// wichtig: der ie 5.0, 5.5 und 6.0 meldet sich vorne immer mit 4.0 ... compatible
	// daher ist die versionsabfrage beim ie genauer noetig
	if(BrowserName=='Microsoft Internet Explorer')
	{
		if(BrowserVersion==4)
		{
			BrowserVersion=navigator.appVersion;
			BrowserVersion=parseInt(BrowserVersion.substr(22,1));
		}		
	}

	if(BrowserName=='Netscape')
	{
		if(BrowserVersion==3)
			return 'NS3';
		else if(BrowserVersion==4)
			return 'NS4';
		else if(BrowserVersion==5) // netscape 6 ist netscape 5 bzw. mozilla 0.9x hat version 5.0
			return 'NS6'; 
		else
			return 'NS6';
	}
	else if(BrowserName=='Microsoft Internet Explorer')
	{
		if(BrowserVersion==3)
			return 'IE3';
		else if(BrowserVersion==4)
			return 'IE4';
		else if(BrowserVersion==5)
			return 'IE5';
		else if(BrowserVersion==6)
			return 'IE6';
		else
			return 'KeineAhnung';
	}
	else
		return 'IE5';
}
// abgleich mit der styledatei notwendig
var BGIColor="#319c63";
var BGAColor="#83b69a";
var CIColor="#000000";
var CAColor="#000000";
// background aktiv farbe setzen
// fuer netscape braucht man 2 ids!
function BGA(ID1,ID2)
{
	ChangeBackgroundColor(ID1,ID2,BGAColor);
}
// background inaktiv farbe setzen
// fuer netscape braucht man 2 ids!
function BGI(ID1,ID2)
{
	ChangeBackgroundColor(ID1,ID2,BGIColor);
}
// color (textcolor) aktiv farbe setzen
function CA(ID)
{
	ChangeTextColor(ID,CAColor);
}
// color (textcolor) inaktiv farbe setzen
function CI(ID)
{
	ChangeTextColor(ID,CIColor);
}
function HREF(URL)
{
	window.location.href=URL;
}
// setzen einer beliebigen farbe fuer den hintergrund von irgendwas
// unterscheidung der anweisung nach unterschiedlichen browsern
function ChangeBackgroundColor(ID1,ID2,BackgroundColor)
{
	switch(Browser)
	{
		case 'NS3':
		break;
		case 'IE3':
		break;
		case 'NS4':
			// es gibt layer, die nicht in layer geschachtelt wurden, dann gibt es auch nur ID1
			// ID2 ist parent-layer
			if(ID2)
				document.layers[ID2].document.layers[ID1].bgColor=BackgroundColor;
			else
				document.layers[ID1].bgColor=BackgroundColor;
		break;
		case 'IE4':
			document.all[ID1].style.background=BackgroundColor;
		break;
		case 'IE5':
			document.getElementById(ID1).style.background=BackgroundColor;
		break;
		case 'IE6':
			document.getElementById(ID1).style.background=BackgroundColor;
		break;
		case 'NS6':
			document.getElementById(ID1).style.background=BackgroundColor;
		break;
		default:
		break;				
	}
}
// setzen einer beliebigen farbe fuer den text von irgendwas
// unterscheidung der anweisung nach unterschiedlichen browsern
function ChangeTextColor(ID,TextColor)
{
	switch(Browser)
	{
		case 'NS3':
		break;
		case 'IE3':
		break;
		case 'NS4':
		break;
		case 'IE4':
			document.all[ID].style.color=TextColor;
		break;
		case 'IE5':
			document.getElementById(ID).style.color=TextColor;
		break;
		case 'IE6':
			document.getElementById(ID).style.color=TextColor;
		break;
		case 'NS6':
			document.getElementById(ID).style.color=TextColor;
		break;
		default:
		break;				
	}
}
function OpenNewWindow(WindowName,WebSiteLocation,WidthX,WidthY)
{
	ScreenWidth=screen.width;
	ScreenHeight=screen.height;
	PosX=(ScreenWidth/2)-(WidthX/2+5);
	PosY=(ScreenHeight/2)-(WidthY/2+10);
	WindowHandle=window.open(WebSiteLocation,WindowName,"width="+WidthX+",height="+WidthY+",status=no,scrollbars=no,resizeable=yes");
	WindowHandle.focus();
	window.WindowHandle.moveTo(PosX,PosY);
}
function OpenNewBrowserWindow(WindowName,WebSiteLocation,WidthX,WidthY)
{
	ScreenWidth=screen.width;
	ScreenHeight=screen.height;
	PosX=(ScreenWidth/2)-(WidthX/2+5);
	PosY=(ScreenHeight/2)-(WidthY/2+10);
	WindowHandle=window.open(WebSiteLocation,WindowName,"width="+WidthX+",height="+WidthY+",status=yes,scrollbars=yes,resizeable=yes");
	WindowHandle.focus();
	window.WindowHandle.moveTo(PosX,PosY);
}
function OpenTooltipWindow(WindowName,strContent,WidthX,WidthY)
{
	ScreenWidth=screen.width;
	ScreenHeight=screen.height;
	PosX = MouseX+10;
	PosY = MouseY+10;

//	PosX=(ScreenWidth/2)-(WidthX/2+5);
//	PosY=(ScreenHeight/2)-(WidthY/2+10);
	WindowHandle=window.open('#',WindowName,"width="+WidthX+",height="+WidthY+",status=no,scrollbars=yes,resizeable=yes");
	WindowHandle.focus();
	window.WindowHandle.moveTo(PosX,PosY);
	window.WindowHandle.document.write('<html><head><title>Tip</title><style>span, body, p, a{font-family:verdana,helvetica,arial,sans-serif;font-size:9pt;}</style></head><body bgcolor="#D3D8EE" onClick="window.close();">');
	window.WindowHandle.document.write(strContent);
	window.WindowHandle.document.write('</body></html>');
}
function SwapImage(BildName,NewImage,DivName)
{
	switch(Browser)
	{
		case 'NS3':
		break;
		case 'IE3':
		break;
		case 'NS4':
			document.layers[DivName].document.images[BildName].src=NewImage;
		break;
		case 'IE4':
			document.images[BildName].src=NewImage;
		break;
		case 'IE5':
			document.images[BildName].src=NewImage;
		break;
		case 'IE6':
			document.images[BildName].src=NewImage;
		break;
		case 'NS6':
			document.images[BildName].src=NewImage;
		break;
		default:
		break;				
	}
}
function HideDiv(DivName,ParentDivName)
{
	switch(Browser)
	{
		case 'NS3':
		break;
		case 'IE3':
		break;
		case 'NS4':
			// schachtelung beachten
			if(ParentDivName)
				document.layers[ParentDivName].document.layers[DivName].visibility="hide";
			else
				document.layers[DivName].visibility="hide";
		break;
		case 'IE4':
			// problem im ie4, der ist schon "out of div", wenn er ueber einem anderen div innerhalb des divs ist
			// klingt seltsam
			// loesung, ermittlung, ob die maus ausserhalb des divs ist
			// idee von www.jasc.com, danke
			leftDiv=document.all[DivName].offsetLeft +2;
			rightDiv=document.all[DivName].offsetLeft + document.all[DivName].clientWidth -2;
			topDiv=document.all[DivName].offsetTop +2;
			bottomDiv=document.all[DivName].offsetTop + document.all[DivName].clientHeight -2;
			if(window.event.clientY > bottomDiv || window.event.clientY < topDiv || window.event.clientX < leftDiv || window.event.clientX > rightDiv)
			{
				document.all[DivName].style.visibility="hidden";
			}
		break;
		case 'IE5':
			document.getElementById(DivName).style.visibility="hidden";
		break;
		case 'IE6':
			document.getElementById(DivName).style.visibility="hidden";
		break;
		case 'NS6':
			document.getElementById(DivName).style.visibility="hidden";
		break;
		default:
		break;				
	}
}
function ShowDiv(DivName,ParentDivName)
{
	switch(Browser)
	{
		case 'NS3':
		break;
		case 'IE3':
		break;
		case 'NS4':
			// schachtelung beachten
			if(ParentDivName)
				document.layers[ParentDivName].document.layers[DivName].visibility="show";
			else
				document.layers[DivName].visibility="show";
		break;
		case 'IE4':
			document.all[DivName].style.visibility="visible";
		break;
		case 'IE5':
			document.getElementById(DivName).style.visibility="visible";
		break;
		case 'IE6':
			document.getElementById(DivName).style.visibility="visible";
		break;
		case 'NS6':
			document.getElementById(DivName).style.visibility="visible";
		break;
		default:
		break;				
	}
}
function SetLeftPosition(LayerName,Position)
{
	switch(Browser)
	{
		case 'NS3':
		break;
		case 'IE3':
		break;
		case 'NS4':
			document.layers[LayerName].left=Position;
		break;
		case 'IE4':
			document.all[LayerName].style.pixelLeft=Position;
		break;
		case 'IE5':
			document.all[LayerName].style.pixelLeft=Position;
		break;
		case 'IE6':
			document.all[LayerName].style.pixelLeft=Position;
		break;
		case 'NS6':
			document.getElementById(LayerName).style.left=Position+"px";  
		break;
		default:
			document.all[LayerName].style.pixelLeft=Position;
		break;				
	}
}
function SetTopPosition(LayerName,Position)
{
	switch(Browser)
	{
		case 'NS3':
		break;
		case 'IE3':
		break;
		case 'NS4':
			document.layers[LayerName].top=Position;
		break;
		case 'IE4':
			document.all[LayerName].style.pixelTop=Position;
		break;
		case 'IE5':
			document.all[LayerName].style.pixelTop=Position;
		break;
		case 'IE6':
			document.all[LayerName].style.pixelTop=Position;
		break;
		case 'NS6':
			document.getElementById(LayerName).style.top=Position+"px";  
		break;
		default:
			document.all[LayerName].style.pixelTop=Position;
		break;				
	}
}
function GetMousePosition(e) 
{
	switch(Browser)
	{
		case 'NS3':
		break;
		case 'IE3':
		break;
		case 'NS4':
			MouseX=e.pageX;
			MouseY=e.pageY;

			ScrollX=0;
			ScrollY=0;
		break;
		case 'IE4':
			MouseX=event.x;
			MouseY=event.y;
			ScrollX=document.body.scrollLeft;
			ScrollY=document.body.scrollTop;
		break;
		case 'IE5':
			MouseX=event.x;
			MouseY=event.y;
			ScrollX=document.body.scrollLeft;
			ScrollY=document.body.scrollTop;
		break;
		case 'NS6':
			MouseX=e.x;
			MouseY=e.y;
			ScrollX=0;
			ScrollY=0;
		break;
		default:
			MouseX=event.x;
			MouseY=event.y;
			ScrollX=document.body.scrollLeft;
			ScrollY=document.body.scrollTop;
		break;				
	}
	String+=MouseX+","+MouseY+", ";
	//document.maus.mausdaten.value=String;
}

function reload (formName)
{
	window.document.forms[formName].submit();
}	// function

function openOpener (url)
{
	opener.location.href = url;
	return;
}	// function openOpener

function selectSelections (sForm, sSelect, bSelect)
{
	options = document.forms[sForm].elements[sSelect].options
	childNumber = options.length;
	for (i=0;i<childNumber;i++)
	{
		options[i].selected = bSelect;
	}	// for
}	// function selectSelections

var blank_page = "about:blank";

function open_window(targetX,name,width,height,posx,posy,windowoptions,init_target) {
        var it, wo, px, py, host,target;

        it = targetX;
        wo = "location=no,toolbar=no,status=no,statusbar=no,scrollbars=no,resizable=no,dependent=yes";
        px = py = 0;
        target = targetX;

        if(typeof new_window != "undefined") {
                if(new_window.closed != true) {
                        new_window.close();
                }
        }

        if (typeof posx != "undefined") px = posx;
        if (typeof posy != "undefined") py = posy;
        if ((typeof windowoptions != "undefined") && (windowoptions != "")) wo = windowoptions;


        if (typeof init_target != "undefined") {
                it = init_target;
        } else {
                if (targetX.indexOf("http://") != -1) {
                        host = "http://" + window.location.hostname;
                        if (navigator.appName != "Opera") {
                                if (targetX.indexOf(host) == -1) it = blank_page;
                        }
                }
        }
        new_window = window.open(it,name,"width=" + width + ",height=" + height + "," + wo);
        new_window.moveTo(px,py);
        new_window.location.replace(targetX);
        new_window.focus();
        return false;
}
  function doChallengeResponse() {
    str = document.login.username.value + ":" +
          MD5(document.login.password.value) + ":" +
          document.login.challenge.value;

    document.login.response.value = MD5(str);
    document.login.password.value = "";
    document.login.submit();
  }

