$(function(){


    //  die lagen
    // -------------  
    
    $("#overview_b1").click(function() {
        $('#lagenSlideImagesEnv').cycle(1);
        $('#lagenSlideTextEnv').cycle(1);
        this.blur();
        return false;
    });
    $("#overview_b2").click(function() {
        $('#lagenSlideImagesEnv').cycle(2);
        $('#lagenSlideTextEnv').cycle(2);
        this.blur();
        return false;
    });
    $("#overview_b3").click(function() {
        $('#lagenSlideImagesEnv').cycle(3);
        $('#lagenSlideTextEnv').cycle(3);
        this.blur();
        return false;
    });
    $("#overview_b4").click(function() {
        $('#lagenSlideImagesEnv').cycle(4);
        $('#lagenSlideTextEnv').cycle(4);
        this.blur();
        return false;
    });
    $("#overview_b5").click(function() {
        $('#lagenSlideImagesEnv').cycle(5);
        $('#lagenSlideTextEnv').cycle(5);
        this.blur();
        return false;
    });
    $("#overview_b6").click(function() {
        $('#lagenSlideImagesEnv').cycle(6);
        $('#lagenSlideTextEnv').cycle(6);
        this.blur();
        return false;
    });
    $("#overview_b7").click(function() {
        $('#lagenSlideImagesEnv').cycle(7);
        $('#lagenSlideTextEnv').cycle(7);
        this.blur();
        return false;
    });
    $("#overview_b8").click(function() {
        $('#lagenSlideImagesEnv').cycle(8);
        $('#lagenSlideTextEnv').cycle(8);
        this.blur();
        return false;
    });
    $("#overview_b9").click(function() {
        $('#lagenSlideImagesEnv').cycle(9);
        $('#lagenSlideTextEnv').cycle(9);
        this.blur();
        return false;
    });
    $("#overview_b10").click(function() {
        $('#lagenSlideImagesEnv').cycle(10);
        $('#lagenSlideTextEnv').cycle(10);
        this.blur();
        return false;
    });

    
    $("#lagenNext").click(function() {
        $('#lagenSlideImagesEnv').cycle('next');
        $('#lagenSlideTextEnv').cycle('next');
        this.blur();
        return false;
    });

    $("#lagenPrev").click(function() {
        $('#lagenSlideImagesEnv').cycle('prev');
         $('#lagenSlideTextEnv').cycle('prev');
        this.blur();
        return false;
    });

    $("#lagenHome").click(function() {
        $('#lagenSlideImagesEnv').cycle(0);
        $('#lagenSlideTextEnv').cycle(0);
        this.blur();
        return false;
    });


    $('#lagenSlideImagesEnv').cycle({
        fx:     'scrollHorz',
        speed:  '2300',
        timeout: 0
    });

    $('#lagenSlideTextEnv').cycle({
        fx:     'fade',
        speed:  '1800',
        timeout: 0
    });



    //  top menu
    // ---------------
    $("#menu").hover(
    function() {
        $("#dropdown").fadeIn(500);
    },
    function() {
        $("#dropdown").fadeOut(500);
    });



    //  change standard easing
    // -----------------------
    jQuery.easing.def = "easeOutQuint";

    // jQuery SmoothScroll | Version 09-11-02
    $('a[href*=#]').click(function() {

       // easing values: swing | linear
       var easing='swing';

       // get / set parameters
       var newHash=this.hash;
       var target=$(this.hash).offset().top;
       var oldLocation=window.location.href.replace(window.location.hash, '');
       var newLocation=this;

       // duration in ms
       //var duration=(target<3000)? 3000 : target*1.2;
       var duration=3000;

       // make sure it's the same location
       if(oldLocation+newHash==newLocation)
       {
          // animate to target and set the hash to the window.location after the animation
          //myAni = $('html:not(:animated),body:not(:animated)').animate({scrollTop: target}, duration, easing, function() {
          $('html,body').stop();
          $('html,body').animate({scrollTop: target}, duration, easing, function() {
             // add new hash to the browser location
             //window.location.href=newLocation;
          });

          // cancel default click action
          return false;
       }

    });




    function handle(delta) {
        $('html,body').stop();
    }

    /** Event handler for mouse wheel events
     */
    function wheel(event){
            var delta = 0;
            if (!event) /* For IE. */
                    event = window.event;
            if (event.wheelDelta) { /* IE/Opera. */
                    delta = event.wheelDelta/120;
                    /** In Opera 9, delta differs in sign as compared to IE.
                     */
                    if (window.opera)
                            delta = -delta;
            } else if (event.detail) { /** Mozilla case. */
                    /** In Mozilla, sign of delta is different than in IE.
                     * Also, delta is multiple of 3.
                     */
                    delta = -event.detail/3;
            }
            /** If delta is nonzero, handle it.
             * Basically, delta is now positive if wheel was scrolled up,
             * and negative, if wheel was scrolled down.
             */
            if (delta) handle(delta);
    }

    /** Initialization code.
     * If you use your own event management code, change it as required.
     */
    if (window.addEventListener)
            /** DOMMouseScroll is for mozilla. */
            window.addEventListener('DOMMouseScroll', wheel, false);
    /** IE/Opera. */
    window.onmousewheel = document.onmousewheel = wheel;







    // neigung
    $('#neigung ul li a').hover(
        function() {
            $("#neigung ul a").removeClass("active");
            var url = "url(images/neigung_gfx_"+$(this).attr("rel")+".gif)";
            $("#neigungImg").css("background-image", url);
        },
        function() {
            $(this).addClass("active");
        });

});


// preloading images
bild = new Array();
for(i=1; i<=19; i++) {
    bild[i] = new Image();bild[i].src = "images/neigung_gfx_"+i+".gif";
}
i++;
bild[i] = new Image();bild[i].src = "/images/neigung_text_over.gif";
i++;
bild[i] = new Image();bild[i].src = "/images/die_lagen_2.jpg";

