function makeRequest(url, vid, enabledInventory, enabledEcommerce, enabledQtyDiscount, callForPricing, ourPriceText, baseURL, popUpStandardWindowWidth, popUpStandardWindowHeight, enableSquareFeetPerPallet, squareFeetPerPallete) 
{

    var http_request = false;
	document.body.style.cursor = 'progress';

    if (window.XMLHttpRequest) { // Mozilla, Safari,...
        http_request = new XMLHttpRequest();
        if (http_request.overrideMimeType) {
            http_request.overrideMimeType('text/xml');
            // See note below about this line
        }
    } else if (window.ActiveXObject) { // IE
        try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
        }
    }

    if (!http_request) {
    	//posting the form because they don't support AJAX
        //alert('Giving up :( Cannot create an XMLHTTP instance');
        //return false;
        document.forms['productForm'].submit();
    }
    
    
    http_request.onreadystatechange = function() { processContents(http_request, vid ,enabledInventory, enabledEcommerce, enabledQtyDiscount, callForPricing, ourPriceText, baseURL, popUpStandardWindowWidth, popUpStandardWindowHeight, enableSquareFeetPerPallet, squareFeetPerPallete); document.body.style.cursor = 'auto'; };
    http_request.open('GET', url, true);
    http_request.send(null);

}

function makeRequestRingBuilder(url, idVariationRing, idVariationDiam) 
{
	//alert(idVariationRing);
	//alert(idVariationDiam);
    var http_request = false;
	document.body.style.cursor = 'progress';

    if (window.XMLHttpRequest) { // Mozilla, Safari,...
        http_request = new XMLHttpRequest();
        if (http_request.overrideMimeType) {
            http_request.overrideMimeType('text/xml');
            // See note below about this line
        }
    } else if (window.ActiveXObject) { // IE
        try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {
            	alert ('could not create xrequest');
            }
        }
    } else {
    	alert ('window.ActiveXobject not defined?');
    }

    if (!http_request) {
    	//posting the form because they don't support AJAX
        //alert('Giving up :( Cannot create an XMLHTTP instance');
        //return false;
        //document.forms['productForm'].submit();
    } 
    //function 										processContentsRingBuilder(http_request, idVariationRing, idVariationDiam)
    http_request.onreadystatechange = function() { processContentsRingBuilder(http_request, idVariationRing, idVariationDiam); document.body.style.cursor = 'auto'; };
    http_request.open('GET', url, true);
    http_request.send(null);
    
}

function notAvailable() {
   	//perhaps also post the form instead here
	//*** alert('This color/size option is currently unavailable.');

	if (document.getElementById("stock_div"))
		document.getElementById("stock_div").innerHTML = '<p class="stock_text">Unavailable</p>';
	if (document.getElementById("add_to_cart_div"))
		//document.getElementById("add_to_cart_div").innerHTML = '';
		document.getElementById("add_to_cart_div").style.display = 'none';
	// hiding "Quantity: field
	if (document.getElementById('productQty')) {
		document.getElementById("productQty").style.display = 'none';
	}
	//document.forms['productForm'].reset();
}

function processContents(http_request, vid, enabledInventory, enabledEcommerce, enabledQtyDiscount, callForPricing, ourPriceText, baseURL, popUpStandardWindowWidth, popUpStandardWindowHeight, enableSquareFeetPerPallet, squareFeetPerPallete)
{

    if (http_request.readyState == 4) {
        if (http_request.status == 200) {
        	//alert(http_request.responseText);
        	//alert(http_request.getAllResponseHeaders());
            var xmldoc = http_request.responseXML;

            if (!xmldoc.getElementsByTagName('displayName').item(0)) return notAvailable();

			var displayName = xmldoc.getElementsByTagName('displayName').item(0).firstChild.data;
			var longDescription2 = (xmldoc.getElementsByTagName('longDescription').item(0).firstChild) ? xmldoc.getElementsByTagName('longDescription').item(0).firstChild.data : "";
			var listPrice = xmldoc.getElementsByTagName('listPrice').item(0).firstChild.data;
			var salePrice = xmldoc.getElementsByTagName('salePrice').item(0).firstChild.data;
			var regularPrice = xmldoc.getElementsByTagName('regularPrice').item(0).firstChild.data;
			var regularPriceLabel = xmldoc.getElementsByTagName('regularPriceLabel').item(0).firstChild.data;
			var mainImage = xmldoc.getElementsByTagName('mainImage').item(0).firstChild.data;
			var attributes = xmldoc.getElementsByTagName('attribute');
			var idVariation = xmldoc.getElementsByTagName('idVariation').item(0).firstChild.data;
			var inventory = xmldoc.getElementsByTagName('inventory').item(0).firstChild.data;
			var sku = (xmldoc.getElementsByTagName('sku').item(0).firstChild) ? xmldoc.getElementsByTagName('sku').item(0).firstChild.data : "";
			var qtyDiscount = xmldoc.getElementsByTagName('discount');
			var availabilityTime = (xmldoc.getElementsByTagName('availability').item(0).firstChild) ? xmldoc.getElementsByTagName('availability').item(0).firstChild.data : "";
			var showSale=false; //show sale price
			var showList=true; // show list price
			inventory=Number(inventory);
			listPrice=Number(listPrice);
			salePrice=Number(salePrice);
			regularPrice=Number(regularPrice);
			var tryiton = 0;
			var svid = 0;
			if((xmldoc.getElementsByTagName('tryItOn').item(0) && xmldoc.getElementsByTagName('tryItOn').item(0).firstChild) && (xmldoc.getElementsByTagName('sidVariation').item(0) && xmldoc.getElementsByTagName('sidVariation').item(0).firstChild)) {
				tryiton = xmldoc.getElementsByTagName('tryItOn').item(0).firstChild.data;
				svid = xmldoc.getElementsByTagName('sidVariation').item(0).firstChild.data;
			}
			var isRxable = 0;
			if(xmldoc.getElementsByTagName('isRxable').item(0) && xmldoc.getElementsByTagName('isRxable').item(0).firstChild)
				isRxable = xmldoc.getElementsByTagName('isRxable').item(0).firstChild.data;

			var highestPrice=listPrice; //normally this is highest
			var lowestPrice=regularPrice; //normally this is lowest
			
			getDefaultImage = 0;
			
			// set the elements on the page
			document.forms['productForm'].vID.value = idVariation;
			// document.mainImage.src = "#request.catalogLiveRelPath#imageLibrary/" + mainImage;
			if (document.mainImage) { 
			document.mainImage.src = mainImage;
			}
			document.getElementById("displayName").innerHTML = displayName;
			// BEGIN: updating breadcrumbs
			// looking for "product name" element (className = crumb_on)
			var breadElements = document.getElementsByTagName('span');
			for (i = 0; i < breadElements.length; i++) {
				if (breadElements[i].className == 'crumb_on') {
					breadElements[i].innerHTML = displayName;
				}
			}
			// END: updating breadcrumbs
			// updating window's title:
			document.title = displayName;
			// restoring "quantity" field
			if (document.getElementById('productQty'))
				document.getElementById("productQty").style.display = 'block';
				
			if (document.getElementById("sku")) 
			{
				if(sku.length > 0)
					document.getElementById("sku").innerHTML = sku;
				else
					document.getElementById("sku").innerHTML = "N/A";
			}
			if(document.getElementById("longDescription2")) {
				document.getElementById("longDescription2").innerHTML = longDescription2;
			} else if (document.getElementById("longDescription")){
				document.getElementById("longDescription").innerHTML = longDescription2;
			}

			//calulate the highest price / lowest price and you save percent - note that user custom prices is not implemented here.. 6/15/2006
			if (regularPrice >= highestPrice) { //if list price was zero or less than regular price
				highestPrice=regularPrice;
				showList=false; //then we dont show list price
			}

			if ((salePrice > 0) && (salePrice < regularPrice)) {  //  sale price > 0 and is less than regular - so it is selling price..
				//then lowest price should be
				lowestPrice=salePrice;
				showSale=true;
				// if sale price, don't show list
				highestPrice=regularPrice;
				showList = false;
			}

			var percentDiscount=0; //default to no discount
			//alert(highestPrice + ' low= ' + lowestPrice);

			if (highestPrice > lowestPrice) {
				percentDiscount = (highestPrice - lowestPrice)/highestPrice * 100;
			}
			//default label values
			var listlabel="";
			var listpricetxt="";
			var oldreglabel="";
			var oldregpricetxt="";
			var reglabel="";
			var regpricetxt="";
			var salepricelabel="";
			var salepricetxt="";
			var percentdiscountlabel="";
			var percentdiscounttxt="";
			var cartonPrice="";	
			var showInSF=false;		
			
			
			
			if(enableSquareFeetPerPallet && squareFeetPerPallete > 0)
			{
				cartonPrice = currency(lowestPrice) + "/carton";
				showInSF = true;
				
				if (document.getElementById("priceCartonLabel"))
					document.getElementById("priceCartonLabel").style.display = "block";
				if (document.getElementById("priceCarton"))
					document.getElementById("priceCarton").style.display = "block";
										
			}
			else
			{
				if (document.getElementById("priceCartonLabel"))
					document.getElementById("priceCartonLabel").style.display = "none";
				if (document.getElementById("priceCarton"))
					document.getElementById("priceCarton").style.display = "none";
			}
			
			if (percentDiscount > 0) 
			{
				percentdiscountlabel="You Save:";
				percentdiscounttxt=Math.round(percentDiscount) + "%";
				document.getElementById("percentDiscountLabel").style.display = "block";
				document.getElementById("percentDiscount").style.display = "block";
			}
			else
			{	
				if (document.getElementById("percentDiscountLabel"))
					document.getElementById("percentDiscountLabel").style.display = "none";
				if (document.getElementById("percentDiscount"))
					document.getElementById("percentDiscount").style.display = "none";
			}
			
			if (showList) 
			{
				listlabel="List Price:";
				if(showInSF)
					listpricetxt=currency(listPrice/squareFeetPerPallete)+"/sf";
				else
					listpricetxt=currency(listPrice);	
				document.getElementById("listPriceLabel").style.display = "block";
				document.getElementById("listPrice").style.display = "block";
			}
			else
			{
				if (document.getElementById("percentDiscount"))
					document.getElementById("listPriceLabel").style.display = "none";
				if (document.getElementById("listPrice"))
					document.getElementById("listPrice").style.display = "none";
			}
			
			if (showSale) 
			{

				salepricelabel="Sale Price:";
				if(showInSF)
					salepricetxt=currency(salePrice/squareFeetPerPallete)+"/sf";
				else
					salepricetxt=currency(salePrice);
					
				//also show regular price with line thru it.
				if(showInSF)
					oldregpricetxt=currency(regularPrice/squareFeetPerPallete)+"/sf";
				else
					oldregpricetxt=currency(regularPrice);
					
				oldreglabel="Our Price";
				if(ourPriceText.length > 0)
					oldreglabel=ourPriceText + ":";
				
				document.getElementById("salePriceLabelOut").style.display = "block";
				document.getElementById("salePrice").style.display = "block";
				document.getElementById("oldregularPriceLabel").style.display = "block";
				document.getElementById("oldregularPrice").style.display = "block";
				document.getElementById("regularPriceLabel").style.display = "none";
				document.getElementById("regularPrice").style.display = "none";
			}
			else 
			{				
				// there is no sale so don't put line
				if(showInSF)
					regpricetxt=currency(regularPrice/squareFeetPerPallete)+"/sf";
				else
					regpricetxt=currency(regularPrice);
				
				reglabel=regularPriceLabel;
				if (document.getElementById("salePriceLabelOut"))
					document.getElementById("salePriceLabelOut").style.display = "none";
				if (document.getElementById("salePrice"))
					document.getElementById("salePrice").style.display = "none";
				if (document.getElementById("oldregularPriceLabel"))
					document.getElementById("oldregularPriceLabel").style.display = "none";
				if (document.getElementById("oldregularPrice"))
					document.getElementById("oldregularPrice").style.display = "none";
				if (document.getElementById("regularPriceLabel"))
					document.getElementById("regularPriceLabel").style.display = "block";
				if (document.getElementById("regularPrice"))
					document.getElementById("regularPrice").style.display = "block";
			}
						
			
			//alert('salprice txt='+ salepricetxt + ' saleprice= ' + salePrice + ' showsale = ' +  showSale + ' percentdiscounttxt = ' + percentdiscounttxt + ' percentDiscount = ' + percentDiscount);
			if (document.getElementById("listPriceLabel"))
				document.getElementById("listPriceLabel").innerHTML =listlabel;
			if (document.getElementById("listPrice"))
				document.getElementById("listPrice").innerHTML = listpricetxt;
			if (document.getElementById("regularPriceLabel"))
				document.getElementById("regularPriceLabel").innerHTML = reglabel;
			if (document.getElementById("regularPrice"))
				document.getElementById("regularPrice").innerHTML =regpricetxt ;
			if (document.getElementById("percentDiscount"))
				document.getElementById("percentDiscount").innerHTML = percentdiscounttxt;
			if (document.getElementById("percentDiscountLabel"))
				document.getElementById("percentDiscountLabel").innerHTML = percentdiscountlabel;

			if (document.getElementById("oldregularPriceLabel"))
				document.getElementById("oldregularPriceLabel").innerHTML = oldreglabel;
			if (document.getElementById("oldregularPrice"))
				document.getElementById("oldregularPrice").innerHTML =oldregpricetxt ;

			if (document.getElementById("salePriceLabelOut"))
				document.getElementById("salePriceLabelOut").innerHTML = salepricelabel;
			if (document.getElementById("salePrice"))
				document.getElementById("salePrice").innerHTML =salepricetxt ;
			
			//if (document.getElementById("priceCartonLabel"))
				//document.getElementById("priceCartonLabel").innerHTML = salepricelabel;
			if (document.getElementById("priceCarton"))
				document.getElementById("priceCarton").innerHTML = cartonPrice;

			//end calculation
			
			if (document.getElementById("try_it_on") && tryiton > 0 && svid > 0) {
				var link = document.getElementById("try_it_on_link").innerHTML;
				//alert(document.location);
				//alert(link);
				//alert(link.indexOf("vid"));
				//alert(link.slice(0,link.indexOf("vid")+4) + svid + link.slice(link.indexOf('">')));
				//document.getElementById("try_it_on").innerHTML = '<a href="#">Try it on</a>';
				document.getElementById("try_it_on_link").innerHTML = link.slice(0,link.indexOf("vid")+4) + svid + link.slice(link.indexOf('">'));
				document.getElementById("try_it_on").style.display = "block";
			}
			else if (document.getElementById("try_it_on")) {
				document.getElementById("try_it_on").style.display = "none";
			}
			
			if (document.getElementById("add_sub_product") && isRxable > 0) {
				document.getElementById("add_sub_product").style.display = "block";
			}
			else if (document.getElementById("add_sub_product")) {
				document.getElementById("add_sub_product").style.display = "none";
			}

			var myAttribute = "";
			var attributeHTML = "";
			var myAttributeValue = "";
			for (i = 0; i < attributes.length; i++) {
				myAttribute = attributes.item(i).getElementsByTagName('name').item(0).firstChild.data;
				myAttributeValue = attributes.item(i).getElementsByTagName('value').item(0).firstChild.data;
				myAttributeType = attributes.item(i).getElementsByTagName('type').item(0).firstChild.data;
				if (myAttribute == 'Style Number') {
					document.getElementById("styleNumber").innerHTML = myAttributeValue;
				}
				if (myAttributeType == 'image') {
					myAttributeValue = '<a class="size_chart" href="/imageViewer.cfm?i=/images/catalog/live/attribute/'+myAttributeValue+'" onclick="window.open(this.href,\'imager\',\'resizable=1,width=680,height=550\'); return false;" target="_blank">View</a>';
				}
				attributeHTML = attributeHTML + "<li><span><strong>" + myAttribute + ":</strong> " + myAttributeValue + "</span></li>";

			}
			if (document.getElementById("attributes"))
				document.getElementById("attributes").innerHTML = attributeHTML;
		
		if(enabledQtyDiscount)
		{
			var myQty = "";
			var myPrice = "";
			var qtyDiscountHTML = "";

			for (i = 0; i < qtyDiscount.length; i++) {
				myQty = qtyDiscount.item(i).getElementsByTagName('qty').item(0).firstChild.data;
				myPrice = qtyDiscount.item(i).getElementsByTagName('price').item(0).firstChild.data;
				qtyDiscountHTML = qtyDiscountHTML + "<tr><td><strong>Buy at least " + myQty + ":</strong></td><td>" + currency(myPrice) + "</td></tr>";
			}
			if (document.getElementById("qtyDiscount"))
				document.getElementById("qtyDiscount").innerHTML = '<table class="qtyDiscount">' + qtyDiscountHTML + '</table>';
		}
		if (document.getElementById("idAddToCart")) {
			var addToCartButt = document.getElementById("idAddToCart");
			addToCartButt.disabled = false;
		}
		if(enabledInventory && enabledEcommerce)
		{			
			if (document.getElementById("stock_div")) {
				if (inventory < 1) {
					//***alert('This color/size option is out of stock.');
					document.getElementById("stock_div").innerHTML = '<p class="stock_text">Out of Stock</p><p><a href="javascript:void(0)" class="stock_link" onclick="openPopUp(\'' + baseURL + 'a/popup.notifyStock.show/vid/' + vid + '\',' + popUpStandardWindowWidth + ',' + popUpStandardWindowHeight + ')" onkeypress="openPopUp(\'' + baseURL + 'a/popup.notifyStock.show/vid/' + vid + '\',' + popUpStandardWindowWidth + ',' + popUpStandardWindowHeight + ')">Notify me when this product becomes available</a></p>';
					if(document.getElementById("qtyboxdiv"))
						document.getElementById("qtyboxdiv").style.display = 'none';

				} 
				else
				{
					document.getElementById("stock_div").innerHTML = '';
					if(document.getElementById("qtyboxdiv"))
						document.getElementById("qtyboxdiv").style.display = 'block';
				}
			}
			
			if(!callForPricing)
			{
				if (document.getElementById("add_to_cart_div")) {
					if (inventory < 1)
						document.getElementById("add_to_cart_div").style.display = 'none';
					else
						document.getElementById("add_to_cart_div").style.display = 'block';
				}
			}
			
			if(document.getElementById("availability"))
			{
				document.getElementById("availability").style.display = 'block';
				if(document.getElementById("avail_time"))
					document.getElementById("avail_time").innerHTML = availabilityTime;
			}
		}
		else
		{		
			if (inventory < 1) {
				//***alert('This product option is not available.');
				if (document.getElementById("stock_div"))
					document.getElementById("stock_div").innerHTML = '<p class="stock_text">Unavailable</p>';
				if (document.getElementById("add_to_cart_div"))
					document.getElementById("add_to_cart_div").style.display = 'none';
				if(document.getElementById("qtyboxdiv"))
					document.getElementById("qtyboxdiv").style.display = 'none';
				// hiding "Quantity: field
				if (document.getElementById('productQty')) {
					document.getElementById("productQty").style.display = 'none';
				}
			
			}
			else {
				if (document.getElementById("stock_div"))
					document.getElementById("stock_div").innerHTML = '';

				if (document.getElementById("add_to_cart_div"))
					document.getElementById("add_to_cart_div").style.display = 'block';
				
				if(document.getElementById("qtyboxdiv"))
					document.getElementById("qtyboxdiv").style.display = 'block';	
			}
			
			if(document.getElementById("availability"))
				document.getElementById("availability").style.display = 'none';
				
		}

        } else {
        	return notAvailable();
        }
    }
}

function processContentsRingBuilder(http_request, idVariationRing, idVariationDiam)
{
    if (http_request.readyState == 4) {
        if (http_request.status == 200) {
            var xmldoc = http_request.responseXML;
            if (xmldoc.parseError && xmldoc.parseError.errorCode != 0) {
  				var myErr = xmldoc.parseError;
   				alert("You have error " + myErr.reason);
			}
			if (!xmldoc.getElementsByTagName('properties').item(0)) {
				return notAvailable();
			}
				
			var idVariation;
			var nameRing;
			var skuRing;
			var metalRing;
			var prongRing;
			var finishRing;
			var weightRing;
			var shapeDiam;
			var clarityDiam;
			var sidestonesRing;
			var approximateWeightRing;
			var weightDiam;
			var priceRing;
			var t2ImgRing;
			var t3ImgRing;
			var largeImgRing;
			var typeRing;
			var imgClass;
			
			if(xmldoc.getElementsByTagName('idVariation').item(0).hasChildNodes()) 
				idVariation = xmldoc.getElementsByTagName('idVariation').item(0).firstChild.data;

			if(xmldoc.getElementsByTagName('nameRing').item(0).hasChildNodes()) 
				nameRing = xmldoc.getElementsByTagName('nameRing').item(0).firstChild.data;
				
			if(xmldoc.getElementsByTagName('skuRing').item(0).hasChildNodes())
				skuRing = xmldoc.getElementsByTagName('skuRing').item(0).firstChild.data;
				
			if(xmldoc.getElementsByTagName('metalRing').item(0).hasChildNodes())
				metalRing = xmldoc.getElementsByTagName('metalRing').item(0).firstChild.data;
				
			if(xmldoc.getElementsByTagName('prongRing').item(0).hasChildNodes())	
				prongRing = xmldoc.getElementsByTagName('prongRing').item(0).firstChild.data;
				
			if(xmldoc.getElementsByTagName('finishRing').item(0).hasChildNodes())	
				finishRing = xmldoc.getElementsByTagName('finishRing').item(0).firstChild.data;
				
			if(xmldoc.getElementsByTagName('weightRing').item(0).hasChildNodes())
				weightRing = xmldoc.getElementsByTagName('weightRing').item(0).firstChild.data;
			
			if(xmldoc.getElementsByTagName('shapeDiam').item(0).hasChildNodes())
				shapeDiam = xmldoc.getElementsByTagName('shapeDiam').item(0).firstChild.data;
			
			if(xmldoc.getElementsByTagName('clarityDiam').item(0).hasChildNodes())
				clarityDiam = xmldoc.getElementsByTagName('clarityDiam').item(0).firstChild.data;
				
			if(xmldoc.getElementsByTagName('sidestonesRing').item(0).hasChildNodes())
				sidestonesRing = xmldoc.getElementsByTagName('sidestonesRing').item(0).firstChild.data;	
			
			if(xmldoc.getElementsByTagName('approximateWeightRing').item(0).hasChildNodes())
				approximateWeightRing = xmldoc.getElementsByTagName('approximateWeightRing').item(0).firstChild.data;
			
			if(xmldoc.getElementsByTagName('weightDiam').item(0).hasChildNodes())
				weightDiam= xmldoc.getElementsByTagName('weightDiam').item(0).firstChild.data;
				
			if(xmldoc.getElementsByTagName('priceRing').item(0).hasChildNodes())
				priceRing= xmldoc.getElementsByTagName('priceRing').item(0).firstChild.data;
				
			if(xmldoc.getElementsByTagName('t2ImgRing').item(0).hasChildNodes())
				t2ImgRing= xmldoc.getElementsByTagName('t2ImgRing').item(0).firstChild.data;
				
			if(xmldoc.getElementsByTagName('t3ImgRing').item(0).hasChildNodes())
				t3ImgRing= xmldoc.getElementsByTagName('t3ImgRing').item(0).firstChild.data;
		
			if(xmldoc.getElementsByTagName('typeRing').item(0).hasChildNodes())
				typeRing= xmldoc.getElementsByTagName('typeRing').item(0).firstChild.data;
				
			if(xmldoc.getElementsByTagName('imgClass').item(0).hasChildNodes())
				imgClass= xmldoc.getElementsByTagName('imgClass').item(0).firstChild.data;			
			
			if(document.getElementById("ringDetails"))
				document.getElementById("ringDetails").className = 'showRingDetails';
				
			if(document.getElementById("skuRing") && !(skuRing == undefined))
				document.getElementById("skuRing").innerHTML = skuRing;
			
			if(document.getElementById("metalRing")&& !(metalRing == undefined))
				document.getElementById("metalRing").innerHTML = metalRing;
			
			//if(document.getElementById("metalRingHeader")&& !(metalRing == undefined))
			//	document.getElementById("metalRingHeader").innerHTML = metalRing;
				
			if(document.getElementById("prongRing") && !(prongRing == undefined))
				document.getElementById("prongRing").innerHTML = prongRing;
			
			if(document.getElementById("finishRing") && !(finishRing == undefined))
				document.getElementById("finishRing").innerHTML = finishRing;
				
			if(document.getElementById("weightRing") && !(weightRing == undefined))
				document.getElementById("weightRing").innerHTML = weightRing;
								
			if(document.getElementById("shapeDiam") && !(shapeDiam == undefined))
				document.getElementById("shapeDiam").innerHTML = shapeDiam;
				
			//if(document.getElementById("shapeDiamHeader") && !(shapeDiam == undefined))
			//	document.getElementById("shapeDiamHeader").innerHTML = shapeDiam;
				
			if(document.getElementById("clarityDiam") && !(clarityDiam == undefined))
				document.getElementById("clarityDiam").innerHTML = clarityDiam;
			
			if(document.getElementById("sidestonesRing") && !(sidestonesRing == undefined))
				document.getElementById("sidestonesRing").innerHTML = sidestonesRing;	
			
			if(document.getElementById("approximateWeightRing") && !(approximateWeightRing == undefined))
				document.getElementById("approximateWeightRing").innerHTML = approximateWeightRing;
			
			if(document.getElementById("weightDiam") && !(weightDiam == undefined))
				document.getElementById("weightDiam").innerHTML = weightDiam;
				
			if(document.getElementById("priceRing") && !(priceRing == undefined))
				document.getElementById("priceRing").innerHTML = priceRing;		
			
			if(document.getElementById("t2ImgRing") && !(t2ImgRing == '')) 
				document.getElementById("t2ImgRing").src = t2ImgRing;
				
			if(document.getElementById("t3ImgRing") && !(t3ImgRing == '')) 
				document.getElementById("t3ImgRing").href = t3ImgRing;	
			
			if(document.getElementById("idRingVariation") && !(idVariation == undefined))
				document.getElementById("idRingVariation").value = idVariation;

			if(document.getElementById("typeRing") && !(typeRing == undefined))
				document.getElementById("typeRing").innerHTML= typeRing;
			
			if(document.getElementById("imgClass") && !(imgClass == undefined))
				document.getElementById("imgClass").className = imgClass;	
			
			if(document.getElementById("nameRing") && !(nameRing == undefined))
				document.getElementById("nameRing").innerHTML = nameRing;		
        }
    }
}

function TrimString(sInString) {
  sInString = sInString.replace( /^\s+/g, "" );// strip leading
  return sInString.replace( /\s+$/g, "" );// strip trailing
}

function updateVariation(vid, prodID, enabledInventory, enabledEcommerce, enabledQtyDiscount, callForPricing, ourPriceText, baseURL, popUpStandardWindowWidth, popUpStandardWindowHeight) 
{
	var myArray = document.forms['productForm'].attributeValueID;
	var myList = "";
	for (i = 0; i < myArray.length; i++) {
		myList = myList +  myArray[i].value + ",";
	}
		
	if (myList.search(/090909/) == -1) {
		makeRequest("/get.cfm?" + "vid=" + vid + "&attributeValueID=" + myList + "&ProdID=" + prodID, vid, enabledInventory, enabledEcommerce, enabledQtyDiscount, callForPricing, ourPriceText, baseURL, popUpStandardWindowWidth, popUpStandardWindowHeight);
	}
}

function updateVariationRingBuilder(idVariationRing, idVariationDiam) {
	makeRequestRingBuilder("/getRingBuilder.cfm?" + "idVariationRing=" + idVariationRing + "&idVariationDiam=" + idVariationDiam, idVariationRing, idVariationDiam);
}


function updateVariationNew(attributeID, attributeIDValue, vid, prodID, enabledInventory, enabledEcommerce, enabledQtyDiscount, callForPricing, ourPriceText, baseURL, popUpStandardWindowWidth, popUpStandardWindowHeight, enableSquareFeetPerPallet, squareFeetPerPallete, reload) 
{
   if (document.getElementById("idAddToCart")) {
	   var addToCartButt = document.getElementById("idAddToCart");
   	   addToCartButt.disabled = true;
   }
   
   if (reload == 0)
	//showLightbox();
	if (attributeIDValue == "")
		attributeIDValue = document.getElementById("idattr" + attributeID).value;
	
	if (typeof enableSquareFeetPerPallet == "undefined") 
		enableSquareFeetPerPallet = false;
  	
	if (typeof squareFeetPerPallete == "undefined")	
    	squareFeetPerPallete = 0;
		
	if (document.getElementById("hidden" + attributeID)) document.getElementById("hidden" + attributeID).value = attributeIDValue;
	if (document.getElementById("idattr" + attributeID)) document.getElementById("idattr" + attributeID).value = attributeIDValue;
	updateSwatches(attributeID,attributeIDValue);
	var myArray = document.forms['productForm'].attributeValueID;
	var myList = "";
	for (i = 0; i < myArray.length; i++) {
		myList = myList +  myArray[i].value + ",";
	}
	if (!myArray.length) {
		myList = myArray.value;
	}
	if (reload > 0) {
		if (document.getElementById("reload")) document.getElementById("reload").value = 1;
		document.forms['productForm'].submit();
	}
	else makeRequest("/get.cfm?" + "vid=" + vid + "&attributeValueID=" + myList + "&ProdID=" + prodID, vid, enabledInventory, enabledEcommerce, enabledQtyDiscount, callForPricing, ourPriceText, baseURL, popUpStandardWindowWidth, popUpStandardWindowHeight, enableSquareFeetPerPallet, squareFeetPerPallete);
	//hideLightbox();
	//var addToCartButt = document.getElementById("idAddToCart");
	//addToCartButt.removeAttribute("disabled");
}

function updateNoneVariationOption(attributeID, attributeValueID)
{
	if (attributeValueID == "")
		attributeValueID = document.getElementById("idattr" + attributeID).value;
	if (document.getElementById("hidden" + attributeID)) document.getElementById("hidden" + attributeID).value = attributeValueID;
	if (document.getElementById("idattr" + attributeID)) document.getElementById("idattr" + attributeID).value = attributeValueID;
	updateSwatches(attributeID,attributeValueID);
}

function updateSwatches(attributeID, attributeIDValue)
{
	var swatchArray = document.getElementsByName("swatchImage" + attributeID);
	var swatchNameArray = document.getElementsByName("swatchName" + attributeID.replace(/-/g,'_'));
	var swatchInfix = "";
	if (swatchArray.length) {
		swatchInfix = "image";
	}
	else {
		swatchArray = document.getElementsByName("swatchHex" + attributeID);
		if (swatchArray.length) swatchInfix = "hex";
	}
	var swatchList = "";
	for (i = 0; i < swatchArray.length; i++) {
		swatchList = swatchList + swatchArray[i].id + ",";
		if (swatchArray[i].id == "swatch" + attributeIDValue) {
			document.getElementById(swatchArray[i].id).className = "swatch_" + swatchInfix + " swatch_" + swatchInfix + "_active";
		}
		else {
			document.getElementById(swatchArray[i].id).className = "swatch_" + swatchInfix;
		}
		if (swatchNameArray[i].value == "swatchName" + attributeIDValue) {
			document.getElementById(swatchNameArray[i].value).className = "swatch_name_display swatch_name_display_active";
		}
		else {
			document.getElementById(swatchNameArray[i].value).className = "swatch_name_display";
		}
	}
}

function currency( num )
{
   var prefix = "$";
   var suffix = "";
   if ( num < 0 )
   {
       prefix = "($";
       suffix = ")";
       num = - num;
   }
       var temp = Math.round( num * 100.0 ); // convert to pennies!
       if ( temp < 10 ) return prefix + "0.0" + temp + suffix;
       if ( temp < 100 ) return prefix + "0." + temp + suffix;
       temp = prefix + temp; // convert to string!
       return temp.substring(0,temp.length-2) + "." + temp.substring(temp.length-2) + suffix;
}



