

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=PSROSE COPNAT.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_PSROSE COPNAT.jpg\" class=\"imgBorder\" alt=\"Metallic Tints 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"] = 1051;
fldValueStruct["fld1array"][0]["text"] = "5.25 X 3.50 X 13.00";
fldValueStruct["fld1array"][1] = new Object();
fldValueStruct["fld1array"][1]["value"] = 1262;
fldValueStruct["fld1array"][1]["text"] = "5.25 X 3.50 X 8.25";
fldValueStruct["fld1array"][2] = new Object();
fldValueStruct["fld1array"][2]["value"] = 1239;
fldValueStruct["fld1array"][2]["text"] = "6.50 X 3.50 X 14.00";
fldValueStruct["fld1array"][3] = new Object();
fldValueStruct["fld1array"][3]["value"] = 1259;
fldValueStruct["fld1array"][3]["text"] = "8.00 X 4.75 X 10.38";
fldValueStruct["fld1array"][4] = new Object();
fldValueStruct["fld1array"][4]["value"] = 1048;
fldValueStruct["fld1array"][4]["text"] = "10.00 X 5.00 X 13.00";
fldValueStruct["fld1array"][5] = new Object();
fldValueStruct["fld1array"][5]["value"] = 1235;
fldValueStruct["fld1array"][5]["text"] = "13.00 X 6.00 X 15.50";
fldValueStruct["fld1array"][6] = new Object();
fldValueStruct["fld1array"][6]["value"] = 1243;
fldValueStruct["fld1array"][6]["text"] = "16.00 X 6.00 X 19.00";
fldValueStruct["fld1array"][7] = new Object();
fldValueStruct["fld1array"][7]["value"] = 1252;
fldValueStruct["fld1array"][7]["text"] = "16.00 X 6.00 X 12.38";
fldValueStruct["fld1array"][8] = new Object();
fldValueStruct["fld1array"][8]["value"] = 1247;
fldValueStruct["fld1array"][8]["text"] = "18.00 X 7.00 X 18.75";
fldValueStruct["fld2array"] =  new Array();
fldValueStruct["fld2array"][0] = new Object();
fldValueStruct["fld2array"][0]["value"] = 1370;
fldValueStruct["fld2array"][0]["text"] = "METALLIC BLUE";
fldValueStruct["fld2array"][1] = new Object();
fldValueStruct["fld2array"][1]["value"] = 1362;
fldValueStruct["fld2array"][1]["text"] = "METALLIC COPPER";
fldValueStruct["fld2array"][2] = new Object();
fldValueStruct["fld2array"][2]["value"] = 268;
fldValueStruct["fld2array"][2]["text"] = "METALLIC GOLD";
fldValueStruct["fld2array"][3] = new Object();
fldValueStruct["fld2array"][3]["value"] = 1364;
fldValueStruct["fld2array"][3]["text"] = "METALLIC SAGE";
fldValueStruct["fld2array"][4] = new Object();
fldValueStruct["fld2array"][4]["value"] = 270;
fldValueStruct["fld2array"][4]["text"] = "METALLIC SILVER";


AvailableProducts = new Object();
AvailableProducts["1262_1364"] = 34856;
AvailableProducts["270_1239"] = 34512;
AvailableProducts["270_1243"] = 34545;
AvailableProducts["1243_1370"] = 34546;
AvailableProducts["1259_268"] = 34782;
AvailableProducts["1247_1362"] = 34613;
AvailableProducts["1051_268"] = 34917;
AvailableProducts["270_1252"] = 34696;
AvailableProducts["1252_1364"] = 34695;
AvailableProducts["1243_268"] = 34536;
AvailableProducts["270_1247"] = 34615;
AvailableProducts["1247_1370"] = 34616;
AvailableProducts["270_1051"] = 34919;
AvailableProducts["1362_1252"] = 34694;
AvailableProducts["1362_1247"] = 34613;
AvailableProducts["1252_1370"] = 34697;
AvailableProducts["270_1262"] = 34880;
AvailableProducts["1370_1252"] = 34697;
AvailableProducts["1362_1262"] = 34846;
AvailableProducts["1048_1370"] = 34654;
AvailableProducts["1259_1364"] = 34790;
AvailableProducts["1370_1243"] = 34546;
AvailableProducts["270_1235"] = 34480;
AvailableProducts["1048_270"] = 34653;
AvailableProducts["268_1259"] = 34782;
AvailableProducts["270_1048"] = 34653;
AvailableProducts["270_1259"] = 34791;
AvailableProducts["1262_1370"] = 34857;
AvailableProducts["1235_1364"] = 34479;
AvailableProducts["1364_1252"] = 34695;
AvailableProducts["1239_268"] = 34510;
AvailableProducts["1239_270"] = 34512;
AvailableProducts["1247_268"] = 34609;
AvailableProducts["1252_1362"] = 34694;
AvailableProducts["1252_268"] = 34687;
AvailableProducts["1259_270"] = 34791;
AvailableProducts["1370_1247"] = 34616;
AvailableProducts["1262_270"] = 34880;
AvailableProducts["1247_1364"] = 34614;
AvailableProducts["1362_1243"] = 34543;
AvailableProducts["1364_1048"] = 34652;
AvailableProducts["1362_1048"] = 34651;
AvailableProducts["268_1235"] = 34474;
AvailableProducts["1370_1235"] = 34481;
AvailableProducts["268_1262"] = 34849;
AvailableProducts["268_1239"] = 34510;
AvailableProducts["268_1048"] = 34647;
AvailableProducts["268_1051"] = 34917;
AvailableProducts["1262_1362"] = 34846;
AvailableProducts["1364_1247"] = 34614;
AvailableProducts["268_1243"] = 34536;
AvailableProducts["1048_1364"] = 34652;
AvailableProducts["1370_1262"] = 34857;
AvailableProducts["1243_1362"] = 34543;
AvailableProducts["1247_270"] = 34615;
AvailableProducts["268_1252"] = 34687;
AvailableProducts["1243_1364"] = 34544;
AvailableProducts["268_1247"] = 34609;
AvailableProducts["1364_1235"] = 34479;
AvailableProducts["1262_268"] = 34849;
AvailableProducts["1259_1370"] = 34792;
AvailableProducts["1235_268"] = 34474;
AvailableProducts["1235_270"] = 34480;
AvailableProducts["1364_1262"] = 34856;
AvailableProducts["1364_1259"] = 34790;
AvailableProducts["1252_270"] = 34696;
AvailableProducts["1235_1362"] = 34478;
AvailableProducts["1243_270"] = 34545;
AvailableProducts["1362_1235"] = 34478;
AvailableProducts["1048_1362"] = 34651;
AvailableProducts["1370_1048"] = 34654;
AvailableProducts["1235_1370"] = 34481;
AvailableProducts["1362_1259"] = 34789;
AvailableProducts["1370_1259"] = 34792;
AvailableProducts["1048_268"] = 34647;
AvailableProducts["1259_1362"] = 34789;
AvailableProducts["1364_1243"] = 34544;
AvailableProducts["1051_270"] = 34919;


AttributeArray = new Object();
AttributeArray["270"] = new Object();
AttributeArray["270"]["value"] = 270;
AttributeArray["270"]["text"] = "METALLIC SILVER";
AttributeArray["270"]["prod_id"] = "34653,34919,34480,34512,34545,34615,34696,34791,34880";
AttributeArray["270"]["allowed"] = "1048,1051,1235,1239,1243,1247,1252,1259,1262";
AttributeArray["268"] = new Object();
AttributeArray["268"]["value"] = 268;
AttributeArray["268"]["text"] = "METALLIC GOLD";
AttributeArray["268"]["prod_id"] = "34647,34917,34474,34510,34536,34609,34687,34782,34849";
AttributeArray["268"]["allowed"] = "1048,1051,1235,1239,1243,1247,1252,1259,1262";
AttributeArray["1370"] = new Object();
AttributeArray["1370"]["value"] = 1370;
AttributeArray["1370"]["text"] = "METALLIC BLUE";
AttributeArray["1370"]["prod_id"] = "34654,34481,34546,34616,34697,34792,34857";
AttributeArray["1370"]["allowed"] = "1048,1235,1243,1247,1252,1259,1262";
AttributeArray["1252"] = new Object();
AttributeArray["1252"]["value"] = 1252;
AttributeArray["1252"]["text"] = "16.00 X 6.00 X 12.38";
AttributeArray["1252"]["prod_id"] = "34687,34696,34694,34695,34697";
AttributeArray["1252"]["allowed"] = "268,270,1362,1364,1370";
AttributeArray["1259"] = new Object();
AttributeArray["1259"]["value"] = 1259;
AttributeArray["1259"]["text"] = "8.00 X 4.75 X 10.38";
AttributeArray["1259"]["prod_id"] = "34782,34791,34789,34790,34792";
AttributeArray["1259"]["allowed"] = "268,270,1362,1364,1370";
AttributeArray["1243"] = new Object();
AttributeArray["1243"]["value"] = 1243;
AttributeArray["1243"]["text"] = "16.00 X 6.00 X 19.00";
AttributeArray["1243"]["prod_id"] = "34536,34545,34543,34544,34546";
AttributeArray["1243"]["allowed"] = "268,270,1362,1364,1370";
AttributeArray["1239"] = new Object();
AttributeArray["1239"]["value"] = 1239;
AttributeArray["1239"]["text"] = "6.50 X 3.50 X 14.00";
AttributeArray["1239"]["prod_id"] = "34510,34512";
AttributeArray["1239"]["allowed"] = "268,270";
AttributeArray["1262"] = new Object();
AttributeArray["1262"]["value"] = 1262;
AttributeArray["1262"]["text"] = "5.25 X 3.50 X 8.25";
AttributeArray["1262"]["prod_id"] = "34849,34880,34846,34856,34857";
AttributeArray["1262"]["allowed"] = "268,270,1362,1364,1370";
AttributeArray["1247"] = new Object();
AttributeArray["1247"]["value"] = 1247;
AttributeArray["1247"]["text"] = "18.00 X 7.00 X 18.75";
AttributeArray["1247"]["prod_id"] = "34609,34615,34613,34614,34616";
AttributeArray["1247"]["allowed"] = "268,270,1362,1364,1370";
AttributeArray["1364"] = new Object();
AttributeArray["1364"]["value"] = 1364;
AttributeArray["1364"]["text"] = "METALLIC SAGE";
AttributeArray["1364"]["prod_id"] = "34652,34479,34544,34614,34695,34790,34856";
AttributeArray["1364"]["allowed"] = "1048,1235,1243,1247,1252,1259,1262";
AttributeArray["1362"] = new Object();
AttributeArray["1362"]["value"] = 1362;
AttributeArray["1362"]["text"] = "METALLIC COPPER";
AttributeArray["1362"]["prod_id"] = "34651,34478,34543,34613,34694,34789,34846";
AttributeArray["1362"]["allowed"] = "1048,1235,1243,1247,1252,1259,1262";
AttributeArray["1235"] = new Object();
AttributeArray["1235"]["value"] = 1235;
AttributeArray["1235"]["text"] = "13.00 X 6.00 X 15.50";
AttributeArray["1235"]["prod_id"] = "34474,34480,34478,34479,34481";
AttributeArray["1235"]["allowed"] = "268,270,1362,1364,1370";
AttributeArray["1048"] = new Object();
AttributeArray["1048"]["value"] = 1048;
AttributeArray["1048"]["text"] = "10.00 X 5.00 X 13.00";
AttributeArray["1048"]["prod_id"] = "34647,34653,34651,34652,34654";
AttributeArray["1048"]["allowed"] = "268,270,1362,1364,1370";
AttributeArray["1051"] = new Object();
AttributeArray["1051"]["value"] = 1051;
AttributeArray["1051"]["text"] = "5.25 X 3.50 X 13.00";
AttributeArray["1051"]["prod_id"] = "34917,34919";
AttributeArray["1051"]["allowed"] = "268,270";


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 {
		
	}
	

