//*********************************************************
//Author:        Credit Suisse Web Production, BGIC2, PR
//Erstellt:      27.01.03
//Änderungen: 	 07.05.03
//*********************************************************

/**********************************************************/
/* BrowserCheck                       			  */
/**********************************************************/
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.version = navigator.appVersion
this.v = parseInt(this.version)
this.ns = (this.b=="ns" && this.v>=4)
this.ns4 = (this.b=="ns" && this.v==4)
this.ns6 = (this.b=="ns" && this.v>=5)
this.ie = (this.b=="ie" && this.v>=4)
this.ie4 = (this.version.indexOf('MSIE 4')>0)
for (var i=5; i<10; i++) {
	if ((this.version.indexOf('MSIE '+i)>0)) { this.ie6 = (this.version.indexOf('MSIE '+i)>0); }
}
this.mac = (navigator.appVersion.indexOf("Mac") != -1)
this.min = (this.ns||this.ie)
}
is = new BrowserCheck();

/**********************************************************/
/* Globale Variabeln                        		  */
/**********************************************************/
var e = "ebene";
var a = "arrow";
var ebenenId = '';
var action = "";
var overLayer = '';
var statusWhite = 'YES';
var staticMenu = activMenu;
var staticSubmenu = activSubmenu;
var statusNav = 0;
var statusNavStatic = true;
var statusNavStatic1 = true;
var statusNavStatic2 = true;
var statusNavTemp = -1;
/* Var Includes */ 
var tableInclude = '';

/* Var Breiten und Grössen */  
var z = 60;
var wt1 = 4;
var wt2 = 5;
var wtNs = 144;
var htNs = 27; 
var htNsSub = 24;
var wt2Ns = 121;;

var wtIe = 144;
var htIe = 27;
var htIeSub = 24;
var wt2Ie = 128;

var special = 28;

buildNavigation(null,null);

/**********************************************************/
/* Logic - Bau DHTML Tei                                  */
/**********************************************************/ 
/* Div- oder Layer-Generierung */
function buildNavigation(activmenu,activsubmenu){

getMore(activmenu,activsubmenu);
	
/* Klick auf Main- oder Submenu */
	var position = contentY; 
	for (var menueNr = 0; menueNr < menu.length; menueNr++) // with (menu[menueNr][0])
	{
		for (var subMenueNr in menu[menueNr])
		{ 
			/* Main-/Submenu activ */
			if (activMenu == menueNr && activMenu >= 0 && activSubmenu != -1) {  	
				if (subMenueNr > 0) {
					if (subMenueNr == activSubmenu) { 
						if (activmenu != null) { showLayer(menueNr,subMenueNr,"active",position += special); }
					        else { printMenu(menueNr,subMenueNr,"active",position += special); }
					}
					else { 
						if (activmenu != null) { showLayer(menueNr,subMenueNr,"inactive",position += special); }
						else { printMenu(menueNr,subMenueNr,"inactive",position += special); }
					}
					statusNav += 1;
				}
				else { 
					if (activmenu != null) { showLayer(menueNr,subMenueNr,"active",position += special); }
					else { printMenu(menueNr,subMenueNr,"active",position += special); }
				}					
			}
			/* Main-/Submenu inactiv */
			else {	 				
				if (subMenueNr > 0) {
					if (activmenu != null) { hideLayer(menueNr,subMenueNr,"hidden",position); }
					else { printMenu(menueNr,subMenueNr,"hidden",position); }
					statusNav += 0;
				}
				else {
					if (activmenu != null) { showLayer(menueNr,subMenueNr,"inactive",position += special); }
					else { printMenu(menueNr,subMenueNr,"inactive",position += special); }				
				}
			}
		}
	}
/* Gibt Menu aus, nach dem HTML Code generiert wurde */	
	if (activmenu == null) { document.write(tableInclude); position = 0; }
}

/* Klick auf Submenu - Ergänzung */
function getMore(activmenu,activsubmenu) {
	if (activmenu != null) {	
		if(statusNavStatic == false) { statusNavStatic1 = false; }
		else if (statusNavStatic == true) { statusNavStatic2 = false; }		
		
		if (staticMenu == activmenu) {	
			if (statusNav > 0 && statusNavStatic1 == true) { activMenu = activmenu; activSubmenu = -1; statusNavStatic1 = false; }
			else { activMenu = activmenu; activSubmenu = 0; statusNavStatic1 = true;  }
			statusNavStatic = true;
		}
		else { 
			if (statusNavTemp == activmenu) {	
				if (statusNav > 0 && statusNavStatic2 == true) { activMenu = activmenu; activSubmenu = -1; statusNavStatic2 = false; }
				else { activMenu = activmenu; activSubmenu = 0; statusNavStatic2 = true; }
			}
			else {
				statusNavStatic2 == false; activMenu = activmenu; activSubmenu = 0; statusNavStatic2 = true; statusNavTemp = activmenu;
			}
			statusNavStatic = false;
		}
		statusNav = 0;
	}
}

/**********************************************************/
/* HTML Code                                     	  */
/**********************************************************/ 
function printMenu(menueNr,subMenueNr,activStatus,position) {
	ebeneId = e+menueNr+subMenueNr;
	var arrowId = a+menueNr+subMenueNr;
		if(is.ns4)
		{
			tableInclude += '<layer id="' +ebeneId+ '" left="' +contentX+ '" top="' +position+ '" width="' +getWidth(subMenueNr)+ '" height="' +getHeight(subMenueNr)+ '" z-index=' +z+ ' bgcolor="' +getColor(menueNr,subMenueNr,activStatus)+ '" visibility="' +getVisibility(menueNr,subMenueNr,activStatus)+ '" class="' + naviBorder + '" ';
		}
		else
		{
			tableInclude += '<div id="' +ebeneId+ '" style="position:absolute; top: ' +position+ 'px; left: ' +contentX+ 'px; width=' +getWidth(subMenueNr)+ 'px; height=' +getHeight(ebeneId,subMenueNr)+ 'px; z-index:' +z+ '; background-color:' +getColor(menueNr,subMenueNr,activStatus)+ '; visibility:' +getVisibility(menueNr,subMenueNr,activStatus)+ '; '; 
				if (menu[menueNr][subMenueNr].temphref == null) {tableInclude += '";'} 
				else{
					if (is.ns6){tableInclude += 'cursor:pointer;" '} 
					else {tableInclude += 'cursor:hand;" '} 
				}
			tableInclude += ' class="' +naviBorder+ '" ';
		}
				if (menu[menueNr][subMenueNr].temphref == null) {tableInclude += ''} 
				else {	tableInclude += 'onMouseOver="mouseOver(' +menueNr+ ',' +subMenueNr+ ');self.status=' + getStatus(menueNr,subMenueNr,menu[menueNr][subMenueNr].frame)+ ';return true;" onMouseOut="mouseOut(' +menueNr + ',' + subMenueNr + ');window.status =\'\';return true;" ';
					if (subMenueNr > 0) { tableInclude += 'onClick="' + getAction(menueNr,subMenueNr,menu[menueNr][subMenueNr].frame) + '" '; }
					else { tableInclude += 'onClick="buildNavigation(' +menueNr+ ',0);" '; }				
				}
		tableInclude += '>';
		tableInclude += '<table width="' +getWidth(subMenueNr)+ '" height="' +getHeight(ebeneId,subMenueNr)+ '" border="0" cellspacing="0" cellpadding="0">';
    		tableInclude += '<tr>';
		tableInclude += '<td width="' +wt1+ '">&nbsp;</td>';
		tableInclude += '<td height="' +getHeight(ebeneId,subMenueNr)+ '" width="' +getWidth2(subMenueNr)+ '" align="left" valign="middle" ';
				if (menueNr < 1) {tableInclude += '';} else {tableInclude += 'colspan="2"';}
				if (menu[menueNr][subMenueNr].temphref != null) 
					{
						if (is.ns4) { 
							tableInclude += '><a class="' +getFont(menueNr,subMenueNr,activStatus)+ '"  '; 
							if (is.mac){
								if (subMenueNr > 0) {
									tableInclude += 'href="';
									if (menu[menueNr][subMenueNr].frame == null)  { tableInclude += 'javascript:void(0)'; }
									else { tableInclude += menu[menueNr][subMenueNr].temphref; }
									tableInclude += '" onClick="' +getAction(menueNr,subMenueNr,menu[menueNr][subMenueNr].frame)+ '" ';
								}
								else {
									tableInclude += 'href="javascript:buildNavigation(' +menueNr+ ',0);" '; 
								}
							} else { 
								if (subMenueNr > 0) {
									tableInclude += 'href="';
									if (menu[menueNr][subMenueNr].frame == null) { tableInclude += 'javascript:void(0)'; }
									else { tableInclude += menu[menueNr][subMenueNr].temphref; }
									tableInclude += '" onClick="' +getAction(menueNr,subMenueNr,menu[menueNr][subMenueNr].frame)+ '" ';
								}
								else {
									tableInclude += 'href="javascript:buildNavigation(' +menueNr+ ',0);" '; 
								}
							}
							(subMenueNr > 0) ? tableInclude += '>&nbsp;&nbsp;&nbsp;' +menu[menueNr][subMenueNr].temptext+ '</a>'  : tableInclude += '>' +menu[menueNr][subMenueNr].temptext+ '</a>'; 
						} else {
							tableInclude += ' class="' +getFont(menueNr,subMenueNr,activStatus)+ '">';
							(subMenueNr > 0) ? tableInclude += '&nbsp;&nbsp;&nbsp;' +menu[menueNr][subMenueNr].temptext+ '</a>'  : tableInclude += menu[menueNr][subMenueNr].temptext+ '</a>'; 
						}
					} 
				else 	{
						tableInclude += ' class="' +classInactiv+ '">'; 
						(subMenueNr > 0) ? tableInclude += '&nbsp;&nbsp;&nbsp;' +menu[menueNr][subMenueNr].temptext+ '</a>'  : tableInclude += menu[menueNr][subMenueNr].temptext+ '</a>';
					}
		tableInclude += '</td>';
				if (subMenueNr < 1) {
					if(activMenu == menueNr && activStatus != "inactive"){
						tableInclude += '<td width="7" align="left"><img name="'+arrowId+'" src="'+arrowImgR+'" width="7" height="6"></td>';}
					else if((homeWhite == statusWhite)&&(menueNr == 0)){
						tableInclude += '<td width="7" align="center"><img name="'+arrowId+'" src="'+arrowImgW+'" width="7" height="6"></td>';}
					else if(menu[menueNr][subMenueNr].temphref == null){
						tableInclude += '<td width="7" align="center"><img name="'+arrowId+'" src="'+arrowImgG+'" width="7" height="6"></td>';}
					else {
						tableInclude += '<td width="7" align="center"><img name="'+arrowId+'" src="'+arrowImg+'" width="7" height="6"></td>';} 
				} else {tableInclude += '';}
		tableInclude += '<td width="' +wt2+ '"><img src="'+spacerImg+'" width="' +wt2+ '" height="1"></td>';
		tableInclude += '</tr>';
		tableInclude += '</table>';
		tableInclude += (is.ns4 ? '</layer>' : '</div>');
		
}

/**********************************************************/
/* Show und Hide Navigation                   		  */  
/**********************************************************/ 
/* Zeigt Main-Layer und ausgewählte Sublevel('active' und 'inactive') */
function showLayer(menueNr,subMenueNr,navStatus,position) {	
	ebeneId = e+menueNr+subMenueNr;
	var arrowSrc = '';
	
	if (subMenueNr == 0) { arrowSrc = eval("document."+a+menueNr+subMenueNr); }	
	if (is.ns4){
		document.layers[ebeneId].top = position;
		if (subMenueNr < 1 && navStatus == "active") { arrowSrc.src = arrowImgR; }
		else if (subMenueNr == 0  && navStatus == "inactive") { arrowSrc.src = arrowImg; }			
		document.layers[ebeneId].visibility = "show";
	}
	if (is.ie4){
		if (subMenueNr < 1 && navStatus == "active") { arrowSrc.src = arrowImgR; }
		else if (subMenueNr == 0  && navStatus == "inactive") { arrowSrc.src = arrowImg; }
		document.all[ebeneId].style.top = position;
		document.all[ebeneId].style.visibility = "visible";
	}
	if ((is.ns6)||(is.ie6)){ 
		if (subMenueNr < 1 && navStatus == "active") { arrowSrc.src = arrowImgR; }
		else if (subMenueNr == 0  && navStatus == "inactive") { arrowSrc.src = arrowImg; }
		document.getElementById(ebeneId).style.top = position+"px";
		document.getElementById(ebeneId).style.visibility = "visible";
	}	
}
/* Versteckt alle Sublevel('hidden') */
function hideLayer(menueNr,subMenueNr,navStatus,position) {	
	ebeneId = e+menueNr+subMenueNr;
	if (is.ns4){
		document.layers[ebeneId].top = position;
		document.layers[ebeneId].visibility = "hide";					
	}
	if (is.ie4){
		document.all[ebeneId].style.top = position;
		document.all[ebeneId].style.visibility = "hidden";
	}
	if ((is.ns6)||(is.ie6)){
		document.getElementById(ebeneId).style.top = position+"px";
		document.getElementById(ebeneId).style.visibility = "hidden";
	}			
}

/**********************************************************/
/* MouseOver, MouseOut Steuerung                     	  */
/**********************************************************/ 
function mouseOver(menueNr,subMenueNr)
{ changeColor((e+menueNr+subMenueNr), subMenueNr, true, null); }

function mouseOut(menueNr,subMenueNr)
{ bgColorBefore = getColor(menueNr,subMenueNr); changeColor((e+menueNr+subMenueNr), subMenueNr, false, bgColorBefore); }

function changeColor(menueNr,subMenueNr, overLayer, bgColorBefore){
    	if ((is.ns4)&&(overLayer == true)){ document.layers[menueNr].bgColor = highlight; }
    	if ((is.ns4)&&(overLayer == false)){ document.layers[menueNr].bgColor = bgColorBefore; }
	
	if ((is.ie4)&&(overLayer == true)){ document.all[menueNr].style.backgroundColor = highlight; }
	if ((is.ie4)&&(overLayer == false)){ document.all[menueNr].style.backgroundColor = bgColorBefore; }
	
	if (((is.ns6)||(is.ie6))&&(overLayer == true)){ document.getElementById(menueNr).style.backgroundColor = highlight; }
	if (((is.ns6)||(is.ie6))&&(overLayer == false)){ document.getElementById(menueNr).style.backgroundColor = bgColorBefore; }
}
	
/**********************************************************/
/* Hilfe Funktionen für HTML Code	                  */       
/**********************************************************/ 
/* Bei Print - setzen des Hide/Show-Status */
function getVisibility(menueNr,subMenueNr,activStatus)
{ 
	if (subMenueNr == 0){ 
		if (is.ns4){ return('show'); }
		else { return('visible'); }
	} 
	else { 
		if (activStatus == "hidden") { 
			if (is.ns4){ return('hide'); } 
			return('hidden');
		}
		else {
			if (is.ns4){ return('show'); } 
			return('visible');		
		}
	}
}
/* Bei Print - setzen des Fonts, falls Main- und Sublevel verschieden */
function getFont(menueNr,subMenueNr,activStatus)
{
	if (subMenueNr < 1){ 
		if ((homeWhite == statusWhite)&&(menueNr == 0)) { return(classWhite); }
		return(classOld); 
	}
	else { return(classOldSub); }
}

function getWidth(subMenueNr){
	if (is.ns4) { return(wtNs); }	
	else { return(wtIe); }
}
function getWidth2(subMenueNr){
	if (is.ns4) { 
		if (subMenueNr > 0) { return(wtNs+7); }
		else { return(wtNs); }
	}
	else { 
		if (subMenueNr > 0) { return(wt2Ie+7); }
		else { return(wt2Ie); }
	}
}
function getHeight(ebeneId,subMenueNr){
	if (is.ns4) { return(htNs); }	
	else { return(htIe); }	
}

/* Bei Print - setzt Text für Statusbox */
function getStatus(menueNr,subMenueNr,status)
{
	var linkStatus = menu[menueNr][subMenueNr].temphref;
	if ((status == "_top")||(status == "_blank")){ 
		if (linkStatus.indexOf('http://') >= 0){ linkStatus = "'" +linkStatus+ "'"; return(linkStatus); }
		else { linkStatus = "'" +linkStatus+ "'"; return(linkStatus); }
	} else { return("'CSPB:javascript:'"); }
}
/* Bei Print - setzt Link (Linkart) */
function getAction(menueNr,subMenueNr,action)
{
var js = "javascript:";
var link = menu[menueNr][subMenueNr].temphref;
	if (action == "_top"){
		if (link.indexOf("http") >= 0){ return("document.location.href = '"+ link +"'"); }
		else { return("document.location.href = '"+link+"'"); }
	}
	if (action == "_blank"){ 
		if (link.indexOf("http") >= 0){ return("window.open('"+link+"')"); }
		else { return("window.open('"+link+"')"); }
	}
	else { return(js+link); }
}
/* Bei Print - setzt Layerfarbe */
function getColor(menueNr,subMenueNr,activStatus){
	if (menu[menueNr][subMenueNr].temphref == null){
		return(bgColorInactive);
	}
	if (subMenueNr > 0) { 
		if ((activMenu == menueNr && activSubmenu == subMenueNr) || (staticMenu == menueNr && staticSubmenu == subMenueNr)) { return(bgColorSubActivClick); }
		else { return(bgColorSubActiv); }
	} else { return(bgColor0); }
}
