// yui_paintSelectMenu.js

var aMenuButtonMenu = [];
var sSKU = "";

function onMenuItemClick(p_sType, p_aArgs, p_oItem) {
	oMenuButton.set("label", p_oItem.cfg.getProperty("text"));
	oSelect.selectedIndex = p_oItem.value;
	
	// Need to call the CheckOptionsSKU() function
	//	
	var fnCheck = "CheckOptions" + sSKU;
	eval(fnCheck+'(document.getElementById("paint-form"))');
}


function buildPaintColorMenu(oSelect, aMenu, sku)
{
	buildColorMenu(oSelect, aMenu, sku, "/images/paint/");
}


function buildSelectorColorMenu(oSelect, aMenu, sku)
{
	buildColorMenu(oSelect, aMenu, sku, "/images/selector/");
}

// This builds the color select menu with images from the appropriate product
function buildColorMenu(oSelect, aMenu, sku, sImagePath)
{
	var aTmp, sRow;
	sSKU = sku.replace(/-/, 'DASH');
	
	for (var i = 0; i < oSelect.length; i++)
	{
		aTmp = 	oSelect.options[i].text.split('[');
		sRow = "<img class='menu-color-image' src='" + sImagePath +  
				document.getElementById('key').value.toLowerCase() + "/" + 
				aTmp[1].substring(0,aTmp[1].length - 1) + 
				".gif'><span class='menu-color-text'>&nbsp;&nbsp;" + 
				aTmp[0] + "</span>";
		aMenu[i] = { text: sRow, value: i, onclick: { fn: onMenuItemClick } };
	}
	
	oSelect.style.display='none';
	
}
function isColorOption(e) { return ('opt0' == e.name); }