// products.js
// For building the dynamic list of products
var fams = new Array();

// add product family
function _PF(familyId,familyName) {
	var fam = new Array();
	fam[0] = familyId;
	fam[1] = familyName;
	fam[2] = new Array();
	fams[fams.length] = fam;
}
// add product
function _P(familyId,sku,title,desc) {
	var thisFam = fams[familyId];
	var prod = new Array();
	prod[0] = sku;
	prod[1] = title;
	prod[2] = desc;
	thisFam[2][thisFam[2].length] = prod;
}
function getProdDesc(sku) {
	for (var i  = 0; i < fams.length; i++) {
		if (fams[i][2] != null) {
			for (var j = 0; j < fams[i][2].length; j++) {
				var prod = fams[i][2][j];
				if (prod[0] == sku) {
					return prod[2];
				}
			}
		}
	}
	return '';
}
function getProdTitle(sku) {
	for (var i  = 0; i < fams.length; i++) {
		if (fams[i][2] != null) {
			for (var j = 0; j < fams[i][2].length; j++) {
				var prod = fams[i][2][j];
				if (prod[0] == sku) {
					return prod[1];
				}
			}
		}
	}
	return '';
}
function initFams() {
_PF(0,"none");
}

function initProds() {
_P(0,"70071204021","Medium Utility Hook", "Specifically designed to fit in and enhance a wide variety of decors. They're sure to fit into your individual style.");
_P(0,"70071381399","Medium Utility Hook Value Pack", "1 Specifically designed to fit in and enhance a wide variety of decors. They're sure to fit into your individual style.");
_P(0,"70071204062","Small Utility Hook", "2 Specifically designed to fit in and enhance a wide variety of decors. They're sure to fit into your individual style.");
_P(0,"70071204096","Large Utility Hook", "3 Specifically designed to fit in and enhance a wide variety of decors. They're sure to fit into your individual style.");
_P(0,"70071476033","Large Utility Hook Value Pack", "4 Specifically designed to fit in and enhance a wide variety of decors. They're sure to fit into your individual style.");
_P(0,"70071213790","Medium Picture Hanging Strips", "Specifically designed to fit in and enhance a wide variety of decors. They're sure to fit into your individual style.");
_P(0,"70071213816","Small Picture Hanging Strips", "Specifically designed to fit in and enhance a wide variety of decors. They're sure to fit into your individual style.");
_P(0,"70071490687","Small Brushed Nickel Forever Classic Hook", "Specifically designed to fit in and enhance a wide variety of decors. They're sure to fit into your individual style.");
_P(0,"70071490703","Medium Brushed Nickel Forever Classic Hook", "Specifically designed to fit in and enhance a wide variety of decors. They're sure to fit into your individual style.");
_P(0,"70071490232","Large Brushed Nickel Forever Classic Hook", "Specifically designed to fit in and enhance a wide variety of decors. They're sure to fit into your individual style.");
}

function initFamDD() {
	var l = document.getElementById('selectCategory');
	if (l != null) {
		for (i = 0; i < fams.length; i++) {
			l.options[i] = new Option(fams[i][1], fams[i][0]);
			l.options[i].innerHTML = fams[i][1];
		}
	}
}

function famDDSelect(id) {
	var l = document.getElementById('selectProduct');
	for (i = l.length-1; i >= 0; i--) {
		l.remove(i);		
	}
	l.options[0] = new Option('-- Please Select --', '70071490232');
	var products = fams[id][2];
	for (i = 0; i < products.length; i++) {
		l.options[i+1] = new Option(products[i][1], products[i][0]);
		l.options[i+1].innerHTML = products[i][1];
	}
	var cddl = document.getElementById('selectCategory');
	var disable = (cddl == null) ? false : cddl.value == "0";
	l.disabled = disable;
	document.getElementById('zipcode').disabled = disable;
}
