/*
	Context menu script file
*/

/* Global Variables */
var _productCategoryCount;
var _productMenuTimer;

/* Event Handlers */
function productCategoryCell_over(cell)
{
	// Get the index of the category representing this cell
	var cellIndex = cell.id.replace("productCategoryCell_", "");
	
	// RenderMenus
	displayProductCategoryMenu(cellIndex);
	
	// Clear the timer
	clearProductCategoryMenuTimer();
}

function productCategoryCell_out(cell)
{
	// Set the timer
	setProductCategoryMenuTimer();
}

//function productCategoryMenuCell_over(cell)
//{
//	cell.style.backgroundColor = "#FF6600";
//}

//function productCategoryMenuCell_out(cell)
//{
//	cell.style.backgroundColor = "#01A8FF";
//}

function productCategoryMenu_over(menu)
{
	// Clear the timer
	clearProductCategoryMenuTimer();
}

function productCategoryMenu_out(menu)
{
	// Set the timer
	setProductCategoryMenuTimer();
}

//function contextCell_over(cell)
//{
//	changeContextCell("over", cell);
//}

//function contextCell_out(cell)
//{
//	changeContextCell("out", cell);
//}

/* Methods */
function displayProductCategoryMenu(menuIndex)
{
	// Hide all menus except for menuIndex menu
	for (var i = 0; i <= _productCategoryCount; i++)
	{
	    
		var menu = document.getElementById("productSubCategory_" + i);
		var cell = document.getElementById("productCategoryCell_" + i);
		
		if (menu != null)
		{
			if (i == menuIndex)
			{
				menu.style.display = "block";
			}
			else
			{
				menu.style.display = "none";
			}
		}
	}
}

//function changeContextCell(state, anchor)
//{
//	if (state == "over")
//	{
//	    anchor.style.textDecoration = "underline";
//		//cell.style.backgroundImage = "url(/images/contextmenu_cell_over.gif)";
//	}
//	else
//	{
//	    anchor.style.textDecoration = "none";
//		//cell.style.backgroundImage = "url(/images/contextmenu_cell_out.gif)";
//	}
//}

function setProductCategoryMenuTimer()
{
	_productMenuTimer = setTimeout("displayProductCategoryMenu(-1)", 100);
	
}

function clearProductCategoryMenuTimer()
{
	clearTimeout(_productMenuTimer);
}




