	var
		i = j = k = 0;
		updateTimer = 0,
		maxK = 4;
	
	
	//	form on Submit
	
	function form_onSubmit() {
		var
			counter = -1,
			k = 0;
		
		for (k = 0; k < maxK; k++) {
			counter = eval("parseInt(productForm.input" + k + "count.value)");
			
			if (counter > 0) {
				return true;
			}
		}
		
		alert("Please select quantity for products to add.");
		return false;
	}
	
	
	//	form Update
	
	function formUpdate() {
		var
			k = 0,
			freeK = -1;
		
		for (k = 0; k < maxK; k++) {
			counter = eval("parseInt(productForm.input" + k + "count.value)");
			
			
			if (k < (maxK - 1)) {
				if (
					eval("productForm.check" + k + "more.checked")
					&&
					!eval("productForm.check" + k + "more.disabled")
					&&
					counter > 0
				) {
					eval("productForm.check" + k + "more.disabled = true");
				}
				
				if (
					eval("productForm.check" + k + "more.checked")
					&&
					!eval("productForm.check" + k + "more.disabled")
					&&
					((counter == 0) || (isNaN(counter)))
				) {
					
					alert("Enter correct count, please.");
					eval("productForm.check" + k + "more.checked = false");
					eval("productForm.input" + k + "count.select()");
					eval("productForm.input" + k + "count.focus()");
					return;
					
				}
			}
			
			if (
				(freeK == -1)
				&&
				!(counter > 0)
			) {
				freeK = k;
			}
		}
		
		for (k = 0; k < maxK; k++) {
			if (k != freeK) {
				counter = eval("parseInt(productForm.input" + k + "count.value)");
				
				if (eval("optionRow" + k + ".style.display") != (counter > 0 ? "block" : "none")) {
					eval("optionRow" + k + '.style.display = "' + (counter > 0 ? "block" : "none") + '";');
				}
			}
		}
		
		if (freeK != -1) {
			if (eval("optionRow" + freeK + ".style.display") != "block") {
				eval("optionRow" + freeK + '.style.display = "block";');
			}
		}
		
		updateTimer = 0;
	}
	
	
	//	option Count on Keypress (check more on Click)
	
	function optionCount_onkeypress() {
		if (updateTimer != 0) {
			window.clearTimeout(updateTimer);
		}
		
		updateTimer = window.setTimeout("formUpdate()", 500)
	}
	
	
	//	Main Script (Write Options)
	
	if (options.length < 1) {
		maxK = 1;
	}
	
	for (k = 0; k < maxK; k++) {
		document.write("<tr><td><table width=100% border=0 cellspacing=5 cellpadding=0 id=optionRow" + k + (k > 0 ? ' style="display:none"' : "") + ">");
		
		for (i = 0; i < options.length; i++) {
			option = options[i];
			
			if ((i == 0) && (k!= 0)) {
				document.write("<tr><td colspan=2 class=\"line-dot-gor\" style=\"padding-bottom:1em;\"><img src=images/common/pixel-blank.gif width=1 height=1></td></tr>");
			}

			document.write("<tr><td valign=top><nobr>" + option[0] + ":</nobr></td><td width=100% valign=top>");
			
			if (option[1] == 2) {
				for (j = 0; j < option[2].length; j++) {
					optionValue = option[2][j];
					//document.write("<div><input type=checkbox value=1 name=option" + k + "_" + optionValue[0] + " id=option" + k + "_" + i + "_" + j + "><label for=option" + k + "_" + i + "_" + j + "> " + optionValue[1] + "</label></div>");
					document.write('<DIV><INPUT type="checkbox" value="1" name="option' + k + '_' + i + '_' + optionValue[0] + '" id="option' + k + '_' + i + '_' + j + '"><LABEL for="option' + k + '_' + i + '_' + j + '"> ' + optionValue[1] + '</LABEL></DIV>');
				}
			} else {
				if (option[0] == "Colour") {
					colorI = i;
				}
				document.write("<select size=1 name=option" + k + "_" + i + ">" + (option[1] == 0 ? '<option value="" selected> </option>' : ""));
				
				for (j = 0; j < option[2].length; j++) {
					optionValue = option[2][j];
					document.write("<option value=" + optionValue[0] + ">&nbsp;" + optionValue[1] + " &nbsp;</option>");
				}
				
				document.write("</select>");
			}
			
			document.write("</td></tr>");
		}
		
		/*
		if (bEmbroidery_enable) {
			document.write("<tr><td><label style=\"cursor:hand;\" for=embroidery" + k + "><nobr>Embroidery:</nobr></label></td><td><input type=checkbox id=embroidery"+ k +" name=embroidery" + k + " value=on></td></tr>");
		}
		*/
		
		document.write("<tr><td><nobr>Special Instructions:</nobr></td><td width=100%><input style=\"width:80%;\" type=text size=20 name=option" + k + "special></td></tr>");
		
		//document.write("<tr><td>Quantity:</td><td><input name=input" + k + "count id=input" + k + "count onkeyup=\"optionCount_onkeypress()\" type=text size=3 maxlength=4></td></tr>");
		document.write("<tr><td>Quantity:</td><td><input name=input" + k + "count id=input" + k + "count type=text size=3 maxlength=4></td></tr>");
		if (k < (maxK - 1)) {
			//document.write("<tr><td colspan=\"2\"><input name=check" + k + "more onclick=\"optionCount_onkeypress()\" type=checkbox />do you want to order more of differents product variations</td></tr>");
			document.write("<tr><td colspan=\"2\"><input id=check" + k + "more name=check" + k + "more onclick=\"optionCount_onkeypress()\" type=checkbox /><LABEL for=\"check" + k + "more\">MULTI-ORDER: Please click here if you would like to order more of this product in different sizes or colours</LABEL></td></tr>");
		}
		document.write("</table></td></tr>");
		
		
	}
	
