//++ Menu ++//
/**** Zur Verfügung stehende Fuktionen 
/* windowOpener( url , X-Weite, Y-Höhe, Fensterfaktor)
/* url: relative Seitenangabe
/* X-Weite: absolute Angabe der Breite in Pixeln
/* Y-Weite: absolute Angabe der Höhe in Pixeln
/* Fensterfaktor: relative Angabe, um wieviel die geschrumpft werden soll. Wert zw. 0 und 1
/* Ganzes Fenster: Nur url angeben, oder X und Y mit 0 belegen
/* Ganzes Fenster um Fensterfaktor geschrumpft: url, X und Y = 0, Fensterfaktor 0<x<1
/* Mischung möglich.

/*** SET BUTTON'S FOLDER HERE ***/
var buttonFolder = "../../buttons/";
var Dat = "08.03.07";

var ie4=document.all&&!document.getElementById;
var DOM2=document.getElementById;


// Anzahl der Hauptmenuepunkte
totalButtons = 8;

mainInfo = new Array();
subInfo = new Array();
sx = screen.width;
sy = screen.height;

for (var i=1; i <= totalButtons; i++){
	subInfo[i] = new Array();
	//mainInfo[i] = new Array();
}



mainInfo[1] = new Array(" Startseite", "../index.html", "");
mainInfo[2] = new Array(" Pferde", "javascript:;", "");
mainInfo[3] = new Array(" Rinder", "javascript:;", "");
mainInfo[4] = new Array(" Der Hof", "../site/hof.html", "");
mainInfo[5] = new Array(" Aktuelles", "javascript:;", "");
mainInfo[6] = new Array(" Bilder", "http://www.gut-melb.de/diashow/basis-cgi/", "");
//mainInfo[6] = new Array(" Bilder", "windowOpener( http://www.gut-melb.de/diashow/basis-cgi/ , 0, 0, 0.9)", "");
mainInfo[7] = new Array(" Anfahrt", "../site/anfaht.html", "");
mainInfo[8] = new Array(" Impressum", "../site/impressum.html", "");

//*** SET SUB MENUS TEXT LINKS AND TARGETS HERE ***//  
subInfo[2][1] = new Array(" Unterbringung","../site/unterbringung.html","");
subInfo[2][2] = new Array(" Versorgung","../site/versorgung.html","");
subInfo[2][3] = new Array(" Weiden","../site/weide.html","");
subInfo[2][4] = new Array(" ","../pferde.html","");
subInfo[2][5] = new Array(" Reitbeteiligungen","../site/reitbeteiligung.html","");
subInfo[3][1] = new Array(" Zwergzebus","../site/zwergzebus.html","");
subInfo[3][2] = new Array(" Glanrinder","../site/glanrinder.html","");
subInfo[5][1] = new Array(" Einsatzplan","../site/cal/calender.html","");
subInfo[5][2] = new Array(" Nachrichten","../site/nachrichten.html","");


//alert(subInfo[4][1]);
//*** SET SUB MENU POSITION ( RELATIVE TO BUTTON ) ***//
var xSubOffset = 164;
var ySubOffset = 0;



//*** NO MORE SETTINGS BEYOND THIS POINT ***//
var overSub = false;
var delay = 1000;
var bgcolov = "Maroon";
var bgcol= "#F0FFF0";
var txcol= "Maroon"; //"#556B2F";
var txcolov = "White";
menuContent = "";
submenu = " style='background-image:url(../pic/arrow.gif); background-position: right; background-repeat:no-repeat; '";

// GENERATE MAIN MEUS
function mainMenu(){
	for ( x=1; x<=totalButtons; x++) {
		//alert(mainInfo[x]);
		menuContent = menuContent + '<a href="'+mainInfo[x][1]+'"';
		menuContent = menuContent + ' onMouseOver="overSub=true;showSubMenu(\'submenu'+x+'\',\'button'+x+'\');';
		menuContent = menuContent + ' window.status=\'Navigation >> ' + mainInfo[x][0] + '\';"';
		menuContent = menuContent + ' onMouseOut="overSub=false;setTimeout(\'hideSubMenu(\\\'submenu'+x+'\\\')\',delay);';
		menuContent = menuContent + ' window.status=\'powerd by Doc Database\';"';
		menuContent = menuContent + 'id="button'+x+'"';
		if ( subInfo[x].length > 0 ) menuContent = menuContent + submenu;
		menuContent = menuContent + '>'+mainInfo[x][0]+'</a>';
	}
	if (DOM2){
		document.getElementById("menu").innerHTML=menuContent;
	} else {
		if (ie4) document.all.menu.innerHTML=menuContent;
	}
}

// GENERATE SUB MENUS

for ( x=0; x<totalButtons; x++) {
	// SET EMPTY DIV FOR BUTTONS WITHOUT SUBMENU
	if ( subInfo[x+1].length < 1 ) { 
		//Submenu
		document.write('<table id="submenu' + (x+1) + '">');
	// SET DIV FOR BUTTONS WITH SUBMENU
	} else {
		
		document.write('<table id="submenu' + (x+1) + '" class="dropmenu">');
		
		//Inhalt
		for ( k=0; k<subInfo[x+1].length-1; k++ ) {
			
			document.write('<tr>');
			document.write('<td style="Color:' + txcol + '; background-color:' + bgcol + ';" ');
			document.write('onClick="location.href=\'' + subInfo[x+1][k+1][1] + '\' "');
			document.write('onMouseOver="this.style.backgroundColor=\'' + bgcolov + '\'; this.style.color=\'' + txcolov + '\';' );
			document.write('overSub=true;');
			document.write('window.status=\'Navigation >> ' + mainInfo[x+1][0]+' >>'+subInfo[x+1][k+1][0] + '\'; "');
			document.write('onMouseOut="this.style.backgroundColor=\'' + bgcol + '\'; this.style.color=\'' + txcol + '\'; ');
			document.write('overSub=false;setTimeout(\'hideSubMenu(\\\'submenu' + (x+1) + '\\\')\',delay); ');
			document.write('">');
			document.write(subInfo[x+1][k+1][0] + '</td></tr>');
		}
	}
	document.write('</table>');
}





//*** MAIN BUTTONS FUNCTIONS ***//
// PRELOAD MAIN MENU BUTTON IMAGES
function preload() {
	/*for ( x=0; x<totalButtons; x++ ) {
		buttonUp = new Image();
		buttonUp.src = buttonFolder + upSources[x];
		buttonOver = new Image();
		buttonOver.src = buttonFolder + overSources[x];
	}-*/
}

// SET MOUSEOVER BUTTON
function setOverImg(But, ID) {
	//document.getElementById('button' + But + ID).src = buttonFolder + overSources[But-1];
}

// SET MOUSEOUT BUTTON
function setOutImg(But, ID) {
	//document.getElementById('button' + But + ID).src = buttonFolder + upSources[But-1];
}



//*** SUB MENU FUNCTIONS ***//
// GET ELEMENT ID MULTI BROWSER
function getElement(id) {
	return document.getElementById ? document.getElementById(id) : document.all ? document.all(id) : null; 
}

// GET X COORDINATE
function getRealLeft(id) { 
	var el = getElement(id);
	if (el) { 
		xPos = el.offsetLeft;
		tempEl = el.offsetParent;
		while (tempEl != null) {
			xPos += tempEl.offsetLeft;
			tempEl = tempEl.offsetParent;
		} 
		return xPos;
	} 
} 

// GET Y COORDINATE
function getRealTop(id) {
	var el = getElement(id);
	if (el) { 
		yPos = el.offsetTop;
		tempEl = el.offsetParent;
		while (tempEl != null) {
			yPos += tempEl.offsetTop;
			tempEl = tempEl.offsetParent;
		}
		return yPos;
	}
}

// MOVE OBJECT TO COORDINATE
function moveObjectTo(objectID,x,y) {
	var el = getElement(objectID);
	el.style.left = x;
	el.style.top = y;
	
}

// MOVE SUBMENU TO CORRESPONDING BUTTON
function showSubMenu(subID, buttonID) {
	hideAllSubMenus();
	butX = getRealLeft(buttonID);
	butY = getRealTop(buttonID);
	moveObjectTo(subID,butX+xSubOffset, butY+ySubOffset);
}

// HIDE ALL SUB MENUS
function hideAllSubMenus() {
	//Fade on
	for ( x=0; x<totalButtons; x++) {
		//moveObjectTo("submenu" + (x+1) + "",+500, +500);
		moveObjectTo("submenu" + (x+1) + "",-500, -500 );
	}
}

// HIDE ONE SUB MENU
function hideSubMenu(subID) {
	if ( overSub == false ) {
		moveObjectTo(subID,-500, -500);
		//moveObjectTo(subID,+500, +500);
	}
}



//preload();


<!-- Begin
function BrowserCheck() { 
var b = navigator.appName; 
if (b == "Netscape") this.b = "NS"; 
else if (b == "Microsoft Internet Explorer") this.b = "IE"; 
else this.b = b; 
this.v = parseInt(navigator.appVersion); 
this.NS = (this.b == "NS" && this.v>=4); 
this.NS4 = (this.b == "NS" && this.v == 4); 
this.NS5 = (this.b == "NS" && this.v == 5); 
this.IE = (this.b == "IE" && this.v>=4); 
this.IE4 = (navigator.userAgent.indexOf('MSIE 4')>0); 
this.IE5 = (navigator.userAgent.indexOf('MSIE 5')>0); 
if (this.IE5 || this.NS5) this.VER5 = true; 
if (this.IE4 || this.NS4) this.VER4 = true; 
this.OLD = (! this.VER5 && ! this.VER4) ? true : false; 
this.min = (this.NS||this.IE); 
} 
is = new BrowserCheck();  


/* Anfang Funktionen zum Zoomen der Inhalte einzelner Seiten    */
i= 1.0; 
function zoomIn() 
{ 
	if (i<=4.0){
		i += 0.5; 
		innerZoom(); 
	}
} 
function zoomOut() 
{ 
	if (i > 1) i -= 0.5; 
	innerZoom(); 
} 
function resetZoom() 
{ 
	i = 1; 
	innerZoom(); 
} 
function innerZoom() 
{ 
	this.document.body.style.zoom=i; 
} 

// JavaScript Document

var winheight=10;
var winsize=10;
var yrs = 10;
var xrs = 10;
//var maxheight = screen.height;
//var maxwidth = 400;


function windowOpener(thelocation, maxx, maxy, fensterFaktor){
	maxheight=maxy;
	maxwidth=maxx;
	//alert(maxheight + ', ' + maxwidth + ', ' + fensterFaktor);
	if ((maxheight== undefined)||(maxheight == 0)) maxheight = screen.height;
	if ((maxwidth== undefined)||(maxwidth == 0)) maxwidth = screen.width;
	if (fensterFaktor){
		if (fensterFaktor < 1.0){
			maxwidth *= fensterFaktor;
			maxheight *= fensterFaktor;
		}
	} 
	
	

	var offsetX=((screen.width-maxwidth)/2); //Fenster zentrieren.
	var offsetY=((screen.height-maxheight)/2);
	temploc = thelocation;
	if(!(window.resizeTo&&document.all)&&!(window.resizeTo&&getElementById)){
		window.open(thelocation);
		return true;
	}
	win2=window.open("","OpenWindow","scrollbars");
	
	win2.resizeTo(10,10);
	win2.moveTo(offsetX,offsetY);//alert (offsetX+' + ' +offsetY);
	go2();
}

function go2(){

	if (winsize>=maxwidth-5){
		if(winheight>=maxheight-5){
			//win2.moveTo(500, 50);
			win2.location=temploc;
			winheight=10;
			winsize=10;
			yrs=10;
			xrs=10;
		return true;
		} else {
			winheight+=10;
			yrs = 10;
			xrs = 0;
		}
	} else {
		winsize+=10;
		yrs = 0;
		xrs = 10;
	}
	
	win2.resizeBy(xrs,yrs);
	go2();
}
