﻿$(document).ready(function() {
    $(".nav-deselected").fadeTo(700, 0.4);
    $("#btn-slideshow").fadeTo(700, 0.4);

    $(".nav-deselected").hover(function() {
        //alert($(this).attr('class'));
        $(this).fadeTo(700, 1.0);
    }, function() {
        $(this).fadeTo(700, 0.4);
    });

    $("#btn-slideshow").hover(function() {
        //alert($(this).attr('class'));
        $(this).fadeTo(700, 1.0);
    }, function() {
        $(this).fadeTo(700, 0.4);
    });

    var marg = $("#main").css("width").replace("px", "");
    if (marg < 1200 && marg >= 1024) {
        var a = $("#main").css("width").replace("px", ""), b = 235; // box of 220 + 15px left margin
        var newmargin = (a % b);
        $("#btn-slideshow").css("margin-right", newmargin);
    }
});

$(window).resize(function() {
    var marg = $("#main").css("width").replace("px", "");
    if (marg < 1200 && marg >= 1024) {
        var a = $("#main").css("width").replace("px", ""), b = 235; // box of 220 + 15px left margin
        var newmargin = (a % b);
        $("#btn-slideshow").css("margin-right", newmargin);
    }
    else {
        $("#btn-slideshow").css("margin-right", 20);
    }
});


$(window).scroll(function() {
    var header = $('header');
    var headerHeight = header.height();
    var expandBar = $('#expand');
    var expandBarHeight = expandBar.height();
    //var showNavLink = expandBar.find('a');
    var heightCache;

    var scrollDistance = $(this).scrollTop();
    var isExpanded = header.hasClass('nav-fixed');

    if (headerHeight < scrollDistance) {
        expandBar.fadeIn(400);
        header.fadeOut(400);
    }

    if (headerHeight > scrollDistance) {
        expandBar.fadeOut(400);
        header.fadeIn(400);
    }



    expandBar.hover(function(e) {
        e.preventDefault();
        $(this).fadeOut(400);
        header.addClass('nav-fixed')
            .fadeIn(400);
    });
    //if (searchcheck != 0) {
    //    (scrollDistance >= searchtop) ? searchTerms.addClass('fixed') : searchTerms.removeClass('fixed');
    //}
});


//***** gallery *****
















