function emptyfield(my_el, my_value) {
	my_el = $(my_el);
	if (my_el) {
		my_el.onfocus = function() {
			if (this.value == my_value) this.value = '';
		}
		my_el.onblur = function() {
			if (!this.value.match(/\S/)) this.value = my_value;
		}
	}
	my_el.value = my_value;
}

function quicksearch() {
	var qstf = $("quicksearchform");
	var qst = $("quicksearchtoken");
	var error = false;
	var clicked = false;
	if (qst && qstf) {
		qstf.onsubmit = function(){
			if (qst.value == "Suche" || qst.value == "") {
				if (!error) {
					var msg_txt = "Bitte geben Sie einen Suchbegriff ein.";
					var msg = new Element('div', {
						'id': 'msg'
					}).update(msg_txt).setStyle({
						display: 'none'
					});
					if (!clicked) {
						qstf.insert({
							top: msg
						});
					}
					Effect.Appear("msg");
					msg.onclick = function(){
						Effect.Fade("msg");
						clicked = true;
						error = false;
					}
				}
				error = true;
				return false;
			} else {
				return true;
			}
		}
	}
}

function toplink() {
	var tpl = $("tpl");
	var sub = $("sub");
	if (tpl && sub) {
		tpl.onclick = function() {
			Effect.ScrollTo(sub);
			return false;
		};
	/*
var container_height = $("container").getHeight();
var viewport_height = document.viewport.getHeight();
if (viewport_height < container_height) {
tpl.style.display = "block";
}
*/			
	}
}

function newslist() {
	var news = $('sub');
	if (news) {
		if (news.hasClassName('newslist')) {
			var nitemlink = $$('.news-list-item h4 a');
			nitemlink.each(function(e) {
				e.up(1).onclick = function() {
					document.location.href=e;
				}
			});
		}
	}
}

function  menufix() {
	var el = $$(".main-navigation li")
	if (el) {
		if (el.first().hasClassName("active")) {
			var first = el.first().addClassName("firstactive");
		}
		if (el.last().hasClassName("active")) {
			var last = el.last().addClassName("lastactive");
		}
	}
}

function init(){
	emptyfield("quicksearchtoken", "Suche");
	quicksearch();
	newslist();
	toplink();
	if (Prototype.Browser.IE6) {
		menufix();
	}
}
document.observe("dom:loaded", init);
/*
window.onresize = function() {
};
*/