$(function(){
    $('.auto-confirm').change(function(){
        $(this).closest('form').submit();
    });
    
    $('.auto-confirm-submit').hide();
    
    $("a[rel=lightbox],a.lightbox").fancybox({
        'zoomSpeedIn'	:	500,
        'zoomSpeedOut' :	500,
        'hideOnContentClick': false
    });

    $('#current-time').jclock({
        utc: true,
        utc_offset: +1
    });
    
    $('#slider').nivoSlider({
        effect: 'fade', // Specify sets like: 'fold,fade,sliceDown'
        slices: 15, // For slice animations
        boxCols: 8, // For box animations
        boxRows: 4, // For box animations
        animSpeed: 500, // Slide transition speed
        pauseTime: 3000, // How long each slide will show
        startSlide: 0, // Set starting Slide (0 index)
        directionNav: false, // Next & Prev navigation
        directionNavHide: true, // Only show on hover
        controlNav: false, // 1,2,3... navigation
        controlNavThumbs: false, // Use thumbnails for Control Nav
        controlNavThumbsFromRel: false, // Use image rel for thumbs
        controlNavThumbsSearch: '.jpg', // Replace this with...
        controlNavThumbsReplace: '_thumb.jpg', // ...this in thumb Image src
        keyboardNav: true, // Use left & right arrows
        pauseOnHover: true, // Stop animation while hovering
        manualAdvance: false, // Force manual transitions
        captionOpacity: 0.8 // Universal caption opacity
    });
    
    $('#facebox').mouseenter(show_facebox);
    $('#facebox').mouseleave(hide_facebox);	
       
/*  
    var $floatingbox = $('#sidebar:not(.static)');
    var top = 5;   
    var bodyY = parseInt($('#sidebar').offset().top);
    var originalX =  $('#sidebar').offset().left;
    var documentH = $(document).height();
    var sidebarH = $('#sidebar').height();
    $(window).scroll(function () {

        var scrollY = $(window).scrollTop();
        var isfixed = $floatingbox.css('position') == 'fixed';

        bottom = documentH-scrollY-sidebarH;
        console.debug(bottom);
        if ( scrollY > bodyY && !isfixed) {
            $floatingbox.stop().css({
                position: 'fixed',
                top:top,
                left: originalX
            });
        } else if ( (scrollY < bodyY && isfixed)) {
            $floatingbox.css({
                position: 'relative',
                top:0,
                left: 0
            });
        }
        
    });  
    */
});

function show_facebox(){
    $('#facebox').stop().animate({
        right: '0'
    },500);
}

function hide_facebox(){
    $('#facebox').stop().animate({
        right: '-205px'
    },500);
}

