//<SCRIPT>

var MenueOben = new K_MenueOben();
function K_MenueOben() {
	this.SelectedIndex = -1;
	
	this.allObereMenuePunkts = new Array();
	this.SteuerElements_Fenster=null;
	this.SteuerElements_FensterSeite=null;
	
 	this.SeiteName=null; // zuletzt obengeladene Seite
	this.ElementValuesCopy = MenueOben_ElementValuesCopy;
	this.setSeite = new Function("seite"," this.SeiteName = seite; " );
	this.getSeite = new Function(" return this.SeiteName; " );
	this.setSteuerElements_Fenster = new Function("win"," this.SteuerElements_Fenster = win; this.SteuerElements_FensterSeite = (''+win.location); ");
	this.getSteuerElements_Fenster = new Function(" return this.SteuerElements_Fenster; ");
	this.getDefaultMenuePunkt = MenueOben_getDefaultMenuePunkt;
	this.getMenuePunkt = MenueOben_getMenuePunkt;
	this.getMenuePunkts = MenueOben_getMenuePunkts;
	this.getHTML = MenueOben_getHTML;
	this.setMenuePunkts = MenueOben_setMenuePunkts;
	this.addMenuePunkt = MenueOben_addMenuePunkt;
	this.removeAllMenuePunkt = MenueOben_removeAllMenuePunkt;
	this.setVisible = MenueOben_setVisible;
	this.onclick = MenueOben_onClick;
	this.onchange = MenueOben_onChange;
	this.MenueClickStandart = MenueOben_MenueClickStandart;
	this.Aktulisieren = MenueOben_Aktulisieren;
	this.isOnUnload_inOrdnung = MenueOben_isOnUnload_inOrdnung;
	
	this.setSelectedIndex = MenueOben_setSelectedIndex;
	this.getSelectedIndex = MenueOben_getSelectedIndex;

}

function MenueOben_isOnUnload_inOrdnung() {
	return Lib!=null && typeof(Lib)!="undefined" && Lib.browser.dom 
			&& Lib.browser.version_detail>=5;
}
function MenueOben_Aktulisieren(Knote)
{
	if( Knote==null ) return null;
	if( Knote.KontextMenu==null || Knote.KontextMenu=="") {
		if( this.getSeite() != "oben0.htm" ) {
			Lib_menu.getFrame("FRmenu").location.replace(Lib.getBVerz()+"/service/oben0.htm");
		}
	} else {
		if( !this.isOnUnload_inOrdnung() ) {
			this.removeAllMenuePunkt();
		}
	}
	return null;
}
function MenueOben_MenueClickStandart(obj) {
	if( this.SteuerElements_FensterSeite != (""+this.getSteuerElements_Fenster().location) ) {
		Lib_menu.getFrame("FRtree").focus();
		return;
	}
	if( obj.typ=="text" || obj.typ=="bild" ) {
		this.getSteuerElements_Fenster().setTimeout("weiter("+obj.nr+");",50);
	} else if( obj.typ=="zurueck" ) {
		if( Lib.Steck()!=null && Lib.Steck()!="" && this.getSteuerElements_Fenster()!=null && this.getSteuerElements_Fenster().Zurueck ) {
			this.getSteuerElements_Fenster().setTimeout("Zurueck();",50);
			if( !this.isOnUnload_inOrdnung() ) {
				this.removeAllMenuePunkt();
			}
		} else {
			if( !Lib_menu.getFrame("FRmenu").parent.grosse_bild ) {
				Lib_menu.setFrame("FRtree",parent.createFRTree());
				Lib_menu.TreeReload();
				Lib_menu.getFrame("FRtree").focus();
			}
		}
	} else if( obj.typ=="menu" ) {
		if( !Lib_menu.getFrame("FRmenu").parent.grosse_bild ) {
			Lib_menu.setFrame("FRtree",parent.createFRTree());
			Lib_menu.TreeReload();
			Lib_menu.getFrame("FRtree").focus();
			Lib_menu.openMenu();
		}
	} else if( obj.typ=="hilfe" ) {
		this.getSteuerElements_Fenster().setTimeout("Hilfe_open();",50);
	} else if( obj.typ=="speich" ) {
		this.getSteuerElements_Fenster().setTimeout("INISpeich();",50);
	}
}
function MenueOben_setSelectedIndex(i) {
	this.SelectedIndex = i;
}
function MenueOben_getSelectedIndex() {
	return this.SelectedIndex;
}
/** button.abserver: null	- Standart Function
					Object	- wird Object[button.func]() gerufen
					"eval"	- wird nach 50 ms eval(button.func) gestartet
*/
function MenueOben_onClick(i) { // textButton
	this.setSelectedIndex(i);
	if( Lib_menu.getFrame("FRmenu").wahl_Zeiger ) {
		Lib_menu.getFrame("FRmenu").wahl_Zeiger(i,0,1,2);
	}

	var button = this.getMenuePunkt(i);
	if( button.abserver==null ) {
		this.MenueClickStandart(button);
	} else if( typeof(button.abserver)=="object" && 
				typeof(button.abserver[button.func])=="function" ) {
		button.abserver[button.func](button);
	} else if( button.abserver=="eval" ) {
		this.getSteuerElements_Fenster().setTimeout(button.func,50);
	} else {
		this.MenueClickStandart(button);
	}
}
function MenueOben_onChange(i,obj) { //SelectBox, TextBox
	var button = this.getMenuePunkt(i)
	button.object = obj;
	if( button.abserver!=null && typeof(button.abserver[button.func])=="function" ) {
		button.abserver[button.func](button);
	} else {
		this.MenueClickStandart(button);
	}
}
function MenueOben_getDefaultMenuePunkt() {
	for( var n=0; n<this.allObereMenuePunkts.length; n++ ) {
		if( this.allObereMenuePunkts[n].isDefault )
			return this.allObereMenuePunkts[n];
	}
	return null;
}
function MenueOben_getMenuePunkt(i) {
	if( typeof(i)=="string" ) {
		for( var n=0; n<this.allObereMenuePunkts.length; n++ ) {
			if( i==this.allObereMenuePunkts[n]["name"] )
				return this.allObereMenuePunkts[n];
		}
		return null;
	} else {
		return this.allObereMenuePunkts[i];
	}
}
function MenueOben_getMenuePunkts() {
	return this.allObereMenuePunkts;
}
function MenueOben_setVisible( isVisible ) {
	if( Lib_menu==null || typeof(Lib_menu)=="undefined" ) return;
	this.isVisible = isVisible;
	Lib_menu.getFrame("FRmenu").location.replace(Lib.getBVerz()+"/service/oben.htm");
}
function MenueOben_addMenuePunkt( menuePunkt ) {
	this.allObereMenuePunkts[this.allObereMenuePunkts.length] = menuePunkt;
	menuePunkt.parentMenue = this;
}
function MenueOben_setMenuePunkts( menuePunkts ) {
	this.allObereMenuePunkts = null;
	for( var i=0; i< menuePunkts.length; i++ ) {
		menuePunkts[i].parentMenue = this;
	}
	this.allObereMenuePunkts = menuePunkts;
}
function MenueOben_removeAllMenuePunkt(menuID) {
	if( menuID!=null ) {
		if( this.allObereMenuePunkts==null ||
			this.allObereMenuePunkts["menuID"]==null ||
			this.allObereMenuePunkts.menuID!=menuID ) return;
	}
		
	this.allObereMenuePunkts = null;
	this.allObereMenuePunkts = new Array();
	if( this.getSeite() == "menu.htm" ) {
		MenueOben.setVisible( true );
	}
}
function MenueOben_getHTML() {
	if( !this.isVisible ) return "";
	var ret='';
	if( typeof(this.allObereMenuePunkts)!="undefined" ) {
		var butt = this.allObereMenuePunkts;
		for( var i=0; i<butt.length; i++ ) {
			ret += '<td>';
			ret += butt[i].getHTML_Zelle( i );
			butt[i].i = i;
			ret += '</td>';
		}
	}
	ret = ret.split("__getBVerz__").join(Lib.getBVerz());
	return ret;
}
// Select/Text Box update
function MenueOben_ElementValuesCopy( from_bind_obj ) {
	if( typeof(this.allObereMenuePunkts)!="undefined" ) {
		var butt = this.allObereMenuePunkts;
		for( var i=0; i<butt.length; i++ ) {
			if( butt[i].typ=="obj_select" || butt[i].typ=="obj_text") {
				butt[i].valuesCopy(from_bind_obj);
			}
		}
	}
}


/**
	@param text Button-Text
	@param nr Nummer in Seiten-Array oder (-1), benutzt um Hintergrund und Kugel-Bilder zu steuern und bei weiter(nr) aufruf siehe MenueOben_MenueClickStandart()
	@param abserver Object der wird bei onclick oder onchange aufgerufen
	@param func Function-Name (string) von abserver-Object z.B. abserver[func]( MenuePunkt-Object )
	@param isMitBild true/false ob soll Kugel - Bild angezeigt werden (besonders wichtig für NS4)
	@param typ Menue-Art:"text", "obj_select", "obj_text", "zurueck", "hilfe", 
	@param bind_obj Object mit dem neue Object(wie Select/TextBox) gebunden ist von alten Formular
	@param obj_params Zusätzliche Parameter für INPUT-Object z.B.: " onblur=\"alert(1);\" size=\"10\" usw... aber keine onchange
	@param isClick true/false nur für "text"-Typ wichtig ob Menü kan gedruckt werden
	@param isStyle true/false nur für "text"-Typ wichtig ob Menü soll mit style sein
*/
function MenuePunkt( text, nr, abserver,func, isMitBild, typ, bind_obj, obj_params, isClick, isStyle, isDefault ) {
	this.text = text;
	this.obj_params = ((obj_params==null)?"":obj_params);
	this.isDefault = ((isDefault==null)?false:isDefault);
	switch( typ ) {
	case "text": this.getHTML = MenuePunkt_Text_getHTML;
				 break;
	case "label": this.getHTML = MenuePunkt_Label_getHTML;
				 break;
	case "obj_select": case "obj_text": 
				 this.bind_obj = bind_obj;
				 this.bind_obj.bind_obj = this;
				 this.name = bind_obj.name; // für Selectbox/Textbox
				if( typ=="obj_select" ) {
					this.valuesCopy = MenuePunkt_SelectBox_valuesCopy;
					this.getHTML = MenuePunkt_SelectBox_getHTML;
				}
				if( typ=="obj_text" ) {
					this.valuesCopy = MenuePunkt_TextBox_valuesCopy;
					this.getHTML = MenuePunkt_TextBox_getHTML;
				}
				break;
	case "zurueck": case "hilfe": case "speich": case "menu":
				this.getHTML = MenuePunkt_BildButt_getHTML;
				break;
	case "bild": this.getHTML = MenuePunkt_BildButt_getHTML;
				break;
	}
	this.nr = nr;

	this.abserver = abserver;
	this.func = func;

	this.isMitBild = ((isMitBild==null)?false:isMitBild);
	this.isClick = ((isClick==null)?true:isClick);
	this.isStyle = ((isStyle==null)?true:isStyle);
	this.typ = typ; // "text", "obj_select", "zurueck", "hilfe"
	this.parentMenue = null;
	
	this.getHTML_Zelle = MenueOben_getHTML_Zelle;
}
function MenueOben_getHTML_Zelle( i ) {
    var ret = "";
    var zelle_name;
	if( this.typ == "text" && this.nr >= 0) {
		zelle_name ='menu'+this.nr;
	}
	if( this.typ == "text" && this.isStyle ) {
		ret += '<table border="0"><tr><td valign="bottom" nowrap bgcolor="#cccccc" ';
	} else {
		ret += '<table border="0"><tr><td valign="bottom" nowrap ';
	}
	if( zelle_name!=null ) {
		 ret += 'id="'+zelle_name+'"';
	}
	ret += '>';
	ret += this.getHTML(i);
	ret += '</td></tr></table>';
	return ret;
}

function MenuePunkt_Label_getHTML(elemNr) {
    var ret = "";
    var styleClass = ' ';
    if( this.isStyle ) styleClass = ' class="menueOben" ';
    ret +='<font '+styleClass+'>&nbsp;'+this.text+'&nbsp;</font>';
    return ret;
}
function MenuePunkt_Text_getHTML(elemNr) {
    var ZeichenColor_Name, Bild_Name;
    if( this.nr >= 0 ) {
		ZeichenColor_Name = 'fmenu'+this.nr;
		Bild_Name = 'imenu'+this.nr;
    }
    var ret = "";
    if( this.isMitBild && Bild_Name!=null) {
		ret += '<img name="'+Bild_Name+'" src="__getBVerz__/mf/bilder/blank.gif" width="7" height="7" border="0">';
    }
    var styleClass = ' ';
    if( this.isStyle ) styleClass = ' class="menueOben_button" ';
    if( this.isClick ) {
		ret += '<a href="javascript:parent.MenueOben.onclick('+elemNr+');"';
	} else {
		ret += '<a href="javascript:return;"';
	}
    ret += styleClass+'><span '+styleClass;
    if( ZeichenColor_Name!=null )  ret += ' id="'+ZeichenColor_Name+'" ';
    ret += '>&nbsp;'+this.text+'&nbsp;</span></a>';
    return ret;
}
function MenuePunkt_BildButt_getHTML(elemNr) {
    var ret = "";
	ret += '<a href="javascript:parent.MenueOben.onclick('+elemNr+');">';
	switch( this.typ ) {
		case "zurueck": ret += '<img src="__getBVerz__/mf/bilder/zurueck.jpg" width="18" height="15" border="0" alt="'+this.text+'" title="'+this.text+'">'; break; //Zurück
		case "hilfe":	ret += '<img src="__getBVerz__/mf/bilder/hilfe.jpg" width="18" height="15" border="0" alt="'+this.text+'" title="'+this.text+'">'; break;	//Hilfe
		case "speich":	ret += '<img src="__getBVerz__/mf/bilder/Diskette.gif" width="15" height="15" border="0" alt="'+this.text+'" title="'+this.text+'">'; break; //Speichern
		case "menu":	ret += '<img src="__getBVerz__/mf/bilder/Menu.gif" width="15" height="15" border="0" alt="'+this.text+'" title="'+this.text+'">'; break; //Menüansicht
		case "bild":	ret += this.text; break; 
	}
	ret += '</a>';
	return ret;
}

function MenuePunkt_SelectBox_getHTML( elemNr ) {
	if( typeof(this.text)!="undefined" && this.text!=null ) {
		return this.text;
	}
    var ret = "";
	if( typeof(this.bind_obj)!="undefined" ) {
		ret += 	'<select name="'+this.name+'" size="1" onchange="parent.MenueOben.onchange(this.name, this);" ';
		ret +=  this.obj_params+'> ';

		/* Netscape 4 schlecht unterstützt Style*/
		if( Lib.browser.ie && Lib.browser.version_detail>=5 ) 
			ret = ret.split('<select').join('<select class="gh"');
		
		var opt;
		for( var i=0; i<this.bind_obj.options.length; i++ ) {
			opt = this.bind_obj.options[i];
			ret+= ' <option value="'+escape(opt.value)+'" ';
			if( opt.selected ) ret+=' selected ';
			ret+= '>'+opt.text+'</option>';
		}
		if( Lib.browser.ns4 && this.bind_obj.options.length<2 ) {
			for( var i=this.bind_obj.options.length; i<7; i++ ) {
				ret+= '<option></option>';
			}
		}
		ret += 	'</select> ';
	}
	return ret;
}
function is_SelectBox_valuesCopy_SelberWindows() {
	return ( Lib.browser.ie && (Lib.browser.version_detail>=5 ||
								Lib.browser.version_detail<5.1  ) );
}
function MenuePunkt_SelectBox_valuesCopy( from_bind_obj ) { // from_bind_obj=true/false
	var FRmenu = Lib_menu.getFrame("FRmenu");
	if( this.object==null && typeof(FRmenu.menu_layer)!="undefined" && 
		typeof(FRmenu.menu_layer.document.forms[0][this.name])!="undefined") {
		this.object = FRmenu.menu_layer.document.forms[0][this.name];
	}
	var obj;
	if( typeof(this.object)!="undefined" && typeof(this.bind_obj)!="undefined" ) {
		if( from_bind_obj ) {
			var opt;
			this.object.selectedIndex = -1;
			this.object.options.length = 0;
			if( is_SelectBox_valuesCopy_SelberWindows() ) {
				this.object.opt = new Array();
			}
			for( var i=0; i<this.bind_obj.options.length; i++ ) {
				opt = this.bind_obj.options[i];
				if( is_SelectBox_valuesCopy_SelberWindows()	) {
					this.object.opt[i]=new Array(opt.text,opt.value);
					if( opt.selected ) this.object.optIndex=i;
				} else {
					this.object.options[i] = new Option( opt.text, opt.value );
					this.object.options[i].selected = opt.selected;
				}
			}
			if( is_SelectBox_valuesCopy_SelberWindows()	) {
				FRmenu.setTimeout("setAllSel();",200);
			}
		} else {
			this.bind_obj.selectedIndex = this.object.selectedIndex;
		}
	}
}
/*
function MenuePunkt_SelectBox_valuesCopy( from_bind_obj ) { // from_bind_obj=true/false
	var FRmenu = Lib_menu.getFrame("FRmenu");
	if( this.object==null && typeof(FRmenu.menu_layer)!="undefined" && 
		typeof(FRmenu.menu_layer.document.forms[0][this.name])!="undefined") {
		this.object = FRmenu.menu_layer.document.forms[0][this.name];
	}
	if( typeof(this.object)!="undefined" && typeof(this.bind_obj)!="undefined" ) {
		if( from_bind_obj ) {
			var opt;
			this.object.selectedIndex = -1;
			this.object.options.length = 0;

			for( var i=0; i<this.bind_obj.options.length; i++ ) {
				opt = this.bind_obj.options[i];
				this.object.options[i] = new Option( opt.text, opt.value );
				this.object.options[i].selected = opt.selected;
			}
		} else {
			this.bind_obj.selectedIndex = this.object.selectedIndex;
		}
	}
}
*/
function MenuePunkt_TextBox_getHTML( elemNr ) {
	if( typeof(this.text)!="undefined" && this.text!=null ) {
		return this.text;
	}
	var ret = "";
	if( typeof(this.bind_obj)!="undefined" ) {
		ret += 	'<input name="'+this.name+'" onchange="parent.MenueOben.onchange(this.name, this);" ';
		if( typeof(this.bind_obj.size)!="undefined" && (""+this.obj_params).indexOf("size=")==-1 ) {
			ret += ' size="'+this.bind_obj.size+'" ';
		}
		ret += ' value="'+this.bind_obj.value+'" ';
		ret +=  this.obj_params+'> ';
	}
		/* Netscape 4 schlecht unterstützt Style*/
	if( Lib.browser.ie && Lib.browser.version_detail>=5 ) 
		ret = ret.split('<input').join('<input class="gh"');
	return ret;
}
function MenuePunkt_TextBox_valuesCopy( from_bind_obj ) { // from_bind_obj=true/false
	var FRmenu = Lib_menu.getFrame("FRmenu");
	if( this.object==null && typeof(FRmenu.menu_layer)!="undefined" && 
		typeof(FRmenu.menu_layer.document.forms[0][this.name])!="undefined") {
	}
	if( typeof(this.object)!="undefined" && typeof(this.bind_obj)!="undefined" ) {
		if( from_bind_obj ) {
			this.object.value = this.bind_obj.value;
		} else {
			this.bind_obj.value = this.object.value;
		}
	}
}
