 var progress;
    jQuery(document).ready(function(){
      background.init();

      jQuery("#background-images img").click(function(){
        element = $(this).attr("src");
        
        jQuery("#background-images img").each(function(i){
          if($(this).attr("src") == element){
            background.nextPic(i);
          }
        });
        
        
        return false;
      });


      jQuery("#page-hide a").mouseenter(
        function(){
          $("#page").animate({
              'opacity':'0.01'
          },500);
              

          $("#page-hide-content").slideDown('slow');
          window.clearInterval(background.progressInterval);


        });

        jQuery("#page-hide a").mouseleave(
        function(){
            $("#page").animate({
                'opacity':'1'
              },500);
          $("#page-hide-content").hide();
          background.progressInterval = window.setInterval("background.progress()",1);
        });

    
        select.init();

    });

    select = {
        init : function(){
            jQuery("#select-tours a").click(function(){
                jQuery(this).toggleClass("inactive");
                var cat = "a." + jQuery(this).attr("id");

                if( jQuery(this).hasClass("inactive") ){
                    
                    

                    jQuery(cat).animate({'opacity':'0.1'},500,function(){
                        
                    });
                    
                }else{

                    jQuery(cat).animate({'opacity':1});
                }

                return false;
            });
        }
    }

    background = {
      progressInterval : true,
      step : 0,
      init : function(){


        src = jQuery("#background-images div img").eq(0).attr("src");
        jQuery("#page-hide a span").html(jQuery("#background-images div img").eq(background.step).attr("alt"));

        jQuery("#page-hide-content").html("<p>" + jQuery("#background-images div img").eq(background.step).attr("title") + "</p>")
        
        src = background.bigpic(src);
        
        $.backstretch(src,{speed:1500});

        jQuery("#background-images div").first().addClass("aktiv");


        $("#progress-inner").css("width",0);

        background.progressInterval = window.setInterval("background.progress()",20);
        
        jQuery("#background-images img").click(function(image, i){

        });
        
      },

      progress : function(){
        width = parseInt($("#progress-inner").css("width")) + 1;

        if(width < 1100){
            $("#progress-inner").css("width",width);
          }else{
            $("#progress-inner").css("width",0);
            window.clearInterval(background.progressInterval);

            if(anzahl = jQuery("#background-images div img").length-1 == background.step){
              background.step = 0;
            }
            background.step += 1

            src = jQuery("#background-images div img").eq(background.step).attr("src");
            src = background.bigpic(src);

            $.backstretch(src);
            text = jQuery("#background-images div img").eq(background.step).attr("alt");

            jQuery("#page-hide a span").html(text);
            
            jQuery("#page-hide-content").html("<p>" + jQuery("#background-images div img").eq(background.step).attr("title") + "</p>")            
            
            jQuery("#background-images div").removeClass("aktiv");

            jQuery("#background-images div").eq(background.step).addClass("aktiv");

            $(".backstretch").last().fadeOut("slow",function(){
              $(".backstretch").last().remove();

            });

            background.progressInterval = window.setInterval("background.progress()",20);
          }
      }, 
      
      nextPic : function(no){
        
        // Hallo hier muss das nächste Bild eingetüddelt werden

        
      },

      bigpic : function(file){
        path = file.split("=");
        path = path.reverse();

        return "/files/"+path[0];
      }

    }
