var theOffset = 200;
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;

	/* iframe für gema */
	try {
		$('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");
			try {
				$(what).firstDescendant().setStyle({color : '#fff'});
			} catch(err) {
				void(0);
			}
		}
	} catch(err) {
		void(0);
	}
}

function unmark(what) {
	if(what != currentPage) {
		$(what).removeClassName("marked");
		try {
			$(what).firstDescendant().setStyle({color : '#636564'});
		} catch(err) {
			void(0);
		}
	}
}

function setPage() {
	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;
}




/* install event handlers */

document.observe("dom:loaded", function() {
				anpassen();
				initMenu();
				setPage();
			});

Event.observe(window, "resize", anpassen);

