﻿$(function () {
    //Initialize the LavaLamp...
    var $lavaLamp = $('.lavaLamp').lavaLamp({ fx: 'backout', speed: 700 });

    //Select the current tab, if any...
    var relativePath = location.href.replace(location.protocol + '//' + location.host, '');
    $lavaLamp.find('li').find('a[href="' + relativePath + '"]').click();

    //Initialize NivoSlider...
    var $showCase = $('#showcase #slider');
    if ($showCase.length) {
        $showCase.nivoSlider({
            controlNav: false,
            slices: 40,
            animSpeed: 1000,
            pauseTime: 15000,
            pauseOnHover: false
        });

        //Make sure that any click on showcase images will end up changing the page...
        $showCase.find('>a').click(function () {
            var index = $(this).parent().find('a').index($(this));
            var idx = index == 0 || index == 1 ? 3 : 2;

            var $li = $('#topNavBar li a').eq(idx).mouseover();
            setTimeout(function () {
                location.href = $li.click().attr('href');
            }, 700);

            return false;
        });
    }
});
