

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=ABPSMTECOTEAL.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_ABPSMTECOTEAL.jpg\" class=\"imgBorder\" alt=\"Matte Colors on Kraft\" />\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"] = 898;
fldValueStruct["fld1array"][0]["text"] = "10.00 X 7.00 X 1.25";
fldValueStruct["fld1array"][1] = new Object();
fldValueStruct["fld1array"][1]["value"] = 865;
fldValueStruct["fld1array"][1]["text"] = "11.50 X 8.50 X 1.63";
fldValueStruct["fld1array"][2] = new Object();
fldValueStruct["fld1array"][2]["value"] = 872;
fldValueStruct["fld1array"][2]["text"] = "14.00 X 4.50 X 1.25";
fldValueStruct["fld1array"][3] = new Object();
fldValueStruct["fld1array"][3]["value"] = 910;
fldValueStruct["fld1array"][3]["text"] = "15.00 X 9.50 X 2.00";
fldValueStruct["fld1array"][4] = new Object();
fldValueStruct["fld1array"][4]["value"] = 895;
fldValueStruct["fld1array"][4]["text"] = "17.00 X 11.00 X 2.50";
fldValueStruct["fld1array"][5] = new Object();
fldValueStruct["fld1array"][5]["value"] = 896;
fldValueStruct["fld1array"][5]["text"] = "19.00 X 12.00 X 3.00";
fldValueStruct["fld1array"][6] = new Object();
fldValueStruct["fld1array"][6]["value"] = 883;
fldValueStruct["fld1array"][6]["text"] = "24.00 X 14.00 X 4.00";
fldValueStruct["fld2array"] =  new Array();
fldValueStruct["fld2array"][0] = new Object();
fldValueStruct["fld2array"][0]["value"] = 1351;
fldValueStruct["fld2array"][0]["text"] = "MATTE BLACK";
fldValueStruct["fld2array"][1] = new Object();
fldValueStruct["fld2array"][1]["value"] = 1352;
fldValueStruct["fld2array"][1]["text"] = "MATTE BURGUNDY";
fldValueStruct["fld2array"][2] = new Object();
fldValueStruct["fld2array"][2]["value"] = 486;
fldValueStruct["fld2array"][2]["text"] = "MATTE CHOCOLATE";
fldValueStruct["fld2array"][3] = new Object();
fldValueStruct["fld2array"][3]["value"] = 501;
fldValueStruct["fld2array"][3]["text"] = "MATTE GREEN";
fldValueStruct["fld2array"][4] = new Object();
fldValueStruct["fld2array"][4]["value"] = 1582;
fldValueStruct["fld2array"][4]["text"] = "MATTE GREEN";
fldValueStruct["fld2array"][5] = new Object();
fldValueStruct["fld2array"][5]["value"] = 157;
fldValueStruct["fld2array"][5]["text"] = "MATTE NAVY";
fldValueStruct["fld2array"][6] = new Object();
fldValueStruct["fld2array"][6]["value"] = 1451;
fldValueStruct["fld2array"][6]["text"] = "MATTE PURPLE";
fldValueStruct["fld2array"][7] = new Object();
fldValueStruct["fld2array"][7]["value"] = 183;
fldValueStruct["fld2array"][7]["text"] = "MATTE SAND";
fldValueStruct["fld2array"][8] = new Object();
fldValueStruct["fld2array"][8]["value"] = 316;
fldValueStruct["fld2array"][8]["text"] = "MATTE TEAL";


AvailableProducts = new Object();
AvailableProducts["501_898"] = 461;
AvailableProducts["486_910"] = 607;
AvailableProducts["895_1451"] = 663;
AvailableProducts["898_1352"] = 459;
AvailableProducts["883_183"] = 760;
AvailableProducts["157_910"] = 609;
AvailableProducts["316_865"] = 527;
AvailableProducts["872_316"] = 570;
AvailableProducts["316_896"] = 717;
AvailableProducts["1352_872"] = 564;
AvailableProducts["1351_865"] = 519;
AvailableProducts["898_183"] = 464;
AvailableProducts["501_910"] = 608;
AvailableProducts["872_486"] = 565;
AvailableProducts["486_883"] = 755;
AvailableProducts["898_1451"] = 463;
AvailableProducts["865_1451"] = 524;
AvailableProducts["872_1451"] = 568;
AvailableProducts["501_865"] = 522;
AvailableProducts["1451_895"] = 663;
AvailableProducts["895_486"] = 660;
AvailableProducts["872_157"] = 567;
AvailableProducts["183_895"] = 665;
AvailableProducts["157_883"] = 757;
AvailableProducts["895_1352"] = 659;
AvailableProducts["316_910"] = 613;
AvailableProducts["896_316"] = 717;
AvailableProducts["896_157"] = 713;
AvailableProducts["883_316"] = 761;
AvailableProducts["486_895"] = 660;
AvailableProducts["1451_896"] = 714;
AvailableProducts["883_157"] = 757;
AvailableProducts["157_896"] = 713;
AvailableProducts["910_486"] = 607;
AvailableProducts["316_895"] = 666;
AvailableProducts["501_896"] = 712;
AvailableProducts["895_183"] = 665;
AvailableProducts["1351_872"] = 563;
AvailableProducts["898_486"] = 460;
AvailableProducts["1451_898"] = 463;
AvailableProducts["1351_896"] = 709;
AvailableProducts["865_157"] = 523;
AvailableProducts["910_1451"] = 610;
AvailableProducts["910_501"] = 608;
AvailableProducts["872_501"] = 566;
AvailableProducts["865_316"] = 527;
AvailableProducts["1351_898"] = 458;
AvailableProducts["865_1352"] = 520;
AvailableProducts["898_157"] = 462;
AvailableProducts["910_316"] = 613;
AvailableProducts["1352_896"] = 710;
AvailableProducts["910_1352"] = 605;
AvailableProducts["316_872"] = 570;
AvailableProducts["895_501"] = 661;
AvailableProducts["896_501"] = 712;
AvailableProducts["183_910"] = 612;
AvailableProducts["896_1352"] = 710;
AvailableProducts["1451_865"] = 524;
AvailableProducts["865_486"] = 521;
AvailableProducts["896_486"] = 711;
AvailableProducts["883_501"] = 756;
AvailableProducts["1451_883"] = 758;
AvailableProducts["1351_895"] = 658;
AvailableProducts["910_183"] = 612;
AvailableProducts["1451_910"] = 610;
AvailableProducts["883_1451"] = 758;
AvailableProducts["872_1351"] = 563;
AvailableProducts["157_898"] = 462;
AvailableProducts["183_896"] = 716;
AvailableProducts["895_316"] = 666;
AvailableProducts["486_872"] = 565;
AvailableProducts["872_183"] = 569;
AvailableProducts["183_898"] = 464;
AvailableProducts["865_183"] = 526;
AvailableProducts["883_1351"] = 753;
AvailableProducts["865_501"] = 522;
AvailableProducts["183_883"] = 760;
AvailableProducts["896_183"] = 716;
AvailableProducts["486_896"] = 711;
AvailableProducts["501_883"] = 756;
AvailableProducts["883_486"] = 755;
AvailableProducts["1352_910"] = 605;
AvailableProducts["895_1351"] = 658;
AvailableProducts["1352_898"] = 459;
AvailableProducts["501_895"] = 661;
AvailableProducts["1351_883"] = 753;
AvailableProducts["896_1351"] = 709;
AvailableProducts["183_872"] = 569;
AvailableProducts["501_872"] = 566;
AvailableProducts["883_1352"] = 754;
AvailableProducts["157_865"] = 523;
AvailableProducts["183_865"] = 526;
AvailableProducts["910_1351"] = 604;
AvailableProducts["872_1352"] = 564;
AvailableProducts["1352_895"] = 659;
AvailableProducts["895_157"] = 662;
AvailableProducts["1352_883"] = 754;
AvailableProducts["157_872"] = 567;
AvailableProducts["898_501"] = 461;
AvailableProducts["910_157"] = 609;
AvailableProducts["865_1351"] = 519;
AvailableProducts["157_895"] = 662;
AvailableProducts["316_883"] = 761;
AvailableProducts["486_865"] = 521;
AvailableProducts["486_898"] = 460;
AvailableProducts["898_1351"] = 458;
AvailableProducts["1351_910"] = 604;
AvailableProducts["1352_865"] = 520;
AvailableProducts["1451_872"] = 568;
AvailableProducts["896_1451"] = 714;


AttributeArray = new Object();
AttributeArray["486"] = new Object();
AttributeArray["486"]["value"] = 486;
AttributeArray["486"]["text"] = "MATTE CHOCOLATE";
AttributeArray["486"]["prod_id"] = "521,565,755,660,711,460,607";
AttributeArray["486"]["allowed"] = "865,872,883,895,896,898,910";
AttributeArray["898"] = new Object();
AttributeArray["898"]["value"] = 898;
AttributeArray["898"]["text"] = "10.00 X 7.00 X 1.25";
AttributeArray["898"]["prod_id"] = "462,464,460,461,458,459,463";
AttributeArray["898"]["allowed"] = "157,183,486,501,1351,1352,1451";
AttributeArray["872"] = new Object();
AttributeArray["872"]["value"] = 872;
AttributeArray["872"]["text"] = "14.00 X 4.50 X 1.25";
AttributeArray["872"]["prod_id"] = "567,569,570,565,566,563,564,568";
AttributeArray["872"]["allowed"] = "157,183,316,486,501,1351,1352,1451";
AttributeArray["183"] = new Object();
AttributeArray["183"]["value"] = 183;
AttributeArray["183"]["text"] = "MATTE SAND";
AttributeArray["183"]["prod_id"] = "526,569,760,665,716,464,612";
AttributeArray["183"]["allowed"] = "865,872,883,895,896,898,910";
AttributeArray["1451"] = new Object();
AttributeArray["1451"]["value"] = 1451;
AttributeArray["1451"]["text"] = "MATTE PURPLE";
AttributeArray["1451"]["prod_id"] = "524,568,758,663,714,463,610";
AttributeArray["1451"]["allowed"] = "865,872,883,895,896,898,910";
AttributeArray["883"] = new Object();
AttributeArray["883"]["value"] = 883;
AttributeArray["883"]["text"] = "24.00 X 14.00 X 4.00";
AttributeArray["883"]["prod_id"] = "757,760,761,755,756,753,754,758";
AttributeArray["883"]["allowed"] = "157,183,316,486,501,1351,1352,1451";
AttributeArray["1352"] = new Object();
AttributeArray["1352"]["value"] = 1352;
AttributeArray["1352"]["text"] = "MATTE BURGUNDY";
AttributeArray["1352"]["prod_id"] = "520,564,754,659,710,459,605";
AttributeArray["1352"]["allowed"] = "865,872,883,895,896,898,910";
AttributeArray["1582"] = new Object();
AttributeArray["1582"]["value"] = 1582;
AttributeArray["1582"]["text"] = "MATTE GREEN";
AttributeArray["1351"] = new Object();
AttributeArray["1351"]["value"] = 1351;
AttributeArray["1351"]["text"] = "MATTE BLACK";
AttributeArray["1351"]["prod_id"] = "519,563,753,658,709,458,604";
AttributeArray["1351"]["allowed"] = "865,872,883,895,896,898,910";
AttributeArray["316"] = new Object();
AttributeArray["316"]["value"] = 316;
AttributeArray["316"]["text"] = "MATTE TEAL";
AttributeArray["316"]["prod_id"] = "527,570,761,666,717,613";
AttributeArray["316"]["allowed"] = "865,872,883,895,896,910";
AttributeArray["910"] = new Object();
AttributeArray["910"]["value"] = 910;
AttributeArray["910"]["text"] = "15.00 X 9.50 X 2.00";
AttributeArray["910"]["prod_id"] = "609,612,613,607,608,604,605,610";
AttributeArray["910"]["allowed"] = "157,183,316,486,501,1351,1352,1451";
AttributeArray["896"] = new Object();
AttributeArray["896"]["value"] = 896;
AttributeArray["896"]["text"] = "19.00 X 12.00 X 3.00";
AttributeArray["896"]["prod_id"] = "713,716,717,711,712,709,710,714";
AttributeArray["896"]["allowed"] = "157,183,316,486,501,1351,1352,1451";
AttributeArray["501"] = new Object();
AttributeArray["501"]["value"] = 501;
AttributeArray["501"]["text"] = "MATTE GREEN";
AttributeArray["501"]["prod_id"] = "522,566,756,661,712,461,608";
AttributeArray["501"]["allowed"] = "865,872,883,895,896,898,910";
AttributeArray["157"] = new Object();
AttributeArray["157"]["value"] = 157;
AttributeArray["157"]["text"] = "MATTE NAVY";
AttributeArray["157"]["prod_id"] = "523,567,757,662,713,462,609";
AttributeArray["157"]["allowed"] = "865,872,883,895,896,898,910";
AttributeArray["865"] = new Object();
AttributeArray["865"]["value"] = 865;
AttributeArray["865"]["text"] = "11.50 X 8.50 X 1.63";
AttributeArray["865"]["prod_id"] = "523,526,527,521,522,519,520,524";
AttributeArray["865"]["allowed"] = "157,183,316,486,501,1351,1352,1451";
AttributeArray["895"] = new Object();
AttributeArray["895"]["value"] = 895;
AttributeArray["895"]["text"] = "17.00 X 11.00 X 2.50";
AttributeArray["895"]["prod_id"] = "662,665,666,660,661,658,659,663";
AttributeArray["895"]["allowed"] = "157,183,316,486,501,1351,1352,1451";


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 {
		
	}
	

