var crepeat;

$(document).ready( function () {
	resize_do();
	
	$("#navigation tr").mouseover(function () {
		$(this).addClass("highlightl");
	});
	
	$("#navigation tr").mouseout(function () {
		$(this).removeClass("highlightl");
	});
	
	// Flashmovies register with the swfobject
	 $(".flashmovie").children("object").each( function(index) {
	 	swfobject.registerObject($(this).attr("id"), "9.0.0", $(this).children("param").attr("value"));
	 })
	 
	 $(".bilderow a").each(function () {
		 var buhref = $(this).attr('href');
		 //var getfile = /^.*(\/(.+.jpg))$/;
		 //var filename = getfile.exec(buhref);
		 
		 $(this).attr('href','javascript:showBild(\''+ buhref +'\')');
	 });
	 
	 crepeat = window.setInterval("resize_do()", 1000);

});

$(window).resize( function () {
	resize_do();
});

function showBild(bild) {
	window.open(bild,'Vorschau','width=1027, height=770, directories=no, toolbar=no, location=no, menubar=no, scrollbars=no, status=no, resizable=no, dependent=no')
}

function resize_do() {
	var screen_y = $(document).height();
	var lastlement = $("#lastline").offset();
	var navtop = $("#navigation").offset();
	var navbot = navtop.top + 183;
	var elementbot = $("#botstuff").offset();
	var abstand = screen_y - lastlement.top;
	
	if (lastlement.top -240 <= navbot) {
		var targety = 340;
		lastlement.top = navbot + 20;
		abstand = screen_y - navbot;
	} else {
		var targety = 100;
	}
	
	if (abstand < targety) {
		var possb = lastlement.top;
		if ($("#botstuff").hasClass("regular")) {
			$("#botstuff").addClass("iregular");
			$("#botstuff").css("top",possb + "px");
			$("#botstuff").removeClass("regular");
			window.clearInterval(crepeat);
		}
	} else {
		if ($("#botstuff").hasClass("iregular")) {
			$("#botstuff").addClass("regular");
			$("#botstuff").removeClass("iregular");
			$("#botstuff").css("top","");
		}
	}
}

