divContent = new Array("c_start", "c_starte", "c_startf", "c_rock", "c_schauspiel", "c_info_allgemeines", "c_info_geschichte", "c_info_kontakt", "c_info_lageplan", "c_studium_pläne", "c_studium_pläne_tonsatz", "c_studium_pläne_blasinstrumente", "c_studium_pläne_klavier", "c_studium_pläne_akkordeon", "c_studium_pläne_dirigieren", "c_studium_pläne_violine", "c_studium_pläne_viola", "c_studium_pläne_violoncello", "c_studium_pläne_kontrabass", "c_studium_pläne_sologesang", "c_studium_pläne_gitarre", "c_studium_pläne_oper", "c_studium_pläne_opernrepertoire", "c_studium_pläne_harfe", "c_studium_pläne_schauspiel", "c_studium_pläne_sprechen", "c_studium_pläne_jazz", "c_studium_beiträge", "c_studium_studienjahr", "c_studium_anmeldung", "c_bachelor", "c_dozenten", "c_diplom_zeugnis", "c_diplom_ects", "c_termine", "c_sonstiges_deutschkurse", "c_sonstiges_visum", "c_sonstiges_aec", "c_notfinished", "c_impressum");

// --------------------------------------------Menuleiste unten------------------------------------------------------------------//
var menuLayers = {
  timer: null,
  activeMenuID: null,
  offX: 4,   // horizontal offset
  offY: 6,   // vertical offset
  child: false,
  show: function(id, e, y) {
    var mnu = document.getElementById? document.getElementById(id): null;
        //print("test test");
        //document.getElementById("test").style.visibility = "visible";

    if (!mnu) return;
    this.activeMenuID = id;
        //document.write(this.activeMenuID);
    if ( mnu.onmouseout == null ) mnu.onmouseout = this.mouseoutCheck;
    if ( mnu.onmouseover == null ) mnu.onmouseover = this.clearTimer;
    //viewport.getAll();
        //document.test.style.visibility = 'visible';
    this.position(mnu,e,y);
  },


  hide: function() {
    this.clearTimer();
            if ((this.activeMenuID && document.getElementById))
                      this.timer = setTimeout("document.getElementById('"+menuLayers.activeMenuID+"').style.visibility = 'hidden'", 200);

        },

        hide2: function() {
    this.clearTimer();
        if(this.child == false) {
            if ((this.activeMenuID && document.getElementById))
                      this.timer = setTimeout("menuLayers.mouseoutCheck(this)", 200);
                  }
        },

        position: function(mnu, e, x) {
                  this.clearTimer();
                var koordinaten = findPos(document.getElementById('head'));
                var y = koordinaten.yPos + 101;
                x += koordinaten.xPos;
                mnu.style.left = x + "px";
                mnu.style.top = y + "px";

                this.timer = setTimeout("document.getElementById('"+menuLayers.activeMenuID+"').style.visibility = 'visible'", 0);
        },


  mouseoutCheck: function(e) {
    e = e? e: window.event;
    // is element moused into contained by menu? or is it menu (ul or li or a to menu div)?
    var mnu = document.getElementById(menuLayers.activeMenuID);
    var toEl = e.relatedTarget? e.relatedTarget: e.toElement;
    if ( mnu != toEl && !menuLayers.contained(toEl, mnu) ) menuLayers.hide();
  },

  // returns true of oNode is contained by oCont (container)
  contained: function(oNode, oCont) {
    if (!oNode) return; // in case alt-tab away while hovering (prevent error)
    while ( oNode = oNode.parentNode )
      if ( oNode == oCont ) return true;
    return false;
  },

  clearTimer: function() {
    clearTimeout(menuLayers.timer);
  }
}

// --------------------------------------------Menuleiste oben-------------------------------------------------------------------//

var menuLayers1 = {
  timer: null,
  activeMenuID: null,
  offX: 4,   // horizontal offset
  offY: 6,   // vertical offset
  child: false,
  show: function(id, e, y) {
    var mnu = document.getElementById? document.getElementById(id): null;
        //print("test test");
        //document.getElementById("test").style.visibility = "visible";

    if (!mnu) return;
    this.activeMenuID = id;
        //document.write(this.activeMenuID);
    if ( mnu.onmouseout == null ) mnu.onmouseout = this.mouseoutCheck;
    if ( mnu.onmouseover == null ) mnu.onmouseover = this.clearTimer;
    //viewport.getAll();
        //document.test.style.visibility = 'visible';
    this.position(mnu,e,y);
  },


  hide: function() {
    this.clearTimer();
            if ((this.activeMenuID && document.getElementById))
                      this.timer = setTimeout("document.getElementById('"+menuLayers1.activeMenuID+"').style.visibility = 'hidden'", 200);

        },

        hide2: function() {
    this.clearTimer();
        if(this.child == false) {
            if ((this.activeMenuID && document.getElementById))
                      this.timer = setTimeout("menuLayers1.mouseoutCheck(this)", 200);
                  }
        },

        position: function(mnu, e, x) {
                  this.clearTimer();
                var koordinaten = findPos(document.getElementById('head'));
                var y = koordinaten.yPos + 1;
                x += koordinaten.xPos;
                mnu.style.left = x + "px";
                mnu.style.top = y + "px";

                this.timer = setTimeout("document.getElementById('"+menuLayers1.activeMenuID+"').style.visibility = 'visible'", 0);
        },


  mouseoutCheck: function(e) {
    e = e? e: window.event;
    // is element moused into contained by menu? or is it menu (ul or li or a to menu div)?
    var mnu = document.getElementById(menuLayers1.activeMenuID);
    var toEl = e.relatedTarget? e.relatedTarget: e.toElement;
    if ( mnu != toEl && !menuLayers1.contained(toEl, mnu) ) menuLayers1.hide();
  },

  // returns true of oNode is contained by oCont (container)
  contained: function(oNode, oCont) {
    if (!oNode) return; // in case alt-tab away while hovering (prevent error)
    while ( oNode = oNode.parentNode )
      if ( oNode == oCont ) return true;
    return false;
  },

  clearTimer: function() {
    clearTimeout(menuLayers1.timer);
  }
}



function findPos(el) {
        var xPos = 0;
    var yPos = 0;
            if(document.layers) {
                xPos = el.x;
                yPos = el.y;
            }
            else {
                while(el){
                    xPos += el.offsetLeft;
                    yPos += el.offsetTop;
                    el   =  el.offsetParent;
                }
            }
    return {xPos: xPos, yPos: yPos};
}

function killmenu() {
        document.getElementById('m_home').style.visibility = 'hidden';
        document.getElementById('m_english').style.visibility = 'hidden';
        document.getElementById('m_deutsch').style.visibility = 'hidden';
        document.getElementById('m_franz').style.visibility = 'hidden';
        document.getElementById('m_info').style.visibility = 'hidden';
        document.getElementById('m_studium').style.visibility = 'hidden';
        document.getElementById('m_bachelor').style.visibility = 'hidden';
        document.getElementById('m_dozenten').style.visibility = 'hidden';
        document.getElementById('m_diplom').style.visibility = 'hidden';
        document.getElementById('m_termine').style.visibility = 'hidden';
        document.getElementById('m_sonstiges').style.visibility = 'hidden';
}

function kill_content() {
        for (var i = 0; i < divContent.length; i++){
                document.getElementById(divContent[i]).style.visibility = 'hidden';
                document.getElementById(divContent[i]).style.overflow = 'hidden';
                document.getElementById(divContent[i] + "_title").style.visibility = 'hidden';
        }
}


function link_click(name) {

        //remove all others
        kill_content();
        document.getElementById(name).style.overflow = 'auto';


        //position elements
        var koordinaten = findPos(document.getElementById('head'));
        var y = koordinaten.yPos + 156;
        var x = koordinaten.xPos + 23;
        document.getElementById(name).style.left = x + "px";
        document.getElementById(name).style.top = y + "px";

        //show elements
        document.getElementById(name).style.visibility = 'visible';
        document.getElementById(name + "_title").style.visibility = 'visible';

        var ty = koordinaten.yPos + 130;
        var tx = koordinaten.xPos + 27;
        document.getElementById(name + "_title").style.left = tx + "px";
        document.getElementById(name + "_title").style.top = ty + "px";

        //show table
        var fy = koordinaten.yPos + 155;
        var fx = koordinaten.xPos + 22;
        document.getElementById("flow").style.left = fx + "px";
        document.getElementById("flow").style.top = fy + "px";

        //show impressum
        var iy = koordinaten.yPos + 520;
        var ix = koordinaten.xPos + 22;
        document.getElementById("impressum").style.left = ix + "px";
        document.getElementById("impressum").style.top = iy + "px";

}



function Fensterweite () {
  if (window.innerWidth) {
    return window.innerWidth;
  } else if (document.body && document.body.offsetWidth) {
    return document.body.offsetWidth;
  } else {
    return 0;
  }
}


function Fensterhoehe () {
  if (window.innerHeight) {
    return window.innerHeight;
  } else if (document.body && document.body.offsetHeight) {
    return document.body.offsetHeight;
  } else {
    return 0;
  }
}

function loadPage() {

        kill_content();
        document.getElementById('c_start').style.overflow = 'auto';

        var koordinaten = findPos(document.getElementById('head'));
        var y = koordinaten.yPos + 156;
        var x = koordinaten.xPos + 23;
        var fy = koordinaten.yPos + 155;
        var fx = koordinaten.xPos + 22;
        var ty = koordinaten.yPos + 130;
        var tx = koordinaten.xPos + 27;
        var iy = koordinaten.yPos + 520;
        var ix = koordinaten.xPos + 22;
        document.getElementById('c_no_javascript').style.visibility = 'hidden';
        document.getElementById('c_no_javascript_title').style.visibility = 'hidden';
        document.getElementById('c_start').style.left = x + "px";
        document.getElementById('c_start').style.top = y + "px";
        document.getElementById('c_start').style.visibility = 'visible';
        document.getElementById('c_start_title').style.left = tx + "px";
        document.getElementById('c_start_title').style.top = ty + "px";
        document.getElementById('c_start_title').style.visibility = 'visible';
        document.getElementById('impressum').style.left = ix + "px";
        document.getElementById('impressum').style.top = iy + "px";
        document.getElementById('impressum').style.visibility = 'visible';
        document.getElementById('flow').style.left = fx + "px";
        document.getElementById('flow').style.top = fy + "px";
        document.getElementById('flow').style.visibility = 'visible';
}

function loadPageI() {

        kill_content();

        var koordinaten = findPos(document.getElementById('head'));
        var y = koordinaten.yPos + 156;
        var x = koordinaten.xPos + 23;
        var fy = koordinaten.yPos + 155;
        var fx = koordinaten.xPos + 22;
        var ty = koordinaten.yPos + 130;
        var tx = koordinaten.xPos + 27;
        var iy = koordinaten.yPos + 520;
        var ix = koordinaten.xPos + 22;
        document.getElementById('c_no_javascript').style.visibility = 'hidden';
        document.getElementById('c_no_javascript_title').style.visibility = 'hidden';
        document.getElementById('c_start').style.left = x + "px";
        document.getElementById('c_start').style.top = y + "px";
        document.getElementById('c_start').style.visibility = 'visible';
        document.getElementById('c_start_title').style.left = tx + "px";
        document.getElementById('c_start_title').style.top = ty + "px";
        document.getElementById('c_start_title').style.visibility = 'visible';
        document.getElementById('impressum').style.left = ix + "px";
        document.getElementById('impressum').style.top = iy + "px";
        document.getElementById('impressum').style.visibility = 'visible';
        document.getElementById('flow').style.left = fx + "px";
        document.getElementById('flow').style.top = fy + "px";
        document.getElementById('flow').style.visibility = 'visible';
}

function documentResize () {

        var koordinaten = findPos(document.getElementById('head'));
        var y = koordinaten.yPos + 156;
        var x = koordinaten.xPos + 23;
        var fy = koordinaten.yPos + 155;
        var fx = koordinaten.xPos + 22;
        var ty = koordinaten.yPos + 130;
        var tx = koordinaten.xPos + 27;
        var iy = koordinaten.yPos + 520;
        var ix = koordinaten.xPos + 22;
        for (var i = 0; i < divContent.length; i++) {

                document.getElementById(divContent[i]).style.left = x + "px";
                document.getElementById(divContent[i]).style.top = y + "px";
                document.getElementById(divContent[i] + "_title").style.left = tx + "px";
                document.getElementById(divContent[i] + "_title").style.top = ty + "px";
        }
        document.getElementById('impressum').style.left = ix + "px";
        document.getElementById('impressum').style.top = iy + "px";
        document.getElementById('flow').style.top = fy + "px";
        document.getElementById('flow').style.left = fx + "px";
}