// JavaScript Document

var isIE6;

$(document).ready(function() {


    if(typeof document.body.style.maxHeight === "undefined") {
            isIE6=true
    } else {
            isIE6=false;
    }

    var matchCode=$("#matchcode").attr("content");

    // Hintergrund zentrieren **********
	$("#divBackground").css("left",($(window).width()/2-640)+"px");
	$(window).resize(function() {
    	$("#divBackground").css("left",($(window).width()/2-640)+"px");
	});
    $("#divBackground").cycle();


    // Navigation initialisieren *******
	if ($(mainNavID).length>0) {
		$(mainNavID).removeClass("navImg");
		$(mainNavID).attr("src",$(mainNavID).attr("src").split(".png")[0]+"_f2.png");
	}
	$('.navImg').mouseover(function() {
		$(this).attr("src",$(this).attr("src").split(".png")[0]+"_f2.png");
	});
	$('.navImg').mouseout(function() {
		$(this).attr("src",$(this).attr("src").split("_f2.png")[0]+".png");
	});


    // Servicenavigation initialisieren ******
    $("#divIconSuche").click(function(){
        $("#divLayerSuche").slideToggle();
    });
    $("#imgLayerSuche").click(function(){
        $("#divLayerSuche").slideToggle();
    });
    $("#divIconRSS").click(function(){
        $("#divLayerRSS").slideToggle();
    });
    $("#imgLayerRSS").click(function(){
        $("#divLayerRSS").slideToggle();
    });
    $("#divIconSprachwahl").click(function(){
        $("#divLayerSprachwahl").slideToggle();
    });
    $("#imgLayerSprachwahl").click(function(){
        $("#divLayerSprachwahl").slideToggle();
    });
    $(".newsHeader").click(function(){
        if (isIE6)
            $(this).next().toggle();
        else
            $(this).next().slideToggle();
        $(this).find(".divSchliessenButton").toggle("slow");
    });


    // Galerien und Zooms intialisieren ******************
    $(".lightbox").fancybox({
        centerOnScroll: false,
        cyclic: true
    });
    $(".rundgangLink").fancybox({
        frameWidth: 810,
        frameHeight: 610
    });

	$(".rundgangLink").click(function () {
		$("#fancy_frame").css("height","610px");
    });

	$(".buchenButton").fancybox({
		frameWidth:			900,
		frameHeight:		550,
		zoomSpeedIn: 0,
		zoomSpeedOut: 0,
		overlayShow: true,
		overlayOpacity: 0.65,
        centerOnScroll:false
	});

	$(".buchenButton").click(function () {
		$("#fancy_frame").css("height","550px");
    });

	$(".eCardPopup").fancybox({
		frameWidth:			620,
		frameHeight:		700,
		zoomSpeedIn: 0,
		zoomSpeedOut: 0,
		overlayShow: true,
		overlayOpacity: 0.7,
        centerOnScroll:false
	});

	$(".eCardPopup").click(function () {
		$("#fancy_frame").css("height","700px");
    });


    // Anfrage und Buchen-Buttons *************************

     if(typeof document.body.style.maxHeight === "undefined") { // im IE6 ein bisserl anders
        $(".anfrageButton").click(function(){
            var id=$(this).attr("id");
            $("#divAnfrageFormular").css({"display":"block","left":"-810px","top":"0px"});
            $("#divAnfrageIframeContent").empty().append('<iframe src="/anfrage.php?ID='+id+'" width="950" height="540" border="0" frameborder="0" framespacing="0"></iframe>');

        });
        $("#anfrageFormSchliessenButton").click(function(){
            $("#divAnfrageIframeContent").empty();
            $("#divAnfrageFormular").css({"display":"none"});
        });
    } else {
        $(".anfrageButton").click(function(){
            var id=$(this).attr("id");
            $("#divAnfrageFormular").css({"display":"block"});
            $("#divAnfrageFormular").animate({"left":"0px"},function() {
                $("#divAnfrageIframeContent").empty().append('<iframe src="/anfrage.php?ID='+id+'" width="910" height="540" border="0" frameborder="0" framespacing="0"></iframe>');
            });
        });
        $("#anfrageFormSchliessenButton").click(function(){
            $("#divAnfrageIframeContent").empty();
            $("#divAnfrageFormular").animate({"left":"1000px"},function(){

                $("#divAnfrageFormular").css({"display":"none"});
            });
        });
    }


    $(".planerAddButton").click(function(){
        var id=$(this).attr("id");
        $.ajax({
            type: "GET",
            url: "/ajaxServer.php",
            data: "action=plannerAddItem&ID="+id,
            success: function(msg){
                var message=msg.split("#");
                $("#divUrlaubsplaner").prepend('<div class="plannerItem"><div class="bttnPlannerItemClose" id="'+message[0]+'"></div>'+message[1]+'</div>');
            }
        });
    });


    $(".bttnPlannerItemClose").live("click",function(){
        var id=$(this).attr("id");
        var el=$(this);
        $.ajax({
            type: "GET",
            url: "/ajaxServer.php",
            data: "action=plannerRemoveItem&ID="+id,
            success: function(msg){
                el.parent().hide("slow");
            }
        });
    });

    // Korrekturen an Design
    $(".subnav4:last").css("padding-bottom","12px");


    // MouseOvers für Teaser auf Homepage intialisieren **************
    if (matchCode=="home") {
        $(".singleContent:eq(0)").mouseover(function() {
            $(".singleContent:eq(0)").css("background-image","url(images/themes/home/hl-willkommen.gif)");
        });
        $(".singleContent:eq(0)").mouseout(function() {
            $(".singleContent:eq(0)").css("background-image","");
        });

   //     $(".singleContent:eq(1)").css("cursor","pointer");
        $(".singleContent:eq(1)").mouseover(function() {
            $(".singleContent:eq(1)").css("background-image","url(images/themes/home/hl-angebote.gif)");
        });
        $(".singleContent:eq(1)").mouseout(function() {
            $(".singleContent:eq(1)").css("background-image","");
        });

   //     $(".singleContent:eq(2)").css("cursor","pointer");
        $(".singleContent:eq(2)").mouseover(function() {
            $(".singleContent:eq(2)").css("background-image","url(images/themes/home/hl-rundgang.gif)");
        });
        $(".singleContent:eq(2)").mouseout(function() {
            $(".singleContent:eq(2)").css("background-image","");
        });

   //     $(".singleContent:eq(3)").css("cursor","pointer");
        $(".singleContent:eq(3)").mouseover(function() {
            $(".singleContent:eq(3)").css("background-image","url(images/themes/home/hl-kinderparadies.gif)");
        });
        $(".singleContent:eq(3)").mouseout(function() {
            $(".singleContent:eq(3)").css("background-image","");
        });

   //     $(".singleContent:eq(4)").css("cursor","pointer");
        $(".singleContent:eq(4)").mouseover(function() {
            $(".singleContent:eq(4)").css("background-image","url(images/themes/home/hl-gutscheine.gif)");
        });
        $(".singleContent:eq(4)").mouseout(function() {
            $(".singleContent:eq(4)").css("background-image","");
        });
    }  // Ende MO Home

    if(typeof document.body.style.maxHeight === "undefined")
        $(document).pngFix();
//    $(document).pngFix();
});