// ********************************************
// Farbaustausch für Subnavigation
// ********************************************



var BGColorDefault = new Array();
var BGColorHighlight = new Array();
var BGColorActive = new Array();
var CurMenuItemID = new Array();


// Hauptnavigation links
BGColorDefault [0] = '#153B63';
BGColorHighlight [0] = '#1B528C';
BGColorActive [0] = '#2269B5';
CurMenuItemID [0] = '';

// Unterkategorie-Navigation rechts
BGColorDefault [1]= '#B4C6D9';
BGColorHighlight [1] = '#A0B7CF';
BGColorActive [1]= '#8CA8C5';
CurMenuItemID [1] = '';

// Produkt-Navigation rechts
BGColorDefault [2]= '#B4C6D9';
BGColorHighlight [2] = '#A0B7CF';
BGColorActive [2]= '#8CA8C5';
CurMenuItemID [2] = '';

// Produkdaten-Kategorie-Navigation mitte
BGColorDefault [3] = '#FFFFFF';
BGColorHighlight [3] = '#A0B7CF';
BGColorActive [3] = '#DFE9F4';
CurMenuItemID [3] = '';

var winEdit = false;
var curEditMenuId = null;

document.write ('<style type="text/css">.script { display: block; }</style>');


function MenuHighlight (MenuItemID, Highlight, MenuID) { // Farbaustausch Mouseover

	var Color = Highlight ? BGColorHighlight [MenuID] : BGColorDefault [MenuID];

	if (document.all) {
		var DocMenuItemTD = document.all['menu' + MenuID + 'td' + MenuItemID];
		var DocMenuItemTDp = document.all['menu' + MenuID + 'td' + MenuItemID + 'p'];
		if (DocMenuItemTD && (MenuItemID != CurMenuItemID [MenuID]) ) {
			DocMenuItemTD.style.backgroundColor = Color;
			DocMenuItemTDp.style.backgroundColor = Color;
		}
	}

	if ( (document.getElementsByTagName) && (document.getElementsByTagName('body') ) && (MenuItemID != CurMenuItemID [MenuID]) ) {
		var DocMenuItemP = document.getElementById ('menu' + MenuID + MenuItemID);
		if (DocMenuItemP) DocMenuItemP.style.backgroundColor = Color;
	}

} // function MenuHighlight


function PageStartup (MenuItemID, MenuID) {

	CurMenuItemID [MenuID] = MenuItemID;
	if (document.all && (navigator.userAgent.indexOf ('Opera') < 0) ) {
		var DocMenuItemTD = document.all['menu' + MenuID + 'td' + MenuItemID];
		var DocMenuItemTDp = document.all['menu' + MenuID + 'td' + MenuItemID + 'p'];
		if (DocMenuItemTD != null) {
			DocMenuItemTD.style.backgroundColor = BGColorActive [MenuID];
			DocMenuItemTDp.style.backgroundColor = BGColorActive [MenuID];
		}
	}

	if ( (document.getElementsByTagName) && (document.getElementsByTagName('body') ) ) {
		var DocMenuItemP = document.getElementById ('menu' + MenuID + MenuItemID);
		if (DocMenuItemP) DocMenuItemP.style.backgroundColor = BGColorActive [MenuID];
	}

} // function PageStartup



function naviStartup () {

	// Publication 5: Aufklapp-Navigationspunkte finden und einrichten
	var naviItemIsOpen;

	if ( (document.getElementsByTagName) && (document.getElementById ('navigation') ) ) {
		var naviListItems = document.getElementById ('navigation').getElementsByTagName ('li');
		for (var i = 0; i < naviListItems.length; i++) {
			if (naviListItems[i].getElementsByTagName('ul').length > 0) {
				naviListItems[i].getElementsByTagName ('a')[0].onclick = naviEvent;
				naviItemIsOpen = false;
				for (var l = 0; l < naviListItems[i].getElementsByTagName ('p').length; l++) {
					if (naviListItems[i].getElementsByTagName ('p')[l].className == 'highlight') naviItemIsOpen = true;
				}
				if (!naviItemIsOpen)
					naviListItems[i].getElementsByTagName ('ul')[0].className = 'nodisplay';
				else {
					naviItemImgSrc = naviListItems[i].getElementsByTagName ('img')[0].src;
					naviListItems[i].getElementsByTagName ('img')[0].src = naviItemImgSrc.substring (0, naviItemImgSrc.lastIndexOf ('/') + 1 ) + 'arrow-down.gif';
				}
			} // if (naviListItems[i].getElementsByTagName('ul').length > 0)
		} // for (var i = 0; i < naviListItems.length
	} // if (document.getElementsByTagName != null)

} // function naviStartup


function naviEvent (e) {
// Navigation auf-/zuklappen

	if (e != null) { // Mozilla/Opera
		eventType = e.type;
		eventAnchor = e.currentTarget;
	}	else { // IE/Opera
		eventType = event.type;
		eventAnchor = event.srcElement;
		if ( (event.ctrlKey) && (eventAnchor.href.indexOf ('editAttribute') > -1) ) return true;
	}

	if (eventType == 'click') {
		var myself = eventAnchor.parentNode.parentNode;
		var naviListItems = myself.parentNode.getElementsByTagName ('li');

		for (var i=0; i<naviListItems.length; i++) {
			if (naviListItems[i].parentNode == myself.parentNode)
				if (naviListItems[i] != myself) {
					naviListItems[i].getElementsByTagName('ul')[0].className = 'nodisplay';
					var naviItemImgSrc = naviListItems[i].getElementsByTagName('img')[0].src;
					naviListItems[i].getElementsByTagName('img')[0].src = naviItemImgSrc.substring (0, naviItemImgSrc.lastIndexOf ('/') + 1 ) + 'arrow-right.gif';
				} else {
					var naviItemOpen = (eventAnchor.parentNode.parentNode.getElementsByTagName ('ul')[0].className == 'nodisplay') ? false : true;
					var naviItemImgSrc = (eventAnchor.parentNode.getElementsByTagName ('img')[0].src);
					naviItemImgSrc = naviItemImgSrc.substring (0, naviItemImgSrc.lastIndexOf ('/') + 1 ) + (naviItemOpen ? 'arrow-right.gif' : 'arrow-down.gif');
					eventAnchor.parentNode.getElementsByTagName ('img')[0].src = naviItemImgSrc;
					eventAnchor.parentNode.parentNode.getElementsByTagName ('ul')[0].className = naviItemOpen ? 'nodisplay' : 'blockdisplay';
				}

		}

/*
		var naviItemOpen = (eventAnchor.parentNode.parentNode.getElementsByTagName ('ul')[0].className == 'nodisplay') ? false : true;
		var naviItemImgSrc = (eventAnchor.parentNode.getElementsByTagName ('img')[0].src);
		naviItemImgSrc = naviItemImgSrc.substring (0, naviItemImgSrc.lastIndexOf ('/') + 1 ) + (naviItemOpen ? 'arrow-right.gif' : 'arrow-down.gif');
		eventAnchor.parentNode.getElementsByTagName ('img')[0].src = naviItemImgSrc;
		eventAnchor.parentNode.parentNode.getElementsByTagName ('ul')[0].className = naviItemOpen ? 'nodisplay' : 'blockdisplay';
*/
	}

	if (e != null) {
		E.stopPropagation();
	}

	return false;

} // function naviEvent

/* -----------------------------------

	Funktion zum Aufklappen/Schliessen Navigation

----------------------------------- */
function navClick (level,DivMenuID, editmode) {

	var curDiv, curArrow, clName;

	if(editmode == false) {
		return;
	}
	else {
		curDiv = document.getElementById("menu0" + DivMenuID + "div");
		curP = document.getElementById("menu0" + DivMenuID);
		if( (curDiv == null) || (curDiv.childNodes.length == 0) )
			return true;
		else {
			curArrow = curP.getElementsByTagName ('IMG')[0];
			clName = document.getElementById("menu0" + DivMenuID + "div").className;
			if(clName == 'selectedfalse') {
				document.getElementById("menu0" + DivMenuID + "div").className = "selectedtrue";
				curArrow.src = curArrow.src.replace ('right', 'down');
			}
			else {
				document.getElementById("menu0" + DivMenuID + "div").className = "selectedfalse";
				curArrow.src = curArrow.src.replace ('down', 'right');
		}
			return false;
		}
	}
}

/* -----------------------------------

	 Funktionen für Such-Formular

----------------------------------- */

function submitForm () {

	searchWin = openWindow (globalNeutralRoot + '/program/blank.htm', 438, 410, 20, 20, 'searchwin', wReturnWinHandle, wScrollBars + wResizable + wMenuBar + wLocationBar + wStatusBar);
	document.forms.searchform.submit ();
	searchWin.focus();
	return true;

} // function submitForm

/* -----------------------------------
	function openWindow
	Opens popup windows using additional parameters
	2006-10-12 whe Added parametes wToolBar, wBookmarks, wHotkeys. Replaced openWindowV2 calls
----------------------------------- */

var wScrollBars = 1;
var wResizable = 2;
var wLocationBar = 4;
var wMenuBar = 8;
var wStatusBar = 16;
var wDependent = 32;
var wReturnWinHandle = 64;
var wSetFocus = 128;
var wToolBar = 256;
var wBookmarks = 512;
var wHotkeys = 1024;

function openWindow (winUrl, winWidth, winHeight, winX, winY, winName, winPropsEnable, winPropsDisable) {

	var winParameters = 
		( (winPropsEnable & wDependent) ? 'dependent=yes,' : ( (winPropsDisable & wDependent) ? 'dependent=no,' : '' ) ) +
		( (winPropsEnable & wResizable) ? 'resizable=yes,' : ( (winPropsDisable & wResizable) ? 'resizable=no,' : '' ) ) +
		( (winPropsEnable & wScrollBars) ? 'scrollbars=yes,' : ( (winPropsDisable & wScrollBars) ? 'scrollbars=no,' : '' ) ) +
		( (winPropsEnable & wMenuBar) ? 'menubar=yes,' : ( (winPropsDisable & wMenuBar) ? 'menubar=no,' : '' ) ) +
		( (winPropsEnable & wToolBar) ? 'toolbar=yes,' : ( (winPropsDisable & wToolBar) ? 'toolbar=no,' : '' ) ) +
		( (winPropsEnable & wLocationBar) ? 'location=yes,' : ( (winPropsDisable & wLocationBar) ? 'location=no,' : '' ) ) +
		( (winPropsEnable & wStatusBar) ? 'status=yes,' : ( (winPropsDisable & wStatusBar) ? 'status=no,' : '' ) ) +
		( (winPropsEnable & wBookmarks) ? 'directories=yes,' : ( (winPropsDisable & wBookmarks) ? 'directories=no,' : '' ) ) +
		( (winPropsEnable & wHotkeys) ? 'hotkeys=yes,' : ( (winPropsDisable & wHotkeys) ? 'hotkeys=no,' : '' ) );
window.status = winParameters;
	newWin = window.open (winUrl, winName, 
		'left=' + winX + 
		',top=' + winY + 
		',innerWidth=' + winWidth + 
		',width=' + winWidth + 
		',innerHeight=' + winHeight + 
		',height=' + winHeight + 
		',' + winParameters);

	if (winPropsDisable ^ wSetFocus) newWin.focus();

	return (winPropsEnable & wReturnWinHandle) ? newWin : false;

} // function openWindow


function goToPage (targetUrl, targetWindow, keepCurWindow, keepFocus) {

	if (!targetWindow.closed) {
		if (targetWindow.parent.location.href != targetWindow.location.href)
			targetWindow.parent.location.href = targetUrl;
		else
		targetWindow.location.href = targetUrl;
	}

	if (!keepCurWindow) window.parent.close();
	if (keepFocus) window.focus; else targetWindow.focus();
	return (targetWindow.closed) ? true : false;

} // function goToPage


function printWindow () {

	if (window.print) window.print();

} // function printWindow


function toggleEditMenu (showMenu, menuId) {

	menuHandle = document.getElementById (menuId);
	curEditMenuHandle = document.getElementById (curEditMenuId);

	if (menuHandle) {
		menuHandle.style.display = (menuHandle.style.display == 'none') ? 'block' : 'none';
		if (curEditMenuHandle) {
			curEditMenuHandle.style.display = 'none';
		}
		curEditMenuId = (menuHandle.style.display == 'block') ? menuId : null;
	} else {
		document.all.divEditMenu.style.visibility = ( (document.all.divEditMenu.style.visibility == 'visible') && !showMenu) ? 'hidden' : 'visible';
	}

	return false;

} // function toggleEditMenu


function editAttribute (editAction, editType, attributeReference, attributeIsLocalizable, isLink) {

	if (editType == 'label') return true;

	var secondReference = null;
	var altClick = (window.event) ? window.event.altKey : false;
	var ctrlClick = (window.event) ? window.event.ctrlKey : false;

	if (isLink && ( (!ctrlClick && !altClick) || (altClick && typeof (attributeReference) != 'object') ) ) return true;

	if (ctrlClick) {
		if (typeof (attributeReference) == 'object') attributeReference = attributeReference[0];
		if (typeof (editType) == 'object') editType = editType[0];
	} else if (altClick) {
		if (typeof (attributeReference) == 'object') attributeReference = attributeReference[1];
		if (typeof (editType) == 'object') editType = editType[1];
	}

	var windowWidth = ( (languageCount > 1) && attributeIsLocalizable && (editAction == 'edit') &&
		( (editType == 'value') || (editType == 'all') || (editType == 'ccat') || (editType == 'prod') ) ) ? 920 : 470;

	if (winEdit && (!winEdit.closed) ) winEdit.close();

	var editUrl = 'View.jsp?template=edit.xsl&edit_action=' + editAction + '&edit_content=' + editType;

	if ( (editType == 'ccat') || (editType == 'prod') ) {
		editUrl += '&' + editType + '_id=' + attributeReference;
	} else {
		editUrl += '&ref=' + attributeReference
	}
	editUrl += '&' + urlAttributes;

	window.status = editUrl;

	winEdit = openWindow (editUrl, windowWidth, 350, 20, 20, 'editWindow', wReturnWinHandle + wStatusBar);

	if (winEdit) return false;

} // function editAttribute
