
function husGetProductKey(strProductGroupKey, objColor, objSize, bReverse) {
	strKey = strProductGroupKey.toUpperCase();
	if (bReverse) {
		if (objSize.selectedIndex > -1)
			strKey += objSize.options[objSize.selectedIndex].value;
		if (objColor.selectedIndex > -1)
			strKey += objColor.options[objColor.selectedIndex].value;
	} else {
		if (objColor.selectedIndex > -1)
			strKey += objColor.options[objColor.selectedIndex].value;
		if (objSize.selectedIndex > -1)
			strKey += objSize.options[objSize.selectedIndex].value;
	}
	return strKey.toUpperCase();
}

function husSetProductPrice(objField, strProductGroupKey, objColor, objSize) {
	arrPrice = arrProduct[strProductGroupKey]['arrPrice'];
	objField.value = husWritePrice(arrPrice[husGetProductKey(strProductGroupKey, objColor, objSize)]);
}

function husUpdateFields(strProductGroupKey, objSize, objColor, objProductKey, objPrice, bReverse) {

	if (bReverse == undefined) { bReverse = false; }

	arrSize = arrProduct[strProductGroupKey]['arrSize'];
	arrProductKey = arrProduct[strProductGroupKey]['arrProductKey'];
	
	if (objColor.selectedIndex != -1) {
		husFillSelect(objSize, arrSize[objColor.options[objColor.selectedIndex].value]);
	} else {
		husFillSelect(objSize, arrSize['']);
	}
	
	objSize.disabled = (objSize.options.length == 0);
	objColor.disabled = (objColor.options.length == 0);
	
	husSetProductPrice(objPrice, strProductGroupKey, objColor, objSize);

	objProductKey.value = arrProductKey[husGetProductKey(strProductGroupKey, objColor, objSize)];
}

function husWritePrice(fltValue) {
	var f = Number(fltValue);
	var r = f.toFixed(2) + " $ CAN";
	if (f == 0) { r = 'N/A'; }
	return r;
}


