/**/
var elemCache = [];
function fetchElem(theId) {
	if (elemCache[theId] != null) {
	    return elemCache[theId];
	}
	var obj;
	if (obj = document.getElementById(theId)) {
		obj.hide = function() { obj.style.display = 'none'; };
		obj.show = function() { obj.style.display = ''; };
		elemCache[theId] = obj;
		return elemCache[theId];
	}
	return false;
}

/* Boxansicht ein-ausschalten */
function display_switch(idname) {
	var obj = document.getElementById(idname);
	var iid = (idname + "_icon");
	var iob = document.getElementById(iid);

	if (obj) {
		if (obj.style.display == "none") {
			obj.style.display = "";
		} else {
			obj.style.display = "none";
		}
	}

	if (iob) {
		if (iob.className == "iconShow") {
			iob.className  = "iconHide";
			//set_cookie(idname, 'off');
		} else {
			iob.className  = "iconShow";
			//set_cookie(idname, 'on');
		}
	}
	return false;
}

/* umschalten von Content-Seiten */
function show_content(thePage, numPages) {
    var theElem = false;
	for (var i=1; i <= numPages; i++) {
	    if (thePage != i) {
			theElem = fetchElem('content_page' + i);
			if (theElem) {
			    theElem.hide();
			}
		} else {
			theElem = fetchElem('content_page' + thePage);
			if (theElem) {
	    		theElem.show();
			}
		}
	}
}

/* Submenü Fix für den IE */
function Fix_IE_mainmenu() {
	if (document.all && document.getElementById) {
		var navRoot = document.getElementById('mainmenu');
		for (var i=0; i < navRoot.childNodes.length; i++) {
			var node = navRoot.childNodes[i];
			if (node.nodeName == 'LI') {
				  node.onmouseover = function() {
            this.className += ' over';
            Fix_IE_Current = this;
            //Fix_IE_mainmenu_content('hide');
          }
          
			  	node.onmouseout  = function() {
            //this.className = this.className.replace(' over', '');
            //Fix_IE_mainmenu_content('show');
            Fix_IE_Timer = window.setTimeout(
            function() {
              Fix_IE_Current.className = Fix_IE_Current.className.replace(' over', '');
            }, 1000);
          }
			}
		}
	}
}

var Fix_IE_Current;
var Fix_IE_Timer;

function Fix_IE_mainmenu_content(theMode) {
  var navRoot = document.getElementById('txcontent');
  var theList = navRoot.getElementsByTagName('ul');
  for (var i=0; i < theList.length; i++) {
    for (var j=0; j < theList[i].childNodes.length; j++) {
      var node = theList[i].childNodes[j];
      if (node.nodeName == 'LI') {
        var theChild = node.firstChild;
        if (theChild.nodeName == 'IMG') {
          theChild.style.visibility = (theMode == 'hide') ? 'hidden' : 'visible';
        }
      }
    }
  }
}

/* Wrapper-Funktion für window.onload; erlaubt mehrere Funktionen */
function wrap_window_onload() {
	try {
    	Fix_IE_mainmenu();
    	secure_mailaddy('mailaddy_href', 'nfo');
    	secure_mailaddy('mailaddy_footer', 'nfo');
	} catch(e) {
	}
}

/* Schreibt verschlüsselte eMail-Adresse in angegebenen Context */
function secure_mailaddy(theTarget, theName) {
  var addr = {
    nfo: '&#105;&#110;&#102;&#111;&#64;&#108;&#111;&#99;&#111;&#45;&#105;&#116;&#46;&#100;&#101;',
    hrefnfo: '&#60;&#97;&#32;&#104;&#114;&#101;&#102;&#61;&#34;&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#105;&#110;&#102;&#111;&#64;&#108;&#111;&#99;&#111;&#45;&#105;&#116;&#46;&#100;&#101;&#34;&#62;&#105;&#110;&#102;&#111;&#64;&#108;&#111;&#99;&#111;&#45;&#105;&#116;&#46;&#100;&#101;&#60;&#47;&#97;&#62;'
  };
  if (addr[theName]) {
    try {
      fetchElem(theTarget).innerHTML = addr[theName];
    } catch(e) {
      //alert(e);
    }
  }
}

/* Teste auf richtige eMail-Adressen-Syntax*/
function valid_eMail(strEmail) {
  var a = false;
  var res = false;
  if (typeof(RegExp) == 'function') {
    var b = new RegExp('abc');
    if (b.test('abc') == true) {
      a = true;
    }
  }
  
  if (a == true) {
    reg = new RegExp('^([a-zA-Z0-9\\-\\.\\_]+)' +
                     '(\\@)([a-zA-Z0-9\\-\\.]+)' +
                     '(\\.)([a-zA-Z]{2,4})$');
    res = (reg.test(strEmail));
  } else {
    res = (strEmail.search('@') >= 1 &&
      strEmail.lastIndexOf('.') > strEmail.search('@') &&
      strEmail.lastIndexOf('.') >= strEmail.length-5);
  }
  return(res);
}

/* wird beim Laden der Seite ausgeführt */
window.onload = wrap_window_onload;