
// Berichte werden auf der Homepage nach Klick geoeffnet
function animateBerichtTeaserBox() {
	if ($('div.berichtTeaserBox .body').length) {
		$('div.berichtTeaserBox .body').hide();
		$('div.berichtTeaserBox .head').css('cursor', 'pointer');
		$('div.berichtTeaserBox:first .body').show();
		$('div.berichtTeaserBox .head').click(function(){
			var visibleBody = $('div.berichtTeaserBox div.body:visible');
			$(this).next("div.body").slideToggle("slow");
			visibleBody.slideUp("slow");
		});
	}
}

// ###############################################################################

// platziert ein Stueck vom Headerbild (Ellenbogen) an die richtige Stelle
function placePuzzle() {
	myPos = $('img#topimage').position();
	//alert(myPos.top + " " + myPos.left);
	newTop = myPos.top + 220;
	newLeft = myPos.left + 864;
	$('#puzzle').css('position', 'absolute').css('top', ''+newTop+'px').css('left', ''+newLeft+'px').show();
}

// ###############################################################################

// START
$(function(){
	/*
	var winHeight = $(window).height();
	intPx = winHeight-30;
	$('div#footer').css('top', ''+intPx+'px');
	*/
	removeTrans();
	removeWaiting();
	removeNotice();
	placePuzzle();
	animateBerichtTeaserBox();
	
	// Eventhandler der beim resize-Event das Puzzle neu platziert.
	$(window).bind("resize", function(){
		placePuzzle();
	});
	
	$('a.lightbox').lightBox();
	$('a.lightboxLernort').lightBox();
	
});


// ###############################################################################

// Wartehinweis horizontal und vertikal mittig ausrichten und anzeigen
// verlangt das dimensions-plugin
function showWaiting() {
	$('#waitingDiv').css('top', function(){
		return (($(window).height()-$(this).height()) / 2) + $(window).scrollTop() - $(this).height() + 'px'
	}).css('left', function(){
		return (($(window).width()-$(this).width()) / 2) + $(window).scrollLeft() + 'px'
	}).show();
}

// Wartehinweis entfernen
function removeWaiting() {
	$('#waitingDiv').hide();
}

// ###############################################################################

// Transparente Flaeche anzeigen
function showTrans() {
	$('#transDiv').css({
		width: function(){return $(document).width() + 'px'}, 
		height: function(){return $(document).height() + 'px'}, 
		opacity: 0.5
	}).show();
}

// Transparente Flaeche entfernen
function removeTrans() {
	$('#transDiv').hide();
}

// ###############################################################################

// Wartehinweis horizontal und vertikal mittig ausrichten und anzeigen
// verlangt das dimensions-plugin
function showNotice(objNotice) {
  $('#noticeDiv div.top').empty();
	$('#noticeDiv div.top').append(objNotice.headline);
	
  $('#noticeDiv div.middle:first div.text').empty();
	if (objNotice.subline) $('#noticeDiv div.middle:first div.text').append('<span>'+objNotice.subline+'</span><br />');
  $('#noticeDiv div.middle:first div.text').append(objNotice.text);

  if (objNotice.listLink) {
    l_sString = '<img src="img/arrow_green.png" width="11" height="11" border="0" alt="" /> <a href="';
    l_sString += objNotice.listLink;
    l_sString += '">zur&uuml;ck zur Liste</a>';
    $('#noticeDiv div.middle div.listLink').append(l_sString);
  }
  
	$('#noticeDiv').css('top', function(){
		return (($(window).height()-$(this).height()) / 2) + $(window).scrollTop() - $(this).height() + 'px'
	}).css('left', function(){
		return (($(window).width()-$(this).width()) / 2) + $(window).scrollLeft() + 'px'
	}).show();
}

// Wartehinweis entfernen
function removeNotice() {
	$('#noticeDiv').hide();
}

function testNotice() {
	var objNotice = new Object();
	objNotice.headline = "Fehlermeldung";
	objNotice.subline = "Ein Fehler ist aufgetreten";
	objNotice.text = "Bitte geben Sie Ihren vollständigen Namen ein!<br />";
	
	showTrans();
	showNotice(objNotice);
	
}

function makeErrorBox(f_sNoticeText) {
	var objNotice = new Object();
	objNotice.headline = "Fehlermeldung";
	objNotice.subline = "Ein Fehler ist aufgetreten";
	objNotice.text = f_sNoticeText;
	
	showTrans();
	showNotice(objNotice);
}
function makeNoticeBox(f_sNoticeText, f_sListLink) {
	var objNotice = new Object();
	objNotice.headline = "Hinweis";
	//objNotice.subline = "";
	objNotice.text = f_sNoticeText;
	objNotice.listLink = f_sListLink;
	
	showTrans();
	showNotice(objNotice);
}

