/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/osl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * @copyright  Copyright (c) 2004-2007 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
 * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 */

var Delay=300;

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

var hideW=null;
var showW=null;
var holdW=null;
var holdWHide=false;
var holdWShow=false;

// Shared functions

function clearHold() {
    holdHide = false;
}

// Cart functions

function showCart(flag) {
    if (holdC) clearTimeout(holdC);
    if (!holdHide) {
        if (showC) clearTimeout(showC);
        showC=setTimeout("$('mini-cart').addClassName('show')", Delay);
    }
    if (flag) {
        hideC=setTimeout("hideCart()", 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('show')", Delay);
    }
}

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


// Wishlist functions

function showWishlist(flag) {
    if (holdW) clearTimeout(holdW);
    if (!holdWHide) {
        if (showW) clearTimeout(showW);
        showW=setTimeout("$('mini-wishlist').addClassName('show')", Delay);
    }
    if (flag) {
        hideW=setTimeout("hideWishlist()", 5000);
    }
}

function hideWishlist() {
    if (showW) clearTimeout(showW);
    if (holdWHide) {
        if (holdW) clearTimeout(holdW);
        holdW=setTimeout("clearHold()", Delay);
    }
    if (!holdWShow) {
        if (hideW) clearTimeout(hideW);
        hideW=setTimeout("$('mini-wishlist').removeClassName('show')", Delay);
    }
}

function toogleWishlist() {
    if (!holdWShow) {
        holdWHide = false;
        holdWShow = true;
        $('mini-wishlist').addClassName('show');
    } else {
        holdWShow = false;
        holdWHide = true;
        $('mini-wishlist').removeClassName('show');
    }
}




