

ImageStruct = new Object();
ImageStruct["default"] = "\r\n\t\t\t<div id=\"picture\">\r\n\t\t\t\t<div id=\"mainImageOutline\" style=\"width: 250px; height: 0px;\" onclick=\"javascript:window.open(\'/_largeimage.cfm?image=hidplastic.jpg\',\'popup\',\'width=600,height=600, scrollbars=yes\');\">\r\n\t\t\t\t\t<a href=\"javascript:void(0);\">\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t<img id=\"mainImage\" src=\"/images/product//images/large_hidplastic.jpg\" class=\"imgBorder\" alt=\"H-D Plastic Bags\" />\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t</a>\r\n\t\t\t\t\t<br />\r\n\t\t\t\t\t<a href=\"javascript:void(0);\"><img id=\"mainImage\" src=\"/images/retail/zoom.gif\" alt=\"Zoom\" /></a>\r\n\t\t\t\t</div>\r\n\t\t\t\t\r\n\t\t\t</div>\t\t\r\n\t\t\t<div id=\"previews\" style=\"padding-top:270px;\">\r\n\t\t\t\r\n\t\t\t</div>\r\n\t\t\t";


fldValueStruct = new Object();
fldValueStruct["fld1array"] =  new Array();
fldValueStruct["fld1array"][0] = new Object();
fldValueStruct["fld1array"][0]["value"] = 1173;
fldValueStruct["fld1array"][0]["text"] = "6.50 X 0.00 X 9.25";
fldValueStruct["fld1array"][1] = new Object();
fldValueStruct["fld1array"][1]["value"] = 1006;
fldValueStruct["fld1array"][1]["text"] = "12.00 X 0.00 X 15.00";
fldValueStruct["fld1array"][2] = new Object();
fldValueStruct["fld1array"][2]["value"] = 1158;
fldValueStruct["fld1array"][2]["text"] = "12.00 X 3.00 X 18.00";
fldValueStruct["fld1array"][3] = new Object();
fldValueStruct["fld1array"][3]["value"] = 1162;
fldValueStruct["fld1array"][3]["text"] = "14.00 X 3.00 X 21.00";
fldValueStruct["fld1array"][4] = new Object();
fldValueStruct["fld1array"][4]["value"] = 1165;
fldValueStruct["fld1array"][4]["text"] = "16.00 X 4.00 X 24.00";
fldValueStruct["fld1array"][5] = new Object();
fldValueStruct["fld1array"][5]["value"] = 1168;
fldValueStruct["fld1array"][5]["text"] = "20.00 X 4.00 X 30.00";
fldValueStruct["fld1array"][6] = new Object();
fldValueStruct["fld1array"][6]["value"] = 1170;
fldValueStruct["fld1array"][6]["text"] = "24.00 X 6.00 X 36.00";
fldValueStruct["fld2array"] =  new Array();
fldValueStruct["fld2array"][0] = new Object();
fldValueStruct["fld2array"][0]["value"] = 435;
fldValueStruct["fld2array"][0]["text"] = "DARK BLUE";
fldValueStruct["fld2array"][1] = new Object();
fldValueStruct["fld2array"][1]["value"] = 312;
fldValueStruct["fld2array"][1]["text"] = "DARK GREEN";
fldValueStruct["fld2array"][2] = new Object();
fldValueStruct["fld2array"][2]["value"] = 436;
fldValueStruct["fld2array"][2]["text"] = "FROSTED CLEAR";
fldValueStruct["fld2array"][3] = new Object();
fldValueStruct["fld2array"][3]["value"] = 358;
fldValueStruct["fld2array"][3]["text"] = "MAGENTA";
fldValueStruct["fld2array"][4] = new Object();
fldValueStruct["fld2array"][4]["value"] = 1512;
fldValueStruct["fld2array"][4]["text"] = "RED";
fldValueStruct["fld2array"][5] = new Object();
fldValueStruct["fld2array"][5]["value"] = 1651;
fldValueStruct["fld2array"][5]["text"] = "red";
fldValueStruct["fld2array"][6] = new Object();
fldValueStruct["fld2array"][6]["value"] = 1417;
fldValueStruct["fld2array"][6]["text"] = "SILVER GLOSS";
fldValueStruct["fld2array"][7] = new Object();
fldValueStruct["fld2array"][7]["value"] = 238;
fldValueStruct["fld2array"][7]["text"] = "TEAL";
fldValueStruct["fld2array"][8] = new Object();
fldValueStruct["fld2array"][8]["value"] = 141;
fldValueStruct["fld2array"][8]["text"] = "WHITE";


AvailableProducts = new Object();
AvailableProducts["1168_238"] = 33997;
AvailableProducts["1173_1512"] = 34015;
AvailableProducts["312_1165"] = 33985;
AvailableProducts["1165_358"] = 33986;
AvailableProducts["358_1165"] = 33986;
AvailableProducts["1158_435"] = 33960;
AvailableProducts["1512_1173"] = 34015;
AvailableProducts["1162_1512"] = 33979;
AvailableProducts["1006_435"] = 33953;
AvailableProducts["141_1158"] = 33965;
AvailableProducts["1162_312"] = 33976;
AvailableProducts["238_1165"] = 33988;
AvailableProducts["1512_1162"] = 33979;
AvailableProducts["141_1170"] = 34001;
AvailableProducts["1006_1512"] = 33957;
AvailableProducts["312_1168"] = 33993;
AvailableProducts["358_1168"] = 33994;
AvailableProducts["312_1006"] = 33954;
AvailableProducts["1006_141"] = 33959;
AvailableProducts["1417_1168"] = 33996;
AvailableProducts["312_1173"] = 34013;
AvailableProducts["1006_238"] = 33958;
AvailableProducts["312_1158"] = 33961;
AvailableProducts["1006_312"] = 33954;
AvailableProducts["1162_436"] = 33977;
AvailableProducts["238_1168"] = 33997;
AvailableProducts["1158_238"] = 33964;
AvailableProducts["1158_312"] = 33961;
AvailableProducts["1168_1512"] = 33995;
AvailableProducts["1512_1158"] = 33963;
AvailableProducts["141_1162"] = 33981;
AvailableProducts["141_1173"] = 34017;
AvailableProducts["1173_238"] = 34016;
AvailableProducts["1168_1417"] = 33996;
AvailableProducts["1162_358"] = 33978;
AvailableProducts["1165_312"] = 33985;
AvailableProducts["141_1006"] = 33959;
AvailableProducts["1173_141"] = 34017;
AvailableProducts["435_1162"] = 33975;
AvailableProducts["435_1173"] = 34012;
AvailableProducts["238_1006"] = 33958;
AvailableProducts["435_1158"] = 33960;
AvailableProducts["238_1162"] = 33980;
AvailableProducts["238_1173"] = 34016;
AvailableProducts["435_1006"] = 33953;
AvailableProducts["238_1158"] = 33964;
AvailableProducts["1165_238"] = 33988;
AvailableProducts["358_1006"] = 33956;
AvailableProducts["435_1168"] = 33992;
AvailableProducts["358_1162"] = 33978;
AvailableProducts["358_1173"] = 34014;
AvailableProducts["1170_141"] = 34001;
AvailableProducts["358_1158"] = 33962;
AvailableProducts["1173_312"] = 34013;
AvailableProducts["435_1165"] = 33984;
AvailableProducts["1168_312"] = 33993;
AvailableProducts["1158_1512"] = 33963;
AvailableProducts["436_1162"] = 33977;
AvailableProducts["436_1006"] = 33955;
AvailableProducts["1173_358"] = 34014;
AvailableProducts["1512_1165"] = 33987;
AvailableProducts["1006_436"] = 33955;
AvailableProducts["1512_1006"] = 33957;
AvailableProducts["1165_435"] = 33984;
AvailableProducts["1168_358"] = 33994;
AvailableProducts["1162_238"] = 33980;
AvailableProducts["1162_141"] = 33981;
AvailableProducts["1158_358"] = 33962;
AvailableProducts["1006_358"] = 33956;
AvailableProducts["1158_141"] = 33965;
AvailableProducts["312_1162"] = 33976;
AvailableProducts["1162_435"] = 33975;
AvailableProducts["1173_435"] = 34012;
AvailableProducts["1165_1512"] = 33987;
AvailableProducts["1512_1168"] = 33995;
AvailableProducts["1168_435"] = 33992;


AttributeArray = new Object();
AttributeArray["238"] = new Object();
AttributeArray["238"]["value"] = 238;
AttributeArray["238"]["text"] = "TEAL";
AttributeArray["238"]["prod_id"] = "33958,33964,33980,33988,33997,34016";
AttributeArray["238"]["allowed"] = "1006,1158,1162,1165,1168,1173";
AttributeArray["1165"] = new Object();
AttributeArray["1165"]["value"] = 1165;
AttributeArray["1165"]["text"] = "16.00 X 4.00 X 24.00";
AttributeArray["1165"]["prod_id"] = "33988,33985,33986,33984,33987";
AttributeArray["1165"]["allowed"] = "238,312,358,435,1512";
AttributeArray["1651"] = new Object();
AttributeArray["1651"]["value"] = 1651;
AttributeArray["1651"]["text"] = "red";
AttributeArray["435"] = new Object();
AttributeArray["435"]["value"] = 435;
AttributeArray["435"]["text"] = "DARK BLUE";
AttributeArray["435"]["prod_id"] = "33953,33960,33975,33984,33992,34012";
AttributeArray["435"]["allowed"] = "1006,1158,1162,1165,1168,1173";
AttributeArray["358"] = new Object();
AttributeArray["358"]["value"] = 358;
AttributeArray["358"]["text"] = "MAGENTA";
AttributeArray["358"]["prod_id"] = "33956,33962,33978,33986,33994,34014";
AttributeArray["358"]["allowed"] = "1006,1158,1162,1165,1168,1173";
AttributeArray["1006"] = new Object();
AttributeArray["1006"]["value"] = 1006;
AttributeArray["1006"]["text"] = "12.00 X 0.00 X 15.00";
AttributeArray["1006"]["prod_id"] = "33959,33958,33954,33956,33953,33955,33957";
AttributeArray["1006"]["allowed"] = "141,238,312,358,435,436,1512";
AttributeArray["312"] = new Object();
AttributeArray["312"]["value"] = 312;
AttributeArray["312"]["text"] = "DARK GREEN";
AttributeArray["312"]["prod_id"] = "33954,33961,33976,33985,33993,34013";
AttributeArray["312"]["allowed"] = "1006,1158,1162,1165,1168,1173";
AttributeArray["1173"] = new Object();
AttributeArray["1173"]["value"] = 1173;
AttributeArray["1173"]["text"] = "6.50 X 0.00 X 9.25";
AttributeArray["1173"]["prod_id"] = "34017,34016,34013,34014,34012,34015";
AttributeArray["1173"]["allowed"] = "141,238,312,358,435,1512";
AttributeArray["1158"] = new Object();
AttributeArray["1158"]["value"] = 1158;
AttributeArray["1158"]["text"] = "12.00 X 3.00 X 18.00";
AttributeArray["1158"]["prod_id"] = "33965,33964,33961,33962,33960,33963";
AttributeArray["1158"]["allowed"] = "141,238,312,358,435,1512";
AttributeArray["1512"] = new Object();
AttributeArray["1512"]["value"] = 1512;
AttributeArray["1512"]["text"] = "RED";
AttributeArray["1512"]["prod_id"] = "33957,33963,33979,33987,33995,34015";
AttributeArray["1512"]["allowed"] = "1006,1158,1162,1165,1168,1173";
AttributeArray["1417"] = new Object();
AttributeArray["1417"]["value"] = 1417;
AttributeArray["1417"]["text"] = "SILVER GLOSS";
AttributeArray["1417"]["prod_id"] = "33996";
AttributeArray["1417"]["allowed"] = "1168";
AttributeArray["436"] = new Object();
AttributeArray["436"]["value"] = 436;
AttributeArray["436"]["text"] = "FROSTED CLEAR";
AttributeArray["436"]["prod_id"] = "33955,33977";
AttributeArray["436"]["allowed"] = "1006,1162";
AttributeArray["141"] = new Object();
AttributeArray["141"]["value"] = 141;
AttributeArray["141"]["text"] = "WHITE";
AttributeArray["141"]["prod_id"] = "33959,33965,33981,34001,34017";
AttributeArray["141"]["allowed"] = "1006,1158,1162,1170,1173";
AttributeArray["1162"] = new Object();
AttributeArray["1162"]["value"] = 1162;
AttributeArray["1162"]["text"] = "14.00 X 3.00 X 21.00";
AttributeArray["1162"]["prod_id"] = "33981,33980,33976,33978,33975,33977,33979";
AttributeArray["1162"]["allowed"] = "141,238,312,358,435,436,1512";
AttributeArray["1168"] = new Object();
AttributeArray["1168"]["value"] = 1168;
AttributeArray["1168"]["text"] = "20.00 X 4.00 X 30.00";
AttributeArray["1168"]["prod_id"] = "33997,33993,33994,33992,33996,33995";
AttributeArray["1168"]["allowed"] = "238,312,358,435,1417,1512";
AttributeArray["1170"] = new Object();
AttributeArray["1170"]["value"] = 1170;
AttributeArray["1170"]["text"] = "24.00 X 6.00 X 36.00";
AttributeArray["1170"]["prod_id"] = "34001";
AttributeArray["1170"]["allowed"] = "141";


function filterAttribute(attrID,fldID,srcFld){
	var fld = document.getElementById('attributeID_'+fldID);
	attrID = srcFld.options[srcFld.selectedIndex].value;
	var valueCount = 1;
	var noValueCount = 0;
	if (attrID > 0) {
		var allowedValueList = AttributeArray[attrID]['allowed'];
		var prod_id = AttributeArray[attrID]['prod_id'];
		var allowedValueArray = allowedValueList.split(',');
		var notAllowedValueArray = new Array();
		//alert(attrID);
		//alert(allowedValueList);
	
		//alert(fld.selectedIndex)
		
		var selectedValue = '';
		var removed = false;
		if (fld.selectedIndex > 0){
			selectedValue = fld.options[fld.selectedIndex].value;
		}
		if (fld.options.length > 1) {
			removed = true;
			for(var i=fld.options.length-1;i>=1;i--){
				fld.remove(i);
			}
			
			//fldArray = eval('fld'+fldID+'Array');
			fldArray = fldValueStruct['fld'+fldID+'array']
			for(var i=0; i< fldArray.length; i++){
		
				var  currentValue = fldArray[i]['value'];
			
				for (var j = 0; j < allowedValueArray.length; j++){
					var allowedValue = allowedValueArray[j];
					//alert(currentValue+ ' - ' + allowedValue)
					if (currentValue == allowedValue || attrID == 0){
						fld.options[valueCount] = new Option(fldArray[i]['text'], fldArray[i]['value'], false, false);
						if (selectedValue == currentValue)
							fld.options[valueCount].selected = true;
							
						valueCount = valueCount + 1;
					}
					else {
						
						notAllowedValueArray[noValueCount] = currentValue;
						noValueCount = noValueCount + 1;
					}
		
				}
			}
		}
		
		for(var i=0; i< notAllowedValueArray.length; i++){
			var divID = document.getElementById('img'+notAllowedValueArray[i])
			if (divID!= null) { 
				divID.innerHTML = '<img src="/images/retail/inActive.png">';
			}
		}
		
		for(var i=0; i< allowedValueArray.length; i++){
			var divID = document.getElementById('img'+allowedValueArray[i])
			if (divID!= null) { 
				divID.innerHTML = '';
			}
		}
	}
	else {
		var selectedValue = '';
		var removed = false;
		if (fld.selectedIndex > 0){
			selectedValue = fld.options[fld.selectedIndex].value;
		}
		
		if (fld.options.length > 1) {
			removed = true;
			for(var i=fld.options.length-1;i>=1;i--){
				fld.remove(i);
			}
					
			fldArray = fldValueStruct['fld'+fldID+'array']
			//alert(fldArray.length);
			for(var i=0; i< fldArray.length; i++){
				fld.options[i+1] = new Option(fldArray[i]['text'], fldArray[i]['value'], false, false);
				if (selectedValue == currentValue)
					fld.options[i+1].selected = true;
					
				var divID = document.getElementById('img'+fldArray[i]['value']);
				if (divID!= null) { 
					divID.innerHTML = '';
				}
				
			}
		}
	}
	
	if (!removed || (fld.selectedIndex > 0 && srcFld.selectedIndex > 0 )){
		value = fld.options[fld.selectedIndex].value;
		attrID = srcFld.options[srcFld.selectedIndex].value;
		key = value+'_'+attrID;
		//alert(key);
		//alert(AvailableProducts[key]);
		getProductPrice('/index.cfm?event=shop.dspProductPrice&prod_id='+AvailableProducts[key]);
	}
	else {
		if (fld.selectedIndex == 0 && srcFld.selectedIndex == 0 )
			Spry.Utils.setInnerHTML('imageText',ImageStruct['default']);

		Spry.Utils.setInnerHTML('productPrice', '');
	}
	//alert(fldArray)
	//alert('fld'+fldID+'Array');

	//fld.options[boxLength] = new Option(Text, Value, false, false);
	
	/*for (var j = 0; j < fld.length; j++) {
		if (fld.options[j].value == attrID){
			
		}
	}
	alert(AttributeArray[attrID]['allowed']);*/
}
function selectColor(id,imgText,imgBorder){
	//alert(id);
	var imgTagText = document.getElementById(imgText).innerHTML;
	var imgBorderDiv = document.getElementById(imgBorder);
	
	if (imgTagText.indexOf('<img') >=0 )
		alert('Not available');
	else {
		//alert(imgBorderDiv.style.border);
		//imgBorderDiv.style.border = '5px'
		var fld = document.getElementById('attributeID_2');
		for(i=fld.options.length-1;i>=1;i--){
		if (fld.options[i].value == id)
			fld.options[i].selected = true;
		}
	
		filterAttribute(id,1,fld);
	}
}

	function doAdd(){
		Spry.Utils.setInnerHTML('updateResponseDiv', 'Processing.....');
		return Spry.Utils.submitForm(document.forms['frmProductDetail'], updateResponseDiv);
	}

	function doCheckStatus(sc_que_id){
		document.forms['frmCartStatus'].sc_que_id.value = sc_que_id;
		return Spry.Utils.submitForm(document.forms['frmCartStatus'], updateResponseDiv);
	}
	function updateResponseDivTest(req){
		Spry.Utils.setInnerHTML('updateResponseDiv', req.xhRequest.responseText);
	}
	
	function updateResponseDiv(req){

		var responseXML = Spry.XML.documentToObject(req.xhRequest.responseXML);
		if (responseXML.ShopCart) {
			var sc_que_id = responseXML.ShopCart['sc_que_id']._value();
			var sc_que_status_id = responseXML.ShopCart['sc_que_status_id']._value();
			var sc_que_message = responseXML.ShopCart['sc_que_message']._value();
		}
		if (sc_que_status_id == 3) { // Product added to shopping cart
			
			sc_que_message = '<h3>'+sc_que_message + '</h3>&nbsp;&nbsp;&nbsp;&nbsp;<a href="/index.cfm?event=cart.dspView"><img src="/images/retail/cart.gif" />&nbsp;View Cart</a>';
			
			var sc_sub_total = responseXML.ShopCart['sc_sub_total']._value();

			if (document.getElementById('cartTotal') != null)
				Spry.Utils.setInnerHTML('cartTotal', '$'+sc_sub_total);

			Spry.Utils.setInnerHTML('updateResponseDiv', sc_que_message);
		}
		else if (sc_que_status_id == 1) // In Que
			doCheckStatus(sc_que_id);
		else if (sc_que_status_id == 5 ) {// Unable to add to shopping cart
			sc_que_message = '<h3> out of stock </h3>';
			Spry.Utils.setInnerHTML('updateResponseDiv', sc_que_message);
		}
	}
	
	function getProductPrice(url){
		Spry.Utils.setInnerHTML('productPrice', 'Loading...');
		Spry.Utils.setInnerHTML('updateResponseDiv', '');
		var req = Spry.Utils.loadURL("GET", url, true, processDispPriceResult);
	}
	
	function processDispPriceResult(req){
		var responseXML = Spry.XML.documentToObject(req.xhRequest.responseXML);
		
		var priceText = responseXML.product['price']._value();
		var imageText = responseXML.product['image']._value();
		//alert(responseXML);
		Spry.Utils.setInnerHTML('productPrice', priceText);
		Spry.Utils.setInnerHTML('imageText', imageText);
	}

	
	function fadeIt(ele,url){
		Spry.Utils.setInnerHTML(ele, 'Loading...');
		Spry.Utils.setInnerHTML('productPrice', '');
		Spry.Utils.setInnerHTML('updateResponseDiv', '');
		//FilterData();
		Spry.Utils.updateContent(ele,url);
	}
	
	var keyArray = new Array();
	
	
	//var fld1 = document.getElementById('attributeID_1');
	var attrFld1 = eval(document.forms['frmProductDetail'].attributeID_1);
	if (attrFld1.options.length == 2){
		attrFld1.options[0]= null;
		attrFld1.options[0].selected = true;
		
		keyArray[0] = attrFld1.options[attrFld1.selectedIndex].value;
	}
	
	else
		attrFld1.options[0].selected = true;
	
	//var fld2 = document.getElementById('attributeID_2');
	var attrFld2 = eval(document.forms['frmProductDetail'].attributeID_2);
	if (attrFld2.options.length == 2){
		attrFld2.options[0]= null;
		attrFld2.options[0].selected = true;
		
		keyArray[1] = attrFld2.options[attrFld2.selectedIndex].value;
	}
	
	else
		attrFld2.options[0].selected = true;
	
	
	//alert(keyArray.length);
	var key = '';
	for(var i=0; i < keyArray.length;i++){
		if (keyArray[i] != undefined){
			if (key.length ==0)
				key = keyArray[i];
			else
				key = key + '_' + keyArray[i];
		}
	}
	if (keyArray.length > 0 && key.indexOf('_') >0){
		getProductPrice('/index.cfm?event=shop.dspProductPrice&prod_id='+AvailableProducts[key]);
	}
	else {
		
	}
	

