
window.opacityFilter = navigator.userAgent.toLowerCase().indexOf('msie') > 0 ? true : false;

function initialize() {
	load_header();

	if(Custom) {
		Custom.init();
	}

	if(typeof(window.openPrintDialog) != 'undefined' && window.openPrintDialog) {
		window.print();
	}
}

function setFlashverInfo($flashver) {
	$header = document.getElementById('flashheader');
	$img    = window.pagehead_path + '/images/header/' + window.pagehead_prefix + window.pagehead_name + '.jpg';
	$header.innerHTML = '<img src="' + $img + '" width="' + window.flashhead_width + '" height="' + window.flashhead_height + '" border="0" alt="Flash">';

	$hinweis = document.getElementById('flashget_box');
	if($flashver.major < 1) {
		$textbefore = 'Sie haben leider keinen Flash Player installiert. Um diese Seite korrekt und mit allen Funktionen anzuschauen benötigen sie den';

		if($language != 'de') {
			$textbefore = 'You do not have any Flash Player installed. To view this website correctly and enjoy all of its functions you need';
		}
	}
	else {
		$textbefore = 'Die Version Ihres Flash Players ist zu alt. Um diese Seite korrekt und mit allen Funktionen anzuschauen benötigen sie den';

		if($language != 'de') {
			$textbefore = 'The Version of your Flash Players is too old. To view this website correctly and enjoy all of its functions you need';
		}
	}
	$redtext    = ' Adobe';
	$strongtext = ' Flash Player 10.';
	$textafter  = ' Diesen können Sie sich mit einem Klick auf diesen Text herunterladen und installieren.';

	if($language != 'de') {
		$textafter  = ' You can install this plugin with a click on this text.';
	}

	$flashget = document.createElement('a');
	$flashget.href      = 'http://get.adobe.com/flashplayer/';
	$flashget.target    = '_blank';
	$flashget.className = 'flashget_link';
	
	$hinweisInhalt = $hinweis.appendChild($flashget);

	$flashframe = document.createElement('div');
	$flashframe.className = 'flash_icon';
	$flashiconFrame = $hinweisInhalt.appendChild($flashframe);

	$flashicon = document.createElement('img');
	$flashicon.src = window.pagehead_path + '/images/icons/flash.png';
	$flashicon.setAttribute('width',24);
	$flashicon.setAttribute('height',24);
	$flashicon.setAttribute('border',0);
	$flashicon.setAttribute('alt','');
	$flashiconFrame.appendChild($flashicon);

	$br = document.createElement('br');

	$red = document.createElement('strong');
	$red.className = 'red';

	$strong = document.createElement('strong');

	$hinweisTextBefore = document.createTextNode($textbefore);
	$hinweisRedText    = document.createTextNode($redtext);
	$hinweisStrongText = document.createTextNode($strongtext);
	$hinweisTextAfter  = document.createTextNode($textafter);

	$red.appendChild($hinweisRedText);

	$strong.appendChild($hinweisStrongText);

	$hinweisInhalt.appendChild($hinweisTextBefore);
	$hinweisInhalt.appendChild($red);
	$hinweisInhalt.appendChild($strong);
	$hinweisInhalt.appendChild($br);
	$hinweisInhalt.appendChild($hinweisTextAfter);
}

function load_header() {
	cacheTimer = new Date();

	var so = new SWFObject(window.pagehead_path + '/flash/' + window.flashhead_name + ".swf?tmp=" + cacheTimer.getTime(), "header", window.flashhead_width, window.flashhead_height, "10.0.2.0", "transparent", setFlashverInfo);
	so.addParam("allowNetworking", "all");
	so.addParam("allowScriptAccess", "always");
	so.addParam("allowFullScreen", "true");
	so.addParam("quality", "high");
	so.addParam("scale", "noscale");
	so.addParam("wmode", "transparent");
	so.addParam("FlashVars", window.flashhead_vars);

	so.write("flashheader");
}

function swap_menu($caller) {
	$src = $caller.src;

	$path = $src.substr(0,$src.lastIndexOf('/') + 1);
	$file = $src.substr($src.lastIndexOf('/') + 1);

	if($src.indexOf('over_') < 0) {
		if($src.indexOf('out_') < 0) {
			$file = 'over_' + $file;
		}
		else {
			$file = $file.replace('out_','over_');
		}
	}
	else {
		$file = $file.replace('over_','out_');
	}

	$caller.src = $path + $file;
}

function open_route($route) {
	if(typeof(window.lastRoute) == 'undefined' || window.lastRoute == null || window.lastRoute == '') {
		if(typeof(window.stdRoute) != 'undefined' && window.stdRoute != null && window.stdRoute != '') {
			$lastRoute = window.stdRoute
		}
		else {
			$lastRoute = 'route_main';
		}
	}
	else {
		$lastRoute = window.lastRoute;
	}

	$content = document.getElementById($route);
	if(typeof($content) == 'object' && $content != null) {
		$lastContent = document.getElementById($lastRoute);
		if(typeof($lastContent) == 'object' && $lastContent != null) {
			$lastContent.className = 'content_hidden';
		}

		$content.className   = 'content';

		window.lastRoute = $route;
	}
}

function swap_active($caller,$active,$useImg) {
	if(typeof($active) == 'undefined' || $active !== true) {
		$active = false;
	}

	if(typeof($useImg) == 'undefined' || $useImg !== true) {
		$useImg = false;
	}

	if(typeof($caller) == 'object') {
		$id = $caller.id;
		$id = $id.replace('_img','');
		$id = $id.replace('_frame','');

		$link  = document.getElementById($id);
		$img   = document.getElementById($id + '_img');
		$frame = document.getElementById($id + '_frame');

		if($active) {
			if($useImg && typeof($img) == 'object' && $img != null) {
				$path = $img.src.substr(0,$img.src.lastIndexOf('.'));
				$fext = $img.src.substr($img.src.lastIndexOf('.'));
				$img.src = $path + '_active' + $fext;
			}
			else {
				if(typeof($img) == 'object' && $img != null && window.opacityFilter) {
					$img.style.filter = 'alpha(opacity=80)';
				}
				else if(typeof($img) == 'object' && $img != null) {
					$img.style.opacity = .8;
				}
			}
			if(typeof($link) == 'object' && $link != null) {
				$link.className = $link.className + '_active';
			}
			if(typeof($frame) == 'object' && $frame != null) {
				$frame.className = $frame.className + '_active';
			}
		}
		else {
			if($useImg && typeof($img) == 'object' && $img != null) {
				$img.src = $img.src.replace('_active','');
			}
			else {
				if(typeof($img) == 'object' && $img != null && window.opacityFilter) {
					$img.style.filter = 'alpha(opacity=100)';
				}
				else if(typeof($img) == 'object' && $img != null) {
					$img.style.opacity = 1;
				}
			}
			if(typeof($link) == 'object' && $link != null) {
				$link.className = $link.className.replace('_active','');
			}
			if(typeof($frame) == 'object' && $frame != null) {
				$frame.className = $frame.className.replace('_active','');
			}
		}
	}
}

function swap_submenu($caller,$active) {
	if(typeof($active) == 'undefined' || $active !== true) {
		$active = false;
	}

	if(typeof($caller) == 'object') {
		$count = 0;
		do {
			$link = $caller.childNodes[$count];
			$count++;
		}
		while($link.nodeType == 3 && $caller.childNodes[$count]);

		if($active) {
			$caller.style.backgroundImage = 'url(images/header_dot.png)';

			if(typeof($link) == 'object' && $link != null) {
				$link.className = $link.className + '_active';
			}
		}
		else {
			$caller.style.backgroundImage = 'none';

			if(typeof($link) == 'object' && $link != null) {
				$link.className = $link.className.replace('_active','');
			}
		}
	}
}

function clearField($caller,$clearText) {
	if(typeof($caller) == 'object') {
		if(typeof($clearText) != 'undefined' && ($caller.value.toLowerCase() == $clearText.toLowerCase() || $caller.innerHTML.toLowerCase() == $clearText.toLowerCase())) {
			$caller.value = '';
			$caller.innerHTML = '';
		}
		else {
			$caller.value = '';
			$caller.innerHTML = '';
		}
	}
}
