/*
########################################################################
##
##               Titel: JavaScript Seh-Netz
##           Dateiname: sehnetz.js
##         Verzeichnis: /js/
##               Autor: Marco Krings
##  letzter Bearbeiter: Marco Krings
##    Erstellungsdatum: 2010-01-01
##    Veröffentlichung: 2010-xx-xx
##   Bearbeitungsdatum: 2010-01-01
##             Version: 1.0.0
##           Datenbank: -
##         Komponenten: -
##           Kommentar: -
##
########################################################################
*/

// ##################################################################
// ## C H E C K B O X
// ##################################################################

function setChecked(sBezeichner, bModus) {
	var oElement = document.getElementsByName(sBezeichner);
	for (var n = 0; n < oElement.length; n++) {
		if(oElement[n].type == "checkbox") {
			oElement[n].checked = bModus;
		}
	}
}

$(document).ready(function() {

// ##################################################################
// ## N A V I G A T I O N
// ##################################################################


var hTimer;
$(".ausblenden").hide();

var sAdresse = document.location.toString();
if (sAdresse.match("#nav")) {
	var sAnker = sAdresse.split("#")[1];
	$("#"+sAnker).show();
} else {
	$(".einblenden").show();
}

function handle(e) {
	function einblenden() {
		if(!$(".ausblenden:visible",oElement).length)
			$(".ausblenden").slideUp();
		$(".ausblenden:hidden", oElement).slideDown(500);
	}
	var oElement = this;
	if (hTimer)
		window.clearTimeout(hTimer);
	hTimer = window.setTimeout(einblenden, 200);
};

$(".ausblender").mouseover(handle);
$(".ausblender").click(handle);

// ##################################################################
// ## T A B E L L E N Z E I L E
// ##################################################################

$("tr").mouseover(function() {
	$(this).addClass("ansicht");
});
$("tr").mouseout(function() {
	$(this).removeClass("ansicht");
});

$("table.liste tr:even").addClass("zeile1");
$("table.liste tr:odd").addClass("zeile2");
$("table.liste td").css("border",'0 solid');

// ##################################################################
// ## B U N D E S L A N D Ü B E R S I C H T
// ##################################################################

$("#bundeslandimages area").mouseover(
	function(e) { hoverBundeslandKarte(this, "area_", e) }
);
$("#bundeslandimages area").mouseout(
	function() { resetBundeslandKarte(this, "area_") }
);
$("#bundeslandliste a").mouseover(
	function(e) { hoverBundeslandKarte(this, "link_", e) }
);
$("#bundeslandliste a").mouseout(
	function() { resetBundeslandKarte(this, "link_") }
);

function hoverBundeslandKarte(sAuswahl, sBereich, e) {
	var sKuerzel = sAuswahl.id.toLowerCase();
	if (sKuerzel.match(sBereich)) {
		// Tooltipp deaktivieren
		$(sAuswahl).attr("title","");
		// Karte anzeigen
		var sWert = sKuerzel.split(sBereich)[1];
		document.dkarte.src = "images/dkarte/dkarte_"+ sWert +".gif";
		// Eintrag in Liste auswählen
		$("#link_"+sWert).addClass("markierung");
		// Tooltipp
		if (typeof $(sAuswahl).attr("alt") != "undefined") {
			$("#ausgabe").addClass("ausgabe_css");
			$("#ausgabe").css("top",e.pageY);
			$("#ausgabe").css("left",e.pageX+15);
			$("#ausgabe").text($(sAuswahl).attr("alt"));
		}
	}
}

function resetBundeslandKarte(sAuswahl, sBereich) {
	var sKuerzel = sAuswahl.id.toLowerCase();
	if (sKuerzel.match(sBereich)) {
		var sWert = sKuerzel.split(sBereich)[1];
		document.dkarte.src = "images/leer.gif";
		$("#link_"+sWert).removeClass("markierung");
		$("#ausgabe").text("");
		$("#ausgabe").removeClass("ausgabe_css");
	}
}
// ##################################################################
// ## D E U T S C H L A N D K A R T E
// ##################################################################

$("#deutschlandkarte img").maphilight();

$("#deutschlandkarte area").mouseover(function(e) {
	hoverDeustschlandKarte(this, e);
});

$("#deutschlandkarte area").mouseout(function() {
	resetDeustschlandKarte();
});

$(".karten area").mouseover(function(e) {
	hoverDeustschlandKarte(this, e);
});

$(".karten area").mouseout(function() {
	resetDeustschlandKarte();
});

function hoverDeustschlandKarte(sAuswahl, e) {
	if (typeof $(sAuswahl).attr("alt") != "undefined") {
		$(sAuswahl).attr("title","");
		$("#ausgabe").addClass("ausgabe_css");
		$("#ausgabe").css("top",e.pageY);
		$("#ausgabe").css("left",e.pageX+15);
		$("#ausgabe").text($(sAuswahl).attr("alt"));
	}
}

function resetDeustschlandKarte() {
	$("#ausgabe").text("");
	$("#ausgabe").removeClass("ausgabe_css");
}

// ##################################################################
// ## L I G H T B O X
// ##################################################################

$("a.lightbox").lightBox();

// ##################################################################
// ## F O R M U L A R E
// ##################################################################

$("form.formulare p").mouseover(function () {
	$(this).addClass("markierung");
});

$("form.formulare p").mouseout(function () {
	$(this).removeClass("markierung");
});

$("form.suche2 p").mouseover(function () {
	$(this).addClass("markierung");
});

$("form.suche2 p").mouseout(function () {
	$(this).removeClass("markierung");
});

// ##################################################################
// ## T I T E L   S T A R T S E I T E
// ##################################################################

function setStartTitel() {
	var oDatum  = new Date();
	var nStunde = oDatum.getHours();
	if (nStunde >= 0 && nStunde < 12) {
		sTitel = "Guten Morgen";
	} else if (nStunde >= 12 && nStunde < 18) {
		sTitel = "Guten Tag";
	} else if (nStunde >= 18 && nStunde <= 23) {
		sTitel = "Guten Abend";
	}
	var sText = $("#inhalt h1:first").html();
	$("#inhalt h1:first").html(sText.replace(/Herzlich/, sTitel+","));
}
setStartTitel();

// ##################################################################
// ## F L U G H A F E N K A R T E
// ##################################################################

$("#flughafen area").mouseover(function(e) {
	$(this).attr("title","");
	if (typeof $(this).attr("alt") != "undefined") {
		$("#ausgabe").addClass("ausgabe_css");
		$("#ausgabe").css("top",e.pageY-10);
		$("#ausgabe").css("left",e.pageX+10);
		$("#ausgabe").text($(this).attr("alt"));
	}
});
$("#flughafen area").mouseout(function() {
	$("#ausgabe").text("");
	$("#ausgabe").removeClass("ausgabe_css");
});

// ##################################################################
// ## I N F O B R I E F S U C H E
// ##################################################################

$("form.suche2 p.keinabsatz").html("Klicken Sie auf die &Uuml;berschriften zum ausklappen der Eigenschaften.");
$(".suche_ausblenden").hide();
$(".suche_einblenden legend").attr("title","Auf diese Überschrift klicken zum ausklappen");

$(".suche_einblenden legend").click(function() {
	$("form.suche2 .suche_ausblenden").slideUp(500);
});

$("fieldset.suche_einblenden").click(function() {
	if(!$(".suche_ausblenden:visible",this).length) {
		$(".suche_ausblenden", this).slideDown(500);
	}
});

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

});