com_givensviolins_shop_instrument = new (function() {
	var ViolinPriceCodes = [ 'Up to $1,000'
		, '$1,000 to 2,000'
		, '$2,000 to 4,000'
		, '$4,000 to 4,000'
		, '$8,000 to 12,000'
		, '$12,000 to 20,000'
		, '$20,000 to 40,000'
		, 'Rare and Exceptional'
		, 'Rare and Exceptional'
		, 'Rare and Exceptional'
	];
	var ViolaPriceCodes = [ 'Up to 2,000'
		, 'Up to 2,000'
		, '$2,000 to 4,000'
		, '$4,000 to 4,000'
		, '$8,000 to 12,000'
		, '$12,000 to 20,000'
		, '$20,000 to 40,000'
		, 'Rare and Exceptional'
		, 'Rare and Exceptional'
		, 'Rare and Exceptional'
	];
	var CelloPriceCodes = [ 'Up to $3,500'
		, 'Up to $3,500'
		, '$3,500 to 5,000'
		, '$5,000 to 8,000'
		, '$8,000 to 12,000'
		, '$12,000 to 25,000'
		, '$25,000 to 50,000'
		, 'Rare and Exceptional'
		, 'Rare and Exceptional'
		, 'Rare and Exceptional'
	];
	var BowPriceCodes = [ 'Up to 300'
		, 'Up to 300'
		, '$300 to 600'
		, '$600 to 1,000'
		, '$1,000 to 1,500'
		, '$1,500 to 2,500'
		, '$2,500 to 3,000'
		, 'Rare and Exceptional'
		, 'Rare and Exceptional'
		, 'Rare and Exceptional'
	];
	var BookCodes = [ ];
	var CDCodes = [ ];

	// Public
	this.submit = function(button) {
		button.form.submit();
	};
	this.handleCategoryChange = function(selectElm) {
		var category;
		var itemClass;
		var itemTypeCode;
		var itemPriceCode;
		var codes;
		var lastCode;
		var lastOption;
		var frm = selectElm.form;
		var categorySelect = frm['category'];
		var pricecodeSelect = frm['pricecode'];

		if (categorySelect.selectedIndex >= 0) {
			category = categorySelect.options[categorySelect.selectedIndex].value;
			itemClass = category.substring(0, category.indexOf(':'));
			itemTypeCode = category.substring(category.indexOf(':') + 1);

			pricecodeSelect.options.length = 1;
			if (itemTypeCode == '0') {
				if (itemClass == 'VN') {
					codes = ViolinPriceCodes;
				} else if (itemClass == 'VA') {
					codes = ViolaPriceCodes;
				} else if (itemClass == 'VB' || itemClass == 'WB' || itemClass == 'CB') {
					codes = BowPriceCodes;
				} else if (itemClass == 'BK') {
					codes = BookCodes;
				} else if (itemClass == 'CD') {
					codes = CDCodes;
				} else {
					codes = CelloPriceCodes;
				}

				lastOption = pricecodeSelect.options[0];
				lastCode = '';
				for (var i = 0; i < codes.length; i++) {
					if (lastCode == codes[i]) { 
						lastOption.value += ',' + (i);
					} else {
						lastOption = new Option(codes[i], i);
						lastCode = codes[i];
						pricecodeSelect.options[pricecodeSelect.length] = lastOption;
					}
				}
			}
		}
	};
})();












