/// <reference path="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" />
/// <reference path="jsonhelper.min.js" />
var DataHelper={RecipeAttributes:{},RecipeAttributesSet:false,Init:function(){},DaysOfWeek:{1:"Mandag",2:"Tirsdag",3:"Onsdag",4:"Torsdag",5:"Fredag",6:"Lørdag",7:"Søndag"},RecipeAttributeId:{PRICE:80,DIFFICULTY:81,MAIN_INGREDIENT:78,CATEGORY:79,PREPARATION_TIME:77,COOKING_TIME:82},MakeLink:function(a,c){var b="";if(a.match("RecipeView")){b=DataHelper.Views[a]+"/";$.each(c,function(d,e){b+=(e)})}else{b=DataHelper.Views[a]+"?";$.each(c,function(d,e){b+=(d+"="+e+"&")})}if(b.indexOf("?")==b.length-1){b.replace("?","")}return b},GetCurrentWeekPlan:function(c){var a;var b;if(PersistenceHelper.WeekPlan.IsSet()){a={WeekPlan:JSON.stringify(PersistenceHelper.WeekPlan.GetPlan())};JSONHelper.MakeRequest("GetCustomWeekPlan",a,function(d){b=d.d;c(b)})}else{a={};JSONHelper.MakeRequest("GetCurrentWeek",a,function(d){b=d.d.Recipes;c(b)})}},Views:{MainView:"/mad+og+opskrifter/madplanen",RecipeView:"/mad+og+opskrifter/madplanen/recipe",SearchView:"opskrifter",InspirationView:"inspiration",ThemeView:"/mad+og+opskrifter/inspiration/tema",PrintRecipe:"recipe_print.aspx",PrintShoppinglist:"shoppinglist_print.aspx"},Constants:{Actions:{INSERT_RECIPE:"insertrecipe"}},InitAttributes:function(a){JSONHelper.MakeRequest("GetAttributes",null,function(b){DataHelper.RecipeAttributes=b.d;a()})},GetAttributeCollectionById:function(c){var b=DataHelper.RecipeAttributes;var a=[];$.each(b,function(e,d){if(d.Id==c){a.push(d)}});return a},GetAttributeCollectionByName:function(a){var b=DataHelper.RecipeAttributeId[a];return DataHelper.GetAttributeCollectionById(b)},GetAttributeValueById:function(a,b){var c;$.each(a,function(e,d){if(d.Id==b){c=d.Values[0].Name}});return c}};Date.prototype.getWeek=function(){var d=1;var c=new Date(this.getFullYear(),0,1);var a=c.getDay()-d;a=(a>=0?a:a+7);var b=Math.floor((this.getTime()-c.getTime()-(this.getTimezoneOffset()-c.getTimezoneOffset())*60000)/86400000)+1;var e;if(a<4){e=Math.floor((b+a-1)/7)+1;if(e>52){nYear=new Date(this.getFullYear()+1,0,1);nday=nYear.getDay()-d;nday=nday>=0?nday:nday+7;e=nday<4?1:53}}else{e=Math.floor((b+a-1)/7)}return e};