$(document).ready(function() {

    $('#hf').click(function() {
        $('.hf').slideToggle();
    });

    // top navigation
    $('ul.sf-menu').superfish({ 
        delay:       400,                            // one second delay on mouseout 
        animation:   {opacity:'show',height:'show'},  // fade-in and slide-down animation 
        speed:       'fast',                          // faster animation speed 
        autoArrows:  false,                           // disable generation of arrow mark-up 
        dropShadows: false                            // disable drop shadows 
    });

    // fade in landing
    $(window).load(function() {
        $('#landing > img').fadeIn(3500, function() {
            $('#landing').delay(2500).fadeOut(2000, function() {
                $('#lcontent').fadeIn(500);
                $('#rcontent').fadeIn(500);
             });
        });
    });

    // swap main product image with additional image pics
    var orig = $('#mainimg').attr('src');
    $('#additional > img').hover(
        function() {
            $('#mainimg').attr('src', $(this).attr('alt'));
        },
        function() {
            $('#mainimg').attr('src', orig);
        }
    );

    // easing function for carousel
    jQuery.easing['easeOutQuad'] = function (x, t, b, c, d) {
        return -c *(t/=d)*(t-2) + b;
    }

    // carousel images
    jQuery('#carousel-list').jcarousel({
        easing: 'easeOutQuad',
        animation: 2000,
        scroll: 1,
        start: 1,
        auto: 7,
        wrap: 'circular'
    });

});

// preload background and swap images
function preload(imagearray) {
    $(imagearray).each(function(){
        $('<img/>')[0].src = this;
   });
}
