$(document).ready(function() {

	// Bilder preloaden .....
	$('.navImg').preload({
		find: '.gif',
		replace: '_f2.gif'
	});

	// ZUERST aktuellen Hauptnavipunkt aktiv setzen
//	if ($(mainNavID).length>0) {
//		$(mainNavID).removeClass("navImg");
//		$(mainNavID).attr("src",$(mainNavID).attr("src").split(".gif")[0]+"_f2.gif");
//	}

	// DANN Mouseover/out für Buttons binden .....
	$('.navImg').mouseover(function() {
		$(this).attr("src",$(this).attr("src").split(".gif")[0]+"_f2.gif");
	});
	$('.navImg').mouseout(function() {
		$(this).attr("src",$(this).attr("src").split("_f2.gif")[0]+".gif");
	});

    // Binding für International
	$(".bttnInternational").click(function (){
 		$("#divInternational").toggle();
	});

	// Und das Mouseover/Out für rauf-/runterfahren initialisieren
	$("#divTeaserSlider").mouseover(function() {
		$("#divTeaserSlider").stop().animate({
			"top" : "160",
			"height": "300"
		},300);
	});

	$("#divTeaserSlider").mouseout(function() {
		$("#divTeaserSlider").stop().animate({
			"top" : "360",
			"height": "100"
		},300);
	});

	// Klappmechanismus Newsheader initialisieren...
	$(".newsHeader").click(function() {
	   if (!$.browser.msie)
		$(this).next().slideToggle();
       else
       	$(this).next().toggle();
        $(this).find(".divSchliessenButton").toggle("fade");
	});


    $(document).click(function() {$("#divSubnavProdukte").hide(); });

    //Klappmechanismus der Themen auf der Home initialisieren
    $(".themaHandler").click(function() {
        $(".themaContent").hide();
        $(this).next().show();
        $("#imgThemaBild").attr("src",$(this).find("img").attr("class"));
    });

    // Den ersten Thementeaser aufklappen wenn die Seite lädt.
    $(".themaContent:first").animate({"width":"429px"},500);

	// Jeztzt schauen wir ob der rechte Inhaltsbereich leer ist, wenn ja, blenden wir ihn aus.
	$("#divSidebarInner:empty").css("display","none");
	if($("#divSidebarInner").css("display")=="none") {
	    $("#divSidebar").css("display","none");
		$("#divContent").css("width","745px");
        $("#divContentInner").css("width","695px");
    }

    // Wenn es Downloads gibt, den Button binden
    $("#bttnDownloads").click(function() { $(this).next().toggle();});


    $('.lightbox').lightBox({txtImage:'Bild' , txtOf:'von'});

    $(".lightboxDessins").lightBox({txtImage:'Bild' , txtOf:'von'});


	$(".fachberatersuchePLZ").click(function(){
		$("#fb"+$(this).prev().prev().attr("value")).load("/ajaxServer.php?action=showBeraterPLZ&l="+hellalang+"&land="+$(this).prev().attr("value")+"&plz="+$(this).prev().prev().prev().attr("value"));
	});

	$(".fachberatersucheRegion").change(function(){
        $(this).parent().next().empty();
        $(this).parent().next().next().empty();
        $(this).parent().next().next().next().empty();
		$(this).parent().next().load("/ajaxServer.php?action=showBeraterRegion&l="+hellalang+"&bundesland="+$(this).val(),"",function(){
            $(".fachberatersucheProvinz").change(function(){
                $(this).parent().next().empty();
                $(this).parent().next().next().empty();
				$(this).parent().next().load("/ajaxServer.php?action=showBeraterProvinz&l="+hellalang+"&provinz="+$(this).val(),"",function () {
		        	$(".fachberatersucheOrt").change(function(){
						$(this).parent().next().empty().load("/ajaxServer.php?action=showBeraterOrt&l="+hellalang+"&ort="+$(this).val());
					});
				});
			});
		});
	});


//    $("div").css("border","1px solid black");
});


function findBeraterPLZ(plz,id) {
    $("#"+id).load("/ajaxServer.php?action=showBeraterPLZ&plz="+plz);

}

function showSubnavProduct() {
    $("#divSubnavProdukte").show();
}

function showLoginMask() {
    $(document).scrollTo(0,0);
    $("#divLoginForm").animate({"top":"-1px"},500);

}

function hideLoginForm() {
   $("#divRegForm").hide();
     $("#divLoginForm").css("height","");
   $("#divLoginForm").animate({"top":"-102px"},500);

}

function showRegForm() {
   $("#divLoginForm").css("height","350px");
   $("#divRegForm").show();
}