/* DHTML-Bibliothek */
/* Danke an Selfhtml (http://selfaktuell.teamone.de/)*/
var DHTML = 0, DOM = 0, MS = 0, NS = 0, OP = 0;
/*Broweser bestimmen*/
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;
 }
}
/*Element abfragen*/
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);
 }
}
/*Inhalt bekommen*/
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();
   }
}



function setElemPos (p1,p2,p3,x,y){
   //uncomment next line only for debugging
   //alert("p1: "+p1+ "\np2: " +p2+ "\np3: " + p3+"\nx:  "+xwert+"\ny:  "+ywert);
   if(DOM){
      getElem(p1,p2,p3).style.top = y+"px";
      getElem(p1,p2,p3).style.left = x+"px";
   }
   else if(NS){
        getElem(p1,p2,p3).top = window.pageYOffset + y;
        getElem(p1,p2,p3).left = x;
   }
}

function setObjPos(obj,x,y){
   //alert("obj: "+obj+"\nx: "+x+"\ny: " +y);
   if(DOM){
      obj.style.top = y + "px";
      obj.style.left = x + "px"
   }
   else if(NS){
      obj.top = window.pageYOffset + y;
      obj.left = x;
   }
}

function setElemSize (p1,p2,p3,xwert,ywert){
    if(DOM)
    {
       getElem(p1,p2,p3).style.width= xwert+"px";
       getElem(p1,p2,p3).style.height= ywert+"px";
    }
    else if (NS)
    {
       //der alte ns kann das gar nicht
    }
}

function moveElem (p1,p2,p3,dx,dy){

   if(DOM) {
      var y =parseInt(getElem(p1,p2,p3).style.top);
      var x =parseInt(getElem(p1,p2,p3).style.left);
      getElem(p1,p2,p3).style.left = x + dx + "px";
      getElem(p1,p2,p3).style.top = y + dy + "px";
   }
   else if(NS) {
   //untested
        getElem(p1,p2,p3).top += dy;
        getElem(p1,p2,p3).left += dx;
   }
}

function setObjClip(obj,left,right,top,bottom){
   NIY
}

function setElemVis (p1,p2,p3,sehen){
   if(DOM || MS){
      if (sehen.toLowerCase()=="visible")
         getElem(p1,p2,p3).style.visibility="visible";
      if (sehen.toLowerCase()=="hidden")
         getElem(p1,p2,p3).style.visibility="hidden";
   }
   else if(NS){
      if (sehen.toLowerCase()=="visible") getElem(p1,p2,p3).visibility ="show";
      if (sehen.toLowerCase()=="hidden") getElem(p1,p2,p3).visibility="hide";
   }
}

function setObjVis(obj,visibility){
   if(DOM || MS){
      if (visibility.toLowerCase()=="visible")
         obj.style.visibility="visible";
      if (visibility.toLowerCase()=="hidden")
         obj.style.visibility="hidden";
   }
   else if (NS){
      if (visibility.toLowerCase()=="visible") getElem(p1,p2,p3).visibility ="show";
      if (visibility.toLowerCase()=="hidden") getElem(p1,p2,p3).visibility="hide";
   }

}

function setElemIndex (p1,p2,p3,z) {
   if(DOM || MS)
      getElem(p1,p2,p3).style.zIndex=z;
   if(NS)
      getElem(p1,p2,p3).zIndex=z;
}


function getWindowWidth(){
   //alert("entering getWindowWidth")
   if(MS)
     return document.body.offsetWidth;
   else
     return window.innerWidth;
}
function getWindowHeight(){
   if(MS)
     return document.body.offsetHeight;
   else
     return window.innerHeight;
}
DHTML_init();
