var CurLangID = "de"; // Für jede Sprache anpassen
var Langs = new Array ();
// Verfügbare Sprachversionen
Langs ["de"] = new Language ("de", "Deutsch");
Langs ["en"] = new Language ("en", "English");
Langs ["fr"] = new Language ("fr", "Fran&ccedil;ais");
Langs ["it"] = new Language ("it", "Italiano");


// Komplettes Haupt-Menü ausgeben
function MakeMainMenu () {

	Path = Langs [CurLangID].LangRootPath;
	document.write ('<table border="0" cellpadding="0" cellspacing="0" width="220">'); 

	MakeMainMenuItem ('progas', 'Produktwelten Gaswerkzeuge');
	MakeMainMenuItem ('prosani', 'Produktwelten Sanit&auml;rwerkzeuge');
	MakeMainMenuItem ('proelektro', 'Produktwelten Elektrowerkzeuge');
	MakeMainMenuItem ('grund', 'Grundwissen');
	MakeMainMenuItem ('anwend', 'Anwendungsvideos');

	Code = '<tr>\n';
	Code += '<td><img border="0" src="' + Path + 'shared/00.gif" width="130" height="1" alt=""></td>';
	Code += '<td><img border="0" src="' + Path + 'shared/00.gif" width="90" height="1" alt=""></td>';
	Code += '</tr>\n</table>\n';
	document.write (Code);

} // function MakeMainMenu


// Alle Sub-Menüs ausgeben
function MakeAllSubMenus () {
	
	MakeSubMenu ("progas", "Produktwelten Gaswerkzeuge", "loeten,propan,autogen,spezial,basteln,freizeit,zubehoer", ",,,,,,,");
	MakeSubMenu ("prosani", "Produktwelten Sanit&auml;rwerkzeuge", "reinigung,installation", "Reinigung,Installation");
	MakeSubMenu ("proelektro", "Produktwelten Elektrowerkzeuge", "elektro,zubehoer01", ",");
	MakeSubMenu ("grund", "Grundwissen", "loeten,schweissen,bitumen,einfrieren", "L&ouml;ten,Schwei&szlig;en,Einfrieren");
	MakeSubMenu ("anwend", "Anwendungen", "oekogaertner,miniset,rofire,roflame,hotpen,gluegun,abflussjet,einfrieren", ",,,,,");

} // function MakeAllSubMenus


// Initial-Funktion aller Seiten: Bilder vor-laden, ggf. Menüpunkt vorauswählen
function PageStartup (Page) {

	if (Page == "head") { // Head-Frame

		PreloadPicture ("home", Langs [CurLangID].LangRootPath + "buttons/home_down.gif");
		PreloadPicture ("hwk", Langs [CurLangID].LangRootPath + "buttons/hwk_down.gif");
		PreloadPicture ("hsuche", Langs [CurLangID].LangRootPath + "buttons/hsuche_down.gif");
		PreloadPicture ("knt", Langs [CurLangID].LangRootPath + "buttons/knt_down.gif");

	} else { // normale Inhalts-Seiten

		// Buttons der obersten Navigation vor-laden
		
		PreloadPicture ("wir", Langs [CurLangID].LangRootPath + "buttons/wir_down.gif");
		PreloadPicture ("wir_allg", Langs [CurLangID].LangRootPath + "buttons/wir_allg_down.gif");
		
		PreloadPicture ("progas", Langs [CurLangID].LangRootPath + "buttons/progas_down.gif");
		PreloadPicture ("progas_uebersicht", Langs [CurLangID].LangRootPath + "buttons/progas_uebersicht_down.gif");
		PreloadPicture ("progas_loeten", Langs [CurLangID].LangRootPath + "buttons/progas_loeten_down.gif");
		PreloadPicture ("progas_propan", Langs [CurLangID].LangRootPath + "buttons/progas_propan_down.gif");
		PreloadPicture ("progas_autogen", Langs [CurLangID].LangRootPath + "buttons/progas_autogen_down.gif");
		PreloadPicture ("progas_spezial", Langs [CurLangID].LangRootPath + "buttons/progas_spezial_down.gif");
		PreloadPicture ("progas_basteln", Langs [CurLangID].LangRootPath + "buttons/progas_basteln_down.gif");
		PreloadPicture ("progas_freizeit", Langs [CurLangID].LangRootPath + "buttons/progas_freizeit_down.gif");
		PreloadPicture ("progas_zubehoer", Langs [CurLangID].LangRootPath + "buttons/progas_zubehoer_down.gif");
		
		
		PreloadPicture ("prosani", Langs [CurLangID].LangRootPath + "buttons/prosani_down.gif");
		PreloadPicture ("prosani_reinigung", Langs [CurLangID].LangRootPath + "buttons/prosani_reinigung_down.gif");
		PreloadPicture ("prosani_installation", Langs [CurLangID].LangRootPath + "buttons/prosani_installation_down.gif");
		PreloadPicture ("prosani_einfrieren", Langs [CurLangID].LangRootPath + "buttons/prosani_einfrieren_down.gif");		
    PreloadPicture ("proelektro", Langs [CurLangID].LangRootPath + "buttons/proelektro_down.gif");
		PreloadPicture ("proelektro_elektro", Langs [CurLangID].LangRootPath + "buttons/proelektro_elektro_down.gif");
		PreloadPicture ("proelektro_zubehoer01", Langs [CurLangID].LangRootPath + "buttons/proelektro_zubehoer_down01.gif");	
	
	  PreloadPicture ("grund", Langs [CurLangID].LangRootPath + "buttons/grund_down.gif");
		PreloadPicture ("grund_loeten", Langs [CurLangID].LangRootPath + "buttons/grund_loeten_down.gif");
		PreloadPicture ("grund_schweissen", Langs [CurLangID].LangRootPath + "buttons/grund_schweissen_down.gif");
		PreloadPicture ("grund_bitumen", Langs [CurLangID].LangRootPath + "buttons/grund_bitumen_down.gif");
		PreloadPicture ("grund_einfrieren", Langs [CurLangID].LangRootPath + "buttons/grund_einfrieren_down.gif");
    PreloadPicture ("grund_ventilwechsel", Langs [CurLangID].LangRootPath + "buttons/grund_ventilwechsel_down.gif");	
	
    PreloadPicture ("anwend", Langs [CurLangID].LangRootPath + "buttons/anwend_down.gif");
		PreloadPicture ("anwend_oekogaertner", Langs [CurLangID].LangRootPath + "buttons/anwend_oekogaertner_down.gif");
		PreloadPicture ("anwend_miniset", Langs [CurLangID].LangRootPath + "buttons/anwend_miniset_down.gif");
		PreloadPicture ("anwend_rofire", Langs [CurLangID].LangRootPath + "buttons/anwend_rofire_down.gif");
		PreloadPicture ("anwend_roflame", Langs [CurLangID].LangRootPath + "buttons/anwend_roflame_down.gif");
		PreloadPicture ("anwend_hotpen", Langs [CurLangID].LangRootPath + "buttons/anwend_hotpen_down.gif");
		PreloadPicture ("anwend_gluegun", Langs [CurLangID].LangRootPath + "buttons/anwend_gluegun_down.gif");
		PreloadPicture ("anwend_abflussjet", Langs [CurLangID].LangRootPath + "buttons/anwend_abflussjet_down.gif");
		PreloadPicture ("anwend_einfrieren", Langs [CurLangID].LangRootPath + "buttons/anwend_einfrieren_down.gif");	
	
	
		if (Page && (Page != "")) { // aktuellen Menüpunkt im Menü öffnen, wenn Maus nicht im Menü
			CurPageName = Page;
			MenuOn (CurPageName);
		}
	} // if (Page == "head")

} // function PageStartup


// --------------------------------------------------------------------------
//  Ab hier nur noch allgemeine Funktionen, keine Web-abhängigen Anpassungen
// --------------------------------------------------------------------------

var Pics = new Array ();
var CurMenuName = "";
var CurPageName = "";

var browserVersion = 0;
var ie = (document.all) ? true : false;


// Language-Objekt definieren
function Language (ID, Name, LangRootPath) {

	this.ID = ID;
	this.Name = Name;
	if (LangRootPath && (LangRootPath != "")) {
		this.LangRootPath = LangRootPath;
	} else {
		LangRootPath = document.location.pathname;
		if (LangRootPath.indexOf ("\\") > 0) {
			LangRootPath = LangRootPath.slice (0, LangRootPath.indexOf ("\\" + CurLangID + "\\") + 1) + ID + "\\";
		} else {
			LangRootPath = LangRootPath.slice (0, LangRootPath.indexOf ("/" + CurLangID + "/") + 1) + ID + "/";
		}
		this.LangRootPath = LangRootPath;
	}

} // function Language


// Debug Message
function DM (Message) {
	document.debugform.debug.value = document.debugform.debug.value + Message + " ";
} // function DM


// Beliebiges Bild vor-laden
function PreloadPicture (PicName, PicFileName) {

	Pics [PicName] = new Image ();
	Pics [PicName].src = PicFileName;
	
} // function PreloadPicture 


// Haupt-Menü-Punkt ausgeben
function MakeMainMenuItem (MenuItemName, MenuItemTitle, MenuItemRelURL) {
	
	Path = Langs [CurLangID].LangRootPath;
	
	Code = '<tr>\n';
	Code += '<td valign="top"><a href="';

	if (MenuItemRelURL && (MenuItemRelURL.length > 1)) {
		Code += Path + MenuItemRelURL;
	} else {
		Code += '#';
	}
	
	Code += '" onmouseover="MenuOn (\'' + MenuItemName + '\');" onmouseout="MenuOff (\'' + MenuItemName + '\');">';
	Code += '<img border="0" src="' + Path + 'buttons/' + MenuItemName + '.gif" name="' + MenuItemName + '" ';
	Code += 'width="130" height="32" alt="' + MenuItemTitle + '" title=""></a></td>\n';
  Code += '<td valign="top"></td>\n</tr>\n';

	document.write (Code);

} // function MakeMainMenu


// Sub-Menü-Layers bzw. -DIVs ausgeben
function MakeSubMenu (MenuName, MenuTitle, MenuItemNames, MenuItemTitles) {
	
	Path = Langs [CurLangID].LangRootPath;
	Code = '<div id="menu' + MenuName + '">\n';
	Code += '<table border="0" cellpadding="0" cellspacing="0"><tr>';
	MenuItemNames = MenuItemNames.split (",");
	MenuItemTitles = MenuItemTitles.split (",");
	for (i = 0; i < MenuItemNames.length; i++) {
		Code += '<td><a href="' + Path + MenuName + '/' + MenuItemNames[i] + '.htm" onmouseover="MenuOn (\'' + MenuName + '_' + MenuItemNames[i];
		Code += '\');" onmouseout="MenuOff (\'' + MenuName + '_' + MenuItemNames[i] + '\');" onclick="return GoTo (\'' + MenuName + '_' + MenuItemNames[i] + '\');">';
		Code += '<img src="' + Path + 'buttons/' + MenuName + '_' + MenuItemNames[i] + '.gif" name="' + MenuName + '_' + MenuItemNames[i] + '" ';
		Code += 'width="113" height="32" border="0" alt="' + MenuItemTitles [i] + '" title=""></a></td>\n';
		Code += '</tr><tr>';
	}
	Code += '</tr></table></div>';

	document.write (Code);

} // function MakeSubMenu


// Menütiefe ermitteln: 1 = Hauptmenü; 2 = 1. Sub-Menü etc.
function MenuDepth (MenuName) {
	if (MenuName && (MenuName != "")) {
		Depth = MenuName.split ("_");
		return Depth.length;
	} else {
		return 0;
	}
} // function MenuDepth


// Menüpunkt aktivieren
function MenuOn (MenuName) {

	if (CurMenuName && (CurMenuName != "")) { // zurzeit gedrückten Menüpunkt deaktivieren, wenn es einen gibt
		if (window.MenuOffTimeout) window.clearTimeout (window.MenuOffTimeout);
		while ((MenuDepth (CurMenuName) >= MenuDepth (MenuName)) && (CurMenuName != "")) { // bisherige Sub-Menüs verbergen, bis auf gleicher Menü-Ebene
			// Sub-Menü verbergen, wenn existent
			if (document.layers) { // Netscape
				if (document.layers['menu' + CurMenuName]) {
					document.layers['menu' + CurMenuName].visibility = "hide";
				}
				if (MenuDepth (CurMenuName) > 1) {
					document.layers['menu' + CurMenuName.slice (0, CurMenuName.lastIndexOf ("_"))].document.images[CurMenuName].src = Langs [CurLangID].LangRootPath + "buttons/" + CurMenuName + ".gif"; // Menüpunkt drücken
				} else {
					document.images[CurMenuName].src = Langs [CurLangID].LangRootPath + "buttons/" + CurMenuName + ".gif"; // Menüpunkt loslassen
				}
			} else { // Internet Explorer
				if (document.all['menu' + CurMenuName]) {
					document.all['menu' + CurMenuName].style.visibility = "hidden";
				}
				document.images[CurMenuName].src = Langs [CurLangID].LangRootPath + "buttons/" + CurMenuName + ".gif"; // Menüpunkt loslassen
			}
			if (CurMenuName.lastIndexOf ("_") > 0) {
				CurMenuName = CurMenuName.slice (0, CurMenuName.lastIndexOf ("_")); // Name des übergeordneten Menüs errechnen
			} else {
				CurMenuName = "";
			}
		} 
	}

	if (!MenuName || (MenuName == "")) MenuName = CurPageName;
	CurMenuName = MenuName;

	if (MenuName && (MenuName != "")) { // jetzt neuen Menüpunkt aktivieren, wenn angefordert
		while (MenuDepth (MenuName) >= 1) {
			if (document.layers) { // Netscape 
				if (MenuDepth (MenuName) > 1) {
					document.layers['menu' + MenuName.slice (0, MenuName.lastIndexOf ("_"))].document.images[MenuName].src = Pics [MenuName].src; // Menüpunkt drücken
				} else {
					document.images[MenuName].src = Pics [MenuName].src; // Menüpunkt drücken
				}
				if (document.layers['menu' + MenuName]) {
					document.layers['menu' + MenuName].visibility = "show"; // Sub-Menü anzeigen, wenn existent
				}
			} else { // Internet Explorer
					document.images[MenuName].src = Pics [MenuName].src; // Menüpunkt drücken
				if (document.all['menu' + MenuName]) {
					document.all['menu' + MenuName].style.visibility = "visible"; // Sub-Menü anzeigen, wenn existent
				}
			}
			if (MenuName.lastIndexOf ("_") > 0) {
				MenuName = MenuName.slice (0, MenuName.lastIndexOf ("_")); // Name des übergeordneten Menüs errechnen
			} else {
				MenuName = "";
			}
		}
	}
	
} // function MenuOn


// Menüpunkt nach Wartezeit deaktivieren
function MenuOff (MenuName) {
	MenuOffTimeout = window.setTimeout("MenuOn ('')", 100);
} // function MenuOff 


// Kapitelkopf-Seite in Head-Frame laden
function GoTo (TargetName) {
	if (TargetName.lastIndexOf ("_") > 0) {
		TargetFolder = TargetName.slice (0, TargetName.lastIndexOf ("_")); // Name des Verzeichnisses errechnen
	}
	parent.frames.head.location.replace (Langs [CurLangID].LangRootPath + TargetFolder + "/head.htm");
	return true;
} // function GoTo


// Browser-Fenster öffnen (V3 ohne BookmarkBar)
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 ShowHint (theURL) {

	window.open (theURL, 'hint', 'width=250,height=320,scrollbars=no');

} // function ShowHint 


// soll extra Browserfenster öffnen und Inhalt des Hauptframes bei Pressemitteilungen
function FensterLaden (URL1, URL2) {
	
	neuesFenster=window.open (URL2, 'uebersicht', 'width=317,height=400');
	document.location.href = URL1;
	neuesFenster.focus ();
	return false;

} // function FensterLaden

