// JavaScript Document

// Input label ein- und ausblenden
function switchInputlabel(myselector){
	$(myselector).each(function() {
		$(this).attr('title',$(this).siblings('label').text());
		$(this).siblings('label').attr('title',$(this).siblings('label').text());
		if($(this).val()!=''){$(this).siblings('label').css('visibility','hidden');}
	  });
	$(myselector).focus(function(){
		$(this).siblings('label').css('visibility','hidden');
		$(this).blur(function(){
							  if($(this).val()==''){
								  $(this).siblings('label').css('visibility','visible');
							  }
							  })
	})
};


// Mailform check
function mailformcheck(){
			var error=0;
			$(".mandatory").each(function(){
				$(this).removeClass('error');
				//alert($(this).val());
				if($(this).val()==''){
					$(this).addClass('error');
					$(this).siblings('label').css('color','#fff');
					error++;
				}
			});
	if(error!=0){
				return false;
	}
	else {
		return true;
		}
}


//Ersatz für Funktion von alten NiceForm (für neue jNice)
function replaceSelect(select)
{
	$(select).parent("form").jNice();
}

// Layout-Scripte
function layoutscript(){

	betriebssystem=navigator.platform.toLowerCase();
	if(betriebssystem.indexOf("mac")>-1){
		$("html").addClass("mac");
	}
	// Allen Bildlinks die Klasse "keinpfeil" geben
	$("img").parent('a').addClass('keinpfeil' );

	//Tabelle mit Zwischenlinien aufbauen
	$(".zwischenlinien tr").after('<tr><td colspan="99" class="nopadding"><div class="hTrenner"><div><div><hr></div></div></div></td></tr>' );
	$(".zwischenlinien th").parent('tr').before('<tr><td colspan="99" class="nopadding"><div class="hTrenner"><div><div><hr></div></div></div></td></tr>' );
	
	//Streifentabelle
	$(".streifentabelle tr:even").css("background-color", "#fff");

	/*last child hack*/
	/* TH: "#hauptmenue ul li:last-child" aus Liste entfernt, weil die Menüpunkte jetzt zusammenschrumpfen müssen */
	$("table p:last-child, table ul:last-child, #topmenue li:last-child, .kontaktformular .clearfix .float_50:last-child, .kontaktformular .float_50 .clearfix .float_50:last-child, .bonnform .clearfix .float_50:last-child, .bonnform .float_50 .clearfix .float_50:last-child, #bildzeile .csc-textpic-text p:last-child, .tabelleGrau tbody tr:last-child, .duo_accordion .content p:last-child, .inhalt_s2 .kennzahlen_header li:last-child, .lavaLamp li:last-child, .tx-3stoilettorder-pi1 .row .div.toilett:last-child, .multicolumnLayoutgrey_box .multicolumnContainer:last-child").addClass('last-child');


	/*IE7 Problem mit Positionierung der printsocial-box auf den Startseiten*/
	if ( $.browser.msie && $.browser.version=="7.0") {
		$(".startseite .print_social").css('top', ($("#inhaltszeile").height()-66)+'px' )
	}
	
	/*IE6 Hinweis */
	if ( $(".browserIE6").length > 0 ) {
		$("body").prepend("<div style='background:yellow; text-align:center;color:red;font-weight:bold;padding:10px;border-top:2px solid red; border-bottom:2px solid red;'><p>Sie verwenden den Internet Explorer 6, der im Jahr 2001 veröffentlicht wurde. Dieser Browser ist veraltet und unterstützt in großen Teilen aktuelle Webstandards nicht, so dass es zu Fehlfunktionen und Fehldarstellungen kommen kann.</p><p>Bitte installieren Sie eine aktuelle Version: <a href='http://windows.microsoft.com/de-DE/internet-explorer/products/ie/home' target='_blank'>Microsoft Internet Explorer</a></p></div>");
	}
	if($('.csc-loginform input').lenth!=0){
		switchInputlabel('.csc-loginform input');
	}
	
	/* filelinks immer in neuem Fenster öffnen */
	$("a[href$='.pdf'], a[href$='.ppt'], a[href$='.doc']").attr("target","_blank");
	
	// Abstand des Trenners oben in der hauptinhaltsspalte
	$(".inhalt_s2 .hTrenner").before("<div class='trennerVabstand'>");
	
	//$(".multicolumnLayoutgrey_box .multicolumnContainer.last-child *:last-child").css("margin-bottom","0");
	$(".multicolumnLayoutgrey_box").each(function(){
		$(this).innerHeight($(this).innerHeight()-5);
		});
}


$(document).ready(function() {
    layoutscript({  });
	
	if($("#bildzeile").height()>13){
		$($("#bildzeile")).append('<div class="weiss_oben">').append('<div class="weiss_unten">');
	}
	/* Oberen Abstand der Trennlinie unter Akkordeon entfernen */
	$(".ka-panel").next("div").children(".hTrenner").css("margin-top","-10px");
	
	/* Sortiertipps */
	$(".tx-3ssortiertipps-pi1 .submitold").attr("src","fileadmin/templates/2011/m/topsuche_submit_wbo.png");
	$(".tx-3ssortiertipps-pi1 .searchResults TD").append("<div class='hTrenner'><div><div><hr></div></div></div>");
	
	$("h4.trenner").append('<div class="hTrenner h4Trenner" ><div><div><hr></div></div></div>');
	
});







