

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-MATTEPINK.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-MATTEPINK.jpg\" class=\"imgBorder\" alt=\"Tinted White Paper Shoppers\" />\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"] = 472;
fldValueStruct["fld2array"][0]["text"] = "MATTE IVORY";
fldValueStruct["fld2array"][1] = new Object();
fldValueStruct["fld2array"][1]["value"] = 1353;
fldValueStruct["fld2array"][1]["text"] = "MATTE LIME";
fldValueStruct["fld2array"][2] = new Object();
fldValueStruct["fld2array"][2]["value"] = 1369;
fldValueStruct["fld2array"][2]["text"] = "MATTE METALLIC TURQUOISE";
fldValueStruct["fld2array"][3] = new Object();
fldValueStruct["fld2array"][3]["value"] = 1450;
fldValueStruct["fld2array"][3]["text"] = "MATTE PEACH";
fldValueStruct["fld2array"][4] = new Object();
fldValueStruct["fld2array"][4]["value"] = 1358;
fldValueStruct["fld2array"][4]["text"] = "MATTE PINK";
fldValueStruct["fld2array"][5] = new Object();
fldValueStruct["fld2array"][5]["value"] = 1354;
fldValueStruct["fld2array"][5]["text"] = "MATTE POWDER BLUE";
fldValueStruct["fld2array"][6] = new Object();
fldValueStruct["fld2array"][6]["value"] = 1504;
fldValueStruct["fld2array"][6]["text"] = "PASTEL YELLOW";


AvailableProducts = new Object();
AvailableProducts["1358_1048"] = 34656;
AvailableProducts["1247_1450"] = 34626;
AvailableProducts["1450_1262"] = 34869;
AvailableProducts["1048_1450"] = 34662;
AvailableProducts["1048_1504"] = 34661;
AvailableProducts["1243_1450"] = 34558;
AvailableProducts["1048_1358"] = 34656;
AvailableProducts["1243_1358"] = 34548;
AvailableProducts["1353_1259"] = 34788;
AvailableProducts["1252_1354"] = 34711;
AvailableProducts["1353_1247"] = 34612;
AvailableProducts["1354_1048"] = 34663;
AvailableProducts["1247_1354"] = 34627;
AvailableProducts["1354_1243"] = 34560;
AvailableProducts["1262_1353"] = 34855;
AvailableProducts["1369_1247"] = 34619;
AvailableProducts["1354_1259"] = 34807;
AvailableProducts["1450_1247"] = 34626;
AvailableProducts["1450_1259"] = 34804;
AvailableProducts["1259_1504"] = 34803;
AvailableProducts["1247_472"] = 34617;
AvailableProducts["1358_1243"] = 34548;
AvailableProducts["1358_1235"] = 34483;
AvailableProducts["1354_1262"] = 34871;
AvailableProducts["1247_1353"] = 34612;
AvailableProducts["1243_472"] = 34547;
AvailableProducts["472_1259"] = 34793;
AvailableProducts["1450_1252"] = 34709;
AvailableProducts["1048_1353"] = 34650;
AvailableProducts["472_1243"] = 34547;
AvailableProducts["1504_1247"] = 34625;
AvailableProducts["1504_1048"] = 34661;
AvailableProducts["1262_1358"] = 34859;
AvailableProducts["1235_1353"] = 34477;
AvailableProducts["1369_1259"] = 34795;
AvailableProducts["1259_1358"] = 34794;
AvailableProducts["1235_472"] = 34482;
AvailableProducts["1235_1450"] = 34489;
AvailableProducts["1235_1504"] = 34488;
AvailableProducts["1450_1243"] = 34558;
AvailableProducts["1252_1353"] = 34693;
AvailableProducts["1353_1048"] = 34650;
AvailableProducts["1243_1504"] = 34557;
AvailableProducts["1252_472"] = 34698;
AvailableProducts["1252_1450"] = 34709;
AvailableProducts["1252_1504"] = 34708;
AvailableProducts["1262_472"] = 34858;
AvailableProducts["1048_1369"] = 34657;
AvailableProducts["1262_1504"] = 34868;
AvailableProducts["1369_1235"] = 34484;
AvailableProducts["1504_1243"] = 34557;
AvailableProducts["1369_1048"] = 34657;
AvailableProducts["1235_1369"] = 34484;
AvailableProducts["1353_1262"] = 34855;
AvailableProducts["1259_1353"] = 34788;
AvailableProducts["1354_1252"] = 34711;
AvailableProducts["1450_1235"] = 34489;
AvailableProducts["1262_1354"] = 34871;
AvailableProducts["1369_1252"] = 34700;
AvailableProducts["1358_1262"] = 34859;
AvailableProducts["1235_1354"] = 34490;
AvailableProducts["1504_1259"] = 34803;
AvailableProducts["1243_1354"] = 34560;
AvailableProducts["1353_1235"] = 34477;
AvailableProducts["1252_1358"] = 34699;
AvailableProducts["1354_1235"] = 34490;
AvailableProducts["1358_1252"] = 34699;
AvailableProducts["1504_1262"] = 34868;
AvailableProducts["472_1235"] = 34482;
AvailableProducts["1243_1353"] = 34542;
AvailableProducts["472_1262"] = 34858;
AvailableProducts["1259_1354"] = 34807;
AvailableProducts["472_1048"] = 34655;
AvailableProducts["472_1252"] = 34698;
AvailableProducts["472_1247"] = 34617;
AvailableProducts["1504_1252"] = 34708;
AvailableProducts["1048_1354"] = 34663;
AvailableProducts["1048_472"] = 34655;
AvailableProducts["1358_1247"] = 34618;
AvailableProducts["1369_1262"] = 34860;
AvailableProducts["1354_1247"] = 34627;
AvailableProducts["1262_1369"] = 34860;
AvailableProducts["1247_1358"] = 34618;
AvailableProducts["1353_1243"] = 34542;
AvailableProducts["1504_1235"] = 34488;
AvailableProducts["1259_1369"] = 34795;
AvailableProducts["1369_1243"] = 34549;
AvailableProducts["1247_1369"] = 34619;
AvailableProducts["1262_1450"] = 34869;
AvailableProducts["1235_1358"] = 34483;
AvailableProducts["1259_1450"] = 34804;
AvailableProducts["1358_1259"] = 34794;
AvailableProducts["1353_1252"] = 34693;
AvailableProducts["1252_1369"] = 34700;
AvailableProducts["1247_1504"] = 34625;
AvailableProducts["1243_1369"] = 34549;
AvailableProducts["1259_472"] = 34793;
AvailableProducts["1450_1048"] = 34662;


AttributeArray = new Object();
AttributeArray["472"] = new Object();
AttributeArray["472"]["value"] = 472;
AttributeArray["472"]["text"] = "MATTE IVORY";
AttributeArray["472"]["prod_id"] = "34655,34482,34547,34617,34698,34793,34858";
AttributeArray["472"]["allowed"] = "1048,1235,1243,1247,1252,1259,1262";
AttributeArray["1358"] = new Object();
AttributeArray["1358"]["value"] = 1358;
AttributeArray["1358"]["text"] = "MATTE PINK";
AttributeArray["1358"]["prod_id"] = "34656,34483,34548,34618,34699,34794,34859";
AttributeArray["1358"]["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"] = "34655,34650,34663,34656,34657,34662,34661";
AttributeArray["1048"]["allowed"] = "472,1353,1354,1358,1369,1450,1504";
AttributeArray["1450"] = new Object();
AttributeArray["1450"]["value"] = 1450;
AttributeArray["1450"]["text"] = "MATTE PEACH";
AttributeArray["1450"]["prod_id"] = "34662,34489,34558,34626,34709,34804,34869";
AttributeArray["1450"]["allowed"] = "1048,1235,1243,1247,1252,1259,1262";
AttributeArray["1354"] = new Object();
AttributeArray["1354"]["value"] = 1354;
AttributeArray["1354"]["text"] = "MATTE POWDER BLUE";
AttributeArray["1354"]["prod_id"] = "34663,34490,34560,34627,34711,34807,34871";
AttributeArray["1354"]["allowed"] = "1048,1235,1243,1247,1252,1259,1262";
AttributeArray["1243"] = new Object();
AttributeArray["1243"]["value"] = 1243;
AttributeArray["1243"]["text"] = "16.00 X 6.00 X 19.00";
AttributeArray["1243"]["prod_id"] = "34547,34542,34560,34548,34549,34558,34557";
AttributeArray["1243"]["allowed"] = "472,1353,1354,1358,1369,1450,1504";
AttributeArray["1353"] = new Object();
AttributeArray["1353"]["value"] = 1353;
AttributeArray["1353"]["text"] = "MATTE LIME";
AttributeArray["1353"]["prod_id"] = "34650,34477,34542,34612,34693,34788,34855";
AttributeArray["1353"]["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"] = "34858,34855,34871,34859,34860,34869,34868";
AttributeArray["1262"]["allowed"] = "472,1353,1354,1358,1369,1450,1504";
AttributeArray["1247"] = new Object();
AttributeArray["1247"]["value"] = 1247;
AttributeArray["1247"]["text"] = "18.00 X 7.00 X 18.75";
AttributeArray["1247"]["prod_id"] = "34617,34612,34627,34618,34619,34626,34625";
AttributeArray["1247"]["allowed"] = "472,1353,1354,1358,1369,1450,1504";
AttributeArray["1369"] = new Object();
AttributeArray["1369"]["value"] = 1369;
AttributeArray["1369"]["text"] = "MATTE METALLIC TURQUOISE";
AttributeArray["1369"]["prod_id"] = "34657,34484,34549,34619,34700,34795,34860";
AttributeArray["1369"]["allowed"] = "1048,1235,1243,1247,1252,1259,1262";
AttributeArray["1504"] = new Object();
AttributeArray["1504"]["value"] = 1504;
AttributeArray["1504"]["text"] = "PASTEL YELLOW";
AttributeArray["1504"]["prod_id"] = "34661,34488,34557,34625,34708,34803,34868";
AttributeArray["1504"]["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"] = "34793,34788,34807,34794,34795,34804,34803";
AttributeArray["1259"]["allowed"] = "472,1353,1354,1358,1369,1450,1504";
AttributeArray["1252"] = new Object();
AttributeArray["1252"]["value"] = 1252;
AttributeArray["1252"]["text"] = "16.00 X 6.00 X 12.38";
AttributeArray["1252"]["prod_id"] = "34698,34693,34711,34699,34700,34709,34708";
AttributeArray["1252"]["allowed"] = "472,1353,1354,1358,1369,1450,1504";
AttributeArray["1235"] = new Object();
AttributeArray["1235"]["value"] = 1235;
AttributeArray["1235"]["text"] = "13.00 X 6.00 X 15.50";
AttributeArray["1235"]["prod_id"] = "34482,34477,34490,34483,34484,34489,34488";
AttributeArray["1235"]["allowed"] = "472,1353,1354,1358,1369,1450,1504";


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 {
		
	}
	

