﻿$(document).ready(function() {
    var timeouts = Array();

    /* 
    $('.main-nav .w').hover(
    function() {
    $('#whats-new-nav').show();
    },
    function() { }
    );

    $('.main-nav .d').hover(
    function() {
    $('#designers-nav').show();
    },
    function() { }
    );

    $('#whats-new-nav-c').hover(
    function() {
    clearTimeout(w_timeout);
    },
    function() {
    w_timeout = setTimeout("$('#whats-new-nav').fadeOut ('fast');", 500);
    }
    );

    $('#designers-nav-c').hover(
    function() {
    clearTimeout(d_timeout);
    },
    function() {
    d_timeout = setTimeout("$('#designers-nav').fadeOut ('fast');", 500);
    }
    );
    */

    $('.main-nav li').hover(
        function() {
            clearTimeout(timeouts[$(this).attr('id')]);
            $(this).children('ul.sub').show();
        },
        function() { 
            timeouts[$(this).attr('id')] = setTimeout("$('#" + $(this).children('ul.sub').attr ('id') + "').fadeOut ('fast');", 500);
        }
    );

    // product image switcher
    $('#image-selector a').click(function() {
        var next_image = $(this).attr('href');
        $('.picture img').fadeOut('slow', function() {
            $('.picture img').attr('src', next_image);
            setTimeout(function() {
                $('.picture img').fadeIn('slow');
            }, 500);
        });
        return false;
    });
}); 
