function oldBrowser(){var a={init:function(){this.browser=this.searchString(this.dataBrowser)||"An unknown browser";this.version=this.searchVersion(navigator.userAgent)||this.searchVersion(navigator.appVersion)||"an unknown version";this.OS=this.searchString(this.dataOS)||"an unknown OS"},searchString:function(a){for(var c=0;c=a||"Opera"==c&&95>=10*a||/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)&&3>=new Number(RegExp.$1)||"Safari"==c&&3>= a?!0:!1}oldBrowser()&&(window.location.href="/?t=unsupportedbrowser");(function(a,c){function f(c){return!a(c).parents().andSelf().filter(function(){return"hidden"===a.curCSS(this,"visibility")||a.expr.filters.hidden(this)}).length}function k(c,d){var j=c.nodeName.toLowerCase();if("area"===j){var j=c.parentNode,b=j.name;if(!c.href||!b||"map"!==j.nodeName.toLowerCase())return!1;j=a("img[usemap=#"+b+"]")[0];return!!j&&f(j)}return(/input|select|textarea|button|object/.test(j)?!c.disabled:"a"==j?c.href||d:d)&&f(c)}a.ui=a.ui||{};a.ui.version||(a.extend(a.ui,{version:"1.8.17", keyCode:{ALT:18,BACKSPACE:8,CAPS_LOCK:20,COMMA:188,COMMAND:91,COMMAND_LEFT:91,COMMAND_RIGHT:93,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,MENU:93,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38,WINDOWS:91}}),a.fn.extend({propAttr:a.fn.prop||a.fn.attr,_focus:a.fn.focus,focus:function(c,d){return"number"==typeof c?this.each(function(){var j= this;setTimeout(function(){a(j).focus();d&&d.call(j)},c)}):this._focus.apply(this,arguments)},scrollParent:function(){var c;a.browser.msie&&/(static|relative)/.test(this.css("position"))||/absolute/.test(this.css("position"))?c=this.parents().filter(function(){return/(relative|absolute|fixed)/.test(a.curCSS(this,"position",1))&&/(auto|scroll)/.test(a.curCSS(this,"overflow",1)+a.curCSS(this,"overflow-y",1)+a.curCSS(this,"overflow-x",1))}).eq(0):c=this.parents().filter(function(){return/(auto|scroll)/.test(a.curCSS(this, "overflow",1)+a.curCSS(this,"overflow-y",1)+a.curCSS(this,"overflow-x",1))}).eq(0);return/fixed/.test(this.css("position"))||!c.length?a(document):c},zIndex:function(h){if(h!==c)return this.css("zIndex",h);if(this.length)for(var h=a(this[0]),d;h.length&&h[0]!==document;){d=h.css("position");if("absolute"===d||"relative"===d||"fixed"===d)if(d=parseInt(h.css("zIndex"),10),!isNaN(d)&&0!==d)return d;h=h.parent()}return 0},disableSelection:function(){return this.bind((a.support.selectstart?"selectstart": "mousedown")+".ui-disableSelection",function(a){a.preventDefault()})},enableSelection:function(){return this.unbind(".ui-disableSelection")}}),a.each(["Width","Height"],function(h,d){function j(e,p,c,d){a.each(b,function(){p-=parseFloat(a.curCSS(e,"padding"+this,!0))||0;c&&(p-=parseFloat(a.curCSS(e,"border"+this+"Width",!0))||0);d&&(p-=parseFloat(a.curCSS(e,"margin"+this,!0))||0)});return p}var b="Width"===d?["Left","Right"]:["Top","Bottom"],e=d.toLowerCase(),p={innerWidth:a.fn.innerWidth,innerHeight:a.fn.innerHeight, outerWidth:a.fn.outerWidth,outerHeight:a.fn.outerHeight};a.fn["inner"+d]=function(b){return b===c?p["inner"+d].call(this):this.each(function(){a(this).css(e,j(this,b)+"px")})};a.fn["outer"+d]=function(b,c){return"number"!=typeof b?p["outer"+d].call(this,b):this.each(function(){a(this).css(e,j(this,b,!0,c)+"px")})}}),a.extend(a.expr[":"],{data:function(c,d,j){return!!a.data(c,j[3])},focusable:function(c){return k(c,!isNaN(a.attr(c,"tabindex")))},tabbable:function(c){var d=a.attr(c,"tabindex"),j=isNaN(d); return(j||0<=d)&&k(c,!j)}}),a(function(){var c=document.body,d=c.appendChild(d=document.createElement("div"));a.extend(d.style,{minHeight:"100px",height:"auto",padding:0,borderWidth:0});a.support.minHeight=100===d.offsetHeight;a.support.selectstart="onselectstart"in d;c.removeChild(d).style.display="none"}),a.extend(a.ui,{plugin:{add:function(c,d,j){var c=a.ui[c].prototype,b;for(b in j)c.plugins[b]=c.plugins[b]||[],c.plugins[b].push([d,j[b]])},call:function(a,c,j){if((c=a.plugins[c])&&a.element[0].parentNode)for(var b= 0;bc&&a'))}a.extend(a.ui,{datepicker:{version:"1.8.17"}});var d=(new Date).getTime(),j;a.extend(h.prototype,{markerClassName:"hasDatepicker",maxRows:4,log:function(){this.debug&&console.log.apply("",arguments)},_widgetDatepicker:function(){return this.dpDiv},setDefaults:function(b){f(this._defaults,b||{});return this},_attachDatepicker:function(b,e){var c= null,g;for(g in this._defaults){var d=b.getAttribute("date:"+g);if(d){c=c||{};try{c[g]=eval(d)}catch(j){c[g]=d}}}g=b.nodeName.toLowerCase();d="div"==g||"span"==g;b.id||(this.uuid+=1,b.id="dp"+this.uuid);var f=this._newInst(a(b),d);f.settings=a.extend({},e||{},c||{});"input"==g?this._connectDatepicker(b,f):d&&this._inlineDatepicker(b,f)},_newInst:function(b,e){return{id:b[0].id.replace(/([^A-Za-z0-9_-])/g,"\\\\$1"),input:b,selectedDay:0,selectedMonth:0,selectedYear:0,drawMonth:0,drawYear:0,inline:e, dpDiv:e?k(a('
')):this.dpDiv}},_connectDatepicker:function(b,e){var c=a(b);e.append=a([]);e.trigger=a([]);c.hasClass(this.markerClassName)||(this._attachments(c,e),c.addClass(this.markerClassName).keydown(this._doKeyDown).keypress(this._doKeyPress).keyup(this._doKeyUp).bind("setData.datepicker",function(b,a,c){e.settings[a]=c}).bind("getData.datepicker",function(b,a){return this._get(e, a)}),this._autoSize(e),a.data(b,"datepicker",e),e.settings.disabled&&this._disableDatepicker(b))},_attachments:function(b,e){var c=this._get(e,"appendText"),g=this._get(e,"isRTL");e.append&&e.append.remove();c&&(e.append=a(''+c+""),b[g?"before":"after"](e.append));b.unbind("focus",this._showDatepicker);e.trigger&&e.trigger.remove();c=this._get(e,"showOn");("focus"==c||"both"==c)&&b.focus(this._showDatepicker);if("button"==c||"both"==c){var c=this._get(e, "buttonText"),d=this._get(e,"buttonImage");e.trigger=a(this._get(e,"buttonImageOnly")?a("").addClass(this._triggerClass).attr({src:d,alt:c,title:c}):a('').addClass(this._triggerClass).html(""==d?c:a("").attr({src:d,alt:c,title:c})));b[g?"before":"after"](e.trigger);e.trigger.click(function(){a.datepicker._datepickerShowing&&a.datepicker._lastInput==b[0]?a.datepicker._hideDatepicker():a.datepicker._showDatepicker(b[0]);return!1})}},_autoSize:function(b){if(this._get(b, "autoSize")&&!b.inline){var a=new Date(2009,11,20),c=this._get(b,"dateFormat");if(c.match(/[DM]/)){var g=function(b){for(var a=0,e=0,c=0;ca&&(a=b[c].length,e=c);return e};a.setMonth(g(this._get(b,c.match(/MM/)?"monthNames":"monthNamesShort")));a.setDate(g(this._get(b,c.match(/DD/)?"dayNames":"dayNamesShort"))+20-a.getDay())}b.input.attr("size",this._formatDate(b,a).length)}},_inlineDatepicker:function(b,e){var c=a(b);c.hasClass(this.markerClassName)||(c.addClass(this.markerClassName).append(e.dpDiv).bind("setData.datepicker", function(b,a,c){e.settings[a]=c}).bind("getData.datepicker",function(b,a){return this._get(e,a)}),a.data(b,"datepicker",e),this._setDate(e,this._getDefaultDate(e),!0),this._updateDatepicker(e),this._updateAlternate(e),e.settings.disabled&&this._disableDatepicker(b),e.dpDiv.css("display","block"))},_dialogDatepicker:function(b,e,c,g,d){b=this._dialogInst;b||(this.uuid+=1,this._dialogInput=a(''), this._dialogInput.keydown(this._doKeyDown),a("body").append(this._dialogInput),b=this._dialogInst=this._newInst(this._dialogInput,!1),b.settings={},a.data(this._dialogInput[0],"datepicker",b));f(b.settings,g||{});e=e&&e.constructor==Date?this._formatDate(b,e):e;this._dialogInput.val(e);this._pos=d?d.length?d:[d.pageX,d.pageY]:null;this._pos||(this._pos=[document.documentElement.clientWidth/2-100+(document.documentElement.scrollLeft||document.body.scrollLeft),document.documentElement.clientHeight/ 2-150+(document.documentElement.scrollTop||document.body.scrollTop)]);this._dialogInput.css("left",this._pos[0]+20+"px").css("top",this._pos[1]+"px");b.settings.onSelect=c;this._inDialog=!0;this.dpDiv.addClass(this._dialogClass);this._showDatepicker(this._dialogInput[0]);a.blockUI&&a.blockUI(this.dpDiv);a.data(this._dialogInput[0],"datepicker",b);return this},_destroyDatepicker:function(b){var e=a(b),c=a.data(b,"datepicker");if(e.hasClass(this.markerClassName)){var g=b.nodeName.toLowerCase();a.removeData(b, "datepicker");"input"==g?(c.append.remove(),c.trigger.remove(),e.removeClass(this.markerClassName).unbind("focus",this._showDatepicker).unbind("keydown",this._doKeyDown).unbind("keypress",this._doKeyPress).unbind("keyup",this._doKeyUp)):("div"==g||"span"==g)&&e.removeClass(this.markerClassName).empty()}},_enableDatepicker:function(b){var e=a(b),c=a.data(b,"datepicker");if(e.hasClass(this.markerClassName)){var g=b.nodeName.toLowerCase();if("input"==g)b.disabled=!1,c.trigger.filter("button").each(function(){this.disabled= !1}).end().filter("img").css({opacity:"1.0",cursor:""});else if("div"==g||"span"==g)e=e.children("."+this._inlineClass),e.children().removeClass("ui-state-disabled"),e.find("select.ui-datepicker-month, select.ui-datepicker-year").removeAttr("disabled");this._disabledInputs=a.map(this._disabledInputs,function(a){return a==b?null:a})}},_disableDatepicker:function(b){var e=a(b),c=a.data(b,"datepicker");if(e.hasClass(this.markerClassName)){var g=b.nodeName.toLowerCase();if("input"==g)b.disabled=!0,c.trigger.filter("button").each(function(){this.disabled= !0}).end().filter("img").css({opacity:"0.5",cursor:"default"});else if("div"==g||"span"==g)e=e.children("."+this._inlineClass),e.children().addClass("ui-state-disabled"),e.find("select.ui-datepicker-month, select.ui-datepicker-year").attr("disabled","disabled");this._disabledInputs=a.map(this._disabledInputs,function(a){return a==b?null:a});this._disabledInputs[this._disabledInputs.length]=b}},_isDisabledDatepicker:function(b){if(!b)return!1;for(var a=0;ap||!e||-1h&&h>g?Math.abs(e.left+g-h):0);e.top-=Math.min(e.top,e.top+d>m&&m>d?Math.abs(d+f):0);return e},_findPos:function(b){for(var e=this._get(this._getInst(b),"isRTL");b&&("hidden"==b.type||1!=b.nodeType||a.expr.filters.hidden(b));)b=b[e?"previousSibling":"nextSibling"];b=a(b).offset();return[b.left,b.top]},_hideDatepicker:function(b){var e= this._curInst;if(e&&!(b&&e!=a.data(b,"datepicker"))&&this._datepickerShowing){var b=this._get(e,"showAnim"),c=this._get(e,"duration"),g=this,d=function(){a.datepicker._tidyDialog(e);g._curInst=null};a.effects&&a.effects[b]?e.dpDiv.hide(b,a.datepicker._get(e,"showOptions"),c,d):e.dpDiv["slideDown"==b?"slideUp":"fadeIn"==b?"fadeOut":"hide"](b?c:null,d);b||d();this._datepickerShowing=!1;(b=this._get(e,"onClose"))&&b.apply(e.input?e.input[0]:null,[e.input?e.input.val():"",e]);this._lastInput=null;this._inDialog&& (this._dialogInput.css({position:"absolute",left:"0",top:"-100px"}),a.blockUI&&(a.unblockUI(),a("body").append(this.dpDiv)));this._inDialog=!1}},_tidyDialog:function(b){b.dpDiv.removeClass(this._dialogClass).unbind(".ui-datepicker-calendar")},_checkExternalClick:function(b){if(a.datepicker._curInst){var b=a(b.target),e=a.datepicker._getInst(b[0]);(b[0].id!=a.datepicker._mainDivId&&0==b.parents("#"+a.datepicker._mainDivId).length&&!b.hasClass(a.datepicker.markerClassName)&&!b.hasClass(a.datepicker._triggerClass)&& a.datepicker._datepickerShowing&&(!a.datepicker._inDialog||!a.blockUI)||b.hasClass(a.datepicker.markerClassName)&&a.datepicker._curInst!=e)&&a.datepicker._hideDatepicker()}},_adjustDate:function(b,e,c){var b=a(b),g=this._getInst(b[0]);this._isDisabledDatepicker(b[0])||(this._adjustInstDate(g,e+("M"==c?this._get(g,"showCurrentAtPos"):0),c),this._updateDatepicker(g))},_gotoToday:function(b){var b=a(b),e=this._getInst(b[0]);if(this._get(e,"gotoCurrent")&&e.currentDay)e.selectedDay=e.currentDay,e.drawMonth= e.selectedMonth=e.currentMonth,e.drawYear=e.selectedYear=e.currentYear;else{var c=new Date;e.selectedDay=c.getDate();e.drawMonth=e.selectedMonth=c.getMonth();e.drawYear=e.selectedYear=c.getFullYear()}this._notifyChange(e);this._adjustDate(b)},_selectMonthYear:function(b,e,c){var b=a(b),g=this._getInst(b[0]);g["selected"+("M"==c?"Month":"Year")]=g["draw"+("M"==c?"Month":"Year")]=parseInt(e.options[e.selectedIndex].value,10);this._notifyChange(g);this._adjustDate(b)},_selectDay:function(b,e,c,g){var d= a(b);!a(g).hasClass(this._unselectableClass)&&!this._isDisabledDatepicker(d[0])&&(d=this._getInst(d[0]),d.selectedDay=d.currentDay=a("a",g).html(),d.selectedMonth=d.currentMonth=e,d.selectedYear=d.currentYear=c,this._selectDate(b,this._formatDate(d,d.currentDay,d.currentMonth,d.currentYear)))},_clearDate:function(b){b=a(b);this._getInst(b[0]);this._selectDate(b,"")},_selectDate:function(b,e){var c=this._getInst(a(b)[0]),e=null!=e?e:this._formatDate(c);c.input&&c.input.val(e);this._updateAlternate(c); var g=this._get(c,"onSelect");g?g.apply(c.input?c.input[0]:null,[e,c]):c.input&&c.input.trigger("change");c.inline?this._updateDatepicker(c):(this._hideDatepicker(),this._lastInput=c.input[0],"object"!=typeof c.input[0]&&c.input.focus(),this._lastInput=null)},_updateAlternate:function(b){var c=this._get(b,"altField");if(c){var d=this._get(b,"altFormat")||this._get(b,"dateFormat"),g=this._getDate(b),j=this.formatDate(d,g,this._getFormatConfig(b));a(c).each(function(){a(this).val(j)})}},noWeekends:function(b){b= b.getDay();return[0b,""]},iso8601Week:function(b){b=new Date(b.getTime());b.setDate(b.getDate()+4-(b.getDay()||7));var a=b.getTime();b.setMonth(0);b.setDate(1);return Math.floor(Math.round((a-b)/864E5)/7)+1},parseDate:function(b,c,d){if(null==b||null==c)throw"Invalid arguments";c="object"==typeof c?c.toString():c+"";if(""==c)return null;for(var g=(d?d.shortYearCutoff:null)||this._defaults.shortYearCutoff,g="string"!=typeof g?g:(new Date).getFullYear()%100+parseInt(g,10),j=(d?d.dayNamesShort: null)||this._defaults.dayNamesShort,f=(d?d.dayNames:null)||this._defaults.dayNames,h=(d?d.monthNamesShort:null)||this._defaults.monthNamesShort,o=(d?d.monthNames:null)||this._defaults.monthNames,m=d=-1,r=-1,k=-1,q=!1,n=function(a){(a=B+1d&&(d+=(new Date).getFullYear()-(new Date).getFullYear()% 100+(d<=g?0:-100));if(-1a.getYear()%100?"0":"")+a.getYear()%100;break;case "@":r+=a.getTime();break;case "!":r+= 1E4*a.getTime()+this._ticksTo1970;break;case "'":h("'")?r+="'":k=!0;break;default:r+=b.charAt(q)}return r},_possibleChars:function(b){for(var a="",c=!1,d=function(a){(a=j+1o&&(o+=12,w--);if(n)for(var l=this._daylightSavingAdjust(new Date(n.getFullYear(),n.getMonth()-k[0]*k[1]+1,n.getDate())),l=q&&ll;)o--, 0>o&&(o=11,w--);b.drawMonth=o;b.drawYear=w;var l=this._get(b,"prevText"),l=h?this.formatDate(l,this._daylightSavingAdjust(new Date(w,o-m,1)),this._getFormatConfig(b)):l,l=this._canAdjustMonth(b,-1,w,o)?''+l+"":f?"":''+l+"",t=this._get(b,"nextText"),t=h?this.formatDate(t,this._daylightSavingAdjust(new Date(w,o+m,1)),this._getFormatConfig(b)):t,f=this._canAdjustMonth(b,1,w,o)?''+t+"":f?"":''+t+"",m=this._get(b,"currentText"),t=this._get(b,"gotoCurrent")&&b.currentDay?u:c,m=h?this.formatDate(m,t,this._getFormatConfig(b)):m,h=b.inline?"":'",g=g?'
'+(j?h:"")+(this._isInRange(b,t)?'":"")+(j?"":h)+"
":"",h=parseInt(this._get(b,"firstDay"),10),h=isNaN(h)?0:h,m=this._get(b,"showWeek"),t=this._get(b,"dayNames");this._get(b,"dayNamesShort");var D=this._get(b,"dayNamesMin"),B=this._get(b,"monthNames"),C=this._get(b,"monthNamesShort"),K=this._get(b,"beforeShowDay"),M=this._get(b,"showOtherMonths"),P=this._get(b,"selectOtherMonths");this._get(b,"calculateWeek");for(var N=this._getDefaultDate(b),I="",J=0;J'+(/all|left/.test(v)&& 0==J?j?f:l:"")+(/all|right/.test(v)&&0==J?j?l:f:"")+this._generateMonthYearHeader(b,o,w,q,n,0'),E=m?'":"",v=0;7>v;v++)var z=(v+h)%7,E=E+("'+D[z]+"");A+=E+"";E=this._getDaysInMonth(w,o);w==b.selectedYear&&o==b.selectedMonth&&(b.selectedDay=Math.min(b.selectedDay, E));v=(this._getFirstDayOfMonth(w,o)-h+7)%7;E=Math.ceil((v+E)/7);this.maxRows=E=r?this.maxRows>E?this.maxRows:E:E;for(var z=this._daylightSavingAdjust(new Date(w,o,1-v)),S=0;S",Q=m?'":"",v=0;7>v;v++){var O=K?K.apply(b.input?b.input[0]:null,[z]):[!0,""],L=z.getMonth()!=o,R=L&&!P||!O[0]||q&&zn,Q=Q+('");z.setDate(z.getDate()+1);z=this._daylightSavingAdjust(z)}A+=Q+""}o++;11
'+this._get(b,"weekHeader")+"
'+this._get(b,"calculateWeek")(z)+""+(L&&!M? " ":R?''+z.getDate()+"":''+z.getDate()+"")+"
"+(r?""+(0':""):"");F+=A}I+=F}I+=g+(a.browser.msie&& 7>parseInt(a.browser.version,10)&&!b.inline?'':"");b._keyEvent=!1;return I},_generateMonthYearHeader:function(b,a,c,g,j,f,h,k){var m=this._get(b,"changeMonth"),r=this._get(b,"changeYear"),u=this._get(b,"showMonthAfterYear"),q='
',n="";if(f||!m)n+=''+h[a]+"";else{for(var h=g&&g.getFullYear()==c,w=j&&j.getFullYear()==c,n=n+('"}u||(q+=n+(f||!m||!r?" ":""));if(!b.yearshtml)if(b.yearshtml="",f||!r)q+=''+c+"";else{var k=this._get(b,"yearRange").split(":"),t=(new Date).getFullYear(),h=function(b){b=b.match(/c[+-].*/)?c+parseInt(b.substring(1),10):b.match(/[+-].*/)? t+parseInt(b,10):parseInt(b,10);return isNaN(b)?t:b},a=h(k[0]),k=Math.max(a,h(k[1]||"")),a=g?Math.max(a,g.getFullYear()):a,k=j?Math.min(k,j.getFullYear()):k;for(b.yearshtml+='";q+=b.yearshtml;b.yearshtml=null}q+=this._get(b,"yearSuffix");u&&(q+=(f||!m||!r?" ": "")+n);return q+"
"},_adjustInstDate:function(b,a,c){var d=b.drawYear+("Y"==c?a:0),j=b.drawMonth+("M"==c?a:0),a=Math.min(b.selectedDay,this._getDaysInMonth(d,j))+("D"==c?a:0),d=this._restrictMinMax(b,this._daylightSavingAdjust(new Date(d,j,a)));b.selectedDay=d.getDate();b.drawMonth=b.selectedMonth=d.getMonth();b.drawYear=b.selectedYear=d.getFullYear();("M"==c||"Y"==c)&&this._notifyChange(b)},_restrictMinMax:function(b,a){var c=this._getMinMaxDate(b,"min"),d=this._getMinMaxDate(b,"max"),c=c&& ad?d:c},_notifyChange:function(b){var a=this._get(b,"onChangeMonthYear");a&&a.apply(b.input?b.input[0]:null,[b.selectedYear,b.selectedMonth+1,b])},_getNumberOfMonths:function(b){b=this._get(b,"numberOfMonths");return null==b?[1,1]:"number"==typeof b?[1,b]:b},_getMinMaxDate:function(b,a){return this._determineDate(b,this._get(b,a+"Date"),null)},_getDaysInMonth:function(b,a){return 32-this._daylightSavingAdjust(new Date(b,a,32)).getDate()},_getFirstDayOfMonth:function(b,a){return(new Date(b, a,1)).getDay()},_canAdjustMonth:function(b,a,c,d){var j=this._getNumberOfMonths(b),c=this._daylightSavingAdjust(new Date(c,d+(0>a?a:j[0]*j[1]),1));0>a&&c.setDate(this._getDaysInMonth(c.getFullYear(),c.getMonth()));return this._isInRange(b,c)},_isInRange:function(b,a){var c=this._getMinMaxDate(b,"min"),d=this._getMinMaxDate(b,"max");return(!c||a.getTime()>=c.getTime())&&(!d||a.getTime()<=d.getTime())},_getFormatConfig:function(b){var a=this._get(b,"shortYearCutoff"),a="string"!=typeof a?a:(new Date).getFullYear()% 100+parseInt(a,10);return{shortYearCutoff:a,dayNamesShort:this._get(b,"dayNamesShort"),dayNames:this._get(b,"dayNames"),monthNamesShort:this._get(b,"monthNamesShort"),monthNames:this._get(b,"monthNames")}},_formatDate:function(b,a,c,d){a||(b.currentDay=b.selectedDay,b.currentMonth=b.selectedMonth,b.currentYear=b.selectedYear);a=a?"object"==typeof a?a:this._daylightSavingAdjust(new Date(d,c,a)):this._daylightSavingAdjust(new Date(b.currentYear,b.currentMonth,b.currentDay));return this.formatDate(this._get(b, "dateFormat"),a,this._getFormatConfig(b))}});a.fn.datepicker=function(b){if(!this.length)return this;a.datepicker.initialized||(a(document).mousedown(a.datepicker._checkExternalClick).find("body").append(a.datepicker.dpDiv),a.datepicker.initialized=!0);var c=Array.prototype.slice.call(arguments,1);return"string"==typeof b&&("isDisabled"==b||"getDate"==b||"widget"==b)||"option"==b&&2==arguments.length&&"string"==typeof arguments[1]?a.datepicker["_"+b+"Datepicker"].apply(a.datepicker,[this[0]].concat(c)): this.each(function(){"string"==typeof b?a.datepicker["_"+b+"Datepicker"].apply(a.datepicker,[this].concat(c)):a.datepicker._attachDatepicker(this,b)})};a.datepicker=new h;a.datepicker.initialized=!1;a.datepicker.uuid=(new Date).getTime();a.datepicker.version="1.8.17";window["DP_jQuery_"+d]=a})(jQuery);(function(a){function c(c,b,d){b=a(b);b.bind({mouseenter:function(){var a=b.position();k.showHint.start(c,{text:d(),pos:{x:a.left,y:a.top+b.outerHeight()},delay:200})},mouseleave:function(){k.showHint.cancel()}})}function f(c,b,d){b&&d&&(d=Object.create(d));d&&(c.prototype=d);b&&a.extend(c.prototype,b);return c}var k={_listeners:{started:a.Callbacks(),done:a.Callbacks(),canceled:a.Callbacks()},_fire:function(a,b){this._listeners[a].fire(b)},forEach:function(c){a.forEachOwnProperty(this,function(a, d){d.hasOwnProperty("active")&&c(a,d)})},anyActive:function(){var a=!1;this.forEach(function(b,c){c.active&&(a=!0)});return a},getActive:function(){var a;this.forEach(function(b,c){c.active&&(a?a.length?a.push(c):a=[a,c]:a=c)});return a},define:function(c,b){var d=b.start,f=b.done,g=b.cancel;b.active=!1;b.start=function(){if(this.active||!1===(a.isFunction(this.canStart)?this.canStart.apply(this,arguments):!0))return!1;console.logDebug("start: "+c);this.active=!0;a.isFunction(d)&&d.apply(this,arguments); k._fire("started",b);return this.active};b.done=function(){if(this.active){this.inDone=!0;console.logDebug("done: "+c);if(!1!==(a.isFunction(f)?f.apply(this,arguments):!0))this.active=!1,k._fire("done",b);this.inDone=!1}};b.cancel=function(){this.active&&(console.logDebug("cancel: "+c),this.active=!1,a.isFunction(g)&&g.apply(this,void 0),k._fire("canceled",b))};this[c]=b},addEventListener:function(a,b){this._listeners[a].add(b)}},h=function(){function c(b){var d={};a.each(b,function(a,b){d[b.id]= b});return d}var b=function(){function b(c,d,e){c=c._listeners||{};c[d]&&a.each(c[d],function(a,b){b(e)})}var c={};c.deleteIt=c._deleteIt=function(){this.visit(function(a){h.isModel(a)&&a.views.remove()});var a=this.parent;h.isChildList(a)&&a.remove(this);delete this.parent;this.markDeleted()};c.visit=function(a){function b(c){h.isModel(c)&&c.visit(a)}a(this);var c=this.type;this.forEachProperty(function(a,d){c.isChildList(a)?d.forEach(function(a){b(a)}):c.isChildRef(a)&&b(d)})};c.merge=function(a){var b= this;if(b!==a){if(b.type!==a.type)throw Error("type mismatch");a.mergedInto=b;b.type.copy(a,b);b.forEachProperty(function(b,c){c.merge(a[b])},void 0,{list:!0,childList:!0});b.forEachProperty(function(c){void 0!==b[c]&&void 0!==a[c]?b[c].merge(a[c]):b[c]=a[c]},void 0,{childRef:!0})}};c.markChanged=function(){this.change||(this.change=!1===this.saved?"add":"modify")};c.markDeleted=function(){this.change=!1===this.saved?void 0:"add"==this.change?void 0:"delete"};c.changeCommited=function(){"delete"== this.change?this.deleteIt():this.saved=this.change=void 0};c.addEventListener=function(a,b){this._listeners||(this._listeners={});var c=this._listeners;c[a]?c[a].push(b):c[a]=[b]};c.addStrongRef=function(a){this._refs=this._refs?this._refs.concat([a]):[a]};c.releaseStrongRef=function(b){b=a.inArray(b,this._refs);0<=b&&(this._refs.splice(b,1),0==this._refs.length&&this.views.remove())};c.setParent=function(a){this.parent!==a&&(a&&this.addStrongRef(a),this.parent&&this.releaseStrongRef(this.parent), this.parent=a,this.fireEvent("parentChanged",a,!1))};c.forEachProperty=function(a,b,c){var d=this;d.type.forEachProperty(function(b){return a(b,d[b])},b,c)};c.fireEvent=function(a,c,d){d?this.visit(function(d){b(d,a,c)}):b(this,a,c)};c.dump=function(){};return c}(),d=function(){function b(c,d){a.forEachOwnProperty(c.views,function(a,b){"_"!==a[0]&&"object"===typeof b&&d(a,b)})}function c(a,d){a.visit(function(a){b(a,d)})}var d=f(function(a,b,c,d,e){this.name=a;this.component=b;this._model=c;this.html= d;this._updateHandler=e},{update:function(a){this._model.fireEvent("update",a);this._updateHandler(a)},remove:function(){console.logDebug("view.remove: "+this.name);this.html.remove();delete this._model.views[this.name]},_belongsTo:function(a){return void 0===a||this.component===a}});return f(function(){},{add:function(a,b,c,e){console.logDebug("views.add: "+a+" model: "+this._model.id);if(this[a])throw Error("View with name "+a+" is already active");this[a]=new d(a,c,this._model,b,e)},remove:function(a){b(this._model, function(b,c){c._belongsTo(a)&&c.remove()})},update:function(a,b){c(this._model,function(c,d){d._belongsTo(b)&&d.update(a)})},forEach:function(a){b(this._model,a)}})}(),k=f(function(){},{isChildList:function(){return"child"==this.refType},push:function(a){this.setAt(this.length,a)},pushMany:function(b){var c=this;a.each(b,function(a,b){c.push(b)})},setAt:function(a,b){if(!h.isModel(b))throw Error("invalid model");this.isChildList()&&b.setParent(this);this.length<=a&&(this.length=a+1);this[a]=b},remove:function(b){var c= a.inArray(b,this);0<=c&&(this.splice(c,1),this.isChildList()&&b.setParent(void 0))},removeAll:function(){this.isChildList()&&a.each(this,function(a,b){b.setParent(void 0)});this.length=0},merge:function(b){if(!h.isChildList(b)&&!h.isList(b))throw new TypeError("List or ChildList expected");console.logDebug("ModelList.merge");var d=this,e=c(d),g=c(b);a.each(b,function(a,b){if(!h.isModel(b))throw Error("invalid source model");var c=e[b.id];c?d.isChildList()?(console.logDebug("merging model "+c.type.name+ " id:"+c.id),c.merge(b)):(b=b.mergedInto||b,c!==b&&(console.logDebug("replacing model "+c.type.name+" id:"+c.id),d.remove(c),d.push(b))):(console.logDebug("adding new model "+b.type.name+" id:"+b.id),d.push(b))});var f=[];a.each(d,function(a,b){g[b.id]||f.push(b)});a.each(f,function(a,b){console.logDebug("removing model "+b.type.name+" id:"+b.id);d.remove(b)})},hasId:function(a){return this.some(function(b){return b.id==a})},map:function(){return c(this)}},[]),g=f(function(){},{refType:"child"},new k), y=f(function(){},{}),s=f(function(){},{}),x=function(){function c(b,j,f){var n=Object.create(b.templateInstance);j&&a.forEachOwnProperty(j,function(a,c){if(b.isSimpleProperty(a)||b.isWeakRef(a)||"id"===a)n[a]=c});n.views=new d;b.forEachProperty(function(a){n[a]=new g;j&&j[a]&&n[a].pushMany(j[a])},void 0,{childList:!0});b.forEachProperty(function(a){n[a]=new k;j&&j[a]&&n[a].pushMany(j[a])},void 0,{list:!0});b.forEachProperty(function(a){h.createChildRefProperty(n,a)},void 0,{childRef:!0});n.saved= n.id?!0:!1;a.isFunction(n.init)&&n.init.apply(n,f);n.id||(n.id=a.createId());return n.views._model=n}function j(a){return"number"===typeof a||("boolean"===typeof a||"string"===typeof a)||a instanceof Date}return f(function(c){var d=this;d.templateInstance=Object.create(b);d.templateInstance.type=d;d.properties={};a.forEachOwnProperty(c,function(a,b){var c=b===k||b===g,e=b===s,f=b===y;if(!c&&!e&&"function"===typeof b||j(b))d.templateInstance[a]=!f?b:void 0;if(j(b)||c||e||f)d.properties[a]=b})},{create:function(){return c(this, void 0,arguments)},fromObject:function(a){return c(this,a)},compare:function(a,b,c){var d=!0;a.type.forEachProperty(function(c){var e;e=a[c];c=b[c];e=e instanceof Date&&c instanceof Date?e.getTime()==c.getTime():e==c;if(!e)return d=!1},c,{simple:!0});return d},copy:function(a,b,c){var d=!1;this.forEachProperty(function(c){b[c]!=a[c]&&(b[c]=a[c]&&a[c].mergedInto?a[c].mergedInto:a[c],d=!0)},c,{simple:!0,weakRef:!0});return d},forEachProperty:function(b,c,d){var e=this,g=void 0===d||!0===d.simple,j= void 0===d||!0===d.list,f=void 0===d||!0===d.childList,h=void 0===d||!0===d.childRef,k=void 0===d||!0===d.weakRef;a.each(this.properties,function(a){var d=!1;g&&e.isSimpleProperty(a)?d=!0:f&&e.isChildList(a)?d=!0:j&&e.isList(a)?d=!0:h&&e.isChildRef(a)?d=!0:k&&e.isWeakRef(a)&&(d=!0);if(d&&(!c||!0===c(a)))return b(a)})},isSimpleProperty:function(a){return j(this.properties[a])},isList:function(a){return this.properties[a]===k},isChildList:function(a){return this.properties[a]===g},isChildRef:function(a){return this.properties[a]=== s},isWeakRef:function(a){return this.properties[a]===y}})}();return{define:function(a,b){var c=new x(b);c.name=a;h[a]=c},isList:function(a){return a instanceof k&&!a.isChildList()},isChildList:function(a){return a instanceof k&&a.isChildList()},List:k,ChildList:g,ChildRef:s,WeakRef:y,createChildRefProperty:function(a,b){var c;Object.defineProperty(a,b,{set:function(a){c!==a&&(void 0!==c&&c.setParent(void 0),a&&h.isModel(a)&&a.setParent(this),c=a)},get:function(){return c},enumerable:!0})},isModel:function(a){return a&& void 0!==a.id&&void 0!==a.type&&void 0!==a.views}}}(),d={};a.mvc={actions:k,views:{define:function(c,b){d[c]=b;a.mvc.views[c]=b}},models:h,app:{}};a.fn.mvcload=function(){function c(b){function e(c){function d(b,c,e,g,j){var f=l,b=h.isList(b)||h.isChildList(b)?b:[b],t;a.each(b,function(){var b=this,h,k=!1,B=a.isFunction(g.template)?g.template.call(f,b):g.template;if(void 0!=B){var n=l.templates[B];if(!n)throw Error("Template "+B+" does not exist");if(b.views[B])h=b.views[B].html;else{n=Object.create(n); n.component||(n.component=f);var p=!n.content||""===n.content;h=p?e:a(n.content);p||a("[mvc]",h).mvcload();b.views.add(B,h,f,function(b){a.isFunction(n.applyData)&&n.applyData(b)});a.isFunction(n.init)&&n.init(h,b,c);k=!0}b.views[B].update();n.expand&&a.each(n.expand,function(){var c=this.field?b[this.field]:this.componentField?f[this.componentField]:b;if(c){var e=this.insertAt?a(this.insertAt,h):h;if(0==e.length)throw Error("Cannot insert content. Selector "+this.insertAt+" yelded no results");d(c, b,e,this,j)}});k&&!p&&(t=t?t.add(h):h)}});t&&t[{insertTop:"prependTo",insertBottom:"appendTo",replace:"replaceWith"}[g.insertOperation?g.insertOperation:"insertBottom"]].call(t,e)}var g=l.rootModel;g?(c||(a(b).empty(),g.views.remove(u)),d(g,void 0,b,{insertAt:"",template:l.rootTemplate},c)):a(b).html(l.initialContent?l.initialContent:l.templates[l.rootTemplate].contents);m("layoutCreated")}function j(b,c){if(!b)throw new TypeError;m("dataReceived",b);var d;if(h.isModel(b))d=b;else if(a.isFunction(l.createModelFromData))d= l.createModelFromData(b);else throw Error("Component must implement createModelFromData");var f=l.rootModel;c&&f?f.merge(d):(l.rootModel&&l.rootModel.views.remove(u),l.rootModel=d);m("dataLoaded",l.rootModel);e(c);l.rootModel&&l.rootModel.fireEvent("changed",void 0,!0);m("modelUpdateComplete",l.rootModel)}function f(b){o({successCallback:function(){return{refreshView:b?"incremental":"full"}},errorCallback:function(b,c,d){var e;b&&b.status&&(e+="responseStatus:"+b.status+" ");c&&(e+="TextStatus:"+ c+" ");d&&(e+=d);if(a.isFunction(l.onAjaxError))l.onAjaxError(e)}})}function k(b){a.isFunction(l.getData)?(b=l.getData(b))&&j(b,!0):l.serverModel&&f(b)}function o(c){var d=a.extend({args:null,returnData:!0,successCallback:function(){},errorCallback:function(){},completedCallback:function(){}},c),c=JSON.stringify({Attributes:function(){for(var a={},c=0;c=a&&c<=b}};k.define("showHint",function(){function c(){g&&clearTimeout(g);g=void 0;d&&d.remove();d=void 0}function b(b){(h&&(h.x!=b.pos.x||h.y!=b.pos.y)||k&&k!=b.text)&&c();g||(h=b.pos,k=b.text,g=setTimeout(function(){d=a('').css({left:h.x, top:h.y+3}).setText(b.text).appendTo(f).fadeIn()},b.delay?b.delay:100));shown=!0}var d,f,g,h,k;return{start:function(a,c){f=a;b(c)},update:b,cancel:function(){c();f=void 0}}}());a.fn.contextMenu=function(c){if(0!=this.length){var b=this[0],d,f,g=a('',expand:[{field:"beds",insertAt:"div.design-window",template:function(a){return"delete"==a.change?void 0:"bed"}}],init:function(n,o){function l(a){for(var a=m.tile(a),b=0;bMath.abs(b.x-d.x)&&10>Math.abs(b.y-d.y);g.drawingBed.active?5
<\!--div class="menu-icon"> 
',expand:[{field:"squares",template:"square"}],init:function(a,b){function c(){$(".bed-title",a).toggleClass("muted",!$(".bed-title input",a).val());$(".bed-title .title-text span",a).text($(".bed-title input", a).val()||"Title");b.title=$(".bed-title input",a).val();$(".bed-title .title-text",a).show();$(".bed-title input",a).hide();b.markChanged();$.mvc.app.save()}a.bind("contextmenu",function(a){a.preventDefault();a.stopPropagation();a=e.fromPage(a.pageX,a.pageY);g.showBedActions.start(b,a)});b.title?($(".bed-title .title-text span",a).text(b.title),$(".bed-title input",a).val(b.title)):($(".bed-title .title-text span",a).text("Title"),$(".bed-title",a).addClass("muted"));$(".bed-title input",a).hide(); $(".bed-title .title-text span",a).on("click",function(){$(".bed-title .title-text",a).hide();$(".bed-title input",a).show().focus();$(".bed-title",a).toggleClass("muted",false)});$("div.bed .bed-title .menu-icon",a).on("click",function(){var c=a.getBoundingClientRec(),c=e.fromPage(c.left,c.top);g.showBedActions.start(b,c)});$(".bed-title input",a).focusout(c);$(".bed-title input",a).on("keyup",function(a){a.which==13&&c()});this.applyData=function(){$(a).css({left:!b.moving?m.posX(b.x):g.moveBed.currentPos.x, top:!b.moving?m.posY(b.y):g.moveBed.currentPos.y,width:b.w*k,height:b.h*k,opacity:""}).toggleClass("bed-drawing",b.drawing===true).toggleClass("bed-moving",b.moving===true).toggleClass("squares-selected",b.squaresSelected===true).toggleClass("selected",b.selected===true);for(var c in s)if(s[c]){var d=s[c];$(".bed-title",a).toggleClass("zoom"+d.tileSize,d.tileSize==k)}$("span.info",a).setText(b.drawing?""+b.w+"X"+b.h:"")}}},square:{content:'
', init:function(a,b){function c(){var b=!!u.attr("src");if(b)var d="none"!=$(".planted img",a).css("display"),e="none"!=$(".prev-crop",a).css("display"),d=(125!=k||!d||!e)&&(100!=k||!e)&&(80!=k||!(d||e))&&64!=k&&52!=k;q.toggle(!(!d||!b))}var d=$("div",a),e=$(".prev-crop",a),f=$("span",e);$(".crop-count",a);var h=$("span.crop",a),j=$("span.count",a),p=$(".plant-date",a),y=$("span",p),p=$(".planted",a),r=$("img",p),q=$(".crop-image",a),u=$("img",q),F;this.applyData=function(){$(a).css({left:m.posX(b.x), top:m.posY(b.y),width:k-2,height:k-2}).toggleClass("selected",!0===b.selected);var p=b.plantings;b.selected&&g.editSquares.active&&(p=g.editSquares.plantings());var q,v;$.each(p,function(a,b){if(b.harvested)q=b;else return v=b,!1});v&&!v.crop&&(v=null);f.setText(q?q.displayName(s[x].maxPrevCropName):"");q?e.show():e.hide();h.r(function(){return v?v.displayName(s[x].maxCropName,!0):""});j.setText(v?v.count:"");u.attr("src",v&&v.cropinfo&&v.cropinfo.image||"");y.r(function(){return v?"@"+strings.formatShortDate(v.plantDate): ""});r.toggle(void 0!=v&&v.planted);F!=o&&d.css("font-size",""+o+"%");F=o;c()}}}}}});models.define("CatalogModel",{crops:models.ChildList}); $.mvc.views.define("Catalog",{init:function(){function a(){f.rootModel.views.update("attachEvents")}function c(a){console.logDebug("cropSelected: "+(a?a.name:void 0));b=!0;f.fireEvent("onCropSelected",a)}var f=this,k=!1,h,d;f.serverModel="Catalog";var j,b=!1;f.getData=function(a){k?a=d?{crops:d.crops.slice(0),query:"*"}:f.serverRequestInProgress?void 0:f.defaultGetData(a):(a={crops:[]},k=!0);return a};this.createModelFromData=function(a){!d&&("*"===f.filter&&a.crops&&a.crops.length)&&(d={crops:a.crops.slice(0), query:"*"});a.crops&&"*"!=f.filter&&(a.crops=a.crops.filter(function(a){return a.name.slice(0,f.filter.length)==f.filter}));return models.CatalogModel.fromObject({crops:$.map(a.crops,function(a){return models.CropInfo.fromObject(a)})})};f.setQuery=function(a,b,c){a=a?a.toLowerCase():"*";if(f.filter==a&&!0!==b)return!1;f.setHighlightedIndex(void 0);f.filter=a;f.dataLoaded=c;f.refreshView({fetchData:!0,incremental:!0})};f.setHighlightedIndex=function(a){var b=f.rootModel.crops,c=f.highlightedIndex; f.highlightedIndex=a;if(void 0!=f.highlightedIndex&&(f.highlightedIndex>=b.length&&(f.highlightedIndex=b.length-1),0>a))f.highlightedIndex=void 0;b&&$.each(b,function(a,b){b.highlighted=a==f.highlightedIndex});void 0!=c&&b[c].views.update();void 0!=f.highlightedIndex&&(a=b[f.highlightedIndex],a.views.update(),j.val(a.name))};f.start=function(){b=!1;f.setHighlightedIndex(void 0);j.val("");f.ensureFocus();!1==f.setQuery("*",!1,function(){a()})&&a()};f.ensureFocus=function(){j.focus()};f.acceptInput= function(){if(!b){var a=j.val(),d;d=void 0!=f.highlightedIndex?f.rootModel.crops[f.highlightedIndex]:void 0;if(!d&&!a)return!1;d||f.rootModel.crops.forEach(function(b){if(b.name.toLowerCase()==a.toLowerCase())return d=b,!1});d?c(d):c(a);return!0}};this.templates={root:{content:'
    _Not in the catalog?
    Just type it and hit Enter, or click Accept.
    ', expand:[{field:"crops",template:"catalogitem",insertAt:"ul"}],init:function(a){var b=this.component;h=a.find("div.catalog-viewport");j=$("input.crop-name",a);var c=$("div.not-in-catalog",a);this.applyData=function(a){if("attachEvents"==a){var d=function(){console.logDebug("changeEvent");var a=j.val();b.setQuery(a,!1,function(a){c.toggle(a.crops.length==0)})};j.on({keydown:function(a){console.logDebug("keyEvent - enter");if(a.which&&13==a.which||a.keyCode&&13==a.keyCode)if(a.preventDefault(),a.stopPropagation(), b.acceptInput())return!0},change:d,keyup:function(a){console.logDebug("input.keyup - enter");40==a.keyCode?(f.setHighlightedIndex(void 0==f.highlightedIndex?0:f.highlightedIndex+1),a.preventDefault()):38==a.keyCode&&(f.setHighlightedIndex(f.highlightedIndex?f.highlightedIndex-1:void 0),a.preventDefault());a.isDefaultPrevented()||d();console.logDebug("input.keyup - leave")},focus:function(){b.setHighlightedIndex(void 0)}});$("a.accept",b.div).bind({click:function(a){b.acceptInput();a.preventDefault()}})}}}}, catalogitem:{content:"
  • ",init:function(a,b){var d=!1;this.applyData=function(f){if("attachEvents"==f||!d)console.logDebug("catalogitem attachEvents: "+b.name),d=!0,a.on({click:function(a){c(b);a.preventDefault()}});if(!f&&($("span",a).setText(b.name),b.image&&$("img",a).attr("src",b.image),f=!!b.highlighted,a.toggleClass("highlighted",f),f)){var f=a.position().top,j=a.outerHeight(),k=0;0>f?k=-j:f+j>h.height()&&(k=j);k&&(f=h.scrollTop()+k,h.animate({scrollTop:f},200))}}}}}}}); $.mvc.views.define("PlantingsList",{init:function(){var a=this,c=$.mvc.actions,f;a.MaxCropName=25;a.selectedIndex=0;a.setSelectedIndex=function(c){a.selectedIndex=c;a.refreshView({content:!0});a.fireEvent("selectedIndexChanged")};a.selection=function(){return a.selectedIndex').mvcload().component(), d=$.mvc.app.catalog,d.catalogDiv=d.div,d.canceled=function(){c.editSquares.cancel()});return{catalog:d,canStart:function(){return $.mvc.actions.editSquares.active},start:function(a){f(true,a)},ensureFocus:function(){d.ensureFocus()},done:function(a){if(d.acceptInput()===false)return false;f(false,true,a)},cancel:function(){f(false,false)}}}());a.viewUpdate=function(){var c=a.selection();c&&c.setFocus&&c.setFocus()};this.templates={root:{content:'
    ',expand:[{field:"plantings", template:"planting"}],init:function(a){a.click(function(){console.logDebug("plantings-list click")})}},planting:{content:'





    _Planted
    _Harvested

    ', init:function(h,d,j){function b(a){o.find("option").each(function(){$(this).toggleClass("suggested",$(this).val()==a)})}function e(a){console.logDebug("setCropInfo: "+(a?a.name:"undefined"));H=a;m.attr("src",H&&H.image?H.image:"/images/NotInCatalog.png")}function k(a){a&&(d.crop=a.name,d.count=a.plantsPerSquare,d.daysToHarvest=a.daysToHarvest,d.harvestDurationDays=a.harvestDurationDays,d.yieldKgPerPlant=a.yieldKgPerPlant,d.cropinfo=a,d.views.update(),s());e(a)}function g(){var a=0=c&&b<=d?b:e}d.update({note:F.val(),count:Number(o.val()),daysToHarvest:a(q.val(),0,5E3,d.daysToHarvest),harvestDurationDays:a(n.val(), 0,5E3,d.harvestDurationDays),yieldKgPerPlant:a(w.val(),0,1E4,d.yieldKgPerPlant),planted:l.is(":checked"),harvested:t.is(":checked"),cropinfo:H})}function s(){console.logDebug("changeEvent");y();j.modified=!0;j.none=!d.crop&&!j.modified;j.views.update("keepfocus");a.fireEvent("onchange")}var x=$("img.delete",h),o=$("select.plants-count",h),m=$("img.crop-image",h),r=$("img.status-image",h),u=$("input.plant-date",h),q=$("input.days-to-harvest",h),n=$("input.harvest-duration",h),w=$("input.yield",h), l=$("input.planted",h),t=$("input.harvested",h),D=$("div.crop-details",h),B=$("span.plants-per-square-count",h),C=$("span.plants-per-square-text",h),K=$("span.duration-text",h),M=$("div.plant-status",h);$("div.plant-status",h);var P=$("div.crop-header",h),N=$("span.crop-name",h),I=$("div.notes",h),J=$("div.harvested",h),F=$("input.notes",h);$(".more-details",h).r("edit");$(".crop-details .plants-per-square",h).r("plants_per_square");$(".crop-details .plant-date",h).r("plant_date");$(".crop-details .days-to-harvest", h).r("days_to_harvest");$(".crop-details .harvest-duration",h).r("harvest_duration");$(".crop-details .yield",h).r("yield");$(".plant-status .planted span",h).r("planted");$(".plant-status .harvested span",h).r("harvested");$(".notes label",h).r("notes");var G=c.showCatalog.catalog,H;$.extend(d,{setCrop:function(a){"string"==typeof a?(d.crop=a,d.cropinfo=void 0,d.views.update(),s(),e(void 0)):k(a)},ensureSelected:function(){a.selectedIndex!=this.order&&a.setSelectedIndex(this.order)}});d.views.planting.save= y;h.bind({mouseenter:function(){d!==a.selection()&&h.addClass("hover")},mouseleave:function(){h.removeClass("hover")}});u.datepicker({beforeShow:function(){u.datepicker("setDate",d.plantDate);f=u},onSelect:function(b){d.update({plantDate:new Date(b)});j.views.update();a.fireEvent("onchange")},onClose:function(){f=void 0},minDate:PlantDate.min,maxDate:PlantDate.max});$(h).click(function(){d.ensureSelected()});o.bind("keypress keydown",function(a){if(a.which&&13==a.which||a.keyCode&&13==a.keyCode)return void 0!= G.highlightedIndex?k(G.rootModel.crops[G.highlightedIndex]):c.editSquares.done(),!0;if(a.which&&27==a.which||a.keyCode&&27==a.keyCode)return c.editSquares.cancel(),!0});o.bind("change",s);l.bind("change",s);q.bind("change",s);n.bind("change",s);F.bind("change",s);t.bind({change:function(a){s(a);c.editSquares.harvestedPropertyChanged()},click:function(a){d.harvested&&a.stopPropagation()}});$("a.change",h).click(function(a){d.ensureSelected();c.showCatalog.start();a.preventDefault()});$("a.more-details", h).click(function(a){d.ensureSelected();D.toggle(300);a.preventDefault()});x.click(function(){c.editSquares.deletePlanting(d)});a.div.tooltip(x,function(){return 1
    _PLANT SQUARE(S)
    ', init:function(f,k){var h=$("a.replant",f),d=$("input.ok-button",f),j=$("div[mvc=PlantingsList]",f).component();$(".header",f).r("square_editor_title");d.r_val("ok");$(".cancel-button",f).r_val("cancel");this.applyData=function(){var a=actions.editSquares.plantings();if(a.length){var c=a[a.length-1];h.r(function(){return $.r("replant")+" "+strings.formatShortDate(c.endDate())})}c=a[a.length-1];h.toggle(0a.length&&""!==c.crop&&"perennial"!=c.lifecycle())};c.dialogDiv=f;actions.define("editSquares", function(){function b(){$(f).hide();j.hide();g.none=!0;actions.selectSquares.cancel();actions.showCatalog.cancel();e()}function e(){k.views.root.update();$.mvc.app.model.timeline.views.update("highlight")}function h(){var a=0;$.each(g.plantings,function(b,c){if(!c.harvested||b==g.plantings.length-1)return a=b,!1});j.setSelectedIndex(a)}var g=models.EditorValues.create();return{activePlanting:function(){return j.selection()},plantings:function(){return g.plantings},canStart:function(){return actions.selectSquares.active}, start:function(){function b(){c.fireEvent("shown");a()}actions.editSquares.update();var d=actions.selectSquares.selection().bed,d=$.mvc.app.coords.toViewport({x:$.mvc.app.coords.posX(d.x+d.w)+17,y:$.mvc.app.coords.posY(d.y)}),e=$.mvc.app.designViewport();d.x=Math.max(d.x,0);d.y=Math.max(d.y,0);d.x=Math.min(d.x,e.width());d.y=Math.min(d.y,e.height());$(f).css({left:d.x,top:d.y});$.mvc.app.disableAnimations?b():$(f).fadeIn(200,b)},update:function(){actions.showCatalog.cancel();var b=!1,c=!1;g.none= !0;var d;actions.selectSquares.active&&$.each(actions.selectSquares.selection().squares(),function(a,e){if(e.plantings[0].crop)if(d){if(d.length!=e.plantings.length)return b=!0,!1;for(a=0;a g.plantings.length;)c.plantings[c.plantings.length-1].deleteIt(),b=!0;for(a=0;a>> mouseup");j.dismissDatePickerIfNeeded()});$(f).bind("mousedown mouseup mousemove click",function(a){a.stopPropagation()});d.click(function(){actions.editSquares.done()});$(".cancel-button",f).click(function(){_gaq.push(["_trackEvent","squareEdit","cancel-button"]);actions.editSquares.cancel()})}}}}});$.mvc.app.TIMELINE_BAR_HEIGHT_WITH_MARGIN=25;models.define("Month",{month:0,year:0,init:function(a,c){this.year=c;this.month=a;this.id=c+"$"+a}});models.define("Group",{summary:models.WeakRef,barLines:0,init:function(a){this.summary=a;this.id=a.crop}}); models.define("bar",{startDate:new Date,harvestStartDate:new Date,harvestEndDate:new Date,endDate:new Date,planting:models.WeakRef,group:models.WeakRef,line:0,init:function(a,c,f){this.id=a.id;"perennial"==a.lifecycle()?(this.startDate=f.startDate,this.endDate=f.endDate,f=f.startDate.getFullYear(),this.harvestStartDate=a.harvestStartDate(f),this.harvestEndDate=a.harvestEndDate(f)):(this.startDate=a.plantDate,this.endDate=this.harvestEndDate=minDate(a.endDate(),f.endDate),this.harvestStartDate=minDate(a.harvestStartDate(), f.endDate),this.harvestEndDate=minDate(a.harvestEndDate(),f.endDate));this.planting=a;this.group=c},getLine:function(){return this.line}}); models.define("Timeline",{groups:models.ChildList,bars:models.ChildList,months:models.ChildList,init:function(){var a=this;this.addEventListener("parentChanged",function(){a.parent&&a.parent.addEventListener("changed",function(){a.update(a.parent)})})},update:function(a){var c=this,f=a.minDate();c.startDate=new Date(f.getFullYear(),f.getMonth(),1);var f=new Date(c.startDate.getFullYear()+1,c.startDate.getMonth(),1),k=a.maxDate();c.endDate=k>f?k:f;f=new models.List;f.pushMany($.map(a.summary.crops, function(a){return models.Group.create(a)}));c.groups.merge(f);var h=c.groups.map(),a=a.allPlantings(),a=$.map(a,function(a){var f=h[a.crop];if(!f)throw Error("Summary for "+a.crop+" not found");return $.mvc.models.bar.create(a,f,c)}),k=function(){var a=[],f;f=c.startDate;var b=c.endDate,e;e=12*(b.getFullYear()-f.getFullYear());e-=f.getMonth()+1;f=e+=b.getMonth();for(b=0;b
    ', expand:[{field:"groups",template:"group",insertAt:"table.timeline-groups"},{field:"months",template:"month",insertAt:"table.timeline tbody tr:first"},{field:"months",template:"monthheader",insertAt:"table.timeline thead tr:first"},{field:"months",template:"monthfooter",insertAt:"table.timeline tfoot tr:first"},{field:"bars",template:"bar",insertAt:"div.timeline-container"},{template:"currentdatemarker",insertAt:"div.timeline-container"}],init:function(c,f){var k=$("table.timeline",c),h=k.find("tbody"), d=$("table.timeline-groups",c);this.applyData=function(){var c=h.width();if(c){var b=d.find("tbody"),e=$("tbody>tr:first>td:first",k),b=b.height();e.css({height:Math.max(b-1,0)});k.find("tfoot").toggle(0',init:function(){}},monthheader:{content:'
    ',init:function(a, f){$("span.month",a).r(function(){return strings.shortMonth(f.month)});$("span.year",a).setText(f.year)}},monthfooter:{content:'
    ',init:function(a,f){$("span.month",a).r(function(){return strings.shortMonth(f.month)});$("span.year",a).setText(f.year)}},bar:{content:'
    ',init:function(c,f,k){this.applyData=function(h){console.logDebug("bar.applyData: hint: "+h);if(!("placebars"!=h&&"highlight"!=h))if(f.group.views.group)if("placebars"== h)h=f.group.views.group.html.position().top,console.logDebug("bar.applyData: group: "+f.group.id+" crop: "+f.planting.crop+" groupTop:"+h),c.css({width:(f.endDate-f.startDate)/a.timePerPixel,top:h+f.line*$.mvc.app.TIMELINE_BAR_HEIGHT_WITH_MARGIN+5,left:(f.startDate-k.startDate)/a.timePerPixel}),c.toggleClass("planted",f.planting.planted),c.toggleClass("harvested",f.planting.harvested);else{if("highlight"==h){h=!1;if(actions.editSquares.active){var d=actions.selectSquares.selection();1==d.squaresCount()&& f.planting.square.bed==d.bed&&d.squares()[0]==f.planting.square&&(h=actions.editSquares.selectedPlanting(),h=f.planting.order==h.order&&f.planting.crop==h.crop)}console.logDebug("planting "+f.planting.id+" square: "+f.planting.square.id+" highlight: "+h);$(c).toggleClass("highlighted",h)}}else console.logDebug("bar.applyData: group not set")};c.click(function(){_gaq.push(["_trackEvent","timeline","bar-clicked"]);actions.selectSquares.active?f.planting.square.bed==actions.selectSquares.selection().bed? actions.selectSquares.restart(f.planting.square):(actions.editSquares.done(),actions.selectSquares.start(f.planting.square)):actions.selectSquares.start(f.planting.square);actions.editSquares.setSelectedPlanting(f.planting.order)})}},currentdatemarker:{content:'
    ',init:function(c,f,k){this.applyData=function(){c.css({left:(new Date-k.startDate)/a.timePerPixel})}}}}}}); $.mvc.views.define("HarvestTimeline",function(){var a=Object.create($.mvc.views.Timeline),c=a.init;a.init=function(){var a=this;c.apply(this);this.templates.group={content:'
    ',init:function(a,c){this.applyData=function(){a.css({height:c.barLines*$.mvc.app.TIMELINE_BAR_HEIGHT_WITH_MARGIN+20});$("span.cropName",a).r(c.summary.crop);var d=c.summary.cropinfo;$("img.cropimage",a).attr("src",d&&d.image? d.image:"/images/NotInCatalog.png")}}};this.templates.harvestbar={content:'
    ',init:function(c,h){var d=c.find("img");this.applyData=function(){var j="perennial"==h.planting.lifecycle(),b=(h.harvestEndDate-h.harvestStartDate)/a.timePerPixel;c.css({"float":j?"none":"right","margin-left":j?(h.harvestStartDate-h.startDate)/a.timePerPixel:0,width:b});d.toggle(11<=b)}}};this.templates.bar.expand=[{template:"harvestbar"}]};return a}());models.define("Summary",{crops:models.ChildList,totalsqft:0,plantedsqft:0,bedsCount:0,init:function(){var a=this;this.addEventListener("parentChanged",function(){a.parent&&a.parent.addEventListener("changed",function(){a.update(a.parent)})})},update:function(a){console.logDebug("Summary.update");var c={},f=0,k=0;$.each(a.beds,function(a,d){d.isValid()&&(f+=d.w*d.h,d.forEachSquare(function(a){a.plantings[0].crop&&k++}),d.forEachPlanting(function(a){if(a.square){var b=c[a.crop];b?(b.squares++,b.plants+= a.count):(b=models.CropSummary.fromObject({id:a.crop,cropinfo:a.cropinfo,crop:a.crop,squares:1,plants:a.count}),c[a.crop]=b)}}))});this.merge(models.Summary.fromObject({crops:$.map(c,function(a){return a}),totalsqft:f,plantedsqft:k,bedsCount:a.beds.length}));this.views.update()}});models.define("CropSummary",{crop:"",squares:0,plants:0,cropinfo:models.WeakRef}); $.mvc.views.define("Summary",{init:function(){function a(){return $("div[mvc=HarvestTimeline]",c.div).component()}var c=this;this.modelUpdateComplete=function(){if(c.rootModel){var f=a(),k=c.rootModel.parent.timeline;f.rootModel!==k&&f.setData(k,!0)}};this.show=function(){if("none"==c.div.css("display")){c.div.show();var f=a();f&&f.updateBars()}};this.rootTemplate="summary";this.templates={summary:{content:'
    _Beds_Total Squares_Planted Squares
    ', expand:[],init:function(a,c){$("div.content",a);$("div[mvc=HarvestTimeline]",a);$(".totals th.total-beds",a).r("total_beds");$(".totals th.total-sqft",a).r("total_sqft");$(".totals th.planted-sqft",a).r("planted_sqft");this.applyData=function(){$("span.totalbeds",a).setText(c.bedsCount);$("span.plantedsqft",a).setText(c.plantedsqft+" ("+(c.totalsqft?Math.round(100*c.plantedsqft/c.totalsqft):0)+"%)");$("span.totalsqft",a).setText(c.totalsqft)}}}}}});models.define("Feedback",{}); $.mvc.views.define("Feedback",{returnData:!1,init:function(){var a=this,c=$.mvc.actions;this.serverModel=void 0;this.getData=function(){return models.Feedback.create()};a.show=function(){$("textarea",a.div).focus()};this.templates={root:{content:'