// Alle die Javascript aktiviert haben, genie�en der Vorzug
// dass sich das Layout der Fenstergr��e anpasst


	function showLayout(){
		// Alle Seitenelemente mit dem Namen visible werden angezeigt
		e=document.getElementsByTagName('div');
		for (i=0;i<e.length;i++){
			if (e[i].getAttribute("vis")=='hidden') e[i].style.visibility='hidden';
		}
		for (i=0;i<e.length;i++){
			if (e[i].getAttribute("vis")=='visible') e[i].style.visibility='visible';
		}
	}

	function initLayoutParameter() {

		// originale Layoutgr��e
		originalwidth = 55 + 700;
		originalheight = 100 + 475;

		// Ermitteln der Fenstergr��e
		width = getWindowWidth();
		height = getWindowHeight();

		// nur skalieren, wenn Fenster gr��er als das Original ist
		if (originalwidth>=width || originalheight-30>=height) {//return false;
			//width=originalwidth;//*(originalheight-30)/originalheight;
			//height=originalheight;//-30;
		}

		// globale Layoutparameter
		toplineleft = 55;
		toplineright = 10;//(originalwidth - width) * 0.3;
		leftlinetop = 100;
		leftlinebottom = 0; //(originalheight - height) * 0.3;
		mainbackgroundleft = 112;
		mainbackgroundtop = 102;
		mainbackgroundwidth = 694;
		mainbackgroundheight = 400;
		mainbackgroundbottom = leftlinebottom;// - 10;
		mainbackgroundright = toplineright;
		topmenuleft = 220;
		topmenuwidth = 585;
		toplinkswidth= 440;
		//topmenuright = siluetteright - 30;
		topmenuright = toplineright;
		maincontentleft = 156;
		maincontenttop = 149;
		maincontentwidth = 602;
		maincontentheight = 309;
		mainheadlineleft = 176;
		mainheadlinetop = 122;
		mainheadlinefontsize = 16;
		leftsideimgtop = 129;
		leftsideshadowtop = 223;
		leftsideshadowleft = 157;
		dennissitheight = 70;
		sprechblaseheight = 110;

		leftmenutop = maincontenttop;
		leftmenuleft = toplineleft;
		leftmenuwidth = maincontentleft-leftmenuleft;
		leftmenuheight = maincontentheight;
	}

	function resizeLayout(){


		initLayoutParameter();

		var maincontent = document.getElementById(maincontentid);
		maincontent.style.visibility = 'hidden';



		// Leftline verl�ngern
		var leftline = document.getElementById('leftline');
		leftline.style.height = height + leftlinebottom - leftlinetop;

		// MainBackground skalieren
		var mainbackground = document.getElementById('mainbackground');
		var scalex = (width-mainbackgroundleft-mainbackgroundright)/mainbackgroundwidth;
		var scaley = (height-mainbackgroundtop-mainbackgroundbottom)/mainbackgroundheight;
		scalex = (scalex<scaley) ? scalex : scaley;
		if (scalex<1.05) scalex = 1.05;
		//if (scaley>1.05) scaley = scalex;

		mainbackground.style.width = Math.round(mainbackgroundwidth * scalex);
		mainbackground.style.height = Math.round(mainbackgroundheight * scaley);

		// Topline verl�ngern
		var topline = document.getElementById('topline');
		topline.style.width = mainbackgroundleft - toplineleft + Math.round(mainbackgroundwidth * scalex);

		// TopMen� verbreitern
		var topmenu = document.getElementById('topmenu');
		topmenu.style.width = mainbackgroundleft - topmenuleft + Math.round(mainbackgroundwidth * scalex);
		var toplinks = document.getElementById('toplinks');
		toplinks.style.width = Math.round(toplinkswidth * scalex);
//		topmenu.style.width = width + topmenuright - topmenuleft;

		// MainContent skalieren
		var newmaincontentleft = Math.round(mainbackgroundleft + (maincontentleft-mainbackgroundleft) * scalex);
		var maincontentpaddingbottom = (0.05*height)>30 ? (0.05*height) : 30;
		if (maincontentid == 'maincontent')
		{
			var newmaincontenttop = Math.round(mainbackgroundtop + (maincontenttop-mainbackgroundtop) * scaley);
			var newmaincontentheight = maincontentheight*scaley;//height - newmaincontenttop - maincontentpaddingbottom;
		} else
		{
			var newmaincontenttop = leftlinetop;
			var newmaincontentheight = height-leftlinetop-maincontentpaddingbottom;
			
		}
		maincontent.style.height = newmaincontentheight;
		maincontent.style.left = newmaincontentleft;
		maincontent.style.width = Math.round(maincontentwidth * scalex);
		maincontent.style.top = newmaincontenttop;

		//maincontent.style.clip = 'rect('+(1+4)+' 0 200 200)';

		// MainHeadline verschieben
		var mainheadline = document.getElementById('mainheadline');
		mainheadline.style.left = mainbackgroundleft + (mainheadlineleft-mainbackgroundleft) * scalex;
		mainheadline.style.top = mainbackgroundtop + (mainheadlinetop-mainbackgroundtop) * scaley;
		mainheadline.style.fontSize = (mainheadlinefontsize * scalex)+'pt';

		// leftsideimg verschieben (inkl. Schatten)
		var leftsideimg = document.getElementById('leftsideimg');
		var leftsideshadow = document.getElementById('leftsideshadow');
		var leftsideshadowline = document.getElementById('leftsideshadowline');
		var newleftsideimgtop = /*mainbackgroundtop + (leftsideimgtop-mainbackgroundtop)*/ leftsideimgtop*scalex;
		// Der Schatten unter dem linken Bild wird am Rand der Contentbox abgeschnitten, da er farblich nur
		// zu dieser passt und auf dem �brigen (scharzen) Hintergrund eh kein Schatten zu sehen ist.
		// Desweiteren wandert der Schatten nat�rlich mit dem Bild hoch und runter.
		leftsideimg.style.top = newleftsideimgtop;
		leftsideshadow.style.top = leftsideshadowtop+newleftsideimgtop-leftsideimgtop;
		leftsideshadow.style.clip = 'rect(0 100 100 ' +(newmaincontentleft-maincontentleft+4) +')';
		// Der Schatten auf der MainContentBorder unter dem Bild muss je nach Abstand des Bildes
		// von der Box gr��er oder kleiner werden und hoch und runter gehen.
		// Folgende Berechnungen haben sich als empirisch gut gezeigt, folgen aber keiner
		// nachweisbaren Logik :-)
		leftsideshadowline.style.top = leftsideshadowtop+newleftsideimgtop-leftsideimgtop;
		leftsideshadowline.style.left = leftsideshadowleft+newmaincontentleft-maincontentleft-1;
		leftsideshadowline.height = 46-(newmaincontentleft-maincontentleft);

		// dennissit verschieben
		// hierzu geh�rt ein kleiner Trick:
		// Mozilla stellt im Gegensatz zu IE oder Opera den Rahmen eines Objekts au�erhalb dieses
		// Objektes dar. Das hei�t: echte Objektbreite = objekt.width+borderwidth. Um den Dennis
		// nun genau auf der Border auszurichten, muss man dies beachten und je nach Browser +/-1
		// Pixel Offset hinzuf�gen
		var dennissit= document.getElementById('dennissit');
		dennissit.style.top = ((isIE || isOpera) ? -1 : +1)+Math.round(newmaincontenttop + maincontentheight * scaley)-dennissitheight;
		dennissit.style.left = newmaincontentleft - 14;
		dennissit.style.height = dennissitheight;

		// Dennis hat eine lustige Sprechblase
		var sprechblase= document.getElementById('sprechblase');
		sprechblase.style.left = newmaincontentleft - 27;
		sprechblase.style.top = 30 + newmaincontenttop + maincontentheight * scaley - dennissitheight - sprechblaseheight;

		// leftmenu
		var newleftmenutop = Math.round(mainbackgroundtop + (leftmenutop-mainbackgroundtop) * scaley);
		var imgbrowser_thumbs = document.getElementById('imgbrowser_thumbs');
		var imgbrowser_thumbs_up = document.getElementById('imgbrowser_thumbs_up');
		var imgbrowser_thumbs_dn = document.getElementById('imgbrowser_thumbs_down');
		if (imgbrowser_thumbs)
		{
			leftsideimg.setAttribute('vis','hidden',0);
			leftsideshadow.setAttribute('vis','hidden',0);
			leftsideshadowline.setAttribute('vis','hidden',0);

			imgbrowser_thumbs.style.position = 'absolute';
			imgbrowser_thumbs.style.left = leftmenuleft-20;
//			imgbrowser_thumbs.style.width = newmaincontentleft-leftmenuleft-10;
			imgbrowser_thumbs.style.top = newleftmenutop;
			imgbrowser_thumbs_up.style.left = leftmenuleft-20;
			imgbrowser_thumbs_up.style.top  = newleftmenutop-40-8;
			imgbrowser_thumbs_down.style.left = leftmenuleft-20;

			if (maincontentid == 'maincontent')
			{
				imgbrowser_thumbs.style.height = newmaincontentheight;//leftmenuheight*scaley;
				imgbrowser_thumbs_down.style.top = newleftmenutop + newmaincontentheight+3;
			} else
			{
				imgbrowser_thumbs.style.height = height-newleftmenutop-maincontentpaddingbottom;//height-newleftmenutop-(newleftmenutop-leftlinetop);
				imgbrowser_thumbs_down.style.top = newleftmenutop+ height-newleftmenutop-maincontentpaddingbottom+3;
			}

		}

		// imagebrowser preview
		var imgbrowser_preview = document.getElementById('imgbrowserpreview');
		if (imgbrowser_preview)
		{
			dennissit.setAttribute('vis','hidden',0);
			mainheadline.setAttribute('vis','hidden',0);
		}

/*		// Topmenu anpassen
		topmenu = document.getElementsByName('tmi');
		for (var i=0;i<topmenu.length;i++){
			topmenu[i].style.fontSize = (12*(1.05+(scalex-1.05)/2))+'pt';
			status = i;
		}*/

		showLayout();

	}


	function getWindowWidth(){
		// Internet Explorer kennt das window-Attribut innerWidth nicht,
		// daf�r aber offsetWidth im Body. Dies wird im folgenden unterschieden.
		return (typeof(window.innerWidth) != 'undefined') ? window.innerWidth : (document.body.offsetWidth-20);
	}


	function getWindowHeight(){
		// Internet Explorer kennt das window-Attribut innerHeight nicht,
		// daf�r aber offsetHeight im Body. Dies wird im folgenden unterschieden.
		return (typeof(window.innerHeight) != 'undefined') ? window.innerHeight : (document.body.offsetHeight-20);
	}


