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);
    // blocking form's submit until AJAX transaction is complete
    startUpdate();

}

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 startUpdate() {
	if (document.forms.productForm) {
		var fx = document.forms.productForm;
	//	fx.action = 'javascript:blockSubmit()';
	}
}

function endUpdate() {
	if (document.forms.productForm) {
		var fx = document.forms.productForm;
	//	fx.action = '/index.cfm/';
	}
}

function blockSubmit() {
	alert ('Please wait a while until your changes are applied.');
}

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 shortDescription = (xmldoc.getElementsByTagName('shortDescription').item(0).firstChild) ? xmldoc.getElementsByTagName('shortDescription').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;
			// formatted prices
			var fListPrice = xmldoc.getElementsByTagName('fListPrice').item(0).firstChild.data;
			var fSalePrice = xmldoc.getElementsByTagName('fSalePrice').item(0).firstChild.data;
			var fRegularPrice = xmldoc.getElementsByTagName('fRegularPrice').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 sellOutOfStock = xmldoc.getElementsByTagName('sellOutOfStock').item(0).firstChild.data;
			var reorderTime = xmldoc.getElementsByTagName('reorderTime').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 highestPrice=listPrice; //normally this is highest
			var lowestPrice=regularPrice; //normally this is lowest
			
			
			var discountCalcActive = (xmldoc.getElementsByTagName('discountRanges')).length;
			var discountRanges = xmldoc.getElementsByTagName('dRange');
			
			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;
			//bug 5465, updated 2 lines:
			if (document.getElementById('prod_pg_title'))
				document.getElementById('prod_pg_title').innerHTML = 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;
			}
			
			if (document.getElementById("shortDescription")){
				document.getElementById("shortDescription").innerHTML = shortDescription;
			}
			//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 && document.getElementById("percentDiscountLabel") && document.getElementById("percentDiscount")) 
			{
				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);	
				if (document.getElementById("listPriceLabel"))
					document.getElementById("listPriceLabel").style.display = "block";
				if (document.getElementById("listPrice"))
					document.getElementById("listPrice").style.display = "block";
			}
			else
			{
				if (document.getElementById("listPriceLabel"))
					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 + ":";
				if (document.getElementById("salePriceLabelOut"))
					document.getElementById("salePriceLabelOut").style.display = "block";
				if (document.getElementById("salePrice"))
					document.getElementById("salePrice").style.display = "block";
				if (document.getElementById("oldregularPriceLabel"))
					document.getElementById("oldregularPriceLabel").style.display = "block";
				if (document.getElementById("oldregularPrice"))
					document.getElementById("oldregularPrice").style.display = "block";
				if (document.getElementById("regularPriceLabel"))
					document.getElementById("regularPriceLabel").style.display = "none";
				if (document.getElementById("regularPrice"))
					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 = fListPrice; // listpricetxt;
			if (document.getElementById("regularPriceLabel"))
				document.getElementById("regularPriceLabel").innerHTML = reglabel;
			if (document.getElementById("regularPrice"))
				document.getElementById("regularPrice").innerHTML = fRegularPrice; //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 = fRegularPrice; //oldregpricetxt ;

			if (document.getElementById("salePriceLabelOut"))
				document.getElementById("salePriceLabelOut").innerHTML = salepricelabel;
			if (document.getElementById("salePrice"))
				document.getElementById("salePrice").innerHTML = fSalePrice; // 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";
			}
			
			var myAttribute = "";
			var attributeHTML = "";
			var myAttributeValue = "";
			for (i = 0; i < attributes.length; i++) {
				if (attributes.item(i).getElementsByTagName('name').item(0).firstChild != null)
				{
					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 class="+(i%2 ? 'color-2' : 'color-1')+"><span><strong>" + myAttribute + ":</strong> " + myAttributeValue + "</span></li>";
				}
			}
			if (attributes.length == 0) {
				attributeHTML = '<p>No features available</p>';
			}
			if (document.getElementById("attributes_tab")) {
				document.getElementById("attributes_tab").innerHTML = attributeHTML;
			} else 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';
					if (document.getElementById('productQty'))
						document.getElementById("productQty").style.display = 'none';

				} 
				else
				{
					document.getElementById("stock_div").innerHTML = '';
					if(document.getElementById("qtyboxdiv"))
						document.getElementById("qtyboxdiv").style.display = 'block';
					if (document.getElementById('productQty'))
						document.getElementById("productQty").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")) {
					if (sellOutOfStock == 1) {
						var reorderString = reorderTime + ' day';
						if (reorderTime > 1)
							reorderString += 's';
						document.getElementById("avail_time").innerHTML = reorderString;
					} else {
						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';
				
		}
		// custom function call (for site-specific AJAX processing)
		if (typeof customAJAXfunction=="function") {
			customAJAXfunction(xmldoc); // that's all we need here!
		}
		endUpdate();	
        } else {
        	return notAvailable();
        }
        
        //only if DISCOUNT CALCULATOR plugin is on
        if (discountCalcActive > 0 ){
        	var discountRangesHTML = "";
        	if (discountRanges.length > 0){
        		for (i = 0; i < discountRanges.length; i++) {
					rFrom = discountRanges.item(i).getElementsByTagName('rFrom').item(0).firstChild.data;
					rTo = discountRanges.item(i).getElementsByTagName('rTo').item(0).firstChild.data;
					rPrice = discountRanges.item(i).getElementsByTagName('rPrice').item(0).firstChild.data;
					discountRangesHTML = discountRangesHTML + "<dd>"+rFrom+" - "+rTo+"</dd><dt>"+currency(rPrice)+"</dt>" ;
				}
				document.getElementById("ranges_list").innerHTML = discountRangesHTML;
        		document.getElementById("discount_calculator").style.display = 'block';
        	}else{
        		document.getElementById("discount_calculator").style.display = 'none';
        	}
        }
        
    } // IF ends
}

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(xmldoc.getElementsByTagName('inventory').item(0).hasChildNodes())
				inventory= xmldoc.getElementsByTagName('inventory').item(0).firstChild.data;			
			
			if(xmldoc.getElementsByTagName('callForPrice').item(0).hasChildNodes())
				callForPrice= xmldoc.getElementsByTagName('callForPrice').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(callForPrice==0){			
				if (document.getElementById("ring_btn_select_this_setting")) {
					if (inventory < 1){
						document.getElementById("ring_btn_select_this_setting").style.display = "none";
						document.getElementById("priceRing").innerHTML = "Out of Stock";
						document.getElementById("priceRing").className = "stock_text";
					} else {
						document.getElementById("ring_btn_select_this_setting").style.display = "block";
						document.getElementById("priceRing").innerHTML = "Price: $" + priceRing;
						document.getElementById("priceRing").className = "";
					}	
				}
			} else {
				document.getElementById("ring_btn_select_this_setting").style.display = "none";
				document.getElementById("priceRing").innerHTML = "Call For Price";
				document.getElementById("priceRing").className = "call_for_price";
			}
			
			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 buildList() {
	var elements = document.getElementsByTagName('input');
	var myList = '';
	for (var i = 0; i < elements.length; i++) {
		if (elements[i].name == 'attributeValueID') {
			myList += myList.length ? ',' + elements[i].value : elements[i].value;
		}
	}
	return myList;
}

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 = "";
	alert (myArray);
	if (myArray.value) {
		myList = myArray.value;
	} else if(myArray.length) {
		for (i = 0; i < myArray.length; i++) {
			myList = myList +  myArray[i].value + ",";
		}
	}*/
	var myList = buildList();
	
	
	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) {
	num = num.toString().replace(/\$|\,/g,'');
	if(isNaN(num))
		num = "0";
		sign = (num == (num = Math.abs(num)));
		num = Math.floor(num*100+0.50000000001);
		cents = num%100;
		num = Math.floor(num/100).toString();
		if(cents<10)
			cents = "0" + cents;
		for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
			num = num.substring(0,num.length-(4*i+3))+','+
		num.substring(num.length-(4*i+3));
		return (((sign)?'':'-') + '$' + num + '.' + cents);
}

function currency2( 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;
}