function changeBG(id,value,now) {
    var value = String(value);
    var id = String(id);

    document.getElementById(id).style.backgroundColor=value;
}

var bV=parseInt(navigator.appVersion);
var NS4=(document.layers) ? true : false;
var IE4=((document.all)&&(bV>=4)) ? true : false;
var DOM=(!document.layers && !document.all && bV>=4) ? true : false;
var std_navi_bg = '#9933CC';
// A hack to guess if the browser supports the DOM
var capable = (NS4 || IE4  || DOM) ? true : false;

function initIt(){
	if(DOM){
		tempColl = document.getElementsByTagName("a");
		for (i=0;i<tempColl.length; i++) {
			tempColl[i].addEventListener("mouseover", mousePos, true);
		}
	} else if(IE4){
		document.onmousemove = mousePos;
	} else if(NS4){
		document.captureEvents(Event.MOUSEMOVE);
		document.onmousemove = mousePos;
	}
}

function mousePos(Ereignis){
	if(DOM){
		MouseX = Ereignis.pageX;
		MouseY = Ereignis.pageY;
	} else if(IE4){
		MouseX = window.event.clientX;
		MouseY = window.event.clientY;
	} else if(NS4){
		Ev = Ereignis;
		MouseX = Ev.pageX;
		MouseY = Ev.pageY;
	}
}

var active;
function startclose(){
     active = window.setTimeout("closeAll()",1000);
}
function stopclose(){
     if(active){
		window.clearTimeout(active);
	}
}
function expandIt(el, id, OffsX, OffsY, navid, now) {
	if (!capable) return;
	// closeAll();
	
    changeBG(navid,'#B871DB',now);
    
	var coords;
	var MouseX=0;
	var MouseY=0;
	if (DOM || IE4) {
		coords = {x: 0, y: 0};
		var element = document.getElementById('POSER_'+id);
		while (element) {
			coords.x += element.offsetLeft;
			coords.y += element.offsetTop;
			element = element.offsetParent;
		}
	} else if (NS4) {
		var element = document.links['POSER_'+id];
		coords = {x: element.x, y: element.y};
	} else {
		return false;
	}
	
	
	if (coords){
		var poserX = coords['x'];
		var poserY = coords['y'];
	}

	MouseX=(poserX+OffsX);
	MouseY=(poserY+OffsY);
    
	if(IE4 && navid=='nav_point_7') MouseX = 128;
	if(IE4 && navid=='nav_point_8') MouseX =132;
	
	if(DOM) {
		whichEl = document.getElementById(el);
		whichEl.style.top = MouseY+"px";
		whichEl.style.left = MouseX+"px";
		whichEl.style.visibility = "visible";
		whichEl.style.display = "block";
	} else if (IE4) {
		document.all[eval('el')].style.top = MouseY+"px";
		document.all[eval('el')].style.left = MouseX+"px";
		document.all[eval('el')].style.display = "block";
		document.all[eval('el')].style.visibility = "visible";
	} else if(NS4) {
		whichEl = eval("document." + el);
		whichEl.top = parseInt(MouseY);
		whichEl.left = parseInt(MouseX);  
		whichEl.visibility = "show";
		whichEl.display = "block";
	} 
}

function closeAll(){
  closeAllByName("child");
  /*closeAllByName("subchild");*/
  

}

function closeAllByName(name){
	stopclose();
	if (NS4) {
		for (i=0; i<document.layers.length; i++) {
			whichEl = document.layers[i];
			if (whichEl.id.toLowerCase().indexOf(name) != -1) whichEl.visibility = "hide";
		}
	} else if(IE4) {
		tempColl = document.all.tags("DIV");
		for (i=0; i<tempColl.length; i++) {
			whichEl = tempColl(i);
			if (whichEl.className == name){
				whichEl.style.display = "none";
				whichEl.style.visibility = "hidden";
			}
		}
	} else if(DOM) {
		tempColl = document.getElementsByTagName("DIV");
		for (i=0; i<tempColl.length; i++) {
			whichEl = tempColl[i];
			if (whichEl.className == name) whichEl.style.visibility = "hidden";
		}
	}
    
        tempColl = document.getElementsByTagName("LI");
    for (i=0; i<tempColl.length; i++) {
        whichEl = tempColl[i];
        if (whichEl.className.substr(0, 8) == 'navpoint')  {changeBG(whichEl.id,'transparent',1);}
    }
}

function setPointer(theRow, thePointerColor){
    if(DOM||IE4) theRow.style.backgroundColor = thePointerColor;
    return true;
} 



// #############################################################################

// ### open_function:

// #############################################################################

function open_function(url,width,height,options)

  {
    if ( height > screen.availHeight || width > screen.availWidth) {
      if ( options.indexOf( "scrollbars=") < 0) {
        if ( height > screen.availHeight)
          height = screen.availHeight;
        if ( width > screen.availWidth)
          width = screen.availWidth;
        options += ",scrollbars=yes";
      }
    }

    self.msgWindow = open(url, "Window", "width=" + width + ",height=" + height
      + ",screenX=" + (screen.width-width)/2
      + ",screenY=" + (screen.height-height)/2
      + ",dependent=yes"
      + ",left=" + (screen.width-width)/2
      + ",top=" + (screen.height-height)/2
      + options
      );

    if (self.msgWindow) {
      self.msgWindow.focus();
      if (self.msgWindow.opener == null) self.msgWindow.opener = self;
    }
  }

// #############################################################################

// ### get_url:

// #############################################################################

function get_url (url, k0 ,v0 ,k1 ,v1 ,k2 ,v2 ,k3 ,v3 ,k4 ,v4 ) 

{
  if (k0 && v0) url += "?" + k0 + "=" + escape(v0);
  if (k1 && v1) url += "&" + k1 + "=" + escape(v1);
  if (k2 && v2) url += "&" + k2 + "=" + escape(v2);
  if (k3 && v3) url += "&" + k3 + "=" + escape(v3);
  if (k4 && v4) url += "&" + k4 + "=" + escape(v4)
  return url;
}


/* öffnet neues Fenster ohne Steuerleisten
     Parameter:	x = Href
		w=Fensterbreite
		h=Fensterhöhe
		p=Position links + xx
		n=Name des Fensters
  Aufruf : nw('href-adresse',w,h,p,'FensterName');
*/
function nwr(x,w,h,t,l,n){
          if (h == "") h = 100;
          if (w == "") w = 100;
          if (t == "") t = 10;
          if (l == "") l = 10;
          if (n == "") n = "login";
          var xx = "top="+t+",left="+l+",width="+w+ ",height="+h+", directories=0, status=1, scrollbars=yes, resizable=1, toolbar=0,menubar=0";
          msgWindow=window.open(x,n,xx);
          msgWindow.focus();
       }


isDefined = function(variable){ 
	return this[variable] === undefined ? false : true;
};

function openCurrentSub() {
    if (isDefined("id")) { window.setTimeout("openCurrentSubCheck();",1200); }
}

function openCurrentSubCheck() {
    if (checkSubMenus() == 0) { expandIt('el'+id+'Child',id,si_offset,0,'nav_point_'+si,1); }
}

function checkSubMenus() {
    var childs = getElementsByClassName(document.getElementById("MenuDropDown"), "div", "child");
    var err = 0;
    for (var i = 0; i < childs.length; ++i) { if (childs[i].style.visibility == 'visible') {err = 1;}}
    return err;
}

function getElementsByClassName(oElm, strTagName, oClassNames){
	var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
	var arrReturnElements = new Array();
	var arrRegExpClassNames = new Array();
	if(typeof oClassNames == "object"){
		for(var i=0; i<oClassNames.length; i++){
			arrRegExpClassNames.push(new RegExp("(^|\\s)" + oClassNames[i].replace(/\-/g, "\\-") + "(\\s|$)"));
		}
	}
	else{
		arrRegExpClassNames.push(new RegExp("(^|\\s)" + oClassNames.replace(/\-/g, "\\-") + "(\\s|$)"));
	}
	var oElement;
	var bMatchesAll;
	for(var j=0; j<arrElements.length; j++){
		oElement = arrElements[j];
		bMatchesAll = true;
		for(var k=0; k<arrRegExpClassNames.length; k++){
			if(!arrRegExpClassNames[k].test(oElement.className)){
				bMatchesAll = false;
				break;
			}
		}
		if(bMatchesAll){
			arrReturnElements.push(oElement);
		}
	}
	return (arrReturnElements)
}
