function openkontakt() {
	alert("Kontaktformular");
}

function init() {

	ie4 = (document.all && document.styleSheets)? true : false;
	objXprLogo = MM_findObj('xprlogo');
	objNedstatCounter = MM_findObj('nedstat_counter');
	getWindowSize();
	initTimers();
	scrollLogo();
	startVisibleFlash();
}

function doNedstatCounter(name) {
	// Siehe auch /html/nedstat_other.inc.php
	var tmp = new String(name);
	if (tmp.length > 0)
		if (objNedstatCounter) {
						objNedstatCounter.src = "http://de.nedstatpro.net/cgi-bin/nedstatpro.gif?name=" + name;
			//alert(objNedstatCounter.src);
					}
}

function getWindowSize() {
	// Höhe und Y-Position werden z.Z. nicht benötigt
	if (self.innerWidth) {
		thisWinInnerWidth  = self.innerWidth;
		//thisWinInnerHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientWidth) {
		thisWinInnerWidth  = document.documentElement.clientWidth;
		//thisWinInnerHeight = document.documentElement.clientHeight;
	} else if (document.body) {
		thisWinInnerWidth  = document.body.clientWidth;
		//thisWinInnerHeight = document.body.clientHeight;
	}

	thisWinPosX = (ie4) ? document.body.scrollLeft : window.pageXOffset;
	//thisWinPosY = (ie4) ? document.body.scrollTop  : window.pageYOffset;
}

function scrollLogo() {
	if (timerXprLogo)
		clearTimeout(timerXprLogo);
	if (timerXprLogoFancy)
		clearTimeout(timerXprLogoFancy);

	var css = objXprLogo;
	if (css.style) css = css.style;

	getWindowSize();

	var currX = parseInt(css.paddingLeft);
	if (currX != thisWinPosX + thisWinInnerWidth - 130) {	/* Breite der Logo-Grafik !!! */
		css.paddingLeft = thisWinPosX + thisWinInnerWidth - 130;
	}

	timerXprLogo = setTimeout("scrollLogo()", 5);
}

function scrollLogoFancy() {
	if (timerXprLogo)
		clearTimeout(timerXprLogo);
	if (timerXprLogoFancy)
		clearTimeout(timerXprLogoFancy);
	stopAllFlash();

	var css = objXprLogo;
	if (css.style) css = css.style;

	getWindowSize();

	gofast = 0;
	if (!parent.fs_top.getCheckBoxStatus())
		gofast = 1;

	var currX = parseInt(css.paddingLeft);
	var zielPosition = thisWinPosX + thisWinInnerWidth - 130;

	diff = Math.abs(zielPosition - currX);
	step = diff < 100 ? diff : 100;
	if (gofast)
		step = diff;
	if (currX > zielPosition) step = -step;
	css.paddingLeft = currX + step;

	if (diff > 100) {
		timerXprLogoFancy = setTimeout("scrollLogoFancy()", 15);
	} else {
		// Logo ist richtig positioniert.
		// Sichtbare Flash-Animationen starten.
		startVisibleFlash();

		// Logo dem Scrollbalken folgen lassen
		scrollLogo();
	}
}

function stopAllFlash() {
	return;
	// Alle Flash-Anims stoppen
	for (var i = 0; i < flashAnims.length; i += 3) {
		//alert("Stoppe "+flashAnims[i]+"...");
		setFlashVar(flashAnims[i], "mov_run", 0);
		//setFlashVar(flashAnims[i], "mov_run", 1);
	}
}

function startVisibleFlash() {
	return;
	// Sichtbare Anims starten
	//stopAllFlash();

	getWindowSize();

	for (var i = 0; i < flashAnims.length; i += 3) {
		//setFlashVar(flashAnims[i], "mov_run", 1);

		xpos = flashAnims[i + 1];
		// (Linker Fensterand - FlashBreite) <= (FlashX ) < (Linker Fensterand + sichtbarer Fensterbreite) ?
		if ((thisWinPosX - flashAnims[i + 2] <= xpos ) && (xpos < thisWinPosX + thisWinInnerWidth)) {
			// Animation starten
			//alert("Starte "+flashAnims[i]+"...");
			setFlashVar(flashAnims[i], "mov_run", 1);
		} else {
			// Unsichtbare anhalten
			setFlashVar(flashAnims[i], "mov_run", 0);
		}

	}
}

function initTimers() {
	if (timerXprLogo)
		clearTimeout(timerXprLogo);
	if (timerXprLogoFancy)
		clearTimeout(timerXprLogoFancy);
	if (timerContent)
		clearTimeout(timerContent);
	stopAllFlash();
}

function scrollMich(zielX) { 
	scollingDone = false;

	// Alle Timer abschalten
	initTimers();

	getWindowSize();

	if (thisWinPosX != zielX) {
		gofast = 0;

		if (!parent.fs_top.getCheckBoxStatus() || ie4)
			gofast = 1;


		if (gofast == 1) {
			if (ie4) { 
				scrollTo(zielX, thisWinPosY);
				document.body.scrollLeft = zielX;
			} else {
				scrollTo(zielX, thisWinPosY);
			}

			// Logo nachziehen
			scrollLogoFancy();
			scollingDone = true;
		} else {
			diff = Math.abs(thisWinPosX - zielX);
			step = diff < 50 ? diff : 50;
			if (thisWinPosX > zielX) step = -step;

			oldPosX = thisWinPosX;

			if (ie4) {
				document.body.scrollLeft = thisWinPosX + step;
			} else {
				scrollTo(thisWinPosX + step, thisWinPosY);
			}

			getWindowSize();

			if (oldPosX != thisWinPosX) {
				timerContent = setTimeout("scrollMich(" + zielX + ")", 5);
			} else {
				// Logo nachziehen
				scrollLogoFancy();
				scollingDone = true;
			}
		}
	} else {
		// Logo nachziehen
		scrollLogoFancy();
		scollingDone = true;
	}

	if (scollingDone) {
		var nedstatTmp = new String("echtzeit03_");
		switch (zielX) {
			case 0:			nedstatTmp += "1"; break;
			case 2400:	nedstatTmp += "2"; break;
			case 4800:	nedstatTmp += "7"; break;
			case 13920:		nedstatTmp += "8"; break;
			case 19680:			nedstatTmp += "9"; break;
			default: nedstatTmp = "";
		}
		if (nedstatTmp.length > 0)
			doNedstatCounter(nedstatTmp);
	}
}

function open_popup(ziel) {
	var w = 660;
	var h = 570;
	var pos_x = Math.round((screen.width  - w)/2);
	var pos_y = Math.round((screen.height - h)/2);
	popup_win_win = window.open("popup.php?ziel=" + escape(ziel), "popup_win", "top="+pos_y+",left="+pos_x+",width="+w+",height="+h+",resizable=no,status=no");
	popup_win_win.focus();
}

// Premium System: Seite 2a
function ebeneopen2a(nr, nedstat_cnt_name) {
	nedstatTmp = "echtzeit03_";

	for (i = 1; i <= 9; i++) {
		opt = "hide";
		if (i == nr) {
			opt = "show";
			switch (i) {
				case 1: nedstatTmp += "3"; break;
				case 2: nedstatTmp += "4"; break;
				case 3: nedstatTmp += "5"; break;
				case 4: nedstatTmp += "6"; break;
                case 5: nedstatTmp += "7"; break;
                case 6: nedstatTmp += "8"; break;
                case 7: nedstatTmp += "8"; break;
                case 8: nedstatTmp += "9"; break;
                case 9: nedstatTmp += "10"; break;    
			}
			doNedstatCounter(nedstatTmp);
		}
		MM_showHideLayers('ebene2a' + i, '', opt);
	}
	priv_linkfarbe_setzen(1, 9, 'ebopln', '000000', 'ffffff', nr);
	parent.fs_top.linkfarbe_subnav_premium(nr);
}
                
                
// Decken System: Seite 
function ebeneopen3a(nr, nedstat_cnt_name) {
	nedstatTmp = "echtzeit03_";

	for (i = 1; i <= 2; i++) {
		opt = "hide";
		if (i == nr) {
			opt = "show";
			switch (i) {
				case 1: nedstatTmp += "3"; break;
				case 2: nedstatTmp += "4"; break;
			}
			doNedstatCounter(nedstatTmp);
		}
		MM_showHideLayers('ebene3a' + i, '', opt);
	}
	priv_linkfarbe_setzen(1, 2, 'ebopln02', '000000', 'ffffff', nr);
	parent.fs_top.linkfarbe_subnav_decken(nr);
}


// ======================================================================================================================
// === Navigations-Frame ================================================================================================
// ======================================================================================================================

function zeige_subebene(welche) {
	verstecke_subebene(welche);
	MM_showHideLayers('ebene2' + welche, '', 'show');
	linkfarbe_setzen(welche);
}

function verstecke_subebene(skip) {
	if ((skip < 1) || (skip > 7)) skip = -1;
	for (i = 1; i <= 7; i++) {
		if (i != skip) MM_showHideLayers('ebene2' + i, '', 'hide');
	}
}

function linkfarbe_setzen(setzen) {
	// 1. Navgations-Ebene
	priv_linkfarbe_setzen(1, 5, 'navlink', '000000', 'CCCCCC', setzen);
}

function linkfarbe_subnav_kampagne(setzen) {
	// 2. Navgations-Ebene: Kampagne
	priv_linkfarbe_setzen(1, 4, 'sublink8', '000000', 'CCCCCC', setzen);
}

function linkfarbe_subnav_premium(setzen) {
	// 2. Navgations-Ebene: Premium System
	priv_linkfarbe_setzen(1, 9, 'sublink2', '000000', 'CCCCCC', setzen);
}

function linkfarbe_subnav_decken(setzen) {
	// 2. Navgations-Ebene: Decken System
	priv_linkfarbe_setzen(1, 2, 'sublink7', '000000', 'CCCCCC', setzen);
}

function linkfarbe_subnav_service(setzen) {
	// 2. Navgations-Ebene: Service
	priv_linkfarbe_setzen(1, 5, 'sublink4', '000000', 'CCCCCC', setzen);
}

function linkfarbe_subnav_imprint(setzen) {
	// 2. Navgations-Ebene: Service
	priv_linkfarbe_setzen(1, 1, 'sublink6', '000000', 'CCCCCC', setzen);
}

function priv_linkfarbe_setzen(idxstart, idxende, praefix, farbe_a, farbe_i, setzen) {
	for (i = idxstart; i <= idxende; i++) {
		lnk = MM_findObj(praefix + i);
		if (lnk.style) lnk = lnk.style;

		// === Mit Stylesheet abgleichen! ===
		col = farbe_a;
		if (setzen == i) col = farbe_i;

		lnk.color = "#" + col;
	}
}

// ===================================================================================================================
// === Administration ================================================================================================
// ===================================================================================================================
function adminpopup(ziel) {
	var w = 680;
	var h = 570;
	var pos_x = screen.width - w - 20;
	var pos_y = Math.round((screen.height - h) / 2);
	adminpopup_win_win = window.open(ziel, "adminpopup_win", "top="+pos_y+",left="+pos_x+",width="+w+",height="+h+",scrollbars=yes,resizable=yes,status=no");
	adminpopup_win_win.focus();
}

// ===================================================================================================================
// ===================================================================================================================
// ===================================================================================================================
function setFlashVar(id, v, w) {
	var movie = findeFlash(id);
	if (movie) {
		movie.SetVariable(v, w);
	}
}

function startFlashMovie(id) {
	var movie = findeFlash(id);
	if (movie) movie.TPlay('_root.fitNavMc');
}

function setFlash(id, curmain, cursub) {
	setFlashVar(id, "main", curmain);
	setFlashVar(id, "sub", cursub);
	startFlashMovie(id);
}

function findeFlash(flash) {
	// flash = Id des Films
	var browsername = navigator.userAgent.toLowerCase();
	var opera = (browsername.indexOf("opera") > -1);
	if (opera) return;

	// http://aktuell.de.selfhtml.org/artikel/programmiertechnik/liveconnect/
	if (document.all) {
		if (document.opera) {
			var movie = eval(window.document + flash);
			if (movie.SetVariable) {
				return movie;
			}
		}
		if (document.all[flash]) {
			return document.all[flash];
		}
		return;
	}

	if(document.layers) {
		if(document.embeds) {
			var movie = document.embeds[flash];
			if (movie.SetVariable) {
				return movie;
			}
		}
		return;
	}

	if (!document.getElementById) {
		return;
	}

	var movie = document.getElementById(flash);
	if (movie) {
		if (movie.SetVariable) {
			return movie;
		}

		var movies = movie.getElementsByTagName('embed');
		if (!movies || !movies.length) {
			return;
		}

    	movie = movies[0];
    	if (movie.SetVariable) {
    		return movie;
    	}
    }
    return;
}

// ===================================================================================================================
// ===================================================================================================================
// ===================================================================================================================
function detectFlash() {
	// If navigator.plugins exists...
	if (navigator.plugins) {
		// ...then check for flash 2 or flash 3+.
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			// Some version of Flash was found. Time to figure out which.

		  	// Set convenient references to flash 2 and the plugin description.
		  	var isVersion2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
		  	var flashDescription = navigator.plugins["Shockwave Flash" + isVersion2].description;
		  	//alert(flashDescription);
		  	var flashVersion = parseInt(flashDescription.charAt(flashDescription.indexOf(".") - 1));
			// We found the version, now set appropriate version flags.
			flash2Installed = flashVersion == 2;
			flash3Installed = flashVersion == 3;
			flash4Installed = flashVersion == 4;
			flash5Installed = flashVersion == 5;
			flash6Installed = flashVersion == 6;
			flash7Installed = flashVersion == 7;
			flash8Installed = flashVersion == 8;
			flash9Installed = flashVersion == 9;
            flash10Installed = flashVersion == 10;
		}
	}
	// loop through all versions we're checking, and set actualVersion to highest detected version
	for (var i = 2; i <= maxVersion; i++) {
		if (eval("flash" + i + "Installed") == true) actualVersion = i;
	}
	 //alert("version detected: " + actualVersion);


	// we're finished getting the version. time to take the appropriate action
	return actualVersion;
}

