// JavaScript Document
		// initialise plugins
$(document).ready(function() {
    $('ul.sf-menu').superfish({
        delay: 1000,                            // one second delay on mouseout 
        speed: 'fast',                          // faster animation speed 
        autoArrows: false,                           // disable generation of arrow mark-up 
        dropShadows: false                            // disable drop shadows 
    });

    var impIndex = 0;
    var impMax = $('#impr_img li').length;

    $('#impr_img ul').width(impMax * 72);

    $('#arr_right a').click(function() {
        pos = $("#impr_img").offset().left - $("#impr_img ul").offset().left;
        pos += 72;
        $("#impr_img").animate({ scrollLeft: pos }, "slow", "swing");

        return false;
    });

    $('#arr_left a ').click(function() {
        pos = $("#impr_img").offset().left - $("#impr_img ul").offset().left;
        pos -= 72;
        $("#impr_img").animate({ scrollLeft: pos }, "slow", "swing");


        return false;
    });

    /* FANCYBOX--- This is basic - uses default settings */
    $("a.group").fancybox({
        'hideOnContentClick': false
    });


    $("#open").click(function(e) {
        e.preventDefault();
        $("div#slide").animate({ top: "-110px" }, "slow");
    });

    // Collapse Panel
    $("#close").click(function(e) {
        $("div#slide").animate({ top: "-30px" }, "slow");
        e.preventDefault();
    });

    // Switch buttons from "öffnen" to "schließen" on click
    $("#toggle a").click(function() {
        $("#toggle a").toggle();
    });


    $("#cont_img a").click(function(e) {
        e.preventDefault();
        var url = $(this).attr("href");
        $("#content_bg").fadeOut(300, function() {
            $("#content_bg").attr("src", url);
            $("#content_bg").fadeIn();
        })

    });

    //Galerie
    $("#pfeil_links").hide();
    $("#pfeil_rechts").hide();

    var galIndex = 0;
    var galMax = $('#cont_img li').length;
  

   var breite = 20;

    

    for (count = 0; count < galMax; count++) {
        var b = $("#cont_img ul li img").eq(count).width();
   
        breite = breite + 121 + 20;
    }
    
   
    $('#cont_img ul').width(breite);

    if (breite > 840) {
        $("#pfeil_links").show();
        $("#pfeil_rechts").show();
    } else {
        $("#cont_img").css("margin-top", "10px");
    }

    $('#pfeil_rechts a').click(function() {
        pos = $("#cont_img").offset().left - $("#cont_img ul").offset().left;
        pos += 200;
        $("#cont_img").animate({ scrollLeft: pos }, "slow", "swing");

        return false;
    });

    $('#pfeil_links a').click(function() {
        pos = $("#cont_img").offset().left - $("#cont_img ul").offset().left;
        pos -= 200;
        $("#cont_img").animate({ scrollLeft: pos }, "slow", "swing");


        return false;
    });




    //slideSwitch();
    var iv = window.setInterval("slideSwitch()", 5000);




});

//Bilddurchlauf
var slideSwitch = function() {

    var active = $('#cont_img a.active');

   if (active.length == 0) $active = $('#cont_img a:last');

   var next = active.parent().next().find("a").length ? active.parent().next().find("a") : $('#cont_img a:first');

    //var next = active.parent().next().find("a");
    
   active.addClass('last-active');

    var uri = next.attr("href");

    next.addClass('active');

    $("#content_bg").fadeOut(300, function() {
        $("#content_bg").attr("src", uri);
        $("#content_bg").fadeIn();
        active.removeClass('active last-active');
    })

}




