﻿$(document).ready(function() {
    $('#menu a').hover(
        function() {
            $(this).animate({ 'margin-top': '+=2', 'margin-bottom': '-=2' }, 150)
        },
        function() {
            $(this).animate({ 'margin-top': '-=2', 'margin-bottom': '+=2' }, 150)
        }
    );

    if ($('#slideshow-home').length) {
        $(function() {
            setInterval("slideSwitch('slideshow-home')", 5000);
        });
    };

    if ($('#slideshow-about').length) {
        $(function() {
            setInterval("slideSwitch('slideshow-about')", 5000);
        });
    };
});

$(window).load(function() {
    if ($('#slider').length) {
        $('#slider').nivoSlider({
            effect: 'fade',
            controlNavThumbs: true,
            controlNavThumbsSearch: '.jpg',
            controlNavThumbsReplace: 't.jpg',
            pauseOnHover: false
        });
    };
});
function slideSwitch(slideshow) {
    var $active = $('#' + slideshow + ' img.current-active');
    if ($active.length == 0)
        $active = $('#' + slideshow + ' img:last');

    var $next = $active.next().length ? $active.next() : $('#' + slideshow + ' img:first');

    $active.addClass('last-active');
    $next.css({ opacity: 0.0 }).addClass('current-active').animate({ opacity: 1.0 }, 1000, function()
    { $active.removeClass('current-active last-active'); });
};
