								var
									bIsColourSelect = false,
									optiontypeDescriptionLink = "",
									optionDescriptionLink = "",
									updateTimer = 0,
									maxK = 1;
								
								function form_onSubmit() {
									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;
								}
								
								function formUpdate() {
									var
										freeK = -1;

									for (k = 0; k < maxK; k++) {
										counter = eval("parseInt(productForm.input" + k + "count.value)");

										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;
								}
                                                                
								function optionCount_onkeypress() {
									if (updateTimer != 0) {
//										window.clearTimeout(updateTimer);
									}

//									updateTimer = window.setTimeout("formUpdate()", 500)
								}

								if (options.length < 1) {
									maxK = 1;
								}

								for (k = 0; k < maxK; k++) {
									document.write("<tr><td><table width=100% border=0 cellspacing=1 cellpadding=0 id=optionRow" + k + (k > 0 ? ' style="display:none"' : "") + ">");

									for (i = 0; i < options.length; i++) {
										option = options[i];
										
										if (i > 0) {
											document.write("<tr><td colspan=2 height=1><img src=/images/common/pixel-blank.gif width=1 height=1></td></tr>");
										}
										
										optiontypeDescriptionLink = "";
										if (k == 0 && typeof(option[3]) != "undefined" && option[3] > 0) {
											optiontypeDescriptionLink = '<A class="option-help" href="/options-description.html?id=' + option[3] + '" target="options_description" onclick="return showOptionsDescription(\'' + option[3] + '\');">[<B>?</B>]</A>';
										}
										
										document.write("<tr><td valign=top><nobr>" + option[0] + ":&nbsp;" + optiontypeDescriptionLink + "&nbsp;</nobr></td><td width=100% valign=top>");
										
										bIsColourSelect = false;
										if (option[0] == "Colour" && option[1] == 1 && k == 0 && typeof(option_selColours_onchnage) == "function") {
											option_selColoursName = ("document.productForm.option" + k + "_" + i);
											bIsColourSelect = true;
										}
										
										if (option[1] == 2) {
											for (j = 0; j < option[2].length; j++) {
												optionDescriptionLink = "";
												if (option[2][j][2] > 0) {
													optionDescriptionLink = '&nbsp;<A class="option-help" href="/option-description.html?id=' + option[2][j][2] + '" target="option_description" onclick="return showOptionDescription(\'' + option[2][j][2] + '\');">[<B>?</B>]</A>';
												}
												
												optionValue = option[2][j];
												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>' + optionDescriptionLink + '</DIV>');
											}
										} else {
											optionDescriptionLink = "";
											document.write("<select onchange='return selOptions_onchange(" + (bIsColourSelect ? "true" : "false") + "," + i + ");'" + " size=1 name=option" + k + "_" + i + ">" + (option[1] == 0 ? '<option value="" selected> </option>' : ""));
											
											for (j = 0; j < option[2].length; j++) {
												if (option[2][j][2] > 0 && optionDescriptionLink == "") {
													optionDescriptionLink = '&nbsp;<A id="aOptionDescription' + i + '" class="option-help" href="/option-description.html?id=' + option[2][j][2] + '" target="option_description" onclick="return showOptionDescription(\'' + option[2][j][2] + '\');">[<B>?</B>]</A>';
												}
												
												optionValue = option[2][j];
												document.write("<option value=" + optionValue[0] + ">&nbsp;" + optionValue[1] + " &nbsp;</option>");
											}
											document.write("</select>" + optionDescriptionLink);
										}

										document.write("</td></tr>");
									}

									document.write("<tr><td colspan=2 height=1><img src=/images/common/pixel-blank.gif width=1 height=1></td></tr>");
									document.write("<tr><td><nobr>Special Instructions: &nbsp;</nobr></td><td width=100%><input type=text size=15 name=option" + k + "special></td></tr><tr><td colspan=2 height=1><img src=/images/common/pixel-blank.gif width=1 height=1></td></tr><tr><td>Quantity:</td><td><input name=input" + k + "count id=input" + k + "count onkeyup=\"optionCount_onkeypress()\" type=text size=3 maxlength=4 value=1></td></tr></table></td></tr>");
								}
	
	
	//	Show Options Description
	
	function showOptionsDescription(otpID) {
		var
			wnd = null;
		
		try {
			
			wnd = window.open(
				"/options-description.html?id=" + otpID,
				"options_description",
				"height=330,width=440,status=no,resizable=no,toolbar=no,titlebar=no,scrollbars=yes"
			);
			
			wnd.focus();
			
			return false;
		} catch(e) {
			return true;
		}
	}
	
	
	//	Show Option Description
	
	function showOptionDescription(optID) {
		var
			wnd = null;
		
		try {
			
			wnd = window.open(
				"/option-description.html?id=" + optID,
				"option_description",
				"height=330,width=440,status=no,resizable=no,toolbar=no,titlebar=no,scrollbars=yes"
			);
			
			wnd.focus();
			return false;
		} catch(e) {
			return true;
		}
	}
	
	
	//
	
	for (i = 0; i < options.length; i++) {
		if (typeof(option_selColoursName) != "undefined") {
			selOptions_onchange((option_selColoursName == ("document.productForm.option0" + "_" + i)), i);
		} else {
			selOptions_onchange(false, i);
		}
	}
	
	
	//	sel Options on Change
	
	function selOptions_onchange(bIsColourSelect, i) {
		if (bIsColourSelect && typeof(option_selColours_onchnage) == "function") {
			option_selColours_onchnage();
		}
		
		var
			a = null,
			optID = 0,
			sel = null;
		
		try {
			sel = eval("document.productForm.option0_" + i);
			
			a = document.getElementById("aOptionDescription" + i);
			
			
			if (options[i][1] == 0) {
				if (sel.selectedIndex == 0) {
					optID = 0;
				} else {
					optID = options[i][2][sel.selectedIndex - 1][2];
				}
			} else {
				optID = options[i][2][sel.selectedIndex][2];
			}
			
			if (optID > 0) {
				a.style.display = "";
				a.href = "/option-description.html?id=" + optID;
				a.onclick = function () { return showOptionDescription(optID); }
			} else {
				a.style.display = "none";
			}
			
		} catch(e) {
		}
		
		return true;
	}
