			function validateForm()
			{
				//get control counters
				var parentCount = document.form.parentCount.value;	//= i or the count of parent products on the page.  usually 1
				var childCount = document.form.childCount.value;	//= j or the count of child products on the page.
				//boolean to trap customer not setting at least one quantity > 0
				var bSelectedAtLeastOneQty = false;

				//loop thru the form
				for(i=1; i<=parseInt(parentCount); i++)			
				{
					for(j=1; j<=parseInt(childCount); j++)
					{
						var status = "ItemStatusType_" + i + j;
						oStatus = document.form.elements[status];
						if(oStatus)			//put here to allow multiple items on a quick order to work
						{
							if(oStatus.value != "K2")
							{
								var attrs = "nbrOfAttrs_" + i + j;
								oAttrs = document.form.elements[attrs];
								var nbrOfAttrs = parseInt(oAttrs.value);
								if(nbrOfAttrs == "")
								{
									nbrOfAttrs = 0;
								}
								var qty = "Quantity_" + i + j;
								oQty = document.form.elements[qty];
								
								// did the customer select a quantity?
								if(parseInt(oQty.value) > 0)
								{
									// yes she did... did she select all attributes?
									bSelectedAtLeastOneQty = true;
									// ok, loop thru the net values
								
									//check if a size ddl was selected
									var siz = "size_" + i + j;
									if(document.form.elements[siz])
									{
										oSize = document.form.elements[siz];
										if(oSize.type == "select-one")
										{
											if(oSize.value != "select")
											{
												nbrOfAttrs--;
											}
										}
									}
									
									//check if a color ddl was selected
									var clr = "color_" + i + j;
									if(document.form.elements[clr])
									{
										oClr = document.form.elements[clr];
										if(oClr.type == "select-one")
										{
											if(oClr.value != "select")
											{
												nbrOfAttrs--;
											}
										}
									}
									
									//now were all net values selected?
									if(nbrOfAttrs > 0)
									{
										window.alert("select all attributes that apply to the product you are purchasing");
										//set focus to the attribute corresponding to the non zero quantity
										var netVal = "size_" + i + j;
										oNetVal = document.form.elements[netVal];
										oNetVal.focus();
										//oNetVal.select();
										return false;
									}
								}
							}
							else	// is a K2 kit item
							{
								var childProduct = "product_" + i + j;
								oChildProduct = document.form.elements[childProduct];
								var compQty = "compQty_" + i + j;
								oCompQty = document.form.elements[compQty];
								var k2KitsComps = "k2KitsComps_" + oChildProduct.value;
								oK2KitsComps = document.form.elements[k2KitsComps];
								//have all attributes for the kit been selected?
								var k2Count = parseInt(oK2KitsComps.value);
								for(k=1; k<=parseInt(oK2KitsComps.value); k++)
								{
									//format of the name of the component drop down list is compItem_ijk
									var compItem = "compItem_" + oChildProduct.value + k;
									oCompItem = document.form.elements[compItem];
									if(oCompItem.value != "select")
									{
										k2Count--;
									}
								}
								//if k2Count != 0 and != oK2KitsComps.value, the customer started to select 
								// attributes but did not select all attributes
								if(k2Count != 0 && k2Count != parseInt(oK2KitsComps.value))
								{
										window.alert("select all attributes that apply to the product you are purchasing");
										//set focus to the attribute corresponding to the non zero quantity
										var compItem = "compItem_" + oChildProduct.value + "1";
										oCompItem = document.form.elements[compItem];
										oCompItem.focus();
										//oCompItem.select();
										return false;
								}
								else	//either all k2 attributes were selected or none were selected
								{
									//OK, IF the customer selected all applicable k2 kit attributes (k2Count==0)
									// is there a quantity field and did she enter a quantity?
									var qty = "Quantity_" + i + j;
									if(k2Count == 0 )
									{
										if(document.form.elements[qty])
										{
											oQty = document.form.elements[qty];
											if(parseInt(oQty.value) == 0)
											{
												window.alert("enter product quantity");
												oQty.focus();
												oQty.select();
												return false;
											}
											else
											{
												bSelectedAtLeastOneQty = true;
											}									
										}	//there is a quantity for the current product
										bSelectedAtLeastOneQty = true;
									}	//k2Count = 0
								}	//test of k2Count = 0 and != to oK2KitsComps.value
							}	//status = K2 kits
						}
						else	// oStatus does not exist
						{
							j = j + childCount
						}	// end if(oStatus)
					}	//childCount loop
				}	//parentCount loop
				
				if(!bSelectedAtLeastOneQty)
				{
					window.alert("select at least one product before clicking submit");
					return false;
				}
				
				CheckFreeItem = CheckFreeItemOK()
				//alert("CheckFreeItem=[" + CheckFreeItem + "]")
				if (!CheckFreeItem) return false;
			
				//window.alert("submit commented out");
				//document.form.submit();
				return true;
			}	//function end			
			
			
			function checkColor(ddl)
			{
				/*window.alert("color name = " + ddl.name);
				window.alert("color value = " + ddl.value);
				window.alert("selected index = " + ddl.selectedIndex);
				window.alert("color value by selected index = " + ddl.options[ddl.selectedIndex].text); */
				
				aWrk = ddl.name.split("_");
				var sSizeName = "size_"
				sSizeName = sSizeName + aWrk[1];
				
				
				document.form.selectedColors.value = document.form.selectedColors.value + sSizeName + "," + ddl.name + "," + ddl.selectedIndex + "~";

			}
			
			
			function chgQty(ddl)
			{
				sname = ddl.name;	//ddl = drop down list
				aWrk = sname.split("_")
				//is a non-kit being processed?
				// aWrk[0] = size
				// aWrk[1] = value of i and j
				if(aWrk[0] == "size")
				{

					fillColorsDDL(ddl);
					//non kit being processed
					var qty = "Quantity_" + aWrk[1];
					oQty = document.form.elements[qty];
					// yes
					if(ddl.value == "select")
					{
						oQty.selectedIndex = 0;
					}
					else
					{
						oQty.selectedIndex = 1;
					}
				}
				else
				{
					// aWrk[0] = compItem
					// aWrk[1] = value of i and j OR childProduct + k
					//name != "size" therefore current product is a k2 kit or a color
					if(aWrk[0] != "compItem")
					{
						var qty = "Quantity_" + aWrk[1];	//.substr(0,2);
					}
					else
					{
						compItem_IJ_name = aWrk[0] + "_IJ_" + aWrk[1];
						compItem_IJ_value = document.form.elements[compItem_IJ_name].value;
						var qty = "Quantity_" + compItem_IJ_value;	
					}
						if(document.form.elements[qty])
						{
							oQty = document.form.elements[qty];
							//there is a quantity field
							if(ddl.value == "select")
							{
								oQty.selectedIndex = 0;
							}
							else
							{
								oQty.selectedIndex = 1;
							}
						}	//testing for document containing a quantity field for the current product
				}	//testing ddl name for "net" = non-kit item
			}	//function end
			
			
	function reFillColorsDDL()
	{
		//window.alert(document.form.selectedColors.value);
		
		aSelectedColors = document.form.selectedColors.value.split("~");
		// [0]=size_ij name     [1]=color_ij name     [2]=color_ij selectedIndex
		
		for(x=0; x<aSelectedColors.length-1; x++)
		{
			aSingleColor = aSelectedColors[x].split(",");
			//set the size ddl object
			ddl = document.form.elements[aSingleColor[0]];
			//and refil the color ddl	
			fillColorsDDL(ddl);
			//now, set the ddl object to the color ddl
			ddl = document.form.elements[aSingleColor[1]];
			//and set the selected index
			ddl.selectedIndex = parseInt(aSingleColor[2]);
		}
		
	}			
			
	function fillColorsDDL(ddl)
	{
		try
		{
			if(ddl.value != "select")
			{
				if(ddl.value.indexOf("~")!= -1)
				{
					//size ddl value is a compound value
					ddlValue = ddl.value;
					aDDL = ddlValue.split("~");
					var colors = "colors_" + aDDL[0];				//make the name of the colors hidden field
					var colorsDDL = "colorsDDL_" + aDDL[0];		//make the name of the hidden field that holds the name of the color drop down
				}
				else
				{
					//size ddl value is ONLY child product number
					var colors = "colors_" + ddl.value;				//make the name of the colors hidden field
					var colorsDDL = "colorsDDL_" + ddl.value;		//make the name of the hidden field that holds the name of the color drop down
				}
				oColors = document.form.elements[colors];		//instance the object for the colors hidden field
				oColorsDDL = document.form.elements[colorsDDL]; //instance the object for the colors ddl name hidden field
				oDDL = document.form.elements[oColorsDDL.value];//instance the object for the colors ddl
				// split the colors into an array
				aColors = oColors.value.split("~");
				//sort the colors array ascending
				aColors.sort(sortAscending);
				//now load the color dropdown list
				if(oDDL.length <= aColors.length )
				{
					//there are less entries in the ddl than there are in the colors array...
					for(var c=0; c<aColors.length; c++)
					{
						var newOption = new Option(aColors[c]);
						//c+1 skips over the "select" option
						oDDL.options[c+1] = newOption;
						oDDL.options[c+1].value = aColors[c];
					}
				}
				else
				{
					//there are more entries in the ddl than there are in the colors array...
					for(var dd=1; dd<oDDL.length; dd++)
					{
						if(dd <= aColors.length)
						{
							var newOption = new Option(aColors[dd-1]);
							oDDL.options[dd] = newOption;
							oDDL.options[dd].value = aColors[dd-1];
						}
						else
						{
							// delete the excess ddl options
							for(d=oDDL.length; d>dd; d--)
							{
								oDDL.selectedIndex = d-1;
								oDDL.remove(oDDL.selectedIndex);
							}	//end for
						}	// endif (ddl <= aColors.length)
					}	// end for
				}	// endif(oDDL.length <= aColors.length )
				oDDL.selectedIndex = 0;
			}
			else	//ddl.value IS = to select
			{
				// delete the excess ddl options
				for(d=oDDL.length; d>1; d--)
				{
					oDDL.selectedIndex = d-1;
					oDDL.remove(oDDL.selectedIndex);
				}	//end for
				oDDL.selectedIndex = 0;
			}	//if(ddl.value != "select")
		}	//end try
		catch (problem)
		{
			//window.alert("unsuccessful");
		}	//end catch
	}	//function end
			
			
			
			
			
			
		function sortAscending( arg1, arg2) 
		{
			if (arg1 > arg2) {
			return 1 
			} else if ( arg1 < arg2 ) {
			return -1
			} else { return 0 }
		}
		
		function sortNumbers(arg1, arg2)
		{
			var lcarg1 = arg1.toLowerCase();
			var lcarg2 = arg2.toLowerCase();
	
			if(lcarg1.indexOf("xl twin") != -1)
			{
				arg1 = 1;
			}
			else if(lcarg1.indexOf("twin xl") != -1)
			{
				arg1 = 1;
			}
			else if(lcarg1.indexOf("twin extra long") != -1)
			{
				arg1 = 1;
			}
			else if(lcarg1.indexOf("extra lg twin") != -1)
			{
				arg1 = 1;
			}
			else if(lcarg1.indexOf("extra long twin") != -1)
			{
				arg1 = 1;
			}
			else if(lcarg1.indexOf("twin")!= -1)			
			{
				arg1 = 0;
			}			
			else if(lcarg1.indexOf("standard") != -1)
			{
				arg1 = 2;
			}
			else if(lcarg1.indexOf("full") != -1)
			{
				arg1 = 3;
			}
			else if(lcarg1.indexOf("queen") != -1)
			{
				arg1 = 4;
			}
			else if(lcarg1.indexOf("cal king") != -1)
			{
				arg1 = 6;
			}
			else if(lcarg1.indexOf("cal. king") != -1)
			{
				arg1 = 6;
			}
			else if(lcarg1.indexOf("king/calif. king") != -1)
			{
				arg1 = 6;
			}
			else if(lcarg1.indexOf("california king") != -1)
			{
				arg1 = 6;
			}
			else if(lcarg1.indexOf("king") != -1)
			{
				arg1 = 5;
			}
			else if(lcarg1.indexOf("wash") != 1)
			{
				arg1 = 10;
			}
			else if(lcarg1.indexOf("hand") != 1)
			{
				arg1 = 11;
			}
			else if(lcarg1.indexOf("sheet") != 1)
			{
				arg1 = 13;
			}
			else if(lcarg1.indexOf("bath") != 1)
			{
				arg1 = 12;
			}
			else
			{
				arg1 = 20;
			}
			if(lcarg2.indexOf("xl twin") != -1)
			{
				arg2 = 1;
			}
			else if(lcarg2.indexOf("twin xl") != -1)
			{
				arg2 = 1;
			}
			else if(lcarg2.indexOf("twin extra long") != -1)
			{
				arg2 = 1;
			}
			else if(lcarg2.indexOf("extra lg twin") != -1)
			{
				arg2 = 1;
			}
			else if(lcarg2.indexOf("extra long twin") != -1)
			{
				arg2 = 1;
			}
			else if(lcarg2.indexOf("twin") != -1)			
			{
				arg2 = 0;
			}			
			else if(lcarg2.indexOf("standard") != -1)
			{
				arg2 = 2;
			}
			else if(lcarg2.indexOf("full") != -1)
			{
				arg2 = 3;
			}
			else if(lcarg2.indexOf("queen") != -1)
			{
				arg2 = 4;
			}
			else if(lcarg2.indexOf("cal king") != -1)
			{
				arg2 = 6;
			}
			else if(lcarg2.indexOf("cal. king") != -1)
			{
				arg2 = 6;
			}
			else if(lcarg2.indexOf("king/calif. king") != -1)
			{
				arg2 = 6;
			}
			else if(lcarg2.indexOf("california king") != -1)
			{
				arg2 = 6;
			}
			else if(lcarg2.indexOf("king") != -1)
			{
				arg2 = 5;
			}
			else if(lcarg2.indexOf("wash") != 1)
			{
				arg2 = 10;
			}
			else if(lcarg2.indexOf("hand") != 1)
			{
				arg2 = 11;
			}
			else if(lcarg2.indexOf("sheet") != 1)
			{
				arg2 = 13;
			}
			else if(lcarg2.indexOf("bath") != 1)
			{
				arg2 = 12;
			}
			else
			{
				arg2 = 20;
			}
			
			return parseInt(arg1) - parseInt(arg2);		
		}		
		
		function ReturnSortedArray() 
		{		
			if(document.form.selectedColors.value.length > 0 )
			{
				reFillColorsDDL();
			}
			//go through form elements
			for(var x=0;x<document.form.length;x++)
			
			{	//check for dropdownlist 
				if(document.form.elements[x].type=="select-one")
				{	
					//window.alert(document.form.elements[x].name);
					//populate new array for sort function
					var SortArray = new Array(document.form.elements[x].length - 1)
					//window.alert(SortArray);
					//check if ddl is for color
					var objName = document.form.elements[x].id
					var oDDL = document.form.elements[x]
					var searchstring = "color"
					var result = objName.substring(objName.search(searchstring),searchstring.length)
					
					if( result == "color" || result == "compI" )
					{
						var y=0
						var bK2Set = false;
						if(result=="compI")
						{
							var k2Set = "k2Set_";
							aWrk = objName.split("_");
							k2Set = k2Set + aWrk[1];
							if(document.form.elements[k2Set])
							{
								//the k2Set indicator field exists therefore make bK2Set true
								bK2Set = true;
							}
						}
						for(var i=1;i<document.form.elements[x].length;i++)
						{						
							//SortArray[y] = document.form.product[i].value	
							if(result == "color")						
							{
								SortArray[y] = document.form.elements[x].options[i].value;
							}
							else
							{
								SortArray[y] = document.form.elements[x].options[i].text + "|" + document.form.elements[x].options[i].value;
							}
							y++
						}
						//window.alert(SortArray);
						SortArray.sort(sortAscending);
						//window.alert(SortArray);
						y=1		
						var sColor = "color";
						var sItems = "";	
						var k = 0;
						if(bK2Set)
						{
							//remove all colors from the ddl
							for(d=oDDL.length; d>1; d--)
							{
								oDDL.selectedIndex = d-1;
								oDDL.remove(oDDL.selectedIndex);
							}
						}		
						for(var j=0;j<SortArray.length;j++)
						{
							//window.alert("Array " + SortArray[j] );
							if(result == "color")
							{
								document.form.elements[x].options[y].value=(SortArray[j]);
								document.form.elements[x].options[y].text=(SortArray[j]);
							}
							else
							{
								aWrk = SortArray[j].split("|");
								if(!bK2Set)
								{
									document.form.elements[x].options[y].value=(aWrk[1]);
									document.form.elements[x].options[y].text=(aWrk[0]);
								}
								else
								{
									if(aWrk[0] != sColor)
									{
										
										if(sColor == "color")
										{
											sColor = aWrk[0];
											sItems = "";
											sItems = aWrk[1];
										}
										else
										{
											k++;
											var newOption = new Option(sItems);
											oDDL.options[k] = newOption
											oDDL.options[k].value = sItems;
											oDDL.options[k].text = sColor;
											//document.form.elements[x].options[y].value=(sItems);
											//document.form.elements[x].options[y].text=(sColor);
											sColor = aWrk[0];
											sItems = "";
											sItems = aWrk[1];
										}
									}
									else
									{
										sItems = sItems + "~" + aWrk[1];
									}
								}
							}
							y++
						}
						if(bK2Set)
						{
							//add last record into the color ddl
							k++;
							var newOption = new Option(sItems);
							oDDL.options[k] = newOption
							oDDL.options[k].value = sItems;
							oDDL.options[k].text = sColor;
						}
					}
					//check if ddl is for size
					var objName = document.form.elements[x].id
					var searchstring = "size"
					var result = objName.substring(objName.search(searchstring),searchstring.length)
					
					if( result == "size" )
					{
						var y=0
						for(var i=1;i<document.form.elements[x].length;i++)
						{						
							//SortArray[y] = document.form.elements[x].options[i].value.split('~')
							SortArray[y] = document.form.elements[x].options[i].text + "|" + document.form.elements[x].options[i].value;
							y++
						}
						//window.alert(SortArray);
						SortArray.sort(sortNumbers);
						//window.alert(SortArray);
						y=1						
						for(var j=0;j<SortArray.length;j++)
						{	
							//window.alert("Array " + SortArray[j] );
							
							
								aWrk = SortArray[j].split("|");
								document.form.elements[x].options[y].value=(aWrk[1]);
								document.form.elements[x].options[y].text=(aWrk[0]);
							y++
						}
					}
				}
				
			}
		}

	
		//var url="http://s7d2.scene7.com/s7ondemand/zoom/flasht_zoom.jsp?company=Domestications&sku=A10231x_A7&config=zoom_config&zoomheight=600&zoomwidth=500" ;
		
		function openS7(urlLargeImage)
		{  
			window.open(urlLargeImage,"scene7win","width=600,height=450");  
		}  

		/*
		var sl_path = 'http://catalogs.shoplocal.com/';
		function showLargeView(identifier) {	
			window.open( sl_path + 'domestications/media.aspx?pagename=largeview&identifier=' + identifier + '&mode=l','shoplocal_popup','width=482,height=482,location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no');
		}
		
		function openS7(url)
		{				
			window.open(url,"scene7win","width=630,height=450,top=100,left=0");
		}
		*/
	