function popupOpen() {		// parameter.reihenfolge: URL, WIDTH, HEIGHT
	var w,h,url,aw,ah;
	var a=popupOpen.arguments;
	if (a.length==0) return;
	url=a[0];
	if (a.length>1) {
		w=a[1]; h=a[2];
	}
	else {
		w=500; h=400
	}
	win=window.open(url,'win_front','toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width='+w+',height='+h);
	if (screen) {
		aw=screen.availWidth;
		ah=screen.availHeight;
		win.moveTo(((aw/2)-(w/2)),((ah/2)-(h/2)));
	}
	win.focus();
}

function openPicture() {		// parameter.reihenfolge: URL, WIDTH, HEIGHT
	var w,h,url,aw,ah;
	var a=openPicture.arguments;
	if (a.length==0) return;
	url=a[0];
	if (a.length>1) {
		w=a[1]; h=a[2];
	}
	else {
		w=500; h=400
	}
	win_pic=window.open(url,'win_pic','toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width='+w+',height='+h);
	if (screen) {
		aw=screen.availWidth;
		ah=screen.availHeight;
		win_pic.moveTo(((aw/2)-(w/2)),((ah/2)-(h/2)));
	}
	win_pic.focus();
}


var gal_history=new Array();
function changeGalleryPic(l,g,url,txt) {
	if (typeof gal_history[g] == "undefined")
		var old_g_link="g_"+g+"_0";
	else
		var old_g_link=gal_history[g];
	if (old_g_link==l.id) return true;
	$(old_g_link).className="gal";
	l.className="gal_sel";
	gal_history[g]=l.id;
	$("gallery_"+g).src=url;
	$("gallery_"+g).up("a").href=l.href;
	$("gallery_"+g).up("a").title=txt;
	
	$('bildlegende_'+g).update(txt);
}

/// AJAX
var http_request = false;
var reload_url = location.href;

function BrowserIsCompatible() {
	if (!window.RegExp) return false;
	var AGENTS = ["opera","msie","safari","firefox","netscape","mozilla"];
	var agent = navigator.userAgent.toLowerCase();
	for (var i = 0; i < AGENTS.length; i++) {
		var agentStr = AGENTS[i];
		if (agent.indexOf(agentStr) != -1) {
			var versionExpr = new RegExp(agentStr + "[ \/]?([0-9]+(\.[0-9]+)?)");
			var version = 0;
			if (versionExpr.exec(agent) != null) {
				version = parseFloat(RegExp.$1);
			}
			if (agentStr == "opera") return version >= 9;

			if (agentStr == "safari") return version >= 125;
			if (agentStr == "msie") return (version >= 5.5 &&agent.indexOf("powerpc") == -1);
			if (agentStr == "netscape") return version > 7;
		}
	}
	return document.getElementById;
}
function requestObject(){
	try{
		if(typeof ActiveXObject!="undefined"){
			return new ActiveXObject("Microsoft.XMLHTTP")
		}
		else if (window.XMLHttpRequest){
			var out=new XMLHttpRequest();
			out.overrideMimeType('text/xml');
			return out;
		}
	}
	catch(a){ }return null
}
function makeGetRequest(url) {
	http_request = requestObject();
	http_request.onreadystatechange = alertContents;
	http_request.open('GET', url, true);
	http_request.send(null);
}
function alertContents() {
	if (http_request.readyState == 4) {
		if (http_request.status == 200) {
			var alert_box=false;
			try {
				if (http_request.responseText.indexOf("id='alert_box'") != -1) {
					var rt=http_request.responseText;
					var p1=rt.indexOf('>', rt.indexOf("id='alert_box'"));
					var p2=rt.indexOf('</div>');
					var t=rt.substring(p1,p2)
					alert(t.replace("<([^<>\s]*)(\s[^<>]*)?>"," "));
					
				}
				//debug(http_request.responseText);
			}
			catch(e) {
				alert("fehler: "+e);
			}
			
			if (alert_box) {
				debug(alert_box);
			}
			location.href = reload_url;
			//document.getElementById('container').innerHTML = http_request.responseText;
		}
		else if (http_request.status == 0) {
			// IE: abfangen
		}
		else {
			alert('Anforderung konnte nicht verarbeitet werden, HTTP-Fehler '+http_request.status);
		}
	}
}
function getBrowser() {
	if (!window.RegExp) return false;
	var ret={ name:'', version: 0 };
	var AGENTS = ["opera","msie","safari","firefox","netscape","mozilla"];
	var agent = navigator.userAgent.toLowerCase();
	for (var i = 0; i < AGENTS.length; i++) {
		var agentStr = AGENTS[i];
		if (agent.indexOf(agentStr) != -1) {
			var versionExpr = new RegExp(agentStr + "[ \/]?([0-9]+(\.[0-9]+)?)");
			var version = 0;
			if (versionExpr.exec(agent) != null) {
				ret.version = parseFloat(RegExp.$1);
				ret.name=agentStr;
				return ret;
			}
		}
	}
	return ret;
}

var d=document;
var browser=getBrowser();
function scaleContentDiv() {
	var content=d.getElementById('content');
	var c_text=$$('.text')[0];
	if (browser.name=='opera') {
		var dd=d.body;
	}
	else {
		var dd=d.body.parentNode;
	}
	var m= 180;
	var sh=dd.clientHeight;
	var ch=content.clientHeight;
	var cm=c_text.clientHeight;
	content.style.height=(ch+(sh-ch-m))+'px';
	c_text.style.height=(cm+(sh-cm-m-50))+'px';
}

function writeSWF(code, obj) {
	obj.innerHTML=code;
}

function debug(msg) {
	if (typeof w == "undefined") {
		w=window.open('','w','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,width=640,height=400');
	}
	w.document.write(msg+"<br>");
}
function trace(o) {
	var out="";
	for (z in o) {
		try {
		if (o[z]!="" && o[z]!=null)
			if (z=="innerHTML" || z=="outerHTML") out+=z+" = [..HTML-Code..]; <br>\n";
			else out+=z+" = "+o[z]+"; <br>";
		}
		catch (e) {
			out+= z+" = ERROR: "+e+"; <br>";
		}
	}
	debug(out)
}
Event.observe(document, "dom:loaded",scaleContentDiv);
Event.observe(window, "resize", scaleContentDiv);
/*
if (window.attachEvent) {
	window.attachEvent('onload', scaleContentDiv);
	window.attachEvent('onresize', scaleContentDiv);
}
else if (window.addEventListener) {
	window.addEventListener('load', scaleContentDiv, false);
	window.addEventListener('resize', scaleContentDiv, false);
}
*/
// Intro

//var cookiemanager=new Cookiemanager('cookiemanager',10,'minutes');
var cookiemanager=new CookieManager({shelfLife:0.000579}); //0.0000579

function showIntro() {
	var val=cookiemanager.getCookie('jmb_intro');
	var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
	if ( plugin ) {
		plugin = parseInt(plugin.description.substring(plugin.description.indexOf(".")-2));
	}
	else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 && (navigator.userAgent.indexOf("Windows 95")>=0 || navigator.userAgent.indexOf("Windows 98")>=0 || navigator.userAgent.indexOf("Windows NT")>=0)) {
		// fl_plugin wird in VBScript in metadata.tpl gesetzt
		plugin=fl_plugin;
	}
	if (!val && document.cookie && plugin) {
	//if (plugin) {
		document.getElementById('int_loading').style.display='block';
		document.getElementById('int_inloading').style.display='block';
		document.getElementById('Intro_Decker').style.display='block';
	}
}

function closeIntro() {
	document.getElementById('Intro_Decker').style.display='none';
	document.getElementById('int_inloading').innerHTML='';
}

function setIntroCookie() {
	var res=cookiemanager.setCookie('jmb_intro','played');
}
if (window.attachEvent) {
	window.attachEvent('onload', showIntro);
	window.attachEvent('onunload', setIntroCookie);
}
else if (window.addEventListener) {
	window.addEventListener('load', showIntro, false);
	window.addEventListener('unload', setIntroCookie, false);
}

