/* *******************************
* file pemaGuiScripts.js 
* All rights reserved
* created by Martin Schreiber 2003-05-15
* 
* Scripts used for formatting elements in a page
*
*  last changes: 
*		2003-05-14 by Martin Schreiber enhanced switchLayer() function instead of using fixed for for rows function uses offsetWidth from row1
*		2003-05-15 by Martin Schreiber corrected switchLayer() function only works if Elements row1 and row 2 exists
 * ***************************** */

/* HoleBeschreibung
* Parameter
* Quelle = Name der Quelldatei
*/
function HoleBeschreibung(Quelle) {
	detail.location.href=Quelle + ".html";
}

/* ShowBrowserLimit
* Parameter
* Quelle = Name der Quelldatei
*/
function HideBrowserLimit() {
	if (MSNew){
		BrowserHinweis.style.display="none";
	}
}

/* xnm_switchLayer
Aim
Minimize and restore the next supirior object with class: "cgroup" using styles: cgroup_closed and cgroup
Assumptions
"cgroup" or "cgroup_closed" are used to format the object which should be toggled.
Styles named "cgroup" and "cgroup_closed" exist int he connected stylsheet.
No Function when using Netscape, because no attribute parentElement is existing.

2010-01-14 MSc: Added my_evetn to enable Firefox to use this function 
NOTE: the Call of this function has to include (this) to enable it for Firefox.
*/
function xnm_switchLayer(my_event){
	if (MS) {
		var switchGroup = "window.event.srcElement";
	}
	else {
		var switchGroup = "my_event";
	}
  var doSwitch = true;
  while (eval(switchGroup).className != "cgroup" && eval(switchGroup).className != "cgroup_closed") {
   switchGroup = switchGroup +".parentNode";
      if (eval(switchGroup).tagName == "FORM") {
      // alert("Keine Gruppe zum auf oder zuklappen vorhanden!");
      doSwitch = false;
      break;
    }
}
  if (doSwitch) {
    if (eval(switchGroup).className == "cgroup") eval(switchGroup).className="cgroup_closed";
    else eval(switchGroup).className="cgroup";
  }
}
/* xnm_rowSwitch
Aim
toggle between 1 or 2 rows concerning the clientsize
Assumptions
space left of crow= 20px
there are only 2 rows with the id "row1" and "row2"
Called by event
body.onResize
body.onLoad
Used internal functions
 isElem()
*/
function xnm_rowSwitch(){
	if (isElem("id", "row1", null) && isElem("id", "row2", null)) {
		var xnmClientWidth = document.body.clientWidth;
		var xnmRowWidth = row1.offsetWidth;
		var switchGroup = "0";
		if (xnmClientWidth / 2 >= xnmRowWidth + 20) {
			row2.className="crow_right";
		} else {
			row2.className="crow_left";
		}
		// Bugfix: Layers don't draw correct, toggle layerstyle should help
		for (i = 0; i <= row2.children.length; i++ ) {
			if (row2.children[i].className == "cgroup" || row2.children[i].className == "cgroup_closed")
				switchGroup = row2.children[i];
				break;
			}
			if (switchGroup != "0") { // Switch state is done 2 times so previous state is active again
    			if (eval(switchGroup).className == "cgroup") eval(switchGroup).className="cgroup_closed";
	     		else eval(switchGroup).className="cgroup";
	    		if (eval(switchGroup).className == "cgroup") eval(switchGroup).className="cgroup_closed";
     			else eval(switchGroup).className="cgroup";
  		}
	}
}
/* selfhtml DHTML Bibliothek */
/* DHTML-Bibliothek */

var DHTML = 0, DOM = 0, MS = 0, MSNew = 0, NS = 0, OP = 0;

function DHTML_init() {

 if (window.opera) {
     OP = 1;
 }
 if(document.getElementById) {
   DHTML = 1;
   DOM = 1;
 }
 if(document.all && !OP) {
   DHTML = 1;
   MS = 1;
 }
if(document.layers && !OP) {
   DHTML = 1;
   NS = 1;
 }
if (MS){
	if (navigator.appVersion.substr(22,1) == "5"){
		if (navigator.appVersion.substr(24,1) >= "5"){
			MSNew = 1;
		}
	}
	if (navigator.appVersion.substr(22,1) >= "6"){
		MSNew = 1;
	}
}
}
function getElem(p1,p2,p3) {
 var Elem;
 if(DOM) {
   if(p1.toLowerCase()=="id") {
     if (typeof document.getElementById(p2) == "object")
     Elem = document.getElementById(p2);
     else Elem = void(0);
     return(Elem);
   }
   else if(p1.toLowerCase()=="name") {
     if (typeof document.getElementsByName(p2) == "object")
     Elem = document.getElementsByName(p2)[p3];
     else Elem = void(0);
     return(Elem);
   }
   else if(p1.toLowerCase()=="tagname") {
     if (typeof document.getElementsByTagName(p2) == "object" ||
        (OP && typeof document.getElementsByTagName(p2) == "function"))
     Elem = document.getElementsByTagName(p2)[p3];
     else Elem = void(0);
     return(Elem);
   }
   else return void(0);
 }
 else if(MS) {
   if(p1.toLowerCase()=="id") {
     if (typeof document.all[p2] == "object")
     Elem = document.all[p2];
     else Elem = void(0);
     return(Elem);
   }
   else if(p1.toLowerCase()=="tagname") {
     if (typeof document.all.tags(p2) == "object")
     Elem = document.all.tags(p2)[p3];
     else Elem = void(0);
     return(Elem);
   }
   else if(p1.toLowerCase()=="name") {
     if (typeof document[p2] == "object")
     Elem = document[p2];
     else Elem = void(0);
     return(Elem);
   }
   else return void(0);
 }
 else if(NS) {
   if(p1.toLowerCase()=="id" || p1.toLowerCase()=="name") {
   if (typeof document[p2] == "object")
     Elem = document[p2];
     else Elem = void(0);
     return(Elem);
   }
   else if(p1.toLowerCase()=="index") {
    if (typeof document.layers[p2] == "object")
     Elem = document.layers[p2];
    else Elem = void(0);
     return(Elem);
   }
   else return void(0);
 }
}

function getCont(p1,p2,p3) {
   var Cont;
   if(DOM && getElem(p1,p2,p3) && getElem(p1,p2,p3).firstChild) {
     if(getElem(p1,p2,p3).firstChild.nodeType == 3)
       Cont = getElem(p1,p2,p3).firstChild.nodeValue;
     else
       Cont = "";
     return(Cont);
   }
   else if(MS && getElem(p1,p2,p3)) {
     Cont = getElem(p1,p2,p3).innerText;
     return(Cont);
   }
   else return void(0);
}

function getAttr(p1,p2,p3,p4) {
   var Attr;
   if((DOM || MS) && getElem(p1,p2,p3)) {
     Attr = getElem(p1,p2,p3).getAttribute(p4);
     return(Attr);
   }
   else if (NS && getElem(p1,p2)) {
       if (typeof getElem(p1,p2)[p3] == "object")
    	   Attr=getElem(p1,p2)[p3][p4];
       else {
    	   Attr=getElem(p1,p2)[p4];
    	   return Attr;
       		}
       }
   else return void(0);
}

function setCont(p1,p2,p3,p4) {
   if(DOM && getElem(p1,p2,p3) && getElem(p1,p2,p3).firstChild)
     getElem(p1,p2,p3).firstChild.nodeValue = p4;
   else if(MS && getElem(p1,p2,p3))
     getElem(p1,p2,p3).innerText = p4;
   else if(NS && getElem(p1,p2,p3)) {
     getElem(p1,p2,p3).document.open();
     getElem(p1,p2,p3).document.write(p4);
     getElem(p1,p2,p3).document.close();
   }
}

DHTML_init();
