divContent = new Array("c_start", "c_book_info", "c_book_contents", "c_book_autoren_ast", "c_book_autoren_bmeister", "c_book_autoren_frank", "c_book_autoren_grabner", "c_book_autoren_kling","c_book_autoren_kohl", "c_book_autoren_lauria", "c_book_autoren_mimra", "c_book_autoren_puch", "c_book_autoren_schie", "c_book_autoren_schneid", "c_book_autoren_schrei", "c_book_autoren_stingl", "c_book_autoren_teisch", "c_book_autoren_wimmer", "c_book_autoren_winkler", "c_book_autoren_zukrigl", "c_book_order", "c_tree_general_look", "c_tree_general_nad", "c_tree_general_zapf", "c_tree_general_wurz", "c_tree_general_locate", "c_tree_general_klima", "c_tree_general_danger", "c_tree_general_hybrid", "c_tree_population", "c_tree_wood", "c_tree_klima", "c_tree_pech", "c_tree_history", "c_news_hybrid", "c_news_pech", "c_news_1000", "c_news_quiz", "c_images_div", "c_images_pech", "c_images_foehre", "c_guestbook_insert", "c_guestbook_show", "c_notfinished");


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 + 109;
		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);
  }
}



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_book').style.visibility = 'hidden';
	document.getElementById('m_tree').style.visibility = 'hidden';
	document.getElementById('m_news').style.visibility = 'hidden';
	document.getElementById('m_images').style.visibility = 'hidden';
	document.getElementById('m_log').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 + 283;
	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 + 259;
	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 + 282;
	var fx = koordinaten.xPos + 22;
	document.getElementById("flow").style.left = fx + "px";
	document.getElementById("flow").style.top = fy + "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 + 283;
	var x = koordinaten.xPos + 23;
	var fy = koordinaten.yPos + 282;
	var fx = koordinaten.xPos + 22;
	var ty = koordinaten.yPos + 259;
	var tx = koordinaten.xPos + 27;
	var iy = koordinaten.yPos + 514;
	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();
	document.getElementById('c_guestbook_insert').style.overflow = 'auto';
	
	var koordinaten = findPos(document.getElementById('head'));
	var y = koordinaten.yPos + 283;
	var x = koordinaten.xPos + 23;
	var fy = koordinaten.yPos + 282;
	var fx = koordinaten.xPos + 22;
	var ty = koordinaten.yPos + 259;
	var tx = koordinaten.xPos + 27;
	var iy = koordinaten.yPos + 514;
	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_guestbook_insert').style.left = x + "px";
	document.getElementById('c_guestbook_insert').style.top = y + "px";
	document.getElementById('c_guestbook_insert').style.visibility = 'visible';
	document.getElementById('c_guestbook_insert_title').style.left = tx + "px";
	document.getElementById('c_guestbook_insert_title').style.top = ty + "px";
	document.getElementById('c_guestbook_insert_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 + 283;
	var x = koordinaten.xPos + 23;
	var fy = koordinaten.yPos + 282;
	var fx = koordinaten.xPos + 22;
	var ty = koordinaten.yPos + 259;
	var tx = koordinaten.xPos + 27;
	var iy = koordinaten.yPos + 514;
	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.top = iy + "px";
	document.getElementById('impressum').style.left = ix + "px";
	document.getElementById('flow').style.top = fy + "px";
	document.getElementById('flow').style.left = fx + "px";
}

