

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=ABPSRED.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_ABPSRED.jpg\" class=\"imgBorder\" alt=\"Gloss Colors\" />\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"] = 905;
fldValueStruct["fld1array"][2]["text"] = "11.50 X 8.50 X 1.00";
fldValueStruct["fld1array"][3] = new Object();
fldValueStruct["fld1array"][3]["value"] = 872;
fldValueStruct["fld1array"][3]["text"] = "14.00 X 4.50 X 1.25";
fldValueStruct["fld1array"][4] = new Object();
fldValueStruct["fld1array"][4]["value"] = 911;
fldValueStruct["fld1array"][4]["text"] = "14.00 X 9.50 X 2.00";
fldValueStruct["fld1array"][5] = new Object();
fldValueStruct["fld1array"][5]["value"] = 910;
fldValueStruct["fld1array"][5]["text"] = "15.00 X 9.50 X 2.00";
fldValueStruct["fld1array"][6] = new Object();
fldValueStruct["fld1array"][6]["value"] = 895;
fldValueStruct["fld1array"][6]["text"] = "17.00 X 11.00 X 2.50";
fldValueStruct["fld1array"][7] = new Object();
fldValueStruct["fld1array"][7]["value"] = 896;
fldValueStruct["fld1array"][7]["text"] = "19.00 X 12.00 X 3.00";
fldValueStruct["fld1array"][8] = new Object();
fldValueStruct["fld1array"][8]["value"] = 883;
fldValueStruct["fld1array"][8]["text"] = "24.00 X 14.00 X 4.00";
fldValueStruct["fld2array"] =  new Array();
fldValueStruct["fld2array"][0] = new Object();
fldValueStruct["fld2array"][0]["value"] = 1349;
fldValueStruct["fld2array"][0]["text"] = "BLACK GLOSS";
fldValueStruct["fld2array"][1] = new Object();
fldValueStruct["fld2array"][1]["value"] = 1350;
fldValueStruct["fld2array"][1]["text"] = "BRONZE PLATINUM";
fldValueStruct["fld2array"][2] = new Object();
fldValueStruct["fld2array"][2]["value"] = 1355;
fldValueStruct["fld2array"][2]["text"] = "BURGUNDY GLOSS";
fldValueStruct["fld2array"][3] = new Object();
fldValueStruct["fld2array"][3]["value"] = 1356;
fldValueStruct["fld2array"][3]["text"] = "DARTMOUTH GREEN";
fldValueStruct["fld2array"][4] = new Object();
fldValueStruct["fld2array"][4]["value"] = 1442;
fldValueStruct["fld2array"][4]["text"] = "IVORY";
fldValueStruct["fld2array"][5] = new Object();
fldValueStruct["fld2array"][5]["value"] = 1373;
fldValueStruct["fld2array"][5]["text"] = "RED GLOSS";
fldValueStruct["fld2array"][6] = new Object();
fldValueStruct["fld2array"][6]["value"] = 318;
fldValueStruct["fld2array"][6]["text"] = "SAGE GLOSS";
fldValueStruct["fld2array"][7] = new Object();
fldValueStruct["fld2array"][7]["value"] = 1417;
fldValueStruct["fld2array"][7]["text"] = "SILVER GLOSS";
fldValueStruct["fld2array"][8] = new Object();
fldValueStruct["fld2array"][8]["value"] = 141;
fldValueStruct["fld2array"][8]["text"] = "WHITE";


AvailableProducts = new Object();
AvailableProducts["1373_898"] = 467;
AvailableProducts["1356_910"] = 587;
AvailableProducts["895_1349"] = 637;
AvailableProducts["1356_872"] = 558;
AvailableProducts["1350_895"] = 638;
AvailableProducts["898_1442"] = 27931;
AvailableProducts["898_318"] = 468;
AvailableProducts["898_1373"] = 467;
AvailableProducts["898_1349"] = 27903;
AvailableProducts["318_896"] = 724;
AvailableProducts["1350_910"] = 582;
AvailableProducts["895_1350"] = 638;
AvailableProducts["872_1356"] = 558;
AvailableProducts["1355_895"] = 639;
AvailableProducts["910_318"] = 620;
AvailableProducts["318_898"] = 468;
AvailableProducts["1442_896"] = 703;
AvailableProducts["896_318"] = 724;
AvailableProducts["1355_883"] = 741;
AvailableProducts["883_1356"] = 744;
AvailableProducts["910_1350"] = 582;
AvailableProducts["1349_898"] = 27903;
AvailableProducts["910_1417"] = 622;
AvailableProducts["905_1355"] = 503;
AvailableProducts["1373_910"] = 619;
AvailableProducts["872_1355"] = 556;
AvailableProducts["865_1373"] = 533;
AvailableProducts["865_1349"] = 501;
AvailableProducts["1417_865"] = 536;
AvailableProducts["1417_872"] = 573;
AvailableProducts["910_1355"] = 583;
AvailableProducts["865_1356"] = 507;
AvailableProducts["1417_883"] = 768;
AvailableProducts["1417_896"] = 726;
AvailableProducts["1356_898"] = 27920;
AvailableProducts["896_1442"] = 703;
AvailableProducts["895_318"] = 673;
AvailableProducts["1349_872"] = 554;
AvailableProducts["1373_883"] = 765;
AvailableProducts["1373_896"] = 723;
AvailableProducts["1350_865"] = 502;
AvailableProducts["1350_872"] = 555;
AvailableProducts["896_141"] = 730;
AvailableProducts["1349_910"] = 581;
AvailableProducts["883_318"] = 766;
AvailableProducts["1356_883"] = 744;
AvailableProducts["1356_895"] = 643;
AvailableProducts["1373_865"] = 533;
AvailableProducts["1373_872"] = 572;
AvailableProducts["1349_883"] = 739;
AvailableProducts["1349_896"] = 692;
AvailableProducts["883_1350"] = 740;
AvailableProducts["1356_896"] = 698;
AvailableProducts["1442_911"] = 594;
AvailableProducts["872_1350"] = 555;
AvailableProducts["872_1349"] = 554;
AvailableProducts["883_1349"] = 739;
AvailableProducts["865_318"] = 534;
AvailableProducts["1442_883"] = 749;
AvailableProducts["872_1417"] = 573;
AvailableProducts["865_1350"] = 502;
AvailableProducts["1442_895"] = 649;
AvailableProducts["318_883"] = 766;
AvailableProducts["898_1417"] = 470;
AvailableProducts["1442_898"] = 27931;
AvailableProducts["1355_910"] = 583;
AvailableProducts["895_1373"] = 672;
AvailableProducts["895_1442"] = 649;
AvailableProducts["895_1356"] = 643;
AvailableProducts["910_1356"] = 587;
AvailableProducts["865_1417"] = 536;
AvailableProducts["1417_910"] = 622;
AvailableProducts["905_1442"] = 512;
AvailableProducts["896_1417"] = 726;
AvailableProducts["896_1373"] = 723;
AvailableProducts["896_1349"] = 692;
AvailableProducts["896_1356"] = 698;
AvailableProducts["1417_898"] = 470;
AvailableProducts["883_1373"] = 765;
AvailableProducts["883_1442"] = 749;
AvailableProducts["883_1355"] = 741;
AvailableProducts["318_865"] = 534;
AvailableProducts["872_1373"] = 572;
AvailableProducts["872_1442"] = 561;
AvailableProducts["883_1417"] = 768;
AvailableProducts["1350_896"] = 693;
AvailableProducts["910_1373"] = 619;
AvailableProducts["1350_883"] = 740;
AvailableProducts["318_910"] = 620;
AvailableProducts["141_896"] = 730;
AvailableProducts["1349_895"] = 637;
AvailableProducts["1442_905"] = 512;
AvailableProducts["910_1349"] = 581;
AvailableProducts["895_1355"] = 639;
AvailableProducts["896_1350"] = 693;
AvailableProducts["318_895"] = 673;
AvailableProducts["911_1442"] = 594;
AvailableProducts["1349_865"] = 501;
AvailableProducts["1442_872"] = 561;
AvailableProducts["898_1356"] = 27920;
AvailableProducts["1373_895"] = 672;
AvailableProducts["1356_865"] = 507;
AvailableProducts["1355_872"] = 556;
AvailableProducts["1355_905"] = 503;


AttributeArray = new Object();
AttributeArray["865"] = new Object();
AttributeArray["865"]["value"] = 865;
AttributeArray["865"]["text"] = "11.50 X 8.50 X 1.63";
AttributeArray["865"]["prod_id"] = "534,501,502,507,533,536";
AttributeArray["865"]["allowed"] = "318,1349,1350,1356,1373,1417";
AttributeArray["1355"] = new Object();
AttributeArray["1355"]["value"] = 1355;
AttributeArray["1355"]["text"] = "BURGUNDY GLOSS";
AttributeArray["1355"]["prod_id"] = "556,741,639,503,583";
AttributeArray["1355"]["allowed"] = "872,883,895,905,910";
AttributeArray["905"] = new Object();
AttributeArray["905"]["value"] = 905;
AttributeArray["905"]["text"] = "11.50 X 8.50 X 1.00";
AttributeArray["905"]["prod_id"] = "503,512";
AttributeArray["905"]["allowed"] = "1355,1442";
AttributeArray["895"] = new Object();
AttributeArray["895"]["value"] = 895;
AttributeArray["895"]["text"] = "17.00 X 11.00 X 2.50";
AttributeArray["895"]["prod_id"] = "673,637,638,639,643,672,649";
AttributeArray["895"]["allowed"] = "318,1349,1350,1355,1356,1373,1442";
AttributeArray["1350"] = new Object();
AttributeArray["1350"]["value"] = 1350;
AttributeArray["1350"]["text"] = "BRONZE PLATINUM";
AttributeArray["1350"]["prod_id"] = "502,555,740,638,693,582";
AttributeArray["1350"]["allowed"] = "865,872,883,895,896,910";
AttributeArray["141"] = new Object();
AttributeArray["141"]["value"] = 141;
AttributeArray["141"]["text"] = "WHITE";
AttributeArray["141"]["prod_id"] = "730";
AttributeArray["141"]["allowed"] = "896";
AttributeArray["872"] = new Object();
AttributeArray["872"]["value"] = 872;
AttributeArray["872"]["text"] = "14.00 X 4.50 X 1.25";
AttributeArray["872"]["prod_id"] = "554,555,556,558,572,573,561";
AttributeArray["872"]["allowed"] = "1349,1350,1355,1356,1373,1417,1442";
AttributeArray["896"] = new Object();
AttributeArray["896"]["value"] = 896;
AttributeArray["896"]["text"] = "19.00 X 12.00 X 3.00";
AttributeArray["896"]["prod_id"] = "730,724,692,693,698,723,726,703";
AttributeArray["896"]["allowed"] = "141,318,1349,1350,1356,1373,1417,1442";
AttributeArray["911"] = new Object();
AttributeArray["911"]["value"] = 911;
AttributeArray["911"]["text"] = "14.00 X 9.50 X 2.00";
AttributeArray["911"]["prod_id"] = "594";
AttributeArray["911"]["allowed"] = "1442";
AttributeArray["318"] = new Object();
AttributeArray["318"]["value"] = 318;
AttributeArray["318"]["text"] = "SAGE GLOSS";
AttributeArray["318"]["prod_id"] = "534,766,673,724,468,620";
AttributeArray["318"]["allowed"] = "865,883,895,896,898,910";
AttributeArray["1442"] = new Object();
AttributeArray["1442"]["value"] = 1442;
AttributeArray["1442"]["text"] = "IVORY";
AttributeArray["1442"]["prod_id"] = "561,749,649,703,27931,512,594";
AttributeArray["1442"]["allowed"] = "872,883,895,896,898,905,911";
AttributeArray["910"] = new Object();
AttributeArray["910"]["value"] = 910;
AttributeArray["910"]["text"] = "15.00 X 9.50 X 2.00";
AttributeArray["910"]["prod_id"] = "620,581,582,583,587,619,622";
AttributeArray["910"]["allowed"] = "318,1349,1350,1355,1356,1373,1417";
AttributeArray["883"] = new Object();
AttributeArray["883"]["value"] = 883;
AttributeArray["883"]["text"] = "24.00 X 14.00 X 4.00";
AttributeArray["883"]["prod_id"] = "766,739,740,741,744,765,768,749";
AttributeArray["883"]["allowed"] = "318,1349,1350,1355,1356,1373,1417,1442";
AttributeArray["1417"] = new Object();
AttributeArray["1417"]["value"] = 1417;
AttributeArray["1417"]["text"] = "SILVER GLOSS";
AttributeArray["1417"]["prod_id"] = "536,573,768,726,470,622";
AttributeArray["1417"]["allowed"] = "865,872,883,896,898,910";
AttributeArray["1349"] = new Object();
AttributeArray["1349"]["value"] = 1349;
AttributeArray["1349"]["text"] = "BLACK GLOSS";
AttributeArray["1349"]["prod_id"] = "501,554,739,637,692,27903,581";
AttributeArray["1349"]["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"] = "468,27903,27920,467,470,27931";
AttributeArray["898"]["allowed"] = "318,1349,1356,1373,1417,1442";
AttributeArray["1356"] = new Object();
AttributeArray["1356"]["value"] = 1356;
AttributeArray["1356"]["text"] = "DARTMOUTH GREEN";
AttributeArray["1356"]["prod_id"] = "507,558,744,643,698,27920,587";
AttributeArray["1356"]["allowed"] = "865,872,883,895,896,898,910";
AttributeArray["1373"] = new Object();
AttributeArray["1373"]["value"] = 1373;
AttributeArray["1373"]["text"] = "RED GLOSS";
AttributeArray["1373"]["prod_id"] = "533,572,765,672,723,467,619";
AttributeArray["1373"]["allowed"] = "865,872,883,895,896,898,910";


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 {
		
	}
	

