//browser
function makeBrowser(){

	this.ver=navigator.appVersion
	this.dom=document.getElementById?1:0
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
	this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom)?1:0;
	this.ie4=(document.all && !this.dom)?1:0;
	this.ns6=(this.dom && !document.all)?1:0;
	this.ns5=(this.dom && parseInt(this.ver) >= 5 && !this.ver.indexOf("Netscape6")) ?1:0;
	this.ns4=(document.layers && !this.dom)?1:0;
    this.opera = (navigator.userAgent.indexOf("Opera") != -1);
	if (this.ie6) this.ie5=true;
	this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5 || this.ns6 || this.opera);
	return this;
}
bw=new makeBrowser();

//standard variables
var mac = (navigator.appVersion.indexOf("Mac") != -1);
var ie = (bw.ie4 || bw.ie5);
var iepc = ie && (!mac);
var iemac = ie && (mac);
var ns = (bw.ns4);

var mpassive;
var smpassive;

//Menue/Untermenues einlesen und erzeugen

function Entry (label, url, i) 
{
	this.label = label;
	this.url = url;
	this.i = i;
	this.renderItem	= renderItem;
}

function SubEntry (sublabel, suburl, i) 
{
	this.label = sublabel;
	this.url	= suburl;
	this.i = i;
	this.renderSubItem = renderSubItem;
}

var smen = 0;//Nummer Hauptmenuepunkt mit Untermenue geoeffnet?

var rspace = new Array(42,20,8,6,11,26); // (Abstand der Menueeintraege von der gedachten Vertikale der rechten Aussenseite des Bogens in pixel für menuepunkt 1, menupunkt2, ...,menupunktx)
var rspace2 = new Array(42,20,6,8,20,41); // alternativ bei offenen submenues
var rspace3 = new Array(42,20,6,8,19,3);
var rspace6 = new Array(42,20,6,5,11,6);



//Erzeuge einzelnen Hauptmenuepunkt (aktiv/passiv ensprechend Variable 'mpassive' auf der Seite)
function renderItem () 
{
	var mnow = 0;
	if(this.i == mpassive) mnow = 1;
	if(smen){
		if (smen == 2) var space = rspace2[this.i];
		else if (smen == 3) var space = rspace3[this.i];
		else if (smen == 6) var space = rspace6[this.i];
	}
	else var space = rspace[this.i];
	var html = "";
	html += '<tr>\n<td valign="top"><img src="pixel.gif" width="1" height="40"></td>\n';
	html += '</tr>\n';
	html += '<tr>\n';
	html += (mnow)?'<td valign="top" class="mtxt">' + this.label + '<img src="../shared/mstrich.gif" width="22" height="12"><img src="pixel.gif" width="' + space + '" height="1"></td>\n':'<td valign="top" class="rechts"><a href="' + this.url + '" class="mmen">' + this.label + '</a><img src="../shared/mstrich.gif" width="22" height="12"><img src="pixel.gif" width="' + space + '" height="1"></td>\n';
	html += '</tr>\n';


	return (html);
}

//Erzeuge einzelnen Submenuepunkt (aktiv/passiv ensprechend Variable 'smpassive' auf der Seite)
function renderSubItem () 
{
	var smnow = 0;
	if(this.i == smpassive) smnow = 1;
	var html = "";
	html += '<tr>\n';
	html += (smnow)?'<td valign="top" class="mtxt">' + this.label + '</td>\n<td valign="top"><img src="../shared/smen_pt.gif" width="23" height="14"></td>\n':'<td valign="top" class="rechts"><a href="' + this.url + '" class="mmen">' + this.label + '</a></td>\n<td valign="top"><img src="../shared/smen_pt.gif" width="23" height="14"></td>\n';
	html += '</tr>\n';

	return (html);
}

//Erzeuge gesamtes Menu (mit Submenue, enstprechend Funktionsaufruf (renderMenu()) mit Var-uebergabe oder ohne
function renderMenu(me) 
{
	var html = '<table width="219" border="0" cellspacing="0" cellpadding="0">\n';
	html += '<tr><td valign="top"><img src="pixel.gif" width="219" height="1"></td></tr>\n';
	if (!me) {
		var menu = getMenuEntries();	
		for (i = 0; i < menu.length; i++) {
			html += menu[i].renderItem();		
		}
		html += '</table>\n';
		return (html);
	}
	else if (me) {

		smen = me;
		if (me == 2) var submenu = getSecurity(); //Aufruf auf Seite: renderMenu(3);
		if (me == 3) var submenu = getManagement();
		if (me == 6) var submenu = getVeranstaltung(); //Aufruf auf Seite: renderMenu(6);
	
				
		var menu = getMenuEntries();	
		
		for (i = 0; i < me; i++) {
			html += menu[i].renderItem (i);		
		}
		
		html += '<tr>\n<td valign="top">\n';
		html += '<table width="219" border="0" cellspacing="0" cellpadding="0">\n';
		html += '<tr>\n<td valign="top"><img src="pixel.gif" width="144" height="1"></td>\n<td valign="top"><img src="pixel.gif" width="75" height="6"></td>\n</tr>\n';
		html += '<!-- tr>\n<td valign="top"><img src="pixel.gif" width="144" height="1"></td>\n<td valign="top"><img src="../shared/smen_top.gif" width="23" height="14"></td>\n</tr -->\n';
		
		for (i = 0; i < submenu.length; i++) {
			html += submenu[i].renderSubItem (i);
			}
		
		html += '\n</table>\n';
		html += '</td>\n</tr>\n';
		
		for (i = me; i < menu.length; i++) {
			html += menu[i].renderItem (i);		
		}

		html += '<tr><td valign="top"><img src="pixel.gif" width="219" height="1"></td></tr>\n';
		html += '</table>\n';
		//alert(html);
		return (html);
	}
	else return;
}

//layerhandling

function getLayerStyleRef(lname){

	if (bw.ie4 || iemac)	if (document.all[lname]) return (document.all[lname].style);
	if (bw.ns4)	return (document.layers[lname]);
	if (bw.ie5 || bw.ns6) if (document.getElementById(lname)) return (document.getElementById(lname).style);
	return null;
}

function getLayerRef(lname){

	if (bw.ie4 || iemac) if (document.all[lname]) return (document.all[lname]);
	if (bw.ns4)	return (document.layers[lname]);
	if (bw.ie5 || bw.ns6) if (document.getElementById(lname)) return (document.getElementById(lname));
	return null;
}

//Menue positionieren wg. Groessenaenderung Fenster
var mylay = "menu";
var LayerTimer = 0;

function openLayer () {
	var ref = getLayerRef(mylay);
	
	if (LayerTimer) {
		clearTimeout (LayerTimer)
		LayerTimer = 0;
	}
	if (bw.ns4) {
		w=window.innerWidth-16;
		ref.left=parseInt(((w-900)/2));
		if (w < 900) ref.left = 0;
		ref.visibility = "show";
	} 
	else if (bw.ns6 || bw.opera){
		w=window.innerWidth;
		ref.style.left=parseInt(((w-900)/2));
		if (w < 900) ref.style.left = 0;
		ref.style.visibility = "visible";
	}
	else {
		w=document.body.clientWidth;
		ref.style.left=parseInt(((w-900)/2));
		if (w < 900) ref.style.left = 0;
		ref.style.visibility = "visible";
	}  
	LayerTimer=setTimeout("openLayer()", 200);
}

//other

//Bilderwechsel
function cimg(bname,bild){
	document.images[bname].src=bild;
}

//Infofenster oeffnen
var info = 0; //Infofenster: Standard=geschlossen.
var infowin;
function openWin(me,pnr){
	
	
	if (me == "kontakt"){
		// WEGEN 1 und 1 UMZUG //TODO Heiko am 24.03.2003//SCRIPT fuür ales Formular anlegen
		var url = "../tinc?key=em5uGCYK";
		var name = "kontakt";
		var params = "width=557,height=575,left=10,top=12,resizable=1,status=0,scrollbars=0,toolbar=0,location=0,directories=0,menubar=0";
	}
	else if (me == "angebotsanforderung"){
		var url = "../sec_products/formular3.htm";
		var name = "angebotsanforderung";
		var params = "width=557,height=600,left=10,top=12,resizable=1,status=0,scrollbars=0,toolbar=0,location=0,directories=0,menubar=0";
	}	
	else if (me == "zugangsdaten"){
		var url = "../veranstaltung/formular2.htm";
		var name = "zugangsdaten";
		var params = "width=557,height=600,left=10,top=12,resizable=1,status=0,scrollbars=0,toolbar=0,location=0,directories=0,menubar=0";
	}	
	else if (me == "anfahrt"){
		var url = "../kontakt/anfahrt.htm";
		var name = "anfahrt";
		var params = "width=460,height=362,left=10,top=12,resizable=0,status=0,scrollbars=0,toolbar=0,location=0,directories=0,menubar=0";
	}
	else if (me == "szenario"){
		var url = "../sec_prod_szenario/"+pnr+"_szen.htm";
		var name = "projekt";
		var params = "width=700,height=532,left=10,top=12,resizable=0,status=0,scrollbars=0,toolbar=0,location=0,directories=0,menubar=0";
	}	
	else return;	
	infowin = window.open(url, name, params); //Infofenster: oeffnen.
	info = 1;
}

//Infofenster ggf. wieder schliessen
function chckinfo(){
	if (info){info=0;infowin.close();}
	else return;
}

// Netscape resize fix
function netscapeResizeFix () {

	if (typeof (ns_origWidth) != "number" || typeof (ns_origHeight) != "number") return;
	if (innerWidth != ns_origWidth || innerHeight != ns_origHeight) location.reload();
}

if (bw.ns4) {
	ns_origWidth = innerWidth;
	ns_origHeight = innerHeight;
	onresize = netscapeResizeFix;
}