﻿
// Animation-Time
var time = 500;

function loadImage(id) {
    // Unsichtbares Bild mit übergebener ID einblenden
    if ($(".repImages img:eq(" + id + "):hidden").length > 0) {
        $("#frmBorder").remove();
        $(".repImages img").fadeOut();
        $(".repImages img:eq(" + id + ")").fadeIn(time);
        $(".repThumbs a.active").removeClass("active");
        $(".repThumbs a:eq(" + id + ")").addClass("active");
        $(".repThumbs a:eq(" + id + ")").prepend("<div id='frmBorder' class='frmBorder'></div>");
    }
}

//* NAVIGATION HOVER *//
function navHover() {
    $('#MainNav li').not('#MainNav li.active').hover(function () {
        $(this).find("a").not($(this).find("ul li a")).animate({ backgroundColor: '#615e44' }, 200);
    }, function () {
        $(this).find("a").stop(true, false).animate({ backgroundColor: '#737051' }, 200)
    });
}

$(window).load(function () {
    saveScroll();
});

// 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() {
    window.scrollTo(0, parseInt($.cookie('scrollPos')));
}

$(window).scroll(function () {
    saveScroll();
});

$(document).ready(function () {
    $(".repThumbs li").each(function () {
        $(this).find("a.active").prepend("<div id='frmBorder' class='frmBorder'></div>");
    });

    navHover();

    // Breite der Thumbnail-Box bestimmen
    var repWidth = ($(".repThumbs li").length);
    $(".repThumbs").css({ "width": (repWidth * 50) + (repWidth * 5) + "px" });

    // Button Animation
    var link = $('a.lnkSocial');
    var linkBtn = $('a.lnkBtn, .frmText a.lnkBtn ');
    link.append('<div class="lnkSocialHover" />');
    var linkHover = $('.lnkSocialHover');
    linkBtn.css('background', 'url(/images/construct/lnkBtn.gif) no-repeat 15px 2px');
    linkBtn.css('background-color', '#737051');
    linkHover.css('opacity', '0');
    link.each(function () {
        $(this).hover(function () {
            $(this).find(linkHover).stop(true, false).animate({ "opacity": "1.0"}, 130);
        }, function () {
            $(this).find(linkHover).stop(true, false).animate({ "opacity": "0"}, 130);
        });
    });
    linkBtn.each(function () {
        $(this).hover(function () {
            $(this).stop(true, false).animate({ "background-color": "#615e44" }, 130);
        }, function () {
            $(this).stop(true, false).animate({ "background-color": "#737051" }, 130);
        });
    });

    // Einlbendung Header Bild
    $(".repImages img, img.imgHeader").css({ "display": "none" });
    $(".repImages img:first, img.imgHeader").delay(250).fadeIn(600);
});


