/* DHTML library  ---  FILE: dhtml.js */

/* Distribution or (re)publication of this file is only allowed *
 * with a written permission of Juxi Leitner                    *
 * copyright: Juxi Leitner, 2001-2003                           *
 
 * Die Weitergabe oder Wiederveroeffentlichung von dieser Datei *
 * ist nur mit schriftlicher Erlaubnis von Juxi Leitner erlaubt *
 * copyright: Juxi Leitner, 2001-2003                           * 

 * contact: http://www.Juxi.net             juxi.leitner@aon.at */

var mouseInMenu;
mouseInMenu = false;
var popwnd;
var DHTML = 0, DOM = 0, MS = 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;
 }
}

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();

function showMenu(category) {
	if(DOM) {
		if(MS) getElem("id","Nav" + category,null).style.top = document.body.scrollTop + 50;
   		else getElem("id","Nav" + category,null).style.top = window.pageYOffset + 50;
	}
	if(DOM || MS) {
		if (!DOM) getElem("id","Nav" + category,null).style.top = document.body.scrollTop + 50;
		getElem("id","Nav" + category,null).style.visibility = "visible";
	}
	else if(NS) {
		getElem("id","Nav" + category,null).top = window.pageYOffset + 50;
		getElem("id","Nav" + category,null).visibility = "show";
	}
}

function init(category) {
	var navend;
	navend = category;
	if(category == 0) {
		navend = 3;
		category = 1;
	}
	if(DOM) {
		for(i = category;i <= navend;i++) {
			if(MS) getElem("id","Nav" + i,null).style.top = document.body.scrollTop;
   			else getElem("id","Nav" + i,null).style.top = window.pageYOffset;
		}
	}
	if(DOM || MS) {
		for(i = category;i <= navend;i++) {
			if (!DOM) getElem("id","Nav" + i,null).style.top = document.body.scrollTop;
			getElem("id","Nav" + i,null).style.visibility = "hidden";
		}
	}
	else if(NS) {
		for(i = category;i <= navend;i++) {
			getElem("id","Nav" + i,null).top = window.pageYOffset;
			getElem("id","Nav" + i,null).visibility = "hide";
		}
	}
}

/**
 * Sets/unsets the pointer and marker in browse mode (special thx to phpMyAdmin)
 *
 * @param   object    the table row
 * @param   interger  the row number
 * @param   string    the color to use for action
 *
 * @return  boolean  whether pointer is set or not
 */
function setPointer(theRow, theRowNum, newColor) {
    var theCells = null;

    // 1. Pointer and mark feature are disabled or the browser can't get the row -> exits
    if (newColor == '' || typeof(theRow.style) == 'undefined') {
        return false;
    }

    // 2. Gets the current row and exits if the browser can't get it
    if (typeof(document.getElementsByTagName) != 'undefined') {
        theCells = theRow.getElementsByTagName('td');
    } else if (typeof(theRow.cells) != 'undefined') {
        theCells = theRow.cells;
    } else {
        return false;
    }

    // 3. Gets the current color...
    var rowCellsCnt  = theCells.length;
    var domDetect    = null;
    var currentColor = null;
    // 3.1 ... with DOM compatible browsers except Opera that does not return valid values with "getAttribute"
    if (typeof(window.opera) == 'undefined' && typeof(theCells[0].getAttribute) != 'undefined') {
        currentColor = theCells[0].getAttribute('bgcolor');
        domDetect    = true;
    }
    // 3.2 ... with other browsers
    else {
        currentColor = theCells[0].style.backgroundColor;
        domDetect    = false;
    } // end 3

    // 4. Sets the new color...
    if (newColor) {
        var c =	 null;
        // 4.1 ... with DOM compatible browsers except Opera
        if (domDetect) {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].setAttribute('bgcolor', newColor, 0);
            } // end for
        }
        // 4.2 ... with other browsers
        else {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].style.backgroundColor = newColor;
            }
        }
    } // end 4

    theCell.style.cursor = "pointer";

    return true;
} // end of the 'setPointer()' function


/**
 * Sets/unsets the pointer and marker in browse mode (special thx to phpMyAdmin)
 * this is for a single Cell!
 *
 * @param   object    the table cell
 * @param   string    the color to use for action
 *
 * @return  boolean  whether pointer is set or not
 */
function setPointerCell(theCell, newColor) {
    // 1. Gets the current color...
    var domDetect    = null;
    var currentColor = null;
    // 1.1 ... with DOM compatible browsers except Opera that does not return valid values with "getAttribute"
    if (typeof(window.opera) == 'undefined' && typeof(theCell.getAttribute) != 'undefined') {
        currentColor = theCell.getAttribute('bgcolor');
        domDetect    = true;
    }
    // 1.2 ... with other browsers
    else {
        currentColor = theCell.style.backgroundColor;
        domDetect    = false;
    } // end 1

    // 2. Sets the new color...
    if (newColor) {
        // 2.1 ... with DOM compatible browsers except Opera
        if (domDetect) {
            theCell.setAttribute('bgcolor', newColor, 0);
        }
        // 2.2 ... with other browsers
        else {
            theCell.style.backgroundColor = newColor;
        }
    } // end 2

    theCell.style.cursor = "pointer";

    return true;
} // end of the 'setPointerCell()' function


/**
 * Sends the click in a row to the real link
 *
 * @param   object    the table row
 * @param   integer   the row number
 */
function clickRow(theRow, theRowNum) {
    var theCells = null;

    // 1. Gets the current row and exits if the browser can't get it
    if (typeof(document.getElementsByTagName) != 'undefined') {
        theCells = theRow.getElementsByTagName('td');
    } else if (typeof(theRow.cells) != 'undefined') {
        theCells = theRow.cells;
    } else {
        return false;
    }

    // 2. Gets the link from the first table cell ...
    var domDetect    = null;
    var theLinkTag   = null;
    theLinkTag   = theCells[0].getElementsByTagName('a') [0];
    // 2.1 ... with DOM compatible browsers except Opera that does not return valid values with "getAttribute"
    if (typeof(window.opera) == 'undefined' && typeof(theCells[0].getAttribute) != 'undefined') {
        domDetect    = true;
    }
    // 2.2 ... with other browsers
    else {
        domDetect    = false;
    } 
    if (theLinkTag == null) {
      return false;
    } // end 2


    // 3. Sets the window href
    window.location.href = theLinkTag.href;
    

    return true;
} // end of the 'clickRow()' function


/**
 * Sends the click in a box to the real link
 *
 * @param   theCell	the cell, where the mouse click was produced
 */
function clickCell(theCell) {
    var theLinkTag = theCell.getElementsByTagName('a') [0];
    window.location.href = theLinkTag.href;

    return true;
} // end of the 'clickCell()' function

/**
 * Sends the click in a box to a given link
 *
 * @param   theCell	the cell, where the mouse click was produced
 * @param   uri		the link
 */
function clickCellLink(theCell, uri) {
    var theLinkTag = theCell.getElementsByTagName('a') [0];
    window.location.href = uri;

    return true;
} // end of the 'clickCellLink()' function

/**
 * Sends the click in a box to a given link
 *
 * @param   theCell	the cell, where the mouse click was produced
 * @param   mainLink	the link, shown on the main page
 * @param   extLink	the link, shown on the external page
 */
function clickCellOpenLink(theCell, mainLink, extLink) {
    var theLinkTag = theCell.getElementsByTagName('a') [0];
    window.location.href = mainLink;
    window.open(extLink);

    return true;
} // end of the 'clickCellLink()' function


/* Opens a PopUp-Window for showing small parts of information!
 *
 * @param url	the link to the webpage
 * @param h	the height of the window
 * @param w	the width of the window
 */
function popUp(url, h, w) {
	if(popwnd != null) { 
		popwnd.close(); 
	}
	popwnd = window.open(url,"popDialog","dependent=yes,screenX=100,screenY=100,height=" + h + ",width=" + w + ",status=no,scrollbars=yes")
}