

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 BURGOAT.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 BURGOAT.jpg\" class=\"imgBorder\" alt=\"Tints on Oatmeal \" />\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"] = 1262;
fldValueStruct["fld1array"][0]["text"] = "5.25 X 3.50 X 8.25";
fldValueStruct["fld1array"][1] = new Object();
fldValueStruct["fld1array"][1]["value"] = 1259;
fldValueStruct["fld1array"][1]["text"] = "8.00 X 4.75 X 10.38";
fldValueStruct["fld1array"][2] = new Object();
fldValueStruct["fld1array"][2]["value"] = 1048;
fldValueStruct["fld1array"][2]["text"] = "10.00 X 5.00 X 13.00";
fldValueStruct["fld1array"][3] = new Object();
fldValueStruct["fld1array"][3]["value"] = 1235;
fldValueStruct["fld1array"][3]["text"] = "13.00 X 6.00 X 15.50";
fldValueStruct["fld1array"][4] = new Object();
fldValueStruct["fld1array"][4]["value"] = 1243;
fldValueStruct["fld1array"][4]["text"] = "16.00 X 6.00 X 19.00";
fldValueStruct["fld1array"][5] = new Object();
fldValueStruct["fld1array"][5]["value"] = 1252;
fldValueStruct["fld1array"][5]["text"] = "16.00 X 6.00 X 12.38";
fldValueStruct["fld1array"][6] = new Object();
fldValueStruct["fld1array"][6]["value"] = 1247;
fldValueStruct["fld1array"][6]["text"] = "18.00 X 7.00 X 18.75";
fldValueStruct["fld2array"] =  new Array();
fldValueStruct["fld2array"][0] = new Object();
fldValueStruct["fld2array"][0]["value"] = 1447;
fldValueStruct["fld2array"][0]["text"] = "BURGUNDY";
fldValueStruct["fld2array"][1] = new Object();
fldValueStruct["fld2array"][1]["value"] = 191;
fldValueStruct["fld2array"][1]["text"] = "KHAKI TINT";
fldValueStruct["fld2array"][2] = new Object();
fldValueStruct["fld2array"][2]["value"] = 147;
fldValueStruct["fld2array"][2]["text"] = "MATTE CELERY";
fldValueStruct["fld2array"][3] = new Object();
fldValueStruct["fld2array"][3]["value"] = 271;
fldValueStruct["fld2array"][3]["text"] = "PURPLE";
fldValueStruct["fld2array"][4] = new Object();
fldValueStruct["fld2array"][4]["value"] = 1448;
fldValueStruct["fld2array"][4]["text"] = "SANDKRAFT";
fldValueStruct["fld2array"][5] = new Object();
fldValueStruct["fld2array"][5]["value"] = 1424;
fldValueStruct["fld2array"][5]["text"] = "SOUTHWEST ORANGE";
fldValueStruct["fld2array"][6] = new Object();
fldValueStruct["fld2array"][6]["value"] = 238;
fldValueStruct["fld2array"][6]["text"] = "TEAL";


AvailableProducts = new Object();
AvailableProducts["1243_1448"] = 34565;
AvailableProducts["1048_147"] = 34645;
AvailableProducts["1243_1447"] = 34523;
AvailableProducts["271_1262"] = 34872;
AvailableProducts["271_1048"] = 34664;
AvailableProducts["1448_1259"] = 34813;
AvailableProducts["1048_1448"] = 34667;
AvailableProducts["271_1235"] = 34491;
AvailableProducts["147_1243"] = 34524;
AvailableProducts["271_1252"] = 34712;
AvailableProducts["1235_147"] = 34466;
AvailableProducts["1252_271"] = 34712;
AvailableProducts["1448_1252"] = 34717;
AvailableProducts["1243_238"] = 34568;
AvailableProducts["1447_1252"] = 34675;
AvailableProducts["1262_1448"] = 34878;
AvailableProducts["1235_1448"] = 34494;
AvailableProducts["1447_1048"] = 34644;
AvailableProducts["1243_271"] = 34561;
AvailableProducts["1247_1447"] = 34600;
AvailableProducts["271_1247"] = 34628;
AvailableProducts["1247_147"] = 34601;
AvailableProducts["1252_1447"] = 34675;
AvailableProducts["1243_1424"] = 34567;
AvailableProducts["191_1259"] = 34786;
AvailableProducts["271_1243"] = 34561;
AvailableProducts["1262_1424"] = 34881;
AvailableProducts["1424_1259"] = 34815;
AvailableProducts["1048_271"] = 34664;
AvailableProducts["1448_1235"] = 34494;
AvailableProducts["191_1243"] = 34540;
AvailableProducts["1447_1262"] = 34841;
AvailableProducts["1448_1247"] = 34631;
AvailableProducts["1259_1424"] = 34815;
AvailableProducts["1447_1235"] = 34465;
AvailableProducts["1252_1424"] = 34719;
AvailableProducts["1259_271"] = 34808;
AvailableProducts["1235_1424"] = 34495;
AvailableProducts["147_1252"] = 34676;
AvailableProducts["147_1262"] = 34842;
AvailableProducts["147_1247"] = 34601;
AvailableProducts["147_1259"] = 34770;
AvailableProducts["1235_191"] = 34476;
AvailableProducts["147_1235"] = 34466;
AvailableProducts["1235_238"] = 34496;
AvailableProducts["1424_1247"] = 34632;
AvailableProducts["1235_271"] = 34491;
AvailableProducts["1235_1447"] = 34465;
AvailableProducts["1252_238"] = 34720;
AvailableProducts["1247_1448"] = 34631;
AvailableProducts["1447_1243"] = 34523;
AvailableProducts["1247_238"] = 34633;
AvailableProducts["1252_147"] = 34676;
AvailableProducts["1262_191"] = 34853;
AvailableProducts["191_1247"] = 34611;
AvailableProducts["191_1252"] = 34691;
AvailableProducts["1247_191"] = 34611;
AvailableProducts["191_1235"] = 34476;
AvailableProducts["1259_1447"] = 34769;
AvailableProducts["1243_191"] = 34540;
AvailableProducts["238_1235"] = 34496;
AvailableProducts["1259_191"] = 34786;
AvailableProducts["238_1262"] = 34882;
AvailableProducts["238_1048"] = 34669;
AvailableProducts["238_1252"] = 34720;
AvailableProducts["238_1243"] = 34568;
AvailableProducts["1048_191"] = 34649;
AvailableProducts["147_1048"] = 34645;
AvailableProducts["1448_1048"] = 34667;
AvailableProducts["191_1048"] = 34649;
AvailableProducts["191_1262"] = 34853;
AvailableProducts["1424_1235"] = 34495;
AvailableProducts["238_1259"] = 34816;
AvailableProducts["1424_1262"] = 34881;
AvailableProducts["1447_1259"] = 34769;
AvailableProducts["238_1247"] = 34633;
AvailableProducts["271_1259"] = 34808;
AvailableProducts["1262_1447"] = 34841;
AvailableProducts["1259_238"] = 34816;
AvailableProducts["1424_1252"] = 34719;
AvailableProducts["1424_1243"] = 34567;
AvailableProducts["1448_1262"] = 34878;
AvailableProducts["1448_1243"] = 34565;
AvailableProducts["1252_191"] = 34691;
AvailableProducts["1262_238"] = 34882;
AvailableProducts["1262_147"] = 34842;
AvailableProducts["1048_1447"] = 34644;
AvailableProducts["1259_147"] = 34770;
AvailableProducts["1252_1448"] = 34717;
AvailableProducts["1259_1448"] = 34813;
AvailableProducts["1262_271"] = 34872;
AvailableProducts["1424_1048"] = 34668;
AvailableProducts["1247_1424"] = 34632;
AvailableProducts["1048_1424"] = 34668;
AvailableProducts["1247_271"] = 34628;
AvailableProducts["1447_1247"] = 34600;
AvailableProducts["1048_238"] = 34669;
AvailableProducts["1243_147"] = 34524;


AttributeArray = new Object();
AttributeArray["1424"] = new Object();
AttributeArray["1424"]["value"] = 1424;
AttributeArray["1424"]["text"] = "SOUTHWEST ORANGE";
AttributeArray["1424"]["prod_id"] = "34668,34495,34567,34632,34719,34815,34881";
AttributeArray["1424"]["allowed"] = "1048,1235,1243,1247,1252,1259,1262";
AttributeArray["238"] = new Object();
AttributeArray["238"]["value"] = 238;
AttributeArray["238"]["text"] = "TEAL";
AttributeArray["238"]["prod_id"] = "34669,34496,34568,34633,34720,34816,34882";
AttributeArray["238"]["allowed"] = "1048,1235,1243,1247,1252,1259,1262";
AttributeArray["1048"] = new Object();
AttributeArray["1048"]["value"] = 1048;
AttributeArray["1048"]["text"] = "10.00 X 5.00 X 13.00";
AttributeArray["1048"]["prod_id"] = "34645,34649,34669,34664,34668,34644,34667";
AttributeArray["1048"]["allowed"] = "147,191,238,271,1424,1447,1448";
AttributeArray["1243"] = new Object();
AttributeArray["1243"]["value"] = 1243;
AttributeArray["1243"]["text"] = "16.00 X 6.00 X 19.00";
AttributeArray["1243"]["prod_id"] = "34524,34540,34568,34561,34567,34523,34565";
AttributeArray["1243"]["allowed"] = "147,191,238,271,1424,1447,1448";
AttributeArray["191"] = new Object();
AttributeArray["191"]["value"] = 191;
AttributeArray["191"]["text"] = "KHAKI TINT";
AttributeArray["191"]["prod_id"] = "34649,34476,34540,34611,34691,34786,34853";
AttributeArray["191"]["allowed"] = "1048,1235,1243,1247,1252,1259,1262";
AttributeArray["1262"] = new Object();
AttributeArray["1262"]["value"] = 1262;
AttributeArray["1262"]["text"] = "5.25 X 3.50 X 8.25";
AttributeArray["1262"]["prod_id"] = "34842,34853,34882,34872,34881,34841,34878";
AttributeArray["1262"]["allowed"] = "147,191,238,271,1424,1447,1448";
AttributeArray["1247"] = new Object();
AttributeArray["1247"]["value"] = 1247;
AttributeArray["1247"]["text"] = "18.00 X 7.00 X 18.75";
AttributeArray["1247"]["prod_id"] = "34601,34611,34633,34628,34632,34600,34631";
AttributeArray["1247"]["allowed"] = "147,191,238,271,1424,1447,1448";
AttributeArray["1448"] = new Object();
AttributeArray["1448"]["value"] = 1448;
AttributeArray["1448"]["text"] = "SANDKRAFT";
AttributeArray["1448"]["prod_id"] = "34667,34494,34565,34631,34717,34813,34878";
AttributeArray["1448"]["allowed"] = "1048,1235,1243,1247,1252,1259,1262";
AttributeArray["271"] = new Object();
AttributeArray["271"]["value"] = 271;
AttributeArray["271"]["text"] = "PURPLE";
AttributeArray["271"]["prod_id"] = "34664,34491,34561,34628,34712,34808,34872";
AttributeArray["271"]["allowed"] = "1048,1235,1243,1247,1252,1259,1262";
AttributeArray["147"] = new Object();
AttributeArray["147"]["value"] = 147;
AttributeArray["147"]["text"] = "MATTE CELERY";
AttributeArray["147"]["prod_id"] = "34645,34466,34524,34601,34676,34770,34842";
AttributeArray["147"]["allowed"] = "1048,1235,1243,1247,1252,1259,1262";
AttributeArray["1259"] = new Object();
AttributeArray["1259"]["value"] = 1259;
AttributeArray["1259"]["text"] = "8.00 X 4.75 X 10.38";
AttributeArray["1259"]["prod_id"] = "34770,34786,34816,34808,34815,34769,34813";
AttributeArray["1259"]["allowed"] = "147,191,238,271,1424,1447,1448";
AttributeArray["1252"] = new Object();
AttributeArray["1252"]["value"] = 1252;
AttributeArray["1252"]["text"] = "16.00 X 6.00 X 12.38";
AttributeArray["1252"]["prod_id"] = "34676,34691,34720,34712,34719,34675,34717";
AttributeArray["1252"]["allowed"] = "147,191,238,271,1424,1447,1448";
AttributeArray["1447"] = new Object();
AttributeArray["1447"]["value"] = 1447;
AttributeArray["1447"]["text"] = "BURGUNDY";
AttributeArray["1447"]["prod_id"] = "34644,34465,34523,34600,34675,34769,34841";
AttributeArray["1447"]["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"] = "34466,34476,34496,34491,34495,34465,34494";
AttributeArray["1235"]["allowed"] = "147,191,238,271,1424,1447,1448";


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 {
		
	}
	

