﻿// Animation-Time
var time = 500;

function loadImage(id) {
    // Unsichtbares Bild mit übergebener ID einblenden
    if ($(".genImages img:eq(" + id + "):hidden").length > 0) {
        $(".genImages img").fadeOut();
        $(".genImages img:eq(" + id + ")").fadeIn(time);
        $(".thumbs a.active").removeClass("active");
        $(".thumbs a:eq(" + id + ")").addClass("active");
    }
}


/* Scrollposition speichern */
function getScroll() {
    var scrOfY = 0;
    if (typeof (window.pageYOffset) == 'number') {
        //Netscape compliant   
        scrOfY = window.pageYOffset;
    } else if (document.body && (document.body.scrollLeft || document.body.scrollTop)) {
        //DOM compliant   
        scrOfY = document.body.scrollTop;
    } else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
        //IE6 standards compliant mode   
        scrOfY = document.documentElement.scrollTop;
    }
    return scrOfY;
}

function saveScroll() {
    $.cookie('scrollPos', getScroll(), { path: '/', expires: 10 });    
}

function setScroll() {
    if ($.cookie('scrollPos') != null) {
        window.scrollBy(0, $.cookie('scrollPos'));
    }
}

/* Scrollposition speichern */
$(window).scroll(function () {
    saveScroll();
});

/* Scrollposition setzen */
$(window).load(function () {
    setScroll();
});


$(document).ready(function () {

    // Navigation
    $('ul.sf-menu li a')
        .not('ul.sf-menu li.active a')
        .not('ul.sf-menu li.active ul li')
        .not('ul.sf-menu li.noChilds')
        .click(
            function () {
                $('ul.sf-menu ul').hide();
                $(this).find("ul:first").show();
            },
            function () {
                $('ul.sf-menu li.active ul').show();
                $(this).find("ul:first").hide();
            });


    //Footer am Ende der Seite
    $("#innerFooter").css("top", $(document).height() - $("#innerFooter").height() - 72);

    $(".itmAngebot, .oneColBlock").hover(
      function () {
          $(this).addClass("hover");
      },
      function () {
          $(this).removeClass("hover");
      }
    );

    $(".itmAngebot, .oneColBlock").click(function () {
        location.href = $(this).find("a").attr("href");
    });

});


