ingredientCount=1;ingredientOptionCount=1;stepCount=2;function addIngredientRow(){var c=document.getElementById("ingredientDiv"),b="ingredient"+ingredientCount,a=document.createElement("div");a.setAttribute("id",b);a.innerHTML='<p class="ingredTitle">Ingredient '+ingredientCount+' <span class="noteLink">(<a href="javascript:;" onclick="removeIngredientRow(\''+b+"')\">Remove ingredient "+ingredientCount+'</a>)</span></p><label for="ingredientName">Ingredient name: </label><input name="ingredientName[]" id="ingredientName[]" class="reqField" type="text" size="40" /><br /><label for="ingredientQuantity">Quantity: </label><input name="ingredientQuantity[]" id="ingredientQuantity[]" type="text" size="4" maxlength="4" /><select name="ingredientMeasure[]"><option selected value="">Select a measurement</option><optgroup label="Weight"><option value="g">Grams</option><option value="kg">Kilograms</option><option value="pounds">Pounds</option><option value="ounces">Ounces</option></optgroup><optgroup label="Liquids"><option value="ml">Millelitre</option><option value="litre">Litre</option><option value="juice">Juice(s)</option></optgroup><optgroup label="Size"><option value="small">Small</option><option value="medium">Medium</option><option value="large">Large</option></optgroup><optgroup label="Thickness"><option value="thin slice">Thin slice(s)</option><option value="medium slice">Medium slice(s)</option><option value="thick slice">Thick slice(s)</option></optgroup><optgroup label="Other"><option value="bunch">Bunch</option><option value="bottle">Bottle</option><option value="cube">Cube</option><option value="cup">Cup</option><option value="glass">Glass</option><option value="handful">Handful</option><option value="jar">Jar</option><option value="pinch">Pinch</option><option value="scoop">Scoop</option><option value="tablespoon">Tablespoon</option><option value="heaped tablespoon">Tablespoon (heaped)</option><option value="teaspoon">Teaspoon</option><option value="heaped teaspoon">Teaspoon (heaped)</option><option value="tin">Tin</option></optgroup></select><br /><label for="ingredientDesc">Additional note: </label><input name="ingredientDesc[]" id="ingredientDesc[]" type="text" size="40" /><br />';c.appendChild(a);ingredientCount+=1}function removeIngredientRow(a){ingredientCount-=1;var c=document.getElementById("ingredientDiv"),b=document.getElementById(a);c.removeChild(b)}function addOptionIngredientRow(){var c=document.getElementById("optionIngredientDiv"),b="optionIngredient"+ingredientOptionCount,a=document.createElement("div");a.setAttribute("id",b);a.innerHTML='<p class="ingredTitle">Optional ingredient '+ingredientOptionCount+' <span class="noteLink">(<a href="javascript:;" onclick="removeOptionIngredientRow(\''+b+"')\">Remove optional ingredient "+ingredientOptionCount+'</a>)</span></p><label for="ingredientOptionalName">Ingredient name: </label><input name="ingredientOptionalName[]" id="ingredientOptionalName[]" type="text" size="40" /><br /><label for="ingredientOptionalQuantity">Quantity: </label><input name="ingredientOptionalQuantity[]" id="ingredientOptionalQuantity[]" type="text" size="4" maxlength="4" /><select name="ingredientOptionalMeasure[]"><option selected value="">Select a measurement</option><optgroup label="Weight"><option value="g">Grams</option><option value="kg">Kilograms</option><option value="pounds">Pounds</option><option value="ounces">Ounces</option></optgroup><optgroup label="Liquids"><option value="ml">Millelitre</option><option value="litre">Litre</option><option value="juice">Juice(s)</option></optgroup><optgroup label="Size"><option value="small">Small</option><option value="medium">Medium</option><option value="large">Large</option></optgroup><optgroup label="Thickness"><option value="thin slice">Thin slice(s)</option><option value="medium slice">Medium slice(s)</option><option value="thick slice">Thick slice(s)</option></optgroup><optgroup label="Other"><option value="bunch">Bunch</option><option value="bottle">Bottle</option><option value="cube">Cube</option><option value="cup">Cup</option><option value="glass">Glass</option><option value="handful">Handful</option><option value="jar">Jar</option><option value="pinch">Pinch</option><option value="scoop">Scoop</option><option value="tablespoon">Tablespoon</option><option value="heaped tablespoon">Tablespoon (heaped)</option><option value="teaspoon">Teaspoon</option><option value="heaped teaspoon">Teaspoon (heaped)</option><option value="tin">Tin</option></optgroup></select><br /><label for="ingredientOptionalDesc">Additional note: </label><input name="ingredientOptionalDesc[]" id="ingredientOptionalDesc[]" type="text" size="40" /><br />';c.appendChild(a);ingredientOptionCount+=1}function removeOptionIngredientRow(a){ingredientOptionCount-=1;var c=document.getElementById("optionIngredientDiv"),b=document.getElementById(a);c.removeChild(b)}function addStep(){var d=document.getElementById("stepDiv"),c=stepCount,b="step"+stepCount,a=document.createElement("div");a.setAttribute("id",b);a.innerHTML='<p class="ingredTitle">Step '+stepCount+' <span class="noteLink">(<a href="javascript:;" onclick="removeStep(\''+c+'\')"><img src="/content/images/remove.png" alt="remove step" />Remove step '+stepCount+'</a>)</span></p><label for="recipeStep">Step instruction: </label><textarea name="recipeStep" cols="73" rows="7"></textarea><br /><label for="uploadedFile[]">Photograph of step (optional): </label><input name="uploadedFile[]" type="file" size="50" /><div class="clear" />';d.appendChild(a);stepCount+=1}function removeStep(f){var e=document.getElementsByName("recipeStep");stepCount-=1;var b=parseInt(f);for(b;b<stepCount;b++){var c=b+1,d=document.getElementById("step"+c);if(d!=null){d.setAttribute("id","step"+b);var a=d.innerHTML;a=a.replace("step "+c,"step "+b);a=a.replace("step"+c,"step"+b);a=a.replace("Step "+c,"Step "+b);a=a.replace("removeStep('"+c+"')","removeStep('"+b+"')");a=a.replace("></textarea>",">"+e[b].value+"</textarea>");a=a.replace(">"+e[b].value+"</textarea>",">"+e[b].value+"</textarea>");d.innerHTML=a}}var h=document.getElementById("stepDiv"),g=document.getElementById("step"+f);h.removeChild(g)};