Event.observe(window, 'load', detectFlash);
		
// GET Hack
var qs = location.search.substring(1);
var nv = qs.split('&');
var url = new Object();
for(i = 0; i < nv.length; i++) {
	eq = nv[i].indexOf('=');
	url[nv[i].substring(0,eq).toLowerCase()] = unescape(nv[i].substring(eq + 1));
}

// Debug Modus
if (url['debug'] == 1) {
	var requiredVersion = 10;
} else {
	var requiredVersion = 8;
}

// Flash Check
var flash2Installed = false;
var flash3Installed = false;
var flash4Installed = false;
var flash5Installed = false;
var flash6Installed = false;
var flash7Installed = false;
var flash8Installed = false;
var flash9Installed = false;
var maxVersion = 9;
var actualVersion = 0;

var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;

if(isIE && isWin){
	document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n');
	document.write('on error resume next \n');
	document.write('flash2Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.2"))) \n');
	document.write('flash3Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.3"))) \n');
	document.write('flash4Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.4"))) \n');
	document.write('flash5Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.5"))) \n');  
	document.write('flash6Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.6"))) \n');  
	document.write('flash7Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.7"))) \n');
	document.write('flash8Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.8"))) \n');
	document.write('flash9Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.9"))) \n');
	document.write('<\/SCR' + 'IPT\> \n');
}
	
function detectFlash() {
	if (navigator.plugins) {
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			var isVersion2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
			var flashDescription = navigator.plugins["Shockwave Flash" + isVersion2].description;
			
			var flashVersion = parseInt(flashDescription.substring(16));
			
			flash2Installed = flashVersion == 2;    
			flash3Installed = flashVersion == 3;
			flash4Installed = flashVersion == 4;
			flash5Installed = flashVersion == 5;
			flash6Installed = flashVersion == 6;
			flash7Installed = flashVersion == 7;
			flash8Installed = flashVersion == 8;
			flash9Installed = flashVersion >= 9;
		}
	}
	
	for (var i = 2; i <= maxVersion; i++) {  
		if (eval("flash" + i + "Installed") == true) actualVersion = i;
	}

	if (actualVersion >= requiredVersion) {
		
		insertFlash();
		     
	} else {
	
		$('wrapper').setStyle(
			{
  			visibility: 'visible'
			}
		);
		
		anpassen();
		
		initPfeile();

		Event.observe(window, 'resize', anpassen);
}


};

function anpassen() {
	
	var wrapper = new Position.getWrapperSize();
	
	var bildMasse = new Position.getPictureSize();
	
	var bild = $('bild');
	
	$('wrapper').setStyle({width: wrapper.width + 'px', height: wrapper.height + 'px'});

	var bildMasseBzuH = bildMasse.width / bildMasse.height;
	// 1.77
	
	var stagerHzuB = wrapper.width / wrapper.height;
	
	if (bildMasseBzuH >= stagerHzuB) {
		
		bild.setStyle(
			{
			top: '0px', 
			height: Math.round(wrapper.height) + 'px', 
			width: Math.round(bildMasseBzuH * bildMasse.height) + 'px', 
			left: Math.round((wrapper.width - bildMasse.width) / 2) + 'px'
			}
		);
		
		//window.status = bildMasseBzuH + ' * ' + bildMasse.height;
		
		text = 'X';
		
	} else {
		
		bild.setStyle(
			{
			left: '0px', 
			width: Math.round(wrapper.width) + 'px', 
			height: Math.round(bildMasse.width / bildMasseBzuH) + 'px', 
			top: Math.round((wrapper.height - bildMasse.height) / 2) + 'px'
			}
		);
		
		
		text = 'Y';
		
	}

	//document.title = bildMasseBzuH + ', ' + stagerHzuB + ', B: ' + bild.getStyle('width') + ', H: ' + bild.getStyle('height') + ', X: ' + bild.getStyle('left') + ', Y: ' + bild.getStyle('top') + ', ' + text;
		
}

Position.getWrapperSize = function(w) {
	var width, height;
	w = w ? w : window;
	
	this.width = (w.innerWidth || (w.document.documentElement.clientWidth || w.document.body.clientWidth)) -24;
	this.height = (w.innerHeight || (w.document.documentElement.clientHeight || w.document.body.clientHeight)) -24;
	
	return this;
}

Position.getPictureSize = function(w) {
	var width, height;	
	
	this.width = $('bild').getWidth();
	this.height = $('bild').getHeight();
	
	return this;
}

var to;

function runter(id) {
	
	var hoehe = $('liste-' + id).getHeight();
	
	var position = parseInt($('liste-' + id).getStyle('top')) - 14;
	
	var differenz = 124 - hoehe;
	
	if (position > differenz) {
	
		$('liste-' + id).setStyle({top: position + 'px'});
	
		to = setTimeout("runter(" + id + ")", 150);
		
	} else {
	
		$('liste-' + id).setStyle({top: differenz + 'px'});
		
		stop();
		
	}

}

function rauf(id) {

	var hoehe = $('liste-' + id).getHeight();
	
	var position = parseInt($('liste-' + id).getStyle('top')) + 14;
	
	if (position <= 0) {
	
		$('liste-' + id).setStyle({top: position + 'px'});
	
		to = setTimeout("rauf(" + id + ")", 150);
		
	} else {
	
		$('liste-' + id).setStyle({top: '0px'});
		
		stop();
		
	}
	
}

function stop() {

	clearTimeout(to);

}

function initPfeile() {

	var listen = $$('ul.liste','div.liste');
	
	listen.each(function(n) {
			
			if (n.getHeight() > 124) {
			
				var el_id = n.readAttribute('id');
				
				var id = el_id.replace(/liste-/g, "");
				
				$('pfeile-' + id).setStyle({visibility: 'visible'});
			
			}
			
		}
	)

}

function insertFlash() {
	$('tbl').setStyle(
		{
		visibility: 'visible'
		}
	);
	
	var fonda_swf = new SWFObject(
		PFAD_ROOT + "menu.swf",
		"fonda_swf",
		"100%",
		"100%",
		"8",
		"#FFFFFF"
	);
	
	fonda_swf.addVariable("id", CURR_ID);
	
	fonda_swf.addVariable("pfad_root", PFAD_ROOT);
	
	fonda_swf.addParam("wmode", "transparent");
	
	fonda_swf.write("xx");
}