var hideC=null;
var showC=null;
var holdC=null;
var holdHide=false;
var holdShow=false;
var Delay=300;

function showCart(flag) {
    if (holdC) clearTimeout(holdC);

    if (!holdHide) {
        if (showC) clearTimeout(showC);
        showC=setTimeout("$('mini-cart').addClassName('showCart')", Delay);
    }

    if (flag) {
        hideC=setTimeout("$('mini-cart').removeClassName('showCart')", 5000);
    }
}

function hideCart() {
    if (showC) clearTimeout(showC);

    if (holdHide) {
        if (holdC) clearTimeout(holdC);
        holdC=setTimeout("clearHold()", Delay);
    }

    if (!holdShow) {
        if (hideC) clearTimeout(hideC);
        hideC=setTimeout("$('mini-cart').removeClassName('showCart')", Delay);
    }
}

function toogleCart() {
    if (!holdShow) {
        holdHide = false;
        holdShow = true;
        $('mini-cart').addClassName('showCart');
    } else {
        holdShow = false;
        holdHide = true;
        $('mini-cart').removeClassName('showCart');
    }
}

function clearHold() {
    holdHide = false;
}