var theOffset = 190;
var theWidth = '158px';
var theFrameWidth = '610px';
var params = location.search.toQueryParams();
var currentPage;
var undefined;

function trueheight() {
	var theHeight = 0;
	if (window.innerHeight) {
		theHeight = window.innerHeight;
	} else if (document.body && document.documentElement.clientHeight) {
		theHeight = document.documentElement.clientHeight;
	}
	return theHeight;
}

function anpassen() {
	var fhoehe = trueheight() - theOffset;

	/* Höhe des Menüdivs */
	if($('maincontainer').getHeight() >= fhoehe) {
		fhoehe = $('maincontainer').getHeight() - theOffset;
	}
	try {
		$('menudiv').setStyle({
			'height' : fhoehe + 'px',
			'width'  : theWidth
		});
	} catch(err) {
		void(0);
	}

	/* iframe für gema */
	try {
		if($('theiframe') != undefined) {
			$('theiframe').setStyle({
				'height' : fhoehe + 'px',
				'width' : theFrameWidth
			});
		}
	} catch(err) {
		void(0);
	}
}

function initMenu() {
	var params = location.search.toQueryParams();
	try {
		currentPage = (params.page == undefined) ? "home" : params.page;
		mark(currentPage);
	} catch(err) {
		void(0);
	}
}

function mark(what) {
	try {
		if($(what) != $('null')){
			$(what).addClassName("marked");
		}
	} catch(err) {
		void(0);
	}
}

function unmark(what) {
	if(what != currentPage) {
		$(what).removeClassName("marked");
	}
}

function setPage() {
	$('vidcontainer').hide();
//	alert(currentPage);
	switch(currentPage) {
		case "home":
		case "news":
			$('centercolumn').setStyle({
				'margin' : '0px 10px 0px 10px',
				'width' : '458px'
			});
			$('rightcolumn').setStyle({
				'width' : '167px'
			});
		break;

		default:
		break;
	}
}

/* lädt übergebene Seite und selektiert den entsprechenden Menüpunkt */
function loadPage(thePage) {
	/* alle Menüpunkte deselektieren und gewählten Punkt selektieren */
	$$('#menudiv div.menuitem').invoke('removeClassName', 'marked');
	mark(thePage);

	/* Seite aufrufen */
	location.href = "index.php?page=" + thePage;
}


function openPlayer() {
	try {
		var s1 = new SWFObject("player.swf","ply","352","288","9","#53783A");
			s1.addParam("allowfullscreen","true");
			s1.addParam("allowscriptaccess","always");
			s1.addParam("flashvars","file=media/oechsle.flv&image=img/preview.jpg");
			s1.write("innervidcontainer");
		} catch(err) {
			$('vidcontainer').update('<a href="http://www.macromedia.com/go/getflashplayer">Get the Flash Player</a> to see this player.');
		}
		$('vidcontainer').setStyle({
			'width' : '350px',
			'height' : '300px'
		});
		$('vidcontainer').show();
	return false;
}

function closePlayer() {
	$('vidcontainer').setStyle({
			'width' : '0px',
			'height' : '0px'
	});
	$('vidcontainer').hide();
	return false;
}


/* install event handlers */

document.observe("dom:loaded", function() {
				anpassen();
				initMenu();
				setPage();
			});

Event.observe(window, "resize", anpassen);

