/** 
 *  ================================================
 *    Initialisation on various jQuery plugins
 *    and some globally used jQuery functions
 *
 *    TABLE OF CONTENTS
 *    01 - Main slider on the frontpage
 *    02 - Main navigation
 *    03 - Sliding down login box
 *    04 - inFieldLabels plugin for form field lables
 *    05 - PrettyPhoto plugin
 *    06 - Tabbed widget in the sidebar
 *    07 - Contact forms
 *  ================================================
 */

 
/**
 *  ================================================
 *  01 - Initialise the main slider on the frontpage
 *  ================================================
 */
jQuery(window).load(function() {
    setTimeout(function(){
        $('#slider').nivoSlider({
          effect:'random',
          slices:15,
          animSpeed:500,
          pauseTime:5000,
          startSlide:0,
          directionNav:true,
          controlNav:true,
          keyboardNav:false,
          pauseOnHover:false
        });
    }, 300);
});


$(document).ready(function(){

    /**
     *  ================================================
     *  02 - Main navigation
     *  ================================================
     */
    $('#main-nav').pragmaNavigation();


    /**
     *  ================================================
     *  03 - Slide-down login box
     *  ================================================
     */
    var formHide;
    $('#quick-box').hover(
        function(){
            clearTimeout(formHide);
            $(this)
                .stop().animate( {top: -15}, 300 )
                .find('#quick-link-button').removeClass('down').addClass('up');
    },
        function(){
            formHide = setTimeout(function(){
            $('#quick-box')
                .stop().animate( {top: -65}, 800 )
                .find('#quick-link-button').removeClass('up').addClass('down');
            }, 300);
        }
    );
    $('#quick-link-button').click(function(){
        $(this)
            .removeClass('up').addClass('down')
            .parent().stop().animate( {top: -65}, 300 );
    });


    /**
     *  ================================================
     *  04 - Initialise inFieldLabels plugin on 
     *       form field lables with class "infield"
     *  ================================================
     */
    $("label.infield").inFieldLabels();


    /**
     *  ================================================
     *  05 - Initialise prettyPhoto plugin
     *  ================================================
     */
    $("a.prettyPhoto").prettyPhotoHover().prettyPhoto({
        theme:'neutrino_light',
        opacity:0.60
    });


    /**
     *  ================================================
     *  06 - Tabbed widget in the sidebar
     *  ================================================
     */
    var tabContainers = $('div.tabs > div');
    $('div.tabs ul.tabNavigation a').click(function () {
        tabContainers.hide().filter(this.hash).show()

        $('div.tabs ul.tabNavigation a').removeClass('selected');
        $(this).addClass('selected');

        return false;
    }).filter(':first').click();



});

