jQuery.noConflict();
(function($) {
    $('dt.details').hide();
    function showDetails(){
        $(this).find('dt.details').stop(true,true).slideDown(200);
    }
    function hideDetails(){
        $(this).find('dt.details').stop(true,true).slideUp(200);
    }
    var hoverIntentConfig = {
        sensitivity: 1, // number = sensitivity threshold (must be 1 or higher)
        interval: 25, // number = milliseconds for onMouseOver polling interval
        over: showDetails, // function = onMouseOver callback (REQUIRED)
        timeout: 0, // number = milliseconds delay before onMouseOut
        out: hideDetails // function = onMouseOut callback (REQUIRED)
    };
    if($('#contentWrap dl.thumbs.three-column img.product-image').width() > 150){
        $('#contentWrap dl.thumbs.three-column').hoverIntent(hoverIntentConfig);
    }
    $('.inputSignup').focus(function(){
        $(this).css('color','#000').val('');
    });
    $('input#search').focus(function(){
        $(this).css('color','#000').val('');
    });
    var startTime = $('#startTime').val();
    var endTime = $('#endTime').val();
    var today = $('#nowTime').val();
    if(typeof(endTime) != "undefined"){
        if(today < startTime){
            $('.days').closest('div').addClass('starting').text('-30% starting Monday');
        }
    }
    if(typeof(endTime) != "undefined"){
        calculateTimeRemaining(endTime, today);
        $('.offer').show();
    }
    function calculateTimeRemaining(endTime, today){
        timeRemaining = endTime - today;
        if(timeRemaining > 0){
            daysRemaining = timeRemaining / 60 / 60 / 24;
            wholeDaysRemaining = parseInt(daysRemaining);
            hoursRemaining = (daysRemaining - wholeDaysRemaining) * 24;
            wholeHoursRemaining = parseInt(hoursRemaining);
            minutesRemaining = (hoursRemaining - wholeHoursRemaining) * 60;
            wholeMinutesRemaining = parseInt(minutesRemaining);
            secondsRemaining = (minutesRemaining - wholeMinutesRemaining) * 60;
            wholeSecondsRemaining = Math.round(secondsRemaining);
            if(wholeDaysRemaining > 0){
                $('.days').text(wholeDaysRemaining+'d ');
            } else {
                $('.days').text('');
            }
            if(wholeHoursRemaining > 0){
                $('.hours').text(wholeHoursRemaining+'h ');
            } else {
                $('.hours').text('');
            }
            if(wholeMinutesRemaining > 0){
                $('.minutes').text(wholeMinutesRemaining+'m ');
            } else {
                $('.minutes').text('');
            }
            if(wholeSecondsRemaining > 0){
                $('.seconds').text(wholeSecondsRemaining+'s ');
            } else {
                $('.seconds').text('');
            }
            var nextSecond = parseInt(today)+1;
            setTimeout(function(){
                calculateTimeRemaining(endTime, nextSecond)
            }, 1000);
        } else {
            $('.days').closest('div').text('offer ended');
        }
    }
    $('#designerCrushBanner .more').click(function(){
        $('.designer-crush-banner').addClass('open');
        $(this).blur();
        return false;
    });
    $('#designerCrushBanner .less').click(function(){
        $('.designer-crush-banner').removeClass('open');
        return false;
    });
    $('.mojo-more').click(function(){
        $(this).closest('.text').addClass('open');
        return false;
    });
})(jQuery);
