$(document).ready(function()
{
    $('.slidebox .csc-header')
        .css({
            cursor: 'pointer'
        })
        .addClass('hidden').next().hide();
    
    $('.slidebox .csc-header').bind('click', function()
    {
        if($(this).hasClass('hidden')) {
            $('.slidebox .csc-header').removeClass('shown').addClass('hidden').next().hide();
            $(this).addClass('shown').removeClass('hidden').next().slideDown("slow");
        } else {
            $(this).removeClass('shown').addClass('hidden').next().slideUp("slow");
        }
    });
    
    $('.arrow-dropdown .csc-header')
        .css({
            cursor: 'pointer'
        })
        .addClass('hidden').next().hide();
    
    $('.arrow-dropdown .csc-header').bind('click', function()
    {
        if($(this).hasClass('hidden')) {
            $('.arrow-dropdown .csc-header').removeClass('shown').addClass('hidden').next().hide();
            $(this).addClass('shown').removeClass('hidden').next().slideDown("slow");
        } else {
            $(this).removeClass('shown').addClass('hidden').next().slideUp("slow");
        }
    });

    /* center billiton_gallery thumbnails */
    
    function centerThumbs()
    {
        $('#content .picrow-inner').each(function()
        {
            var width = $('.picrow-inner').width();
            var margin = '-' + Math.round(width/2);
            
            $(this).css({
                position:   'relative',
                left:       '50%',
                marginLeft: margin + 'px'
            });
        });
    }
    
    // call it for initial centering
    centerThumbs();

    /**
     * Re-center thumbs after each click.
     *
     * two important facts:
     * 1. bind event not on buttons, but on their parents (because of event bubbling, the parent
     *    get's the event _after_ the button = our click handler is called after the gallery click handler
     * 2. bind not only click, but also dblclick event (gallery plugin binds to dblclick aswell, to
     *    allow faster browsing through the thumbnails)
     *
     * additional information:
     * - for more information on events and especially event order see here: http://www.quirksmode.org/js/events_order.html
     * - jquery by default calls events on the bubbling phase and NOT on the capturing phase (because capturing phase is not supported by IE = not cross-browser)
     */
    $('.btn-browse-page-back, .btn-browse-page-fwd').parent().bind('click dblclick', centerThumbs);

      $("a.lightbox").fancybox(
      {
             'zoomSpeedIn': 300,
             'zoomSpeedOut': 300,
             'overlayShow': true
         }
     );
});

/*
    $("input#search-input").bind(
        'focus',
        function(){
            $("input#search-input").val("")
        }
    );

*/




