function Browser_Detection() {
	var ua = navigator.userAgent.toLowerCase(); 
	
	this.Gecko     = (ua.indexOf('gecko') != -1 && ua.indexOf('safari') == -1);
	this.Mozilla   = (this.Gecko && ua.indexOf('gecko/') + 14 == ua.length);
	this.NS        = ( (this.Gecko) ? (ua.indexOf('netscape') != -1) : ( (ua.indexOf('mozilla') != -1) && (ua.indexOf('spoofer') == -1) && (ua.indexOf('compatible') == -1) && (ua.indexOf('opera') == -1) && (ua.indexOf('webtv') == -1) && (ua.indexOf('hotjava') == -1) ) );
	this.IE        = ( (ua.indexOf('msie') != -1) && (ua.indexOf('opera') == -1) && (ua.indexOf('webtv') == -1) ); 
	this.Safari    = (ua.indexOf('safari') != - 1);
	this.Opera     = (ua.indexOf('opera') != -1); 
	this.Konqueror = (ua.indexOf('konqueror') != -1 && !this.isSafari); 
	this.Icab      = (ua.indexOf('icab') != -1); 
	this.Aol       = (ua.indexOf('aol') != -1); 
	
	this.versionMinor = parseFloat(navigator.appVersion); 
	
	if (this.NS && this.Gecko) {
		this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('/') + 1 ) );
	} else if (this.IE && this.versionMinor >= 4) {
		this.versionMinor = parseFloat( ua.substring( ua.indexOf('msie ') + 5 ) );
	} else if (this.Mozilla) {
		this.versionMinor = parseFloat( ua.substring( ua.indexOf('rv:') + 3 ) );
	} else if (this.Safari) {
		this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('/') + 1 ) );
	} else if (this.Opera) {
		if (ua.indexOf('opera/') != -1) {
			this.versionMinor = parseFloat( ua.substring( ua.indexOf('opera/') + 6 ) );
		} else {
			this.versionMinor = parseFloat( ua.substring( ua.indexOf('opera ') + 6 ) );
		}
	} else if (this.Konqueror) {
		this.versionMinor = parseFloat( ua.substring( ua.indexOf('konqueror/') + 10 ) );
	} else if (this.Icab) {
		if (ua.indexOf('icab/') != -1) {
			this.versionMinor = parseFloat( ua.substring( ua.indexOf('icab/') + 6 ) );
		} else {
			this.versionMinor = parseFloat( ua.substring( ua.indexOf('icab ') + 6 ) );
		}
	}
	
	this.versionMajor = parseInt(this.versionMinor); 
	this.geckoVersion = ( (this.Gecko) ? ua.substring( (ua.lastIndexOf('gecko/') + 6), (ua.lastIndexOf('gecko/') + 14) ) : -1 );
	
	this.DOM1 = (document.getElementById)? true : false;
	this.DOM2Event = (document.addEventListener && document.removeEventListener) ? true : false;
	this.mode = document.compatMode ? document.compatMode : 'BackCompat';
	
	this.Win   = (ua.indexOf('win') != -1);
	this.Win32 = (this.Win && ( ua.indexOf('95') != -1 || ua.indexOf('98') != -1 || ua.indexOf('nt') != -1 || ua.indexOf('win32') != -1 || ua.indexOf('32bit') != -1 || ua.indexOf('xp') != -1) );
	this.Mac   = (ua.indexOf('mac') != -1);
	this.Unix  = (ua.indexOf('unix') != -1 || ua.indexOf('sunos') != -1 || ua.indexOf('bsd') != -1 || ua.indexOf('x11') != -1)
	this.Linux = (ua.indexOf('linux') != -1);
	this.M1up = (this.Mozilla && this.versionMinor >= 1);
	this.M13up = (this.Mozilla && this.versionMinor >= 1.3);
	this.NS4x = (this.NS && this.versionMajor == 4);
	this.NS40x = (this.NS4x && this.versionMinor < 4.5);
	this.NS47x = (this.NS4x && this.versionMinor >= 4.7);
	this.NS4up = (this.NS && this.versionMinor >= 4);
	this.NS6x = (this.NS && this.versionMajor == 6);
	this.NS6up = (this.NS && this.versionMajor >= 6);
	this.NS7x = (this.NS && this.versionMajor == 7);
	this.NS7up = (this.NS && this.versionMajor >= 7);
	this.IE4x = (this.IE && this.versionMajor == 4);
	this.IE4up = (this.IE && this.versionMajor >= 4);
	this.IE5x = (this.IE && this.versionMajor == 5);
	this.IE55 = (this.IE && this.versionMinor == 5.5);
	this.IE5up = (this.IE && this.versionMajor >= 5);
	this.IE6x = (this.IE && this.versionMajor == 6);
	this.IE6up = (this.IE && this.versionMajor >= 6);
	this.IE4xMac = (this.IE4x && this.Mac);
}

var browser = new Browser_Detection();



var doopt = false;
var amain = false;
var activeElm = false;
var bgColor = "#8F362C";
var color = "#C5C0B4";

function hmainNav(elm) {
	if(document.getElementById("ms"+elm)) {
		if(document.getElementById("ms"+(elm-1))) {
			if((elm-1)!=amain) {
				document.getElementById("ms"+(elm-1)).className = "mainnavspaceractive2";
			} else {
				document.getElementById("ms"+(elm-1)).className = "mainnavspaceractive3";
			}
		} else if(elm==1) {
			document.getElementById("nc").className = "navcontaineractive";
		}
	}
}

iens6=document.all||document.getElementById

var crossobj=false;
var contentheight=false;
var scrolldown = false;
var scrollup = false;




function himg(e) {
	e=e || window.event;
	type = e.type;
	target = e.target || e.srcElement || null;
	if(target.id=="subnavscrolldown") {
		document.getElementById(target.id).className = "scrolldowna";
	} else {
		document.getElementById(target.id).className = "scrollupa";
	}
}

function dimg(e) {
	e=e || window.event;
	type = e.type;
	target = e.target || e.srcElement || null;
	if(target.id=="subnavscrolldown") {
		document.getElementById(target.id).className = "scrolldown";
	} else {
		document.getElementById(target.id).className = "scrollup";
	}
}

function getHeight() {
	if( typeof( window.innerHeight ) == 'number' ) {
		Height = window.innerHeight;
	} else if( document.documentElement &&( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		Height = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		Height = document.body.clientHeight;
	} else {
		Height = screen.availHeight;
	}
	return parseInt(Height);
}

function optimizeSubnav()  {
	if(browser.Mac)  {
		if(!browser.M1up) {return;}
	}
	if(browser.Mac)  {
		if(browser.IE) {return;}
	}

	if(!document.createElement) {return;}
	window.scrollTo(0,0);
	if(self.location==top.location) {	
		h = getHeight();
		cbpos = parseInt(document.getElementById("contentbox").offsetTop);
		cfheight = parseInt(document.getElementById("footer").offsetHeight);
		if(h>=500) {
			f = (cbpos+cfheight)+20;
			ch = (parseInt(h)-f);
			document.getElementById("contentbox").style.height=ch+"px";
		}
	}
	crossobj=document.getElementById? document.getElementById("subnavcontent") : document.all.subnavcontent;
	if(!crossobj) {return;}
	container = document.getElementById? document.getElementById("subnavcontainer") : document.all.subnavcontainer;
	if((crossobj.offsetHeight+5)<container.offsetHeight) {return;}
	if (!scrolldown && document.createElement) {
		var temp=document.createElement('div');
		temp.setAttribute('id','subnavscrolldown');
		temp.setAttribute('class','scrolldown');
		scrolldown = document.body.appendChild(temp);
		document.getElementById("subnavscrolldown").className = "scrolldown";

		if(document.attachEvent) {
			document.getElementById("subnavscrolldown").attachEvent("onmousedown",movedown);
			document.getElementById("subnavscrolldown").attachEvent("onmouseup",stopscroll);
			document.getElementById("subnavscrolldown").attachEvent("onmouseover",himg);
			document.getElementById("subnavscrolldown").attachEvent("onmouseout",dimg);

		} else {
			document.getElementById("subnavscrolldown").addEventListener("mouseover",himg,true);
			document.getElementById("subnavscrolldown").addEventListener("mouseout",dimg,true);
			document.getElementById("subnavscrolldown").addEventListener("mousedown",movedown,true);
			document.getElementById("subnavscrolldown").addEventListener("mouseup",stopscroll,true);
		}
	}
	if (!scrollup && document.createElement) {
		var temp=document.createElement('div');
		temp.setAttribute('id','subnavscrollup');
		scrollup= document.body.appendChild(temp);
		document.getElementById("subnavscrollup").className = "scrollup";
		if(document.attachEvent) {
			document.getElementById("subnavscrollup").attachEvent("onmousedown",moveup);
			document.getElementById("subnavscrollup").attachEvent("onmouseup",stopscroll);
			document.getElementById("subnavscrollup").attachEvent("onmouseover",himg);
			document.getElementById("subnavscrollup").attachEvent("onmouseout",dimg);

		} else {
			document.getElementById("subnavscrollup").addEventListener("mouseover",himg,true);
			document.getElementById("subnavscrollup").addEventListener("mouseout",dimg,true);
			document.getElementById("subnavscrollup").addEventListener("mousedown",moveup,true);
			document.getElementById("subnavscrollup").addEventListener("mouseup",stopscroll,true);
		}
	}
	container.className = "scopt";
	crossobj.style.position = "relative";
	crossobj.style.top = "0px";
	contentheight = crossobj.offsetHeight;
	if(location.search && location.search!="") {
		params = location.search;
		params = params.substr(1,(params.length-1));
		items = params.split("&");
		aid = false;
		for(i = 0; i<items.length; i++) {
			tmp = items[i].split("=");
			if(tmp[0]=="jt") {aid = tmp[1];}
			break;
		}
		if(document.getElementById(aid)) {
			ot = parseInt(document.getElementById(aid).offsetTop);
			if(document.all) {
				crossobj.style.top="-"+ot+"px";
			} else { 
				ot = Math.ceil(ot/2);
				crossobj.style.top="-"+ot+"px";
			}
		}
	}
	doopt = true;
}

speed = 2;

function movedown(){
	if (window.moveupvar) {clearTimeout(moveupvar);}
	if (parseInt(crossobj.style.top)>=(contentheight*(-1)+100)) {
		crossobj.style.top=parseInt(crossobj.style.top)-speed+"px";
	}
	movedownvar=setTimeout("movedown()",20);
}

	
function moveup(){
	if (window.movedownvar) {clearTimeout(movedownvar);}
	if (parseInt(crossobj.style.top)<=0) {
		crossobj.style.top=parseInt(crossobj.style.top)+speed+"px";
	}
	moveupvar=setTimeout("moveup()",20);
}

function stopscroll(){
	if (window.moveupvar) {clearTimeout(moveupvar);}
	if (window.movedownvar) {clearTimeout(movedownvar);}
}

function optimize() {
	if(!browser.Mac)  {
		if(browser.IE) {return;}
	}
	if(!document.styleSheets) {return;}
	if(document.styleSheets.length<1) {return;}
	if(!document.getElementById) {return;}
	h = getHeight();
	cbpos = parseInt(document.getElementById("contentbox").offsetTop);
	cfheight = parseInt(document.getElementById("footer").offsetHeight);
	if(h<500) {return;}
	f = (cbpos+cfheight)+20;
	ch = (parseInt(h)-f);
	document.getElementById("contentbox").style.height=ch+"px";
}

function optIEMAC() {
	if(document.all.subnavcontainer) {
		html = document.all.subnavcontainer.innerHTML;
		document.all.subnavcontainer.innerHTML = "<table cellpadding=\"0\" cellspacing=\"0\"><tr><td nowrap width=\"64\">&nbsp;</td><td valign=\"top\">"+html+"</td></tr></table>";
		rep = false;
	}
	newbox = "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr>";
	if(document.all.leftcontainer) {
		rep = true;
		lcontent = document.all.leftcontainer.innerHTML;
		newbox += "<td width=\"87\" nowrap>&nbsp;</td><td valign=\"top\" width=\"150\">"+lcontent+"</td><td width=\"20\" nowrap>&nbsp;</td>";
	}
	if(document.all.contentbox) {
		var divs=document.all.contentbox.getElementsByTagName("DIV");
		for(var d=0; d < divs.length;d++){  
			if(divs[d].className=="contentcontainer") {
				rep = true;
				mcontent = divs[d].innerHTML;
				newbox += "<td valign=\"top\" width=\"390\">"+mcontent+"</td><td width=\"20\" nowrap>&nbsp;</td>";
				break;
			} else if(divs[d].className=="contentcontainerWide") {
				rep = true;
				mcontent = divs[d].innerHTML;
				newbox += "<td valign=\"top\" width=\"684\">"+mcontent+"</td>";
				break;
			} else if(divs[d].className=="contentcontainerIndex") {
				rep = true;
				mcontent = divs[d].innerHTML;
				newbox += "<td valign=\"top\" width=\"390\" class=\"contentcontainerIndex\">"+mcontent+"</td><td width=\"20\" nowrap>&nbsp;</td>";
				break;
			}
		}
	}
	if(document.all.rightcontainer) {
		rep = true;
		rcontent = document.all.rightcontainer.innerHTML;
		newbox += "<td valign=\"top\">"+rcontent+"</td>";
	}
	newbox += "</tr></table>";
	if(rep && document.all.contentbox) {
		document.all.contentbox.innerHTML = newbox;
	}
}


function initDelphi() {
	if(amain && amain!="") {
		hmainNav(amain);
	}
	if(browser.Mac)  {
		if(browser.IE) {
		if(document.all.movieteaser) {
			nw = window.open("http://www.delphi-film.de/docroot/html/info.html","infowin","left=10,top=10,height=260,width=270,scrollbars=1");
			try {nw.focus();} catch(e){}
		}
		optIEMAC();
		return;
		}
	}
	if(!document.styleSheets) {return;}
	if(document.styleSheets.length<1) {return;}
	optimize();	
	optimizeSubnav();
}

onload = initDelphi;

if(self.location==top.location) {
	onresize = optimize;
}