	var selectedsize = "";
	var selectedcolor = "";
	var selectedstyle = "";
	
	function setdefaults(){
		selectsize();
	}
		
	function cs_emptyList(list) { for (var i=list.options.length-1; i>1; i--) { list.options[i]=null; } }
	
	function stripToNumber(vIncoming){
		var x=0;
		var sbuffer = "";
		for(x=0;x<vIncoming.length;x++){
			if(!isNaN(vIncoming.substring(x,1))){
				sbuffer = sbuffer + vIncoming.substring(x,x+1);
			}
		}
		return sbuffer;
	}
	
	function selectSKU(){
		var i;
		var x;
		var spricebuffer="";
		var currprice = 0;
		var regprice = 0;
		var vqty = document.addtocart.Quantity.value;
		var bestprice =0;
		var aSKUPrices = new Array();
		var spdesc = "";
		var saleprice = 0;
		
		//alert("running select sku - selected size = " + selectedsize + ", selected color = " + selectedcolor);
		for(i=0;i<vSKUs.length;i++){
			if(vSKUs[i][2] == selectedsize && vSKUs[i][3] == selectedcolor){
				//document.getElementById("stocknumber").innerHTML = vSKUs[i][0];
				//alert(vSKUs[i][0]);
				document.addtocart.StockNumbers.value = vSKUs[i][0];
				
				if(!isNaN(vqty)){
				    vqty = vqty * 1;
				}else{
				    vqty = 1;
				}
				
				spricebuffer = "<TABLE CELLSPACING=0 CELLPADDING=7 WIDTH='688'><TR><TD CLASS=qtypriceheader COLSPAN=2><B>Quantity / Applies To</B></TD><TD CLASS=qtypriceheader ALIGN=RIGHT><B>Special Price</B></TD><TD CLASS=qtypriceheader ALIGN=RIGHT><B>In Cart*</B></TD></TR>";
				
				currprice = stripToNumber(vSKUs[i][4]) * 1;
				regprice = stripToNumber(vSKUs[i][7]) * 1;
				
				for(x=0;x<vSKUs[i][8].length;x++){
					if(vSKUs[i][8][x][0] > 1 && vSKUs[i][8][x][1] < regprice){
						//spricebuffer = spricebuffer + "<TR><TD CLASS='content' STYLE='border-top:1px dotted #cccccc;'>Qty " + vSKUs[i][8][x][0] + "+</TD><TD CLASS=content ALIGN=RIGHT STYLE='border-top:1px dotted #cccccc;padding-left:10px;'>" + formatAsCurrency(vSKUs[i][8][x][1]) + "</TD><TD CLASS=contentaccent ALIGN=LEFT STYLE='border-top:1px dotted #cccccc;padding-left:10px;'>" + Math.round((1 - (vSKUs[i][8][x][1] / regprice)) * 100) + "% Savings</TD></TR>";
					    if(vSKUs[i][8][x][2] == 2){
					        spdesc = "of any " + vSKUs[i][8][x][4];   
					    }else if(vSKUs[i][8][x][2] == 1){
					        spdesc = "of any mix of size/color combinations";  
					    }else{
					        spdesc = "of this size/color combination";
					    }
					    spricebuffer = spricebuffer + "<TR><TD CLASS=qtypricerow ALIGN=RIGHT>" + vSKUs[i][8][x][0] + "+</TD><TD CLASS=qtypricerow>" + spdesc + "</TD><TD CLASS=qtypricerow ALIGN=RIGHT>" + formatAsCurrency(vSKUs[i][8][x][1]) + "</TD><TD CLASS=qtypricerow ALIGN=RIGHT>" + (vSKUs[i][8][x][0] - vSKUs[i][8][x][3]) + "</TD></TR>";
					}
					if(vSKUs[i][8][x][3] <= vqty && (bestprice == 0 || vSKUs[i][8][x][1] < bestprice)){
					    bestprice = vSKUs[i][8][x][1];
					}
					if(vSKUs[i][8][x][3] == 1 && vSKUs[i][8][x][5] == 1 && (saleprice == 0 || vSKUs[i][8][x][1] < saleprice)){
					    saleprice = vSKUs[i][8][x][1];
					}
				}
				
				//alert(bestprice);
				
				spricebuffer = spricebuffer + "</TABLE>";	
				
				if(document.getElementById("content_quantity")){
				        document.getElementById("content_quantity").innerHTML = spricebuffer;
				}
				
				//set the retail price
				aSKUPrices[aSKUPrices.length] = new Array(stripToNumber(vSKUs[i][7]) * 1,0);
				
				//if there's a sale price, set that...
				if(saleprice > 0){
				    aSKUPrices[aSKUPrices.length] = new Array(saleprice,1);
				}
				//if the bestprice is different than the last price in the array, add that too...
				if(aSKUPrices[aSKUPrices.length -1][0] > bestprice){
				    aSKUPrices[aSKUPrices.length] = new Array(bestprice,0);   
				}
				
				renderPrices(aSKUPrices);
				
				break;
			}
		}
	}
	
	function renderPrices(aPrices){
	    var oTD;
	    var i=0;
	    
	    if(aPrices.length == 3){
	        
	        //setup the regular price cell
	        oTD = document.getElementById("Price_0_Description");
	        oTD.style.color = "#444444";
	        oTD.style.borderBottom = "1px dotted #cccccc";
	        oTD.innerHTML = "Regular Price";
	        
	        oTD = document.getElementById("Price_0_Price");
	        oTD.style.color = "#444444";
	        oTD.style.textDecoration = "line-through";
	        oTD.style.borderBottom = "1px dotted #cccccc";
	        oTD.innerHTML = formatAsCurrency(aPrices[0][0]);
	        
	        oTD = document.getElementById("Price_0_Savings");
	        oTD.style.color = "#444444";
	        oTD.style.borderBottom = "1px dotted #cccccc";
	        
	        //setup the sale price cells...
	        oTD = document.getElementById("Price_1_Description");
	        oTD.style.color = "#cc3300";
	        oTD.style.borderBottom = "1px dotted #cccccc";
	        oTD.innerHTML = "Sale Price";
	        
	        oTD = document.getElementById("Price_1_Price");
	        oTD.style.color = "#cc3300";
	        oTD.style.textDecoration = "line-through";
	        oTD.style.borderBottom = "1px dotted #cccccc";
	        oTD.innerHTML = formatAsCurrency(aPrices[1][0]);
	        
	        oTD = document.getElementById("Price_1_Savings");
	        oTD.style.color = "#cc3300";
	        oTD.style.borderBottom = "1px dotted #cccccc";
	        oTD.style.textDecoration = "line-through";
	        oTD.innerHTML = calculateSavings(aPrices[0][0],aPrices[1][0]) + "% Savings!";
	        
	        //setup the actual price cells...
	        oTD = document.getElementById("Price_2_Description");
	        oTD.style.color = "green";
	        oTD.innerHTML = "Your Price";
	        
	        oTD = document.getElementById("Price_2_Price");
	        oTD.style.color = "green";
	        oTD.innerHTML = formatAsCurrency(aPrices[2][0]) + "*";
	        
	        oTD = document.getElementById("Price_2_Savings");
	        oTD.style.color = "green";
	        oTD.innerHTML = calculateSavings(aPrices[0][0],aPrices[2][0]) + "% Savings!";
	        
	        document.getElementById("pricenote").style.display = "block";
	        
	    }else if(aPrices.length == 2){
	    
	        //setup the regular price cell
	        oTD = document.getElementById("Price_0_Description");
	        oTD.style.color = "#444444";
	        oTD.style.borderBottom = "1px dotted #cccccc";
	        oTD.innerHTML = "Regular Price";
	        
	        oTD = document.getElementById("Price_0_Price");
	        oTD.style.color = "#444444";
	        oTD.style.textDecoration = "line-through";
	        oTD.style.borderBottom = "1px dotted #cccccc";
	        oTD.innerHTML = formatAsCurrency(aPrices[0][0]);
	        
	        oTD = document.getElementById("Price_0_Savings");
	        oTD.style.color = "#444444";
	        oTD.style.borderBottom = "1px dotted #cccccc";
	        
	        //setup the sale price cells...
	        oTD = document.getElementById("Price_1_Description");
	        oTD.style.color = "green";
	        oTD.style.borderBottom = "";
	        oTD.innerHTML = "Sale Price";
	        
	        oTD = document.getElementById("Price_1_Price");
	        oTD.style.color = "green";
	        oTD.style.textDecoration = "";
	        oTD.style.borderBottom = "";
	        if(aPrices[1][1] == 1){
	            oTD.innerHTML = formatAsCurrency(aPrices[1][0]);
	            document.getElementById("pricenote").style.display = "none";
	        }else{
	            oTD.innerHTML = formatAsCurrency(aPrices[1][0]) + "*";
	            document.getElementById("pricenote").style.display = "block";
	        }
	        
	        oTD = document.getElementById("Price_1_Savings");
	        oTD.style.color = "green";
	        oTD.style.borderBottom = "";
	        oTD.style.textDecoration = "";
	        oTD.innerHTML = calculateSavings(aPrices[0][0],aPrices[1][0]) + "% Savings!";
	        
	        //setup the actual price cells...
	        oTD = document.getElementById("Price_2_Description");
	        oTD.style.color = "green";
	        oTD.innerHTML = "";
	        
	        oTD = document.getElementById("Price_2_Price");
	        oTD.style.color = "green";
	        oTD.innerHTML = "";
	        
	        oTD = document.getElementById("Price_2_Savings");
	        oTD.style.color = "green";
	        oTD.innerHTML = "";
	        
	        
	        
	    }else{
	    
	        //setup the regular price cell
	        oTD = document.getElementById("Price_0_Description");
	        oTD.style.color = "green";
	        oTD.style.borderBottom = "";
	        oTD.innerHTML = "Your Price";
	        
	        oTD = document.getElementById("Price_0_Price");
	        oTD.style.color = "green";
	        oTD.style.textDecoration = "";
	        oTD.style.borderBottom = "";
	        oTD.innerHTML = formatAsCurrency(aPrices[0][0]);
	        
	        oTD = document.getElementById("Price_0_Savings");
	        oTD.style.color = "green";
	        oTD.style.borderBottom = "";
	        
	        //setup the sale price cells...
	        oTD = document.getElementById("Price_1_Description");
	        oTD.style.color = "green";
	        oTD.style.borderBottom = "";
	        oTD.innerHTML = "";
	        
	        oTD = document.getElementById("Price_1_Price");
	        oTD.style.color = "green";
	        oTD.style.textDecoration = "";
	        oTD.style.borderBottom = "";
	        oTD.innerHTML = "";
	        
	        oTD = document.getElementById("Price_1_Savings");
	        oTD.style.color = "green";
	        oTD.style.borderBottom = "";
	        oTD.style.textDecoration = "";
	        oTD.innerHTML = "";
	        
	        //setup the actual price cells...
	        oTD = document.getElementById("Price_2_Description");
	        oTD.style.color = "green";
	        oTD.innerHTML = "";
	        
	        oTD = document.getElementById("Price_2_Price");
	        oTD.style.color = "green";
	        oTD.innerHTML = "";
	        
	        oTD = document.getElementById("Price_2_Savings");
	        oTD.style.color = "green";
	        oTD.innerHTML = "";
	        document.getElementById("pricenote").style.display = "none";
	    }
	}
	
	function calculateSavings(bigprice,littleprice){
	    var dsavings = Math.round(((bigprice - littleprice) / bigprice) * 100,0);
	    return dsavings;
	}
	
	function selectsize(){
		//alert("executing selectsize");
		if(document.addtocart.Sizes.selectedIndex > -1){
			selectedsize = document.addtocart.Sizes[document.addtocart.Sizes.selectedIndex].value;
		}
		
		if(selectedsize != ""){
			//alert("selected size reports typeof color control = " + typeof(document.addtocart.Colors));
			if (typeof(document.addtocart.Colors)!="undefined"){
				listcolors();
			}else{
				if (typeof(document.addtocart.Styles)!="undefined"){
					liststyles();
				}else{
					selectSKU();
				}
			}
		}
	}
	
	function selectcolor(){
		//alert("executing selectcolor");
		if(document.addtocart.Colors.selectedIndex > -1){
			selectedcolor = document.addtocart.Colors[document.addtocart.Colors.selectedIndex].value;
		}
		//alert("select color reports selectedcolor = '" + selectedcolor + "'");
		if(selectedcolor != ""){
			if (typeof(document.addtocart.Styles)!="undefined"){
				liststyles();
			}else{
				selectSKU();
			}
		}
	}
	
	function listcolors(){
		var iCount = 1;
		
		//alert("executing listcolors");
		if(document.addtocart.Colors.selectedIndex > -1){
			selectedcolor = document.addtocart.Colors[document.addtocart.Colors.selectedIndex].value;
		}
		
		if(vColors.length > 0){
			cs_emptyList(document.addtocart.Colors);
			for(i=0;i<vColors.length;i++){
				//alert("listcolors: checking color " + vColors[i]);
				for(x=0;x<vSKUs.length;x++){
					//alert("checking SKU[" + x + "] (Size = " + vSKUs[x][2] + ", Color = " + vSKUs[x][3] + ") against selected size '" + selectedsize + ", color " + vColors[i]);
					if(vSKUs[x][2] == selectedsize && vSKUs[x][3] == vColors[i]){
						//alert("match found - color " + vColors[i]);
						if(vSKUs[x][5] == 1){
							document.addtocart.Colors.options[iCount]=new Option(vColors[i] + " (SALE! " + vSKUs[x][6] + "% OFF!)",vColors[i]);
						}else{
							document.addtocart.Colors.options[iCount]=new Option(vColors[i],vColors[i]);
						}
						iCount++;
						break;
					}
				}
			}
		}
		
		if(selectedcolor != ""){
			for(i=0;i<document.addtocart.Colors.length;i++){
				if(document.addtocart.Colors[i].value == selectedcolor){
					document.addtocart.Colors[i].selected = true;
					selectSKU();
					break;
				}
			}
		}
	}
	
	function selectstyle(){
		alert("executing selectstyle");
		if(document.addtocart.Styles.selectedIndex > -1){
			selectedstyle = document.addtocart.Styles[document.addtocart.Styles.selectedIndex].value;
		}
		
		if(selectedstyle != ""){
			selectSKU();
		}
	}
	
	function liststyles(){
		alert("executing liststyles");
		if(document.addtocart.Styles.selectedIndex > -1){
			selectedstyle = document.addtocart.Styles[document.addtocart.Styles.selectedIndex].value;
		}
		
		if(vStyles.length > 0){
			cs_emptyList(document.addtocart.Styles);
			for(i=0;i<vStyles.length;i++){
				document.addtocart.Styles.options[i]=new Option(vStyles[i],vStyles[i]);
			}
		}
		
		if(selectedstyle != ""){
			for(i=0;i<document.addtocart.Styles.length;i++){
				if(document.addtocart.Styles[i].value == selectedstyle){
					document.addtocart.Styles[i].selected = true;
					selectSKU();
					break;
				}
			}
		}
	}
	
	
	function submitform(){
		var stocknos;
		var astocknos;
		var sbuffer = new Array();
		var bsuccess = true;
		var oselect;
		var sMessage = "";
		
		if (typeof(document.addtocart.Sizes)!="undefined"){
			//check for valid value
			oselect = document.addtocart.Sizes;
			for(i=0;i<oselect.length;i++){
				if(oselect[i].selected){
					if(oselect[i].value == ""){
						bsuccess = false;
						sbuffer[sbuffer.length] = "SIZE";
					}
					break;
				}
			}
		}
		
		if (typeof(document.addtocart.Colors)!="undefined"){
			//check for valid value
			oselect = document.addtocart.Colors;
			for(i=0;i<oselect.length;i++){
				if(oselect[i].selected){
					if(oselect[i].value == ""){
						bsuccess = false;
						sbuffer[sbuffer.length] = "COLOR";
					}
					break;
				}
			}
		}
		
		if (typeof(document.addtocart.Styles)!="undefined"){
			//check for valid value
			oselect = document.addtocart.Styles;
			for(i=0;i<oselect.length;i++){
				if(oselect[i].selected){
					if(oselect[i].value == ""){
						bsuccess = false;
						sbuffer[sbuffer.length] = "STYLE";
					}
					break;
				}
			}
		}
		
		if(isNaN(document.addtocart.Quantity.value) || document.addtocart.Quantity.value == ""){
			bsuccess = false;
			sbuffer[sbuffer.length] = "QUANTITY";
		}else{
			//alert("quantity = " + document.addtocart.Quantity.value);
		}
		
		//alert(sbuffer);
		if(bsuccess){
			document.addtocart.Quantities.value = document.addtocart.Quantity.value;
			//document.addtocart.submit();
			callAddToCart(document.addtocart.ProductID.value,document.addtocart.StockNumbers.value,document.addtocart.Quantity.value);
		}else{
			for(i=0;i<sbuffer.length;i++){
				if(i == 0){
					sMessage = sbuffer[i];
				}else{
					if(i == (sbuffer.length -1)){
						sMessage = sMessage + ", and " + sbuffer[i];
					}else{
						sMessage = sMessage + ", " + sbuffer[i];
					}
				}
			}
			alert("If you wish to purchase this item, you must select a valid " + sMessage + " before pressing the 'Add To Cart' button.  Please check your selections and try again.");
		}
	}
	
	function formatAsCurrency(vNumber){
		var vValue = vNumber.toString();
		var vDecimal = vValue.indexOf(".");
		var vLength = vValue.length;
		
		if(vDecimal > 0){
			if((vLength - vDecimal) == 2){
				//only one char after decimal
				vValue = vValue + "0";
			}else{
				if((vLength - vDecimal) == 1){
					//no chars after decimal
					vValue = vValue + "00";
				}
			}
		}else{
			//need to add decimal and 2 zeros
			vValue = vValue + ".00"
		}
		vValue = "$" + vValue;
		return vValue;
	}


	function OpenWindow(UrlToOpen,Width,Height){
		window.open(UrlToOpen,"imagewindow","toolbar=no,location=no,directories=no,status=no,menubar=no,width=" + Width + ",height=" + Height + ",scrollbars=yes,resizable=yes");
	}
	
	function callAddToCart(productid,stocknumber,quantity){
		document.getElementById("cartstatus").innerHTML = "<TABLE CELLSPACING=0 CELLPADDING=10 BGCOLOR='#f5f5f5' STYLE='border:1px dotted #cccccc;' WIDTH='100%'><TR><TD><IMG SRC='" + sImageURL + "/Cart_Loading.gif'></TD><TD CLASS='content'><FONT STYLE='font-size:12pt;color:#444444;'><B>Adding to cart...please wait...</B></FONT></TD></TR></TABLE>"
		document.getElementById("cartstatus").style.display = "block";
		document.getElementById("purchaseoptions").style.display = "none";
		
		if(document.addtocart.Sizes){document.addtocart.Sizes.disabled = true;}
		if(document.addtocart.Colors){document.addtocart.Colors.disabled = true;}
		if(document.addtocart.Styles){document.addtocart.Styles.disabled = true;}
		
		oncartrefresh="updateCartStatus()";
		queueAjaxRequest(sRootURL + "/ajax_AddToCart.asp", "EntityType=MultipleSKUs&ProductID=" + productid + "&StockNumbers=" + stocknumber + "&Quantities=" + quantity, processRefreshCart, "txt")
	}

	function updateCartStatus(){
	    var i = 0;
	    var x = 0;
	    var vqty = document.addtocart.Quantities.value * 1;
	    var stocknumber = document.addtocart.StockNumbers.value;
	    
		//update cart status to show item added to cart...
		document.getElementById("cartstatus").innerHTML = "<TABLE CELLSPACING=0 CELLPADDING=10 BGCOLOR='#f5f5f5' STYLE='border:1px dotted #cccccc;' WIDTH='100%'><TR><TD><IMG SRC='" + sImageURL + "/Cart_Success.gif'></TD><TD CLASS='content'><FONT STYLE='font-size:12pt;color:#cc3300;'><B>Item added successfully!</B></FONT><P><A HREF='javascript:hideCartStatus();'><u>Add Another of This Item</u></A>&nbsp;&nbsp;&bull;&nbsp&nbsp;<A HREF='" + sRootURL + "/ShoppingCart.asp'><u>Go to your Shopping Cart</u></A>&nbsp;&nbsp;&bull;&nbsp&nbsp;<A HREF='" + sRootSSL + "/Checkout.asp'><u>Checkout Now</u></A></TD></TR></TABLE>";
		
		//update sku price data to reflect current cart contents...
		for(i=0;i<vSKUs.length;i++){
		    for(x=0;x<vSKUs[i][8].length;x++){
		        //1 = price
		        //2 = sku scope
		        //3 = quantity required
		        
		        //if it's a quantity price and either the stocknumber just added = current, or the skuscope of the price allows any
		        if(vSKUs[i][8][x][0] > 1 && (stocknumber == vSKUs[i][0] || vSKUs[i][8][x][2] > 0)){
		            //update the minimum required quantity, subtracting the quantity just added
		            vSKUs[i][8][x][3] = vSKUs[i][8][x][3] - vqty;
		        }
		    }   
		}
		selectSKU();
		
		if(document.addtocart.Sizes){document.addtocart.Sizes.disabled = false;}
		if(document.addtocart.Colors){document.addtocart.Colors.disabled = false;}
		if(document.addtocart.Styles){document.addtocart.Styles.disabled = false;}
		
		setTimeout("hideCartStatus()",5000)
	}

	function hideCartStatus(){
		document.getElementById("cartstatus").style.display = "none";
		document.getElementById("purchaseoptions").style.display = "block";
	}

	function setFeaturedImage(vImageToSet){
		document.getElementById("featuredimage").src = sImageURL + "/products/" + vImageToSet + "_FS.jpg";
		vCurrentImage = vImageToSet;
	}
			
	function zoomFeaturedImage(){
		OpenWindow(sImageURL + "/products/" + vCurrentImage + ".jpg",500,500);
	}
	
	
	//product purchase options tab management
    var lasttabid = "purchase";
    
    function tabmo(oImg){
        var vsrc = "";
        var iext = 0;
        
        vsrc = oImg.src;
        iext = vsrc.lastIndexOf('_');
        vsrc = vsrc.substr(0,iext);
        vsrc = vsrc + "_active.gif";
        oImg.src = vsrc
        
    }
    
    function tabmout(oImg){
        var vsrc = "";
        var iext = 0;
        
        if(lasttabid != oImg.id){
            vsrc = oImg.src;
            iext = vsrc.lastIndexOf('_');
            vsrc = vsrc.substr(0,iext);
            oImg.src = vsrc + "_gray.gif";
        }
    }
    
    function setTabContent(tabid){
        var sbuffer = "";
        var index = "";
        
        //hide the last content tab
        document.getElementById("content_" + lasttabid).style.display = "none";
        
        //set the display of the last active tab to gray
        sbuffer = document.getElementById(lasttabid).src;
        index = sbuffer.lastIndexOf('_');
        sbuffer = sbuffer.substr(0,index);
        document.getElementById(lasttabid).src = sbuffer + "_gray.gif";
        
        lasttabid = tabid
        
        //show this content
        document.getElementById("content_" + tabid).style.display = "block";
        
        //set tab to selected
        sbuffer = document.getElementById(lasttabid).src;
        index = sbuffer.lastIndexOf('_');
        sbuffer = sbuffer.substr(0,index);
        document.getElementById(lasttabid).src = sbuffer + "_active.gif";
            
    }


//size chart display...
function showSizeChart(vscid){
	var i;
	var sc;
	var scl;
	
	for(i=0;i<10;i++){
		if(document.getElementById("sc_" + i)){
			sc = document.getElementById("sc_" + i);
			scl = document.getElementById("scl_" + i);
			if(i == vscid){
				sc.style.display = "block";
				scl.className = "scMenuSel";
			}else{
				sc.style.display = "none";
				scl.className = "scMenu";
			}
		}else{
			break;
		}
	}
}