$(document).ready(function(){var a={beforeSubmit:validate,success:showResponse,clearForm:true};$("#servingsNotice").hide();$("#submitPhotograph").ajaxForm(a);$("#submitPhotograph").validate({errorElement:"div",errorPlacement:function(b,a){b.insertAfter(a)},rules:{mainImage:{required:true},spamCheckImage:{required:true,range:[4,4]}}});$("#addPhotoButton[rel]").overlay();$(function(){$("ul.tabs").tabs("div.panes > div")});$("a#toggleServings").click(function(){$("#changeServings").toggle(400);$(this).text($(this).text()=="Change servings"?"Hide servings":"Change servings");return false});$(".watermarkText").focus(function(){if($(this).val()==$(this)[0].title){$(this).removeClass("defaultTextActive");$(this).val("")}});$(".watermarkText").blur(function(){if($(this).val()==""){$(this).addClass("defaultTextActive");$(this).val($(this)[0].title)}});$(".watermarkText").blur()});function showResponse(){$("#addPhotoButton[rel]").overlay().close();$("#submitPhotograph div.warningBox").remove();$("#mainImage").value="";$("#spamCheckImage").value="";$("#submitPhoto").removeAttr("disabled");alert("Thanks for uploading the photo! It will appear on this page once a member of staff has approved it.")}function validate(c,b){var a=b[0];if(a.spamCheckImage.value!=4)return false;if(!a.mainImage.value)return false;$("#submitPhoto").attr("disabled","disabled");$("#submitPhotograph").append('<div class="warningBox">Please wait while your photo is being uploaded. You will see a new message once this has been completed.</div>')}function flash(a){$(a).css("opacity",1).animate({backgroundColor:"khaki",opacity:1},800).animate({backgroundColor:"#f0f0f0"},350,function(){})}function validateRecipeServings(){return $("#updateRecipeServings").validate({errorElement:"div",errorPlacement:function(b,a){b.insertAfter(a)},rules:{newServings:{required:true,number:true}}}).form()}function validateReview(){return $("#createReview").validate({errorElement:"div",errorPlacement:function(b,a){b.insertAfter(a)},rules:{review:{required:true},spamCheck:{required:true,min:2,max:2}}}).form()}function validateSuggestion(){return $("#createSuggestion").validate({errorElement:"div",errorPlacement:function(b,a){b.insertAfter(a)},rules:{suggestion:{required:true},spamCheckSuggestion:{required:true,range:[2,2]}}}).form()}function printpage(){window.print()}function photoAdded(){$("#photoResult").Visible=true;flash("#photoResult")}function reviewAdded(){flash("#reviews > li:first");$("#review").value="";$("#spamCheck").value="";$("#review").focus()}function reviewPending(){$("#review").value="";$("#spamCheck").value="";$("#review").focus();$('<div id="reviewPending">Because you are not <a href="/login">logged in</a> your message will not appear here until a member of staff has approved it. See the <a href="/why-register">other features</a> you get when you <a href="/register">register</a> (it\'s free!).</div>').insertBefore("#reviews");flash("#reviewPending")}function suggestionAdded(){flash("#suggestions > li:first");$("#suggestion").value="";$("#spamCheckSuggestion").value="";$("#suggestion").focus()}function suggestionPending(){$("#suggestion").value="";$("#spamCheckSuggestion").value="";$("#suggestion").focus();$('<div id="suggestionPending">Because you are not <a href="/login">logged in</a> your message will not appear here until a member of staff has approved it. See the <a href="/why-register">other features</a> you get when you <a href="/register">register</a> (it\'s free!).</div>').insertBefore("#suggestions");flash("#suggestionPending")}function addToRecipeBox(b,d,e){var c="/User/"+b+"/AddRecipeToCategory/"+d,a=new Sys.Net.WebRequest;a.set_httpVerb("POST");a.set_url(c);a.invoke();a.add_completed(jAlert('Recipe added to your <a href="'+e+'">recipe box</a>',"Recipe box",function(a){a&&completed()}))}function addToRecipeBoxLogin(c,b,a){jAlert('You must <a href="'+c+'">login</a> or <a href="'+b+'">register</a> to add this recipe to your recipe box.<br/><br/>See the other <a href="'+a+'">features</a> you get when you register.',"Recipe box")}function deleteFromRecipeBox(b,d,e){var c="/User/"+b+"/DeleteRecipeFromRecipeBox/"+d,a=new Sys.Net.WebRequest;a.set_httpVerb("DELETE");a.set_url(c);a.invoke();a.add_completed(jAlert('Recipe removed from your <a href="'+e+'">recipe box</a>',"Recipe box",function(a){a&&completed()}))}function updatedMeasurementType(a){$("#measurementType").value=a;updatedIngredientList()}function updatedRecipeServings(){var c=$("#newServings").val(),e=$("#existingServings").val(),b=$("a#imperial").attr("href"),d=b.lastIndexOf("/"),a=b.substring(0,d+1);a+=c;$("#imperial").href=a;b=$("a#metric").attr("href");d=b.lastIndexOf("/");a=b.substring(0,d+1);a+=c;$("#metric").href=a;b=$("a#usa").attr("href");d=b.lastIndexOf("/");a=b.substring(0,d+1);a+=c;$("#usa").href=a;if(c!=e)$("#recipeServing").replaceWith('<td id="recipeServing">'+c+" (changed from "+e+")</td>");else $("#recipeServing").replaceWith('<td id="recipeServing">'+c+"</td>");updatedIngredientList();$("#servingsNotice").show();$("#servingsNotice").css("opacity",1).animate({backgroundColor:"khaki",opacity:1},800).animate({backgroundColor:"#ffffc0"},350,function(){})}function updatedIngredientList(){flash("#ingredients")}function completed(){window.location.reload()};