﻿$(document).ready(function() {
    $('#pnlGalleryWrapper').css('position', 'absolute'); // To avoid a nice IE7 Bug :)))
    $('.aShowHideNavigation').click(function() { HideNavigation(); });
    //GetRemainingWindowHeight()
    $(window).resize(function() {
        //GetRemainingWindowHeight();
    });
});

function GetRemainingWindowHeight() {
    var windowRemainingHeight = ($(window).height());
    SetHeaderAndFooterHeight(windowRemainingHeight);
}

function SetHeaderAndFooterHeight(height) {
}

function ChangePageBackground(path) {

    if ($('#pnlBgImage').css('background-image').indexOf(path) == -1) {
        $('#pnlBgImage').fadeOut(200, function() {
            $('#pnlBgImage').css('background-image', 'url("' + path + '")');
            $('#pnlBgImage').fadeIn(200);
        });
    }
    // Hide InfoBox by GalleryThmub click
    $('#pnlInfo').css('display', 'none');
    $('#imgInfoBoxIcon').attr('src', '/Content/IMG/Icons/ZettelInactiv.png');
}


function ShowNavigation() {

    var slidePanel = $('#pnlNavigation');

    HideInfoBox();
    if ($('#pnlGalleryWrapper').css('bottom') == '0px') {
        slidePanel.animate({ 'top': '35px' }, 'slow', function() { MoveOutGallery() });
    }
    else {
        slidePanel.animate({ 'top': '35px' }, 'slow');
    }
    $('#pnlNavigationHeader').css('background', 'url("/Content/IMG/Logos/RB_Logobalken_minus.png") no-repeat');
    $('.aShowHideNavigation').unbind('click').click(function() { HideNavigation() });
    MoveInContent();
}


function HideNavigation() {
    var slidePanel = $('#pnlNavigation');

    slidePanel.animate({ 'top': '549px' }, 1000);
    $('#pnlNavigationHeader').css('background', 'url("/Content/IMG/Logos/RB_Logobalken_plus.png") no-repeat');
    $('.aShowHideNavigation').unbind('click').click(function() { ShowNavigation() });
    
    MoveOutContent();
}

function HideNavigationShowGalleryWrapper() {
    HideNavigation();
    MoveInGallery();
}


function MoveInGallery() {
    $('#pnlGalleryWrapper').animate({ 'bottom': '0px' }, 'slow');
}

function MoveOutGallery() {
    $('#pnlGalleryWrapper').animate({ 'bottom': '-70px' }, 'slow');
}


function MoveOutContent() {
    $('#pnlContentWrapper').animate({ 'left': '990px' }, 1000);
}

function MoveInContent() {
    $('#pnlContentWrapper').animate({ 'left': '265px' }, 'slow');
}

// Hide .pnlInfoBox and put defBgImg
function HideInfoBox() {
    $('#pnlInfo').css('display', 'none');
    ChangePageBackground('/Content/IMG/Backgrounds/RB_LAYHG_01.jpg');
}

function InitGallery() {

    $(".imgGallery").click(function() {
        var obj = $(this);
        $(".imgGallery").each(function() {
            $(this).css("border-color", "rgb(132, 137, 133)");
            //            if ($(this).attr("rel") != obj.attr("rel"))
            //            $(this).stop().animate({ 'height': '50px' }, 100);
        });
        var obj = $(this);
        ChangePageBackground(obj.attr("rel"));
        obj.css("border-color", "#e46809");
        //        obj.css("height", "75px");
    });

    var speed = 200;
    $(".imgGallery").mouseover(function() {
        var obj = $(this);
        obj.stop().animate({ 'height': '80px', 'top': '-30px' }, speed, function() { $(this).animate({ 'height': '75px', 'top': '-25px' }, speed); });
    }).mouseout(function() {
        var obj = $(this);
        //        if ($(this).css("border-color") == "rgb(132, 137, 133)")
        obj.stop().animate({ 'height': '40px', 'top': '10px' }, speed, function() { $(this).animate({ 'height': '50px', 'top': '0px' }, speed); });
    });

}

