

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=sizzle.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_sizzle.jpg\" class=\"imgBorder\" alt=\"Sizzle \" />\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"] = 394;
fldValueStruct["fld1array"][0]["text"] = "0.00 X 0.00 X 0.00";
fldValueStruct["fld2array"] =  new Array();
fldValueStruct["fld2array"][0] = new Object();
fldValueStruct["fld2array"][0]["value"] = 1506;
fldValueStruct["fld2array"][0]["text"] = "BLACK";
fldValueStruct["fld2array"][1] = new Object();
fldValueStruct["fld2array"][1]["value"] = 1447;
fldValueStruct["fld2array"][1]["text"] = "BURGUNDY";
fldValueStruct["fld2array"][2] = new Object();
fldValueStruct["fld2array"][2]["value"] = 456;
fldValueStruct["fld2array"][2]["text"] = "COPPER";
fldValueStruct["fld2array"][3] = new Object();
fldValueStruct["fld2array"][3]["value"] = 302;
fldValueStruct["fld2array"][3]["text"] = "FOREST GREEN";
fldValueStruct["fld2array"][4] = new Object();
fldValueStruct["fld2array"][4]["value"] = 1547;
fldValueStruct["fld2array"][4]["text"] = "FORESTGREEN";
fldValueStruct["fld2array"][5] = new Object();
fldValueStruct["fld2array"][5]["value"] = 592;
fldValueStruct["fld2array"][5]["text"] = "FUSCHIA";
fldValueStruct["fld2array"][6] = new Object();
fldValueStruct["fld2array"][6]["value"] = 1549;
fldValueStruct["fld2array"][6]["text"] = "GOLDEN ROD";
fldValueStruct["fld2array"][7] = new Object();
fldValueStruct["fld2array"][7]["value"] = 375;
fldValueStruct["fld2array"][7]["text"] = "GREEN";
fldValueStruct["fld2array"][8] = new Object();
fldValueStruct["fld2array"][8]["value"] = 1442;
fldValueStruct["fld2array"][8]["text"] = "IVORY";
fldValueStruct["fld2array"][9] = new Object();
fldValueStruct["fld2array"][9]["value"] = 1550;
fldValueStruct["fld2array"][9]["text"] = "KRAFT";
fldValueStruct["fld2array"][10] = new Object();
fldValueStruct["fld2array"][10]["value"] = 1551;
fldValueStruct["fld2array"][10]["text"] = "LAVNDER";
fldValueStruct["fld2array"][11] = new Object();
fldValueStruct["fld2array"][11]["value"] = 1552;
fldValueStruct["fld2array"][11]["text"] = "LIME GREEN";
fldValueStruct["fld2array"][12] = new Object();
fldValueStruct["fld2array"][12]["value"] = 140;
fldValueStruct["fld2array"][12]["text"] = "NATURAL KRAFT";
fldValueStruct["fld2array"][13] = new Object();
fldValueStruct["fld2array"][13]["value"] = 1553;
fldValueStruct["fld2array"][13]["text"] = "NAVY BLUE";
fldValueStruct["fld2array"][14] = new Object();
fldValueStruct["fld2array"][14]["value"] = 1554;
fldValueStruct["fld2array"][14]["text"] = "ORANGE SHERBET";
fldValueStruct["fld2array"][15] = new Object();
fldValueStruct["fld2array"][15]["value"] = 1512;
fldValueStruct["fld2array"][15]["text"] = "RED";
fldValueStruct["fld2array"][16] = new Object();
fldValueStruct["fld2array"][16]["value"] = 1651;
fldValueStruct["fld2array"][16]["text"] = "red";
fldValueStruct["fld2array"][17] = new Object();
fldValueStruct["fld2array"][17]["value"] = 307;
fldValueStruct["fld2array"][17]["text"] = "ROYAL BLUE";
fldValueStruct["fld2array"][18] = new Object();
fldValueStruct["fld2array"][18]["value"] = 238;
fldValueStruct["fld2array"][18]["text"] = "TEAL";
fldValueStruct["fld2array"][19] = new Object();
fldValueStruct["fld2array"][19]["value"] = 141;
fldValueStruct["fld2array"][19]["text"] = "WHITE";
fldValueStruct["fld2array"][20] = new Object();
fldValueStruct["fld2array"][20]["value"] = 248;
fldValueStruct["fld2array"][20]["text"] = "YELLOW";


AvailableProducts = new Object();
AvailableProducts["394_456"] = 35987;
AvailableProducts["394_1506"] = 35983;
AvailableProducts["394_248"] = 36011;
AvailableProducts["394_307"] = 36005;
AvailableProducts["394_1442"] = 35994;
AvailableProducts["394_141"] = 36007;
AvailableProducts["394_375"] = 35993;
AvailableProducts["1551_394"] = 35996;
AvailableProducts["1442_394"] = 35994;
AvailableProducts["1512_394"] = 36004;
AvailableProducts["1447_394"] = 35985;
AvailableProducts["394_592"] = 35992;
AvailableProducts["1553_394"] = 35998;
AvailableProducts["394_1552"] = 35997;
AvailableProducts["302_394"] = 35989;
AvailableProducts["1552_394"] = 35997;
AvailableProducts["141_394"] = 36007;
AvailableProducts["140_394"] = 35995;
AvailableProducts["1506_394"] = 35983;
AvailableProducts["307_394"] = 36005;
AvailableProducts["394_1553"] = 35998;
AvailableProducts["394_1512"] = 36004;
AvailableProducts["394_140"] = 35995;
AvailableProducts["248_394"] = 36011;
AvailableProducts["394_1551"] = 35996;
AvailableProducts["375_394"] = 35993;
AvailableProducts["394_302"] = 35989;
AvailableProducts["238_394"] = 36006;
AvailableProducts["394_1447"] = 35985;
AvailableProducts["394_238"] = 36006;
AvailableProducts["456_394"] = 35987;
AvailableProducts["592_394"] = 35992;


AttributeArray = new Object();
AttributeArray["248"] = new Object();
AttributeArray["248"]["value"] = 248;
AttributeArray["248"]["text"] = "YELLOW";
AttributeArray["248"]["prod_id"] = "36011";
AttributeArray["248"]["allowed"] = "394";
AttributeArray["140"] = new Object();
AttributeArray["140"]["value"] = 140;
AttributeArray["140"]["text"] = "NATURAL KRAFT";
AttributeArray["140"]["prod_id"] = "35995";
AttributeArray["140"]["allowed"] = "394";
AttributeArray["592"] = new Object();
AttributeArray["592"]["value"] = 592;
AttributeArray["592"]["text"] = "FUSCHIA";
AttributeArray["592"]["prod_id"] = "36001,35992";
AttributeArray["592"]["allowed"] = "394,394";
AttributeArray["456"] = new Object();
AttributeArray["456"]["value"] = 456;
AttributeArray["456"]["text"] = "COPPER";
AttributeArray["456"]["prod_id"] = "35987";
AttributeArray["456"]["allowed"] = "394";
AttributeArray["1554"] = new Object();
AttributeArray["1554"]["value"] = 1554;
AttributeArray["1554"]["text"] = "ORANGE SHERBET";
AttributeArray["1506"] = new Object();
AttributeArray["1506"]["value"] = 1506;
AttributeArray["1506"]["text"] = "BLACK";
AttributeArray["1506"]["prod_id"] = "35983";
AttributeArray["1506"]["allowed"] = "394";
AttributeArray["302"] = new Object();
AttributeArray["302"]["value"] = 302;
AttributeArray["302"]["text"] = "FOREST GREEN";
AttributeArray["302"]["prod_id"] = "35989";
AttributeArray["302"]["allowed"] = "394";
AttributeArray["1442"] = new Object();
AttributeArray["1442"]["value"] = 1442;
AttributeArray["1442"]["text"] = "IVORY";
AttributeArray["1442"]["prod_id"] = "35994";
AttributeArray["1442"]["allowed"] = "394";
AttributeArray["1547"] = new Object();
AttributeArray["1547"]["value"] = 1547;
AttributeArray["1547"]["text"] = "FORESTGREEN";
AttributeArray["1552"] = new Object();
AttributeArray["1552"]["value"] = 1552;
AttributeArray["1552"]["text"] = "LIME GREEN";
AttributeArray["1552"]["prod_id"] = "35997";
AttributeArray["1552"]["allowed"] = "394";
AttributeArray["1553"] = new Object();
AttributeArray["1553"]["value"] = 1553;
AttributeArray["1553"]["text"] = "NAVY BLUE";
AttributeArray["1553"]["prod_id"] = "35998";
AttributeArray["1553"]["allowed"] = "394";
AttributeArray["1550"] = new Object();
AttributeArray["1550"]["value"] = 1550;
AttributeArray["1550"]["text"] = "KRAFT";
AttributeArray["1447"] = new Object();
AttributeArray["1447"]["value"] = 1447;
AttributeArray["1447"]["text"] = "BURGUNDY";
AttributeArray["1447"]["prod_id"] = "35985";
AttributeArray["1447"]["allowed"] = "394";
AttributeArray["394"] = new Object();
AttributeArray["394"]["value"] = 394;
AttributeArray["394"]["text"] = "0.00 X 0.00 X 0.00";
AttributeArray["394"]["prod_id"] = "35995,36007,36006,36011,35989,36005,35993,35987,36001,35992,35994,35985,35983,36004,35996,35997,35998";
AttributeArray["394"]["allowed"] = "140,141,238,248,302,307,375,456,592,592,1442,1447,1506,1512,1551,1552,1553";
AttributeArray["307"] = new Object();
AttributeArray["307"]["value"] = 307;
AttributeArray["307"]["text"] = "ROYAL BLUE";
AttributeArray["307"]["prod_id"] = "36005";
AttributeArray["307"]["allowed"] = "394";
AttributeArray["375"] = new Object();
AttributeArray["375"]["value"] = 375;
AttributeArray["375"]["text"] = "GREEN";
AttributeArray["375"]["prod_id"] = "35993";
AttributeArray["375"]["allowed"] = "394";
AttributeArray["1651"] = new Object();
AttributeArray["1651"]["value"] = 1651;
AttributeArray["1651"]["text"] = "red";
AttributeArray["1512"] = new Object();
AttributeArray["1512"]["value"] = 1512;
AttributeArray["1512"]["text"] = "RED";
AttributeArray["1512"]["prod_id"] = "36004";
AttributeArray["1512"]["allowed"] = "394";
AttributeArray["1549"] = new Object();
AttributeArray["1549"]["value"] = 1549;
AttributeArray["1549"]["text"] = "GOLDEN ROD";
AttributeArray["238"] = new Object();
AttributeArray["238"]["value"] = 238;
AttributeArray["238"]["text"] = "TEAL";
AttributeArray["238"]["prod_id"] = "36006";
AttributeArray["238"]["allowed"] = "394";
AttributeArray["1551"] = new Object();
AttributeArray["1551"]["value"] = 1551;
AttributeArray["1551"]["text"] = "LAVNDER";
AttributeArray["1551"]["prod_id"] = "35996";
AttributeArray["1551"]["allowed"] = "394";
AttributeArray["141"] = new Object();
AttributeArray["141"]["value"] = 141;
AttributeArray["141"]["text"] = "WHITE";
AttributeArray["141"]["prod_id"] = "36007";
AttributeArray["141"]["allowed"] = "394";


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 {
		
	}
	

