divContent = new Array("c_kontakt", "c_person", "c_aktuelles", "c_programm", "c_angebot", "c_fragen", "c_links");
divSubContent = new Array("c_angebot_adi", "c_angebot_dia", "c_angebot_fet", "c_angebot_her", "c_angebot_ver", "c_angebot_ost", "c_angebot_pol", "c_angebot_hyp", "c_angebot_sch", "c_angebot_kre");


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 + 68;
		x = koordinaten.xPos + 27;
		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);
  }
}



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_all').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';
		document.getElementById(divContent[i] + "_image").style.visibility = 'hidden';
	}
	for (var i = 0; i < divSubContent.length; i++){
		document.getElementById(divSubContent[i]).style.visibility = 'hidden';
		document.getElementById(divSubContent[i]).style.overflow = '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 + 188;
	var x = koordinaten.xPos + 187;
	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';
	document.getElementById(name + "_image").style.visibility = 'visible';
	
	var ty = koordinaten.yPos + 32;
	var tx = koordinaten.xPos + 175;
	document.getElementById(name + "_title").style.left = tx + "px";
	document.getElementById(name + "_title").style.top = ty + "px";
	
	var imy = koordinaten.yPos + 0;
	var imx = koordinaten.xPos + 630;
	document.getElementById(name + "_image").style.left = imx + "px";
	document.getElementById(name + "_image").style.top = imy + "px";
	
	//show table
	var fy = koordinaten.yPos + 187;
	var fx = koordinaten.xPos + 186;
	document.getElementById("flow").style.left = fx + "px";
	document.getElementById("flow").style.top = fy + "px";
	
	
}

function sublink_click(name) {
	
	for (var i = 0; i < divSubContent.length; i++){
		document.getElementById(divSubContent[i]).style.visibility = 'hidden';
		document.getElementById(divSubContent[i]).style.overflow = 'hidden';
	}
	
	//position elements
	var koordinaten = findPos(document.getElementById('head'));
	var y = koordinaten.yPos + 77;
	var x = koordinaten.xPos + 186;
	document.getElementById(name).style.left = x + "px";
	document.getElementById(name).style.top = y + "px";
	
	//show elements
	document.getElementById(name).style.visibility = 'visible';
}






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_kontakt').style.overflow = 'auto';
	
	var koordinaten = findPos(document.getElementById('head'));
	var y = koordinaten.yPos + 188;
	var x = koordinaten.xPos + 187;
	var fy = koordinaten.yPos + 187;
	var fx = koordinaten.xPos + 186;
	var ty = koordinaten.yPos + 32;
	var tx = koordinaten.xPos + 175;
	var iy = koordinaten.yPos + 514;
	var ix = koordinaten.xPos + 22;
	var imy = koordinaten.yPos + 0;
	var imx = koordinaten.xPos + 630;
	document.getElementById('c_kontakt').style.left = x + "px";
	document.getElementById('c_kontakt').style.top = y + "px";
	document.getElementById('c_kontakt').style.visibility = 'visible';
	document.getElementById('c_kontakt_title').style.left = tx + "px";
	document.getElementById('c_kontakt_title').style.top = ty + "px";
	document.getElementById('c_kontakt_title').style.visibility = 'visible';
	document.getElementById('c_kontakt_image').style.left = imx + "px";
	document.getElementById('c_kontakt_image').style.top = imy + "px";
	document.getElementById('c_kontakt_image').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 + 188;
	var x = koordinaten.xPos + 187;
	var fy = koordinaten.yPos + 187;
	var fx = koordinaten.xPos + 186;
	var ty = koordinaten.yPos + 32;
	var tx = koordinaten.xPos + 175;
	var iy = koordinaten.yPos + 514;
	var ix = koordinaten.xPos + 22;
	var imy = koordinaten.yPos + 0;
	var imx = koordinaten.xPos + 630;
	var sy = koordinaten.yPos + 77;
	var sx = koordinaten.xPos + 186;
	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(divContent[i] + "_image").style.left = imx + "px";
		document.getElementById(divContent[i] + "_image").style.top = imy + "px";
	}
	for (var i = 0; i < divSubContent.length; i++) {
		
		document.getElementById(divSubContent[i]).style.left = sx + "px";
		document.getElementById(divSubContent[i]).style.top = sy + "px";
	}
	
	document.getElementById('impressum').style.top = iy + "px";
	document.getElementById('impressum').style.left = ix + "px";
	document.getElementById('flow').style.top = fy + "px";
	document.getElementById('flow').style.left = fx + "px";
}


