﻿function cartmini() {
    if ($('#box_popup').hasClass('hide-it')) {
        $('#box_popup').show('fast').removeClass('hide-it').addClass('show-it');
    } else {
        $('#box_popup').hide('fast').removeClass('show-it').addClass('hide-it');
    }

    return false;
}

var timer;
var current;

var showBox = function(box) {

    if (current == box) {
        return;
    } else {
        current = box;
        var callback = function(o) {
            return function() {
                o.show('fast').removeClass('hide-it').addClass('show-it');
            }

        } (box);

        if (timer != undefined) {
            window.clearTimeout(timer);
        }
        timer = window.setTimeout(callback, 500); //you can change the 500 to you wanted.
    }
};


var hideBox = function(box) {
    if (timer != undefined) {
        window.clearTimeout(timer);
    }
    box.hide('fast').removeClass('show-it').addClass('hide-it');
    current = null;
};

$(function() {
    $(".rt").mouseenter(function() {
        if (current != undefined) {
            var box = $("#cart").find(".show-it");
            hideBox(box);
        }
        var box = $(this).find(".hide-it");
        showBox(box);
    })

    $(".rt").mouseleave(function() {
        var box = $(this).find(".show-it");
        hideBox(box);
    });

});
