/**
 * 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 hideM=null;
var showM=null;
var holdM=false;

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


// Menu functions

function showMenu() {
    if (showM) clearTimeout(showM);
    if (hideM) clearTimeout(hideM);
    showM=setTimeout("hideExtraItem();$('navigation').show()", Delay/2);
}

function hideMenu() {
    if (showM) clearTimeout(showM);
    if (hideM) clearTimeout(hideM);
    if (!holdM) {
        hideM=setTimeout("$('navigation').hide();hideExtraItem();", Delay);
    }
}

function holdMenu(flag) {
    if (showM) clearTimeout(showM);
    if (hideM) clearTimeout(hideM);
    if (flag) {
        holdM = true;
    } else {
        holdM = false;
        hideMenu();
    }
}


// Cart functions

function showCart() {
    if (showC) clearTimeout(showC);
    if (hideC) clearTimeout(hideC);
    showC=setTimeout("$('cart-content').addClassName('show')", Delay/2);
}

function hideCart() {
    if (showC) clearTimeout(showC);
    if (hideC) clearTimeout(hideC);
    if (!holdC) {
        hideC=setTimeout("$('cart-content').removeClassName('show')", Delay);
    }
}

function holdCart(flag) {
    if (showC) clearTimeout(showC);
    if (hideC) clearTimeout(hideC);
    if (flag) {
        holdC = true;
    } else {
        holdC = false;
        hideCart();
    }
}

function showExtraItem(ref) {
	$(ref).parentNode.hide();
	$(ref.parentNode.parentNode).select('.extraitem').each(function(item){item.removeClassName('hide')});
	return false;
}

function hideExtraItem() {
	$('menu').select('.extraitem').each(function(item){item.addClassName('hide')});
	$('menu').select('.view-all').each(function(item){item.show()});
	return false;
}
