// 2003-07-23 whe, hho: var current_language angepasst auf lange Sprachkürzel, z. B. "/es-ES/" plus Anpassung get_header ()

// Begin of international Bosch header wrapper by www.kittelberger.de (whe 2003-07-10)
/***********************/
/* language properties */
/***********************/
if (window.param_lang) {
	// current language on this page
	var current_language = param_lang[param_currentLanguageIndex].id;
	var curLangUrlSegment = '/' + current_language + '/';
	var curPageHref = document.location.href;
	
	// urls of inactive languages of this page - relative to server_root in header.js or absolute
	var other_languages = new Array();
	for (var langCount = 0; langCount < param_lang.length; langCount++) {
		other_languages[param_lang[langCount].id] = curPageHref.replace (curLangUrlSegment , '/' + param_lang[langCount].id + '/');
	}

	if (window.header_actions) {

		/* business division and sub divisions */
		
		var business_division = header_actions[1].id;
		var sub_division1 		= "";
		var sub_division2 		= "";
		var sub_division3 		= "";
		var contact_email 		= "";
		
		/*******************************************/
		/* backlinks for header - max. three links */
		/*******************************************/
	
		var backlink = new Array();
		
		// use given three objects with "text" for link-text and "url" for link-URL
		// first (root) back link 
		backlink[0] = new Object();
		backlink[0].label  = header_actions[0].text;
		backlink[0].url   = header_actions[0].url;
		
		// second (child) back link
		backlink[1] = new Object();
		backlink[1].label 	= header_actions[1].text;
		backlink[1].url 	= header_actions[1].url;
		
		// third (grandchild) back link
		backlink[2] = new Object();
		backlink[2].label 	= header_actions[2].text;
		backlink[2].url 	= header_actions[2].url;
	}	// if (window.header_actions)
} // if (window.param_lang)


function get_header() {
	
	current_language = current_language.substr (0, 2);
	
	var relPath = curPageHref.substr (0, curPageHref.indexOf (curLangUrlSegment) );
	relPath = (relPath == '') ? curPageHref.substr (0, curPageHref.indexOf ('admin') -1 ) : relPath;
	
	var code = '<script language="JavaScript" src="'
		+ relPath
		+ '/header_central/scripts/header.js" type="text/javascript"></script>';
	return code;
	
}


// End of international Bosch header wrapper



// Browser-Fenster öffnen
function OpenWindow (URL, Width, Height, Left, Top, Name, Resizable, ScrollBars, MenuBar, ToolBar, LocationBar, StatusBar, Dependent, HotKeys) {

	var BookmarkBar = false;
	// Vorsicht bei NN: Wird die MenuBar angezeigt, wird ab Breiten kleiner 303 die Fensterhöhe vom NN falsch berechnet.

	// Testen, ob Positions- und Größen-Parameter angegeben und nicht zu groß sind
	if ( (Top == null) || isNaN (Top) ) Top = 20;
	if ( (Left == null) || isNaN (Left) ) Left = 20;
	if ( (Height == null) || isNaN (Height) || (Height + Top > screen.availHeight - 10) ) Height = screen.availHeight - 10 - Top;
	if ( (Width == null) || isNaN (Width) || (Width + Left > screen.availWidth - 10) ) Width = screen.availWidth - 10 - Left;
	Name = (Name == null) ? '' : Name; // Name = Leerstring, wenn kein Name angegeben ist
	// Testen, ob alle Parameter vorhanden sind, sonst Default-Werte vergeben

	Resizable = ((Resizable == null) || (Resizable == true)) ? 'yes' : 'no';
	ScrollBars = ((ScrollBars == null) || (ScrollBars == true)) ? 'yes' : 'no';
	MenuBar = ((MenuBar == null) || (MenuBar == false)) ? 'no' : 'yes';
	ToolBar = ((ToolBar == null) || (ToolBar == false)) ? 'no' : 'yes';
	LocationBar = ((LocationBar == null) || (LocationBar == false)) ? 'no' : 'yes';
	BookmarkBar = ((BookmarkBar == null) || (BookmarkBar == false)) ? 'no' : 'yes';
	StatusBar = ((StatusBar == null) || (StatusBar == true)) ? 'yes' : 'no';
	Dependent = ((Dependent == null) || (Dependent == true)) ? 'yes' : 'no';
	HotKeys = ((HotKeys == null) || (HotKeys == true)) ? 'yes' : 'no';

	// Für IE Fenstergrößen extra berechnen, da IE "innerWidth" und "InnerHeight" nicht beachtet.
	if (document.all) {
		Height += 31; // 31 Pixel höher für Fensterrahmen und Titelleiste des Fensters
		Width = Width + 12; // 12 Pixel breiter für den Fensterrahmen
		Height = (Resizable == 'no') ? Height - 2 : Height; // Der Fensterrahmen von Nicht-"Resizable"-Fenstern ist 2 Pixel schmaler.
		Width = (Resizable == 'no') ? Width - 2 : Width; // dto.
		Width = (ScrollBars == 'yes') ? Width + 16 : Width;
		Height = (MenuBar == 'yes') ? Height + 29 : Height;
		Height = (ToolBar == 'yes') ? Height + 47 : Height;
		Height = (LocationBar == 'yes') ? Height + 29 : Height; 
		var BarCompensation = (MenuBar == 'yes') ? 1 : 0; // je "Bar"-Paar werden wiederum 5 Pixel eingespart
		BarCompensation = (ToolBar == 'yes') ? BarCompensation + 1 : BarCompensation;
		BarCompensation = (LocationBar == 'yes') ? BarCompensation + 1 : BarCompensation;
		BarCompensation = (BarCompensation < 1) ? 1 : BarCompensation;
		Height -= ( (BarCompensation - 1) * 5);
		Height = (StatusBar == 'yes') ? Height + 20 : Height;
		// Fenster wieder verkleinern, falls es jetzt wieder zu groß ist
		if (!Width || isNaN (Width) || (Width > screen.availWidth - 10)) Width = screen.availWidth - 10;
		if (!Height || isNaN (Height) || (Height > screen.availHeight - 10)) Height = screen.availHeight - 10;
	}
	
	// Fenster mit den gegebenen Parametern öffnen
	NewWindow = window.open(URL, Name, 'screenX=' + Left + ',screenY=' + Top 
	+ ',height=' + Height + ',width=' + Width + ',innerHeight=' + Height + ',innerWidth=' + Width
	+ ',resizable=' + Resizable + ',scrollbars=' + ScrollBars + ',menubar=' + MenuBar 
	+ ',toolbar=' + ToolBar + ',location=' + LocationBar + ',directories=' + BookmarkBar 
	+ ',status=' + StatusBar + ',dependent=' + Dependent);

	if (navigator.appVersion.indexOf ('MSIE 5.0')) NewWindow.focus (); // IE 5.0 bricht hier sonst ab

	URL += ''; // IE versteht die URL nur so als String ...

	// Für IE muss extra positioniert. Der Fenster-Zugriff wird aber verweigert, wenn eine 
	// komplette HTTP-Adresse aufgerufen wird ...

	if (!NewWindow.innerWidth && (URL.indexOf ('http://') < 0)) {
		NewWindow.moveTo (Left, Top);
	}

	NewWindow.focus (); // Fenster ganz nach vorn stellen, also Focus auf das Fenster

	return false; // damit der HREF-Link nicht ausgeführt wird
	
} // function OpenWindow


function submitForm (formName, targetAction) {

	if (targetAction != null) {
		var formElements = document.forms[formName].elements;
		for (var i=0; i < formElements.length; i++) {
			if (formElements[i].name.indexOf ('action') > -1) {
				formElements[i].name = targetAction;
				break;
			}
		}
	}

 	document.forms[formName].submit ();
	
	return true;

} // function submitForm

