var BrowserDetect={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(D){for(var A=0;A<D.length;A++){var B=D[A].string;var C=D[A].prop;this.versionSearchString=D[A].versionSearch||D[A].identity;if(B){if(B.indexOf(D[A].subString)!=-1){return D[A].identity;}}else{if(C){return D[A].identity;}}}},searchVersion:function(B){var A=B.indexOf(this.versionSearchString);if(A==-1){return ;}return parseFloat(B.substring(A+this.versionSearchString.length+1));},dataBrowser:[{string:navigator.userAgent,subString:"OmniWeb",versionSearch:"OmniWeb/",identity:"OmniWeb"},{string:navigator.vendor,subString:"Apple",identity:"Safari"},{prop:window.opera,identity:"Opera"},{string:navigator.vendor,subString:"iCab",identity:"iCab"},{string:navigator.vendor,subString:"KDE",identity:"Konqueror"},{string:navigator.userAgent,subString:"Firefox",identity:"Firefox"},{string:navigator.vendor,subString:"Camino",identity:"Camino"},{string:navigator.userAgent,subString:"Netscape",identity:"Netscape"},{string:navigator.userAgent,subString:"MSIE",identity:"Explorer",versionSearch:"MSIE"},{string:navigator.userAgent,subString:"Gecko",identity:"Mozilla",versionSearch:"rv"},{string:navigator.userAgent,subString:"Mozilla",identity:"Netscape",versionSearch:"Mozilla"}],dataOS:[{string:navigator.platform,subString:"Win",identity:"Windows"},{string:navigator.platform,subString:"Mac",identity:"Mac"},{string:navigator.platform,subString:"Linux",identity:"Linux"}]};BrowserDetect.init();var WeekUtil={getDay:function(E,D){var B=this.getDayName(D);for(var C=0;C<E.length;C++){var A=E[C];if(A.name==B){return A;}}return null;},getDayName:function(A){switch(A){case 1:return"monday";case 2:return"tuesday";case 3:return"wednesday";case 4:return"thursday";case 5:return"friday";case 6:return"saturday";case 7:return"sunday";default:return"";}}};var WorkoutUtil={appendEditDiv:function(B,I,E,G,F){var D=document.createElement("div");D.className=E;B.appendChild(D);var C=document.createElement("a");C.href="";C.id="edit_"+I;C.className=G;C.innerHTML="E";D.appendChild(C);var A=document.createTextNode("\u00a0");D.appendChild(A);Event.observe(C,"click",EditWorkout.editWorkout.bindAsEventListener(EditWorkout));var H=document.createElement("a");H.href="";H.id="delete_"+I;H.className=F;H.innerHTML="X";D.appendChild(H);Event.observe(H,"click",DeleteWorkout.deleteWorkout.bindAsEventListener(DeleteWorkout));},appendPlannedEditDiv:function(B,I,E,G,F){var D=document.createElement("div");D.className=E;B.appendChild(D);var C=document.createElement("a");C.href="";C.id="editPlanned_"+I;C.className=G;C.innerHTML="E";D.appendChild(C);var A=document.createTextNode("\u00a0");D.appendChild(A);Event.observe(C,"click",EditPlannedWorkout.editWorkout.bindAsEventListener(EditPlannedWorkout));var H=document.createElement("a");H.href="";H.id="deletePlanned_"+I;H.className=F;H.innerHTML="X";D.appendChild(H);Event.observe(H,"click",DeletePlannedWorkout.deleteWorkout.bindAsEventListener(DeletePlannedWorkout));}};var StringUtil={trimString:function(A){return A.replace(/^\s+/g,"").replace(/\s+$/g,"");}};function entityEncode(B,F){if(!isNaN(B)){return B;}var D=[];var A=[];var I=0;var C=0;var H=/[\\w\\s]/;for(var K=0;K<B.length;++K){var G=B.charAt(K);var J=G.charCodeAt(0);if(isNaN(J)){D.push(A.push(G));}else{var E="&#"+J+";";A.push(E);D.push(H.test(G)?G:E);}}return(F?D.join(""):A.join(""));}function urlencode(F){var E={},C={},D=0,B=[];var A=F.toString();E["!"]="%21";E["%20"]="+";A=encodeURIComponent(A);for(search in E){replace=E[search];B=A.split(search);A=B.join(replace);}return A.replace(/(\%([a-z0-9]{2}))/g,function(I,H,G){return"%"+G.toUpperCase();});return A;}function urldecode(E){var D={},B={},C=0,F=[];var A=E.toString();D["!"]="%21";D["%20"]="+";for(replace in D){search=D[replace];tmp_arr=A.split(search);A=tmp_arr.join(replace);}A=decodeURIComponent(A);return A;}var URLUtil={encode:function(A){return escape(this._utf8_encode(A));},decode:function(A){return this._utf8_decode(unescape(A));},_utf8_encode:function(B){B=B.replace(/\r\n/g,"\n");var A="";for(var D=0;D<B.length;D++){var C=B.charCodeAt(D);if(C<128){A+=String.fromCharCode(C);}else{if((C>127)&&(C<2048)){A+=String.fromCharCode((C>>6)|192);A+=String.fromCharCode((C&63)|128);}else{A+=String.fromCharCode((C>>12)|224);A+=String.fromCharCode(((C>>6)&63)|128);A+=String.fromCharCode((C&63)|128);}}}return A;},_utf8_decode:function(A){var B="";var C=0;var D=c1=c2=0;while(C<A.length){D=A.charCodeAt(C);if(D<128){B+=String.fromCharCode(D);C++;}else{if((D>191)&&(D<224)){c2=A.charCodeAt(C+1);B+=String.fromCharCode(((D&31)<<6)|(c2&63));C+=2;}else{c2=A.charCodeAt(C+1);c3=A.charCodeAt(C+2);B+=String.fromCharCode(((D&15)<<12)|((c2&63)<<6)|(c3&63));C+=3;}}}return B;}};var I18N={messages:new Array(),addMessage:function(A,B){this.messages[A]=B;},getMessage:function(A){return this.messages[A];}};var FormValidator={MONTH_LOOKUP:{"01":31,"03":31,"04":30,"05":31,"06":30,"07":31,"08":31,"09":30,"10":31,"11":30,"12":31},MONTH_REGEX:/^\d{4}(\-)\d{2}\1\d{2}$/,HR_REGEX:/^\d{2,3}$/,DOUBLE_DIGIT_REGEX:/^\d{1,2}$/,DECIMAL_REGEX:/(^\d\d*\.\d*$)|(^\d\d*$)|(^\.\d\d*$)/,SINGLE_DIGIT_REGEX:/^\d{1}$/,EMAIL_REGEX:/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/,INVALID:"INVALID",VALID:"VALID",INVALID_EMPTY:"INVALID_EMPTY",INVALID_CONTAINS_SPACES:"INVALID_CONTAINS_SPACES",INVALID_LENGTH:"INVALID_LENGTH",INVALID_CHARACTERS:"INVALID_CHARACTERS",validateDate:function(A){return this.validateDate(A,true);},validateDate:function(F,A){var D=false;if(F==""){if(A){return true;}else{return false;}}else{if(!this.MONTH_REGEX.test(F)){return false;}else{var B="-";var G=F.split(B);var H=parseInt(G[2],10);if(this.MONTH_LOOKUP[G[1]]!=null){if(H<=this.MONTH_LOOKUP[G[1]]&&H!=0){return true;}}var E=parseInt(G[1],10);if(E==2){var C=parseInt(G[0]);if(H>0&&H<29){return true;}else{if(H==29){if((C%4==0)&&(C%100!=0)||(C%400==0)){return true;}}}}}}return false;},validateHr:function(A){if(A==""){return true;}if(!this.HR_REGEX.test(A)){return false;}else{if(A>=20&&A<=240){return true;}}return false;},validateDoubleDigit:function(A){if(A==""){return true;}else{return this.DOUBLE_DIGIT_REGEX.test(A);}},validateDecimal:function(A){return this.validateDecimal(A,true);},validateDecimal:function(B,A){if(!B){if(A){return true;}else{return false;}}else{return this.DECIMAL_REGEX.test(B);}},validateSingleDigit:function(A){if(!A){return true;}else{return this.SINGLE_DIGIT_REGEX.test(A);}},validateUser:function(B,D,C){var A=new UserValidator(B,C,"ValidateUser",D);A.validateUser();},validateNewUserId:function(B,D,C){var A=new UserValidator(B,C,"CheckFreeUsername",D);A.validateUser();},validatePassword:function(A){if(!A){return this.INVALID_EMPTY;}else{if(/\s/g.test(A)){return this.INVALID_CONTAINS_SPACES;}else{if(A.length<4||A.length>100){return this.INVALID_LENGTH;}}}return this.VALID;},validateEmail:function(A){if(!A){return true;}return this.EMAIL_REGEX.test(A);},validateLength:function(B,A){if(!B){return true;}if(B.length>A){return false;}return true;},validateGoalName:function(A){if(!A){return this.INVALID_EMPTY;}else{if(A.length>100){return this.INVALID_LENGTH;}}return this.VALID;},validateRouteName:function(A){if(!A){return this.INVALID_EMPTY;}else{if(A.length>100){return this.INVALID_LENGTH;}}return this.VALID;},validateNewGroupName:function(B,D,C){var A=new GroupValidator(B,C,D);A.validateName();},validateNewGroupId:function(B,D,C){var A=new GroupValidator(B,C,D);A.validateId();},validateAcceptTerms:function(A){return A.checked;},alertException:function(B,A){alert(A);},showResult:function(A,B){if(!B){this.validationResultElement.update("");A.style.backgroundColor="white";}else{this.validationResultElement.update(entityEncode(B));this.validationResultElement.style.color="red";A.style.backgroundColor="red";}this.validationResultElement.style.display="block";}};UserValidator=Class.create();UserValidator.prototype={SPACES_REGEX:/\s/g,initialize:function(B,C,A,D){this.element=B;this.validationResultElement=$(C);this.serverCall=A;this.callback=D;},validateUser:function(){if(!this.element.value){this.callback.apply(this,new Array(FormValidator.INVALID_EMPTY,this.element));return ;}if(this.element.value.length>30){this.callback.apply(this,new Array(FormValidator.INVALID_LENGTH,this.element));return ;}this.validationResultElement.update(I18N.getMessage("jsMessage.loadMessage.checkingUser"));var B="user="+URLUtil.encode(this.element.value);var A=new Ajax.Request(this.serverCall,{method:"get",parameters:B,onSuccess:this.handleUserValidationResult.bind(this),onFailure:this.alertException.bind(this)});},alertException:function(B,A){alert(A);},handleUserValidationResult:function(request){this.validationResultElement.update("");var resultJSON=eval("("+request.responseText+")");if(resultJSON.ok){this.callback.apply(this,new Array(FormValidator.VALID,this.element));}else{this.callback.apply(this,new Array(resultJSON.message,this.element));}}};GroupValidator=Class.create();GroupValidator.prototype={SPACES_REGEX:/\s/g,GROUPID_REGEX:/^([0-9A-Za-z_])+$/,initialize:function(A,B,C){this.element=A;this.validationResultElement=B;this.callback=C;},validateName:function(){if(!this.element.value){this.callback.apply(this,new Array(FormValidator.INVALID_EMPTY,this.element));return ;}if(this.element.value.length>100){this.callback.apply(this,new Array(FormValidator.INVALID_LENGTH,this.element));return ;}this.validationResultElement.update(I18N.getMessage("jsMessage.loadMessage.checkingName"));var B="groupname="+this.element.value;var A=new Ajax.Request("ValidateGroup",{method:"get",parameters:B,onSuccess:this.handleValidationResult.bind(this),onFailure:this.alertException.bind(this)});},validateId:function(){if(!this.element.value){this.callback.apply(this,new Array(FormValidator.INVALID_EMPTY,this.element));return ;}if(this.element.value.length>30){this.callback.apply(this,new Array(FormValidator.INVALID_LENGTH,this.element));return ;}if(this.SPACES_REGEX.test(this.element.value)){this.callback.apply(this,new Array(FormValidator.INVALID_CONTAINS_SPACES),this.element);return ;}if(!this.GROUPID_REGEX.test(this.element.value)){this.callback.apply(this,new Array(FormValidator.INVALID_CHARACTERS),this.element);return ;}this.validationResultElement.update(I18N.getMessage("jsMessage.loadMessage.checkingId"));var B="groupid="+this.element.value;var A=new Ajax.Request("ValidateGroup",{method:"get",parameters:B,onSuccess:this.handleValidationResult.bind(this),onFailure:this.alertException.bind(this)});},alertException:function(B,A){alert(A);},handleValidationResult:function(request){this.validationResultElement.update("");var resultJSON=eval("("+request.responseText+")");if(resultJSON.ok){this.callback.apply(this,new Array(FormValidator.VALID,this.element));}else{this.callback.apply(this,new Array(resultJSON.message,this.element));}}};var ValidationMessageHandler={handleInvalidDate:function(A,B){this.handleInvalid(A,"validation.invalidDate",B);},handleInvalidHr:function(A,B){this.handleInvalid(A,"validation.invalidHr",B);},handleInvalidSingleDigit:function(A,B){this.handleInvalid(A,"validation.invalidSingleDigit",B);},handleInvalidDoubleDigit:function(A,B){this.handleInvalid(A,"validation.invalidDoubleDigit",B);},handleInvalidDecimal:function(A,B){this.handleInvalid(A,"validation.invalidDecimal",B);},handleInvalidEmail:function(A,B){this.handleInvalid(A,"validation.invalidEmail",B);},handleEmpty:function(A,B){this.handleInvalid(A,"validation.invalidEmpty",B);},handleTooLong30:function(A,B){this.handleInvalid(A,"validation.tooLong30",B);},handleContainSpaces:function(A,B){this.handleInvalid(A,"validation.invalidContainSpaces",B);},handleInvalidNewName:function(A,B){this.handleInvalid(A,"validation.invalidNewName",B);},handleInvalidPasswordLength:function(A,B){this.handleInvalid(A,"validation.invalidPasswordLength",B);},handleInvalidLength100:function(A,B){this.handleInvalid(A,"validation.tooLong100",B);},handleInvalidLength50:function(A,B){this.handleInvalid(A,"validation.tooLong50",B);},handleInvalidCharacters:function(A,B){this.handleInvalid(A,"validation.invalidCharacters",B);},handleInvalidCountry:function(A,B){this.handleInvalid(A,"validation.invalidCountry",B);},handleNotAcceptedTerms:function(A,B){this.handleInvalid(A,"validation.notAcceptedTerms",B);},handleInvalid:function(A,C,B){$(A).update(entityEncode(I18N.getMessage(C)));$(A).show();},handleInvalidNoI18N:function(A,C,B){$(A).update(entityEncode(C));$(A).show();},setValid:function(A,B){$(A).update("");$(A).hide();}};Tags=Class.create();Tags.prototype={initialize:function(){},MONDAY:"monday",TUESDAY:"tuesday",WEDNESDAY:"wednesday",THURSDAY:"thursday",FRIDAY:"friday",SATURDAY:"saturday",SUNDAY:"sunday",DAY_WORKOUT:"dayworkout",SPORT:"sport",DURATION:"duration",DISTANCE:"distance",WID:"wid",IS_TODAY:"istoday"};DatePicker=Class.create();DatePicker.prototype={initialize:function(F,B,E,A,C,D){this.calendar=new YAHOO.widget.Calendar(F,E);this.datePickerContainerId=B;this.dateInputId=D;this.calendar.selectEvent.subscribe(this.calendarDateSelected.bind(this),this.calendar,true);Event.observe($(C),"click",this.closeCalendar.bindAsEventListener(this));Event.observe($(A),"click",this.show.bindAsEventListener(this));this.manualSelect=false;},init:function(){var C=new Date();var D=C.getFullYear();var E=C.getMonth()+1;var B=C.getDate();if(E<10){E="0"+E;}if(B<10){B="0"+B;}var A=this.getCalendarDateStr(D,E,B);$(this.dateInputId).value=this.getFormDateStr(D,E,B);this.manualSelect=false;this.calendar.select(C);this.calendar.setYear(D);this.calendar.setMonth(E-1);},show:function(G){Event.stop(G);if($(this.datePickerContainerId).visible()){return ;}var C=$(this.dateInputId).value;if(C&&FormValidator.validateDate(C)){var E=C.split("-");var D=E[0];var F=E[1];var B=E[2];var A=this.getCalendarDateStr(D,F,B);this.manualSelect=false;this.calendar.select(A);this.calendar.setYear(D);this.calendar.setMonth(F-1);}this.calendar.render();this.manualSelect=true;Effect.BlindDown(this.datePickerContainerId);},calendarDateSelected:function(G,F,C){if(!this.manualSelect){return ;}var B=F[0][0];var H=B[0];var E=B[1];if(E<10){E="0"+E;}var I=B[2];if(I<10){I="0"+I;}var A=this.getFormDateStr(H,E,I);$(this.dateInputId).value=A;if(document.createEvent){var D=document.createEvent("HTMLEvents");D.initEvent("change",true,false);$(this.dateInputId).dispatchEvent(D);}else{if(document.createEventObject){$(this.dateInputId).fireEvent("onchange");}}this.closeCalendar();},getCalendarDateStr:function(B,C,A){return C+"/"+A+"/"+B;},getFormDateStr:function(B,C,A){return B+"-"+C+"-"+A;},closeCalendar:function(A){if(A){Event.stop(A);}Effect.BlindUp(this.datePickerContainerId);}};ServerAction=Class.create();ServerAction.prototype={initialize:function(){},alertException:function(B,A){this.showMessage(A,false);},handleMessage:function(request){try{var message=eval("("+request.responseText+")");if(message.redirecturl&&message.ok){window.location=message.redirecturl;return true;}if(message.message){this.showMessage(message.message,message.ok);return message.ok;}else{this.showMessage(I18N.getMessage("jsMessage.unknownError"),false);return false;}}catch(e){this.showMessage(I18N.getMessage("jsMessage.messageError"),false);return false;}return false;},showMessage:function(B,A){if(A){$("infoMessage").update(entityEncode(B));$("errorMessage").update("");new Effect.Highlight("infoMessage",{startcolor:"#489eda;",duration:"3"});}else{$("errorMessage").update(entityEncode(B));$("infoMessage").update("");new Effect.Highlight("errorMessage",{startcolor:"#663399;",duration:"3"});}}};EnterSleep=Class.create();EnterSleep.prototype=Object.extend(new ServerAction(),{enterSleep:function(E){this.showLoading();Event.stop(E);var C=$("EnterSleepForm");var D=Form.serialize(C);var A="EnterSleep";var B=new Ajax.Request(A,{method:"post",parameters:D,onSuccess:this.updateChart.bind(this),onFailure:this.alertException.bind(this)});},updateChart:function(A){this.hideLoading();plotrSleep.getChart();this.handleMessage(A);},showLoading:function(){$("loadingMainArea").style.display="block";},hideLoading:function(){$("loadingMainArea").style.display="none";}});EnterSleep=new EnterSleep();EnterWeight=Class.create();EnterWeight.prototype=Object.extend(new ServerAction(),{enterWeight:function(E){this.showLoading();Event.stop(E);var C=$("EnterWeightForm");var D=Form.serialize(C);var A="EnterWeight";var B=new Ajax.Request(A,{method:"post",parameters:D,onSuccess:this.updateChart.bind(this),onFailure:this.alertException.bind(this)});},updateChart:function(A){this.hideLoading();plotrWeight.getChart();this.handleMessage(A);},showLoading:function(){$("loadingMainArea").style.display="block";},hideLoading:function(){$("loadingMainArea").style.display="none";}});EnterWeight=new EnterWeight();EditUserView=Class.create();EditUserView.prototype={initialize:function(){},addEventListeners:function(){Event.observe($("metricUnit"),"click",this.toggleMetric.bindAsEventListener(this));Event.observe($("usUnit"),"click",this.toggleUS.bindAsEventListener(this));Event.observe($("firstName"),"blur",this.ehCheckFirstName.bindAsEventListener(this));Event.observe($("lastName"),"blur",this.ehCheckLastName.bindAsEventListener(this));Event.observe($("email"),"blur",this.ehCheckEmail.bindAsEventListener(this));Event.observe($("birthday"),"blur",this.ehCheckDate.bindAsEventListener(this));Event.observe($("height1"),"blur",this.ehCheckHeight1.bindAsEventListener(this));Event.observe($("height2"),"blur",this.ehCheckHeight2.bindAsEventListener(this));Event.observe($("submitUser"),"click",this.ehCheckAll.bindAsEventListener(this));},ehCheckEmail:function(B){var A=Event.element(B);this.checkEmail(A);},checkEmail:function(A){if(FormValidator.validateEmail(A.value)==true){ValidationMessageHandler.setValid("emailValidation",A);return true;}else{ValidationMessageHandler.handleInvalidEmail("emailValidation",A);return false;}},ehCheckFirstName:function(B){var A=Event.element(B);this.checkFirstName(A);},checkFirstName:function(A){if(FormValidator.validateLength(A.value,100)==true){ValidationMessageHandler.setValid("firstNameValidation",A);return true;}else{ValidationMessageHandler.handleInvalidLength100("firstNameValidation",A);return false;}},ehCheckLastName:function(B){var A=Event.element(B);this.checkLastName(A);},checkLastName:function(A){if(FormValidator.validateLength(A.value,100)==true){ValidationMessageHandler.setValid("lastNameValidation",A);return true;}else{ValidationMessageHandler.handleInvalidLength100("lastNameValidation",A);return false;}},ehCheckDate:function(B){var A=Event.element(B);if(!A.value){return ;}this.checkDate(A);},checkDate:function(A){if(!A.value){return true;}var B=FormValidator.validateDate(A.value);if(!B){ValidationMessageHandler.handleInvalidDate("birthdayValidation",A);}else{ValidationMessageHandler.setValid("birthdayValidation",A);}return B;},ehCheckHeight1:function(B){var A=Event.element(B);this.checkHeight1(A);},checkHeight1:function(A){var B=FormValidator.validateSingleDigit(A.value);if(!B){ValidationMessageHandler.handleInvalidSingleDigit("height1Validation",A);}else{ValidationMessageHandler.setValid("height1Validation",A);}return B;},ehCheckHeight2:function(B){var A=Event.element(B);this.checkHeight2(A);},checkHeight2:function(A){var B=FormValidator.validateDoubleDigit(A.value);if(!B){ValidationMessageHandler.handleInvalidDoubleDigit("height2Validation",A);}else{ValidationMessageHandler.setValid("height2Validation",A);}return B;},ehCheckAll:function(A){if(!this.checkFirstName($("firstName"))){Event.stop(A);}if(!this.checkLastName($("lastName"))){Event.stop(A);}if(!this.checkEmail($("email"))){Event.stop(A);}if(!this.checkDate($("birthday"))){Event.stop(A);}if(!this.checkHeight1($("height1"))){Event.stop(A);}if(!this.checkHeight2($("height2"))){Event.stop(A);}},toggleMetric:function(){$("heigh1label").update(I18N.getMessage("jsMessage.unit.m"));$("heigh2label").update(I18N.getMessage("jsMessage.unit.cm"));},toggleUS:function(){$("heigh1label").update(I18N.getMessage("jsMessage.unit.ft"));$("heigh2label").update(I18N.getMessage("jsMessage.unit.in"));}};LoadGroups=Class.create();LoadGroups.prototype=Object.extend(new ServerAction(),{initialize:function(){},searchGroup:function(F){Event.stop(F);var A=$("loadingArea");A.style.display="block";var D=$("searchGroupForm");var E=Form.serialize(D);var B="SearchGroup";var C=new Ajax.Request(B,{method:"get",parameters:E,onSuccess:this.showSearchResult.bind(this),onFailure:this.alertException.bind(this)});},sortGroup:function(E){Event.stop(E);var A=$("loadingArea");A.style.display="block";var C=Event.element(E);var F="sortBy="+C.value+"&startFrom=0";var B="SortGroups";var D=new Ajax.Request(B,{method:"get",parameters:F,onSuccess:this.showSearchResult.bind(this),onFailure:this.alertException.bind(this)});},navigateGroup:function(G){Event.stop(G);scroll(0,0);var A=$("loadingArea");A.style.display="block";var D=$("sortGroupBy");var C=Event.element(G);if(C.tagName=="DIV"){C=C.parentNode;}var F=C.href.split("Groups?")[1];var H="?sortBy="+D.value+"&"+F;var B="SortGroups";var E=new Ajax.Request(B,{method:"get",parameters:H,onSuccess:this.showSearchResult.bind(this),onFailure:this.alertException.bind(this)});},clearResultArea:function(){var A=$("groupsDiv");A.update("");},showSearchResult:function(request){var resultJSON=eval("("+request.responseText+")");var groups=resultJSON.result;this.clearResultArea();var groupsDiv=$("groupsDiv");var groupTemplateStr='<div class="group"><div><div class="spacer"></div><div style="float:left;"><a href="#{href}"><img src="#{imgSrc}"></a></div><div style="float:left"><div><a href="#{href}">#{groupName}</a></div><div>#{memberNum} members</div></div><div class="spacer"></div></div></div>';var groupTemplate=new Template(groupTemplateStr);for(var i=0;i<groups.length;i++){var toInsert="";var group=groups[i];var left=i%2!=0;if(!left){toInsert+='<div><div class="spacer"></div>';}toInsert+=groupTemplate.evaluate({href:"ViewGroup?groupid="+entityEncode(group.groupid),groupName:entityEncode(group.name),notes:entityEncode(group.notes),imgSrc:"images/group/"+entityEncode(group.smallimgthumburl),memberNum:entityEncode(group.membernum)});if(left){toInsert+='<div class="spacer"></div></div>';}new Insertion.Bottom(groupsDiv,toInsert);}this.navigation.updateNavigation(resultJSON,this.navigateGroup.bindAsEventListener(this));var loadingArea=$("loadingArea");loadingArea.style.display="none";}});var LoadGroups=new LoadGroups();NewGroupView=Class.create();NewGroupView.prototype={initialize:function(){this.observeInputFields();},observeInputFields:function(){Event.observe($("groupName"),"blur",this.ehCheckGroupName.bindAsEventListener(this));Event.observe($("groupId"),"blur",this.ehCheckGroupId.bindAsEventListener(this));Event.observe($("submitGroup"),"click",this.ehCheckAll.bindAsEventListener(this));},ehCheckGroupName:function(B){var A=Event.element(B);this.checkGroupName(A,this.handleGroupNameValidationResult.bind(this));},checkGroupName:function(A,B){FormValidator.validateNewGroupName(A,B,"groupNameValidation");},ehCheckGroupId:function(B){var A=Event.element(B);this.checkGroupId(A,this.handleGroupIdValidationResult.bind(this));},checkGroupId:function(A,B){FormValidator.validateNewGroupId(A,B,"groupIdValidation");},ehCheckAll:function(A){},handleGroupNameValidationResult:function(B,A){if(B==FormValidator.VALID){ValidationMessageHandler.setValid("groupNameValidation",A);}else{if(B==FormValidator.INVALID_EMPTY){ValidationMessageHandler.handleEmpty("groupNameValidation",A);}else{if(B==FormValidator.INVALID_LENGTH){ValidationMessageHandler.handleInvalidLength100("groupNameValidation",A);}else{if(B==FormValidator.INVALID){ValidationMessageHandler.handleInvalidNewName("groupNameValidation",A);}else{ValidationMessageHandler.handleInvalid("groupNameValidation",B,A);}}}}},handleGroupIdValidationResult:function(B,A){if(B==FormValidator.VALID){ValidationMessageHandler.setValid("groupIdValidation",A);}else{if(B==FormValidator.INVALID_EMPTY){ValidationMessageHandler.handleEmpty("groupIdValidation",A);}else{if(B==FormValidator.INVALID_LENGTH){ValidationMessageHandler.handleTooLong30("groupIdValidation",A);}else{if(B==FormValidator.INVALID_CONTAINS_SPACES){ValidationMessageHandler.handleContainSpaces("groupIdValidation",A);}else{if(B==FormValidator.INVALID_CHARACTERS){ValidationMessageHandler.handleInvalidCharacters("groupIdValidation",A);}else{if(B==FormValidator.INVALID){ValidationMessageHandler.handleInvalidNewName("groupIdValidation",A);}else{ValidationMessageHandler.handleInvalid("groupIdValidation",B,A);}}}}}}}};NewUserView=Class.create();NewUserView.prototype=Object.extend(new EditUserView(),{initialize:function(){this.addEventListeners();},addEventListeners:function(){Event.observe($("username"),"blur",this.ehCheckUserName.bindAsEventListener(this));Event.observe($("pwd"),"blur",this.ehCheckPassword.bindAsEventListener(this));Event.observe($("email"),"blur",this.ehCheckEmail.bindAsEventListener(this));Event.observe($("terms"),"click",this.ehCheckAccept.bindAsEventListener(this));Event.observe($("submitUser"),"click",this.ehCheckAll.bindAsEventListener(this));},ehCheckAccept:function(B){var A=Event.element(B);this.checkAccept(A);},checkAccept:function(B){var A=FormValidator.validateAcceptTerms(B);if(A){ValidationMessageHandler.setValid("termsValidation",B);return true;}ValidationMessageHandler.handleNotAcceptedTerms("termsValidation",B);return false;},ehCheckUserName:function(B){var A=Event.element(B);this.checkUserName(A,this.handleUserValidationResult.bind(this));},checkUserName:function(A,B){FormValidator.validateNewUserId(A,B,"usernameValidation");},ehCheckPassword:function(B){var A=Event.element(B);this.checkPassword(A);},checkPassword:function(A){var B=FormValidator.validatePassword(A.value);if(B==FormValidator.VALID){ValidationMessageHandler.setValid("pwdValidation",A);return true;}else{if(B==FormValidator.INVALID_EMPTY){ValidationMessageHandler.handleEmpty("pwdValidation",A);}else{if(B==FormValidator.INVALID_CONTAINS_SPACES){ValidationMessageHandler.handleContainSpaces("pwdValidation",A);}else{if(B==FormValidator.INVALID_LENGTH){ValidationMessageHandler.handleInvalidPasswordLength("pwdValidation",A);}else{ValidationMessageHandler.handleInvalid("pwdValidation",B,A);}}}}return false;},handleUserValidationResult:function(B,A){if(B==FormValidator.VALID){ValidationMessageHandler.setValid("usernameValidation",A);}else{if(B==FormValidator.INVALID_EMPTY){ValidationMessageHandler.handleEmpty("usernameValidation",A);}else{if(B==FormValidator.INVALID_LENGTH){ValidationMessageHandler.handleTooLong30("usernameValidation",A);}else{if(B==FormValidator.INVALID_CONTAINS_SPACES){ValidationMessageHandler.handleContainSpaces("usernameValidation",A);}else{if(B==FormValidator.INVALID_CHARACTERS){ValidationMessageHandler.handleInvalidCharacters("usernameValidation",A);}else{if(B==FormValidator.INVALID){ValidationMessageHandler.handleInvalidNewName("usernameValidation",A);}else{ValidationMessageHandler.handleInvalidNoI18N("usernameValidation",B,A);}}}}}}},ehCheckAll:function(A){if(!this.checkPassword($("pwd"))){Event.stop(A);}if(!this.checkEmail($("email"))){Event.stop(A);}if(!this.checkAccept($("terms"))){Event.stop(A);}}});TimelineManager=Class.create();TimelineManager.prototype={resizeTimerID:null,initialize:function(){},addEventListeners:function(){Event.observe(window,"load",this.initTimeline.bindAsEventListener(this));Event.observe(window,"resize",this.handleResize.bindAsEventListener(this));var A=this.initTimeline.bindAsEventListener(this);EventManager.registerEventHandler(Events.WORKOUT_ADDED,A);},initTimeline:function(){var A=new Date();eventSource=new Timeline.DefaultEventSource(0);var B=[Timeline.createBandInfo({eventSource:eventSource,date:A,width:"80%",intervalUnit:Timeline.DateTime.DAY,intervalPixels:100}),Timeline.createBandInfo({width:"20%",intervalUnit:Timeline.DateTime.MONTH,intervalPixels:200})];B[1].syncWith=0;B[1].highlight=true;this.tl=Timeline.create(document.getElementById("timeline"),B);this.tl.loadJSON("GetTimelineData",function(D,C){eventSource.loadJSON(D,C);});},handleResize:function(){if(this.resizeTimerID==null){this.resizeTimerID=window.setTimeout(function(){this.resizeTimerID=null;this.tl.layout();},500);}}};var TimelineManager=new TimelineManager();NewGroupView=Class.create();NewGroupView.prototype={initialize:function(){this.observeInputFields();},observeInputFields:function(){Event.observe($("groupName"),"blur",this.ehCheckGroupName.bindAsEventListener(this));Event.observe($("groupId"),"blur",this.ehCheckGroupId.bindAsEventListener(this));Event.observe($("submitGroup"),"click",this.ehCheckAll.bindAsEventListener(this));},ehCheckGroupName:function(B){var A=Event.element(B);this.checkGroupName(A,this.handleGroupNameValidationResult.bind(this));},checkGroupName:function(A,B){FormValidator.validateNewGroupName(A,B,"groupNameValidation");},ehCheckGroupId:function(B){var A=Event.element(B);this.checkGroupId(A,this.handleGroupIdValidationResult.bind(this));},checkGroupId:function(A,B){FormValidator.validateNewGroupId(A,B,"groupIdValidation");},ehCheckAll:function(A){},handleGroupNameValidationResult:function(B,A){if(B==FormValidator.VALID){ValidationMessageHandler.setValid("groupNameValidation",A);}else{if(B==FormValidator.INVALID_EMPTY){ValidationMessageHandler.handleEmpty("groupNameValidation",A);}else{if(B==FormValidator.INVALID_LENGTH){ValidationMessageHandler.handleInvalidLength100("groupNameValidation",A);}else{if(B==FormValidator.INVALID){ValidationMessageHandler.handleInvalidNewName("groupNameValidation",A);}else{ValidationMessageHandler.handleInvalid("groupNameValidation",B,A);}}}}},handleGroupIdValidationResult:function(B,A){if(B==FormValidator.VALID){ValidationMessageHandler.setValid("groupIdValidation",A);}else{if(B==FormValidator.INVALID_EMPTY){ValidationMessageHandler.handleEmpty("groupIdValidation",A);}else{if(B==FormValidator.INVALID_LENGTH){ValidationMessageHandler.handleTooLong30("groupIdValidation",A);}else{if(B==FormValidator.INVALID_CONTAINS_SPACES){ValidationMessageHandler.handleContainSpaces("groupIdValidation",A);}else{if(B==FormValidator.INVALID_CHARACTERS){ValidationMessageHandler.handleInvalidCharacters("groupIdValidation",A);}else{if(B==FormValidator.INVALID){ValidationMessageHandler.handleInvalidNewName("groupIdValidation",A);}else{ValidationMessageHandler.handleInvalid("groupIdValidation",B,A);}}}}}}}};SummarySelector=Class.create();SummarySelector.prototype={initialize:function(D,B,C,A){this.previousSelector=$(D);this.nextSelector=$(B);this.selection=$(C);this.updateEvent=A;Event.observe(this.selection,"change",this.selectionChanged.bindAsEventListener(this));Event.observe(this.previousSelector,"click",this.previous.bindAsEventListener(this));Event.observe(this.nextSelector,"click",this.next.bindAsEventListener(this));},next:function(A){if(this.selection.selectedIndex<(this.selection.options.length-1)){this.selection.selectedIndex=this.selection.selectedIndex+1;this.selectionChanged(A);}},previous:function(A){if(this.selection.selectedIndex>0){this.selection.selectedIndex=this.selection.selectedIndex-1;this.selectionChanged(A);}},selectionChanged:function(A){Event.stop(A);this.updateSelectorStyles();EventManager.fireEvent(this.updateEvent,A);},updateSelectorStyles:function(){if(this.selection.selectedIndex==(this.selection.options.length-1)){Event.observe(this.nextSelector,"click",this.killEvent.bindAsEventListener(this));this.nextSelector.className="statRightArrowInactive";}else{Event.stopObserving(this.nextSelector,"click",this.killEvent.bindAsEventListener(this));this.nextSelector.className="statRightArrow";}if(this.selection.selectedIndex==0){Event.observe(this.previousSelector,"click",this.killEvent.bindAsEventListener(this));this.previousSelector.className="statLeftArrowInactive";}else{Event.stopObserving(this.previousSelector,"click",this.killEvent.bindAsEventListener(this));this.previousSelector.className="statLeftArrow";}},killEvent:function(A){Event.stop(A);}};AbstractDialog=Class.create();AbstractDialog.prototype=Object.extend(new ServerAction(),{MASK_HTML:'<div id="mask" class="mask""><!--[if IE 6]><iframe></iframe><![endif]--></div>',init:function(A){this.dialogPrefixId=A;this.dialogId=A+"Dialog";this.closeButton=$(A+"Close");this.cancelButton=$(A+"Cancel");this.dialogHeaderId=A+"Header";this.dialogLabelId=this.dialogHeaderId+"Label";this.formId=A+"Form";new Draggable(this.dialogId,{handle:this.dialogHeaderId});Event.observe(this.closeButton,"click",this.close.bindAsEventListener(this));Event.observe(this.cancelButton,"click",this.close.bindAsEventListener(this));Event.observe($(A+"Ok"),"click",this.handleSubmit.bindAsEventListener(this));},getWindowSize:function(){var B=0,A=0;if(typeof (window.innerWidth)=="number"){B=window.innerWidth;A=window.innerHeight;}else{if(document.documentElement&&(document.documentElement.clientWidth||document.documentElement.clientHeight)){B=document.documentElement.clientWidth;A=document.documentElement.clientHeight;}else{if(document.body&&(document.body.clientWidth||document.body.clientHeight)){B=document.body.clientWidth;A=document.body.clientHeight;}}}var C=new Object();C.height=A;C.width=B;return C;},handleClick:function(A){if(A!=null){Event.stop(A);}this.show();},show:function(){var C=$$("div.swfchart");if(C){C.each(function(F,E){F.style.visibility="hidden";});}new Insertion.Top(document.body,this.MASK_HTML);var A=$("mask");A.style.width=document.documentElement.scrollWidth+"px";A.style.height=document.documentElement.scrollHeight+"px";this.hideLoading();var B=$(this.dialogId);var D=this.getWindowSize();B.style.top=(D.height-B.offsetHeight)/2+"px";B.style.left=(D.width-B.offsetWidth)/2+"px";B.style.visibility="visible";},clearDialog:function(){},close:function(B){if(B){Event.stop(B);}this.clearDialog();$("mask").remove();if(this.selectMask){this.selectMask.remove();}var A=$$("div.swfchart");if(A){A.each(function(D,C){D.style.visibility="visible";});}$(this.dialogId).style.visibility="hidden";},showLoading:function(){$("loadingMainArea").style.display="block";},hideLoading:function(){$("loadingMainArea").style.display="none";}});OkCancelDialog=Class.create();OkCancelDialog.prototype=Object.extend(new AbstractDialog(),{addEventListeners:function(B,A){Event.observe($(B),"click",this.handleOk.bindAsEventListener(this));Event.observe($(A),"click",this.handleCancel.bindAsEventListener(this));},handleOk:function(A){},handleCancel:function(A){Event.stop(A);this.close();}});CommentDialog=Class.create();CommentDialog.prototype=Object.extend(new AbstractDialog(),{initialize:function(D,C,A,B){this.init(D);this.wid=C;this.user=A;this.isPlanned=B;},invoke:function(A){$(this.dialogLabelId).update(I18N.getMessage("jsMessage.commentDialog.addComment"));this.newComment=true;this.handleClick(A);},invokeEdit:function(A){$(this.dialogLabelId).update(I18N.getMessage("jsMessage.commentDialog.editComment"));this.newComment=false;this.cid=A;this.doEditRequest();},doEditRequest:function(){var C=$(this.formId);var D=Form.serialize(C);D+="&cid="+this.cid+"&isPlanned="+this.isPlanned;var A="GetComment";var B=new Ajax.Request(A,{method:"get",parameters:D,onSuccess:this.showEditDialog.bind(this),onFailure:this.alertException.bind(this)});},showEditDialog:function(request){this.setValues(eval("("+request.responseText+")"));this.handleClick();},setValues:function(A){this.newComment=false;$("workoutComment").value=A.comment;},handleSubmit:function(D){Event.stop(D);var C=$(this.formId);var E=Form.serialize(C);if(this.newComment){E+="&wid="+this.wid+"&forUser="+this.user+"&isPlanned="+this.isPlanned;}else{E+="&cid="+this.cid+"&isPlanned="+this.isPlanned;}var A=this.newComment?"NewComment":"EditComment";var B=new Ajax.Request(A,{method:"post",parameters:E,onSuccess:this.showSubmitResult.bind(this),onFailure:this.alertException.bind(this)});},showSubmitResult:function(request){this.close();var message=eval("("+request.responseText+")");if(message.ok){if(this.newComment){EventManager.fireEvent(Events.WORKOUT_COMMENT_ADDED);}else{EventManager.fireEvent(Events.WORKOUT_COMMENT_EDITED);}}this.handleMessage(request);},clearDialog:function(){Form.reset($(this.formId));}});DeleteGoalDialog=Class.create();DeleteGoalDialog.prototype=Object.extend(new OkCancelDialog(),{initialize:function(){this.init("deleteGoal");},invoke:function(C){Event.stop(C);var A=Event.element(C);var D=Event.element(C).id;var B=D.split("deleteGoal_")[1];this.goalId=B.split("_")[0];this.goalType=B.split("_")[1];this.handleClick();},handleSubmit:function(D){Event.stop(D);var B="goalId="+this.goalId+"&goalType="+this.goalType;var A="DeleteGoal";var C=new Ajax.Request(A,{method:"post",parameters:B,onSuccess:this.handleMessage.bind(this),onFailure:this.alertException.bind(this)});this.close();}});DeleteRouteDialog=Class.create();DeleteRouteDialog.prototype=Object.extend(new OkCancelDialog(),{initialize:function(A){this.init("deleteRoute");this.routeId=A;this.addEventListeners("deleteRouteOk","deleteRouteCancel");},handleSubmit:function(D){Event.stop(D);var B="routeId="+this.routeId;var A="DeleteRoute";var C=new Ajax.Request(A,{method:"post",parameters:B,onSuccess:this.deleteOk.bind(this),onFailure:this.alertException.bind(this)});this.close();},deleteOk:function(A){this.handleMessage(A);}});DeleteWorkoutDialog=Class.create();DeleteWorkoutDialog.prototype=Object.extend(new OkCancelDialog(),{initialize:function(B,C){this.wid=B;this.referer=C;var A="deleteWorkout";this.init(A);this.addEventListeners(A+"Ok",A+"Cancel");},handleSubmit:function(D){Event.stop(D);var B="wid="+this.wid+"&backTo="+this.referer;var A="DeleteWorkout";var C=new Ajax.Request(A,{method:"post",parameters:B,onSuccess:this.handleMessage.bind(this),onFailure:this.alertException.bind(this)});this.close();}});DeleteMessageDialog=Class.create();DeleteMessageDialog.prototype=Object.extend(new OkCancelDialog(),{initialize:function(A,B){this.mid=A;this.referer=B;this.init("deleteMessage");},handleSubmit:function(D){Event.stop(D);var B="mid="+this.mid+"&backTo="+this.referer;var A="DeleteMessage";var C=new Ajax.Request(A,{method:"post",parameters:B,onSuccess:this.handleMessage.bind(this),onFailure:this.alertException.bind(this)});this.close();}});DeleteChallengeDialog=Class.create();DeleteChallengeDialog.prototype=Object.extend(new OkCancelDialog(),{initialize:function(){this.init("deleteChallenge");},invoke:function(C){Event.stop(C);var A=Event.element(C);var D=Event.element(C).id;var B=D.split("deleteChallenge_")[1];this.challengeId=B.split("_")[0];this.challengeType=B.split("_")[1];this.handleClick();},handleSubmit:function(D){Event.stop(D);var B="challengeId="+this.challengeId+"&challengeType="+this.challengeType;var A="DeleteChallenge";var C=new Ajax.Request(A,{method:"post",parameters:B,onSuccess:this.handleMessage.bind(this),onFailure:this.alertException.bind(this)});this.close();}});FilterRoutesDialog=Class.create();FilterRoutesDialog.prototype=Object.extend(new AbstractDialog(),{initialize:function(A){this.init(A);this.isUserRoutes=false;},__observeInputFields:function(){},invoke:function(A){this.clearDialog();this.isUserRoutes=false;this.handleClick(A);},invokeUserRoutes:function(A){this.clearDialog();this.isUserRoutes=true;this.handleClick(A);},handleSubmit:function(B){Event.stop(B);var A=$(this.formId);A.submit();},clearDialog:function(){Form.reset($(this.formId));var B=$$("div.validation");B.each(function(D,C){D.update("");});var A=$$("input.dialogInput");A.each(function(D,C){D.style.backgroundColor=ValidationMessageHandler.VALID_COLOR;});}});ForumPostDialog=Class.create();ForumPostDialog.prototype=Object.extend(new AbstractDialog(),{initialize:function(A,C,D,E,B){this.init(A,C,D);this.formId=E;Event.observe($(B),"click",this.handleSubmit.bindAsEventListener(this));},invoke:function(D){var C=Event.element(D);var A=C.id;var B=A.indexOf("replyToGroupPost_");if(B!=-1){this.replyToId=A.split("replyToGroupPost_")[1];}else{this.replyToId=null;}this.handleClick(D);},handleSubmit:function(F){var D=$(this.formId);var E=Form.serialize(D);var A=Form.serialize(D,true);this.groupId=A["forumPostGroupId"];this.threadId=A["forumThreadId"];if(this.replyToId){E+="&replyToId="+this.replyToId;}var B="NewForumPost";this.close();var C=new Ajax.Request(B,{method:"post",parameters:E,onSuccess:this.showSubmitResult.bind(this),onFailure:this.alertException.bind(this)});},showSubmitResult:function(A){this.handleMessage(A);if(this.replyToId){this.reloadThread();}else{this.reloadThreadList();}},reloadThreadList:function(){LoadForumThreadList.loadThreadList(this.threadId,this.groupId);},reloadThread:function(){},clearDialog:function(){Form.reset($(this.formId));}});GoalDialog=Class.create();GoalDialog.prototype=Object.extend(new AbstractDialog(),{GOAL_UNIT_TEMPLATE_STR:'<option value="0">#{metricUnit}</option><option value="1">#{usUnit}</option>',initialize:function(A){this.init(A);this.UNIT_TEMPLATE=new Template(this.GOAL_UNIT_TEMPLATE_STR);this.noRedirect=false;Event.observe($("goalType"),"change",this.ehHandleTypeChange.bindAsEventListener(this));this.calendar=new DatePicker(A+"DatePickerCal",A+"DateContainer",A+"CalContainer",A+"DatePicker",A+"CloseCal",A+"Date");this.observeInputFields();},setNoRedirect:function(A){this.noRedirect=A;},observeInputFields:function(){Event.observe($("goalName"),"change",this.ehCheckGoalName.bindAsEventListener(this));Event.observe($("goalValue"),"change",this.ehCheckGoalValue.bindAsEventListener(this));Event.observe($(this.dialogPrefixId+"Date"),"change",this.ehCheckCompleteBy.bindAsEventListener(this));},getServerCall:function(){if(this.newGoal){return"NewGoal";}return"EditGoal";},invoke:function(B){this.newGoal=true;var A=$("goalType");A.enable();this.handleTypeChange(A.value);this.calendar.init();this.handleClick(B);},invokeEdit:function(E){Event.stop(E);var A=Event.element(E);var F=Event.element(E).id;var D=F.split("editGoal_")[1];var C=D.split("_")[0];var B=D.split("_")[1];this.doEditRequest(C,B);},doEditRequest:function(C,B){var D="goalId="+C+"&goalType="+B;var A="GetGoal";var E=new Ajax.Request(A,{method:"get",parameters:D,onSuccess:this.showEdit.bind(this),onFailure:this.alertException.bind(this)});},showEdit:function(request){this.setValues(eval("("+request.responseText+")"));this.handleClick(null);},setValues:function(B){this.newGoal=false;this.goalId=B.id;var A=$("goalType");A.value=B.type;this.handleTypeChange(A.value);A.disable();if(B.type=="simple"){$("goalName").value=B.name;$("goalDescription").value=B.description;$(this.dialogPrefixId+"Date").value=B.enddate;}else{$("goalValue").value=B.goalvalue;$("goalValueUnit").value=B.unit;$("goalValueFrequency").value=B.goalmeasure;$(this.dialogPrefixId+"Date").value=B.enddate;$("goalSport").value=B.sport;$("goalDescription").value=B.comment;}},ehHandleTypeChange:function(B){var A=Event.element(B);this.handleTypeChange(A.value);},handleTypeChange:function(A){if(A=="time"){this.showTimeDialog();}else{if(A=="distance"){this.showDistanceDialog();}else{if(A=="weight"){this.showWeightDialog();}else{if(A=="frequency"){this.showFrequencyDialog();}else{this.showSimpleDialog();}}}}},showTimeDialog:function(){$("goalNameDiv").hide();$("goalValueUnit").hide();$("goalValueUnitDiv").update(I18N.getMessage("jsMessage.goalDialog.hours"));$("goalValueLabel").update(I18N.getMessage("jsMessage.goalDialog.time"));$("goalSportDiv").show();$("goalTimeDiv").show();$("goalValueFrequency").show();$("goalValueUnitDiv").show();},showDistanceDialog:function(){this.showUnits(I18N.getMessage("jsMessage.unit.km"),I18N.getMessage("jsMessage.unit.mi"));$("goalValueLabel").update(I18N.getMessage("jsMessage.goalDialog.distance"));$("goalSportDiv").show();$("goalTimeDiv").show();$("goalValueFrequency").show();$("goalNameDiv").hide();$("goalValueUnitDiv").hide();},showWeightDialog:function(){$("goalNameDiv").hide();$("goalSportDiv").hide();$("goalValueFrequency").hide();$("goalValueUnitDiv").hide();this.showUnits(I18N.getMessage("jsMessage.unit.kg"),I18N.getMessage("jsMessage.unit.lbs"));$("goalValueLabel").update(I18N.getMessage("jsMessage.goalDialog.weight"));$("goalTimeDiv").show();},showFrequencyDialog:function(){$("goalNameDiv").hide();$("goalValueUnit").hide();$("goalValueUnitDiv").update(I18N.getMessage("jsMessage.goalDialog.times"));$("goalValueLabel").update(I18N.getMessage("jsMessage.goalDialog.frequency"));$("goalSportDiv").show();$("goalTimeDiv").show();$("goalValueFrequency").show();$("goalValueUnitDiv").show();},showSimpleDialog:function(){$("goalSportDiv").hide();$("goalTimeDiv").hide();$("goalNameDiv").show();},showUnits:function(B,D){var A=$("goalValueUnit");A.update("");var C=this.UNIT_TEMPLATE.evaluate({metricUnit:B,usUnit:D});new Insertion.Bottom(A,C);A.show();},handleSubmit:function(D){Event.stop(D);if(!this.checkAll()){return ;}var B=$(this.formId);var C=Form.serialize(B);C+="&goalValueUnit="+$("goalValueUnit").value;if(!this.newGoal){C+="&goalId="+this.goalId+"&goalType="+$("goalType").value;}if(this.noRedirect){C+="&noRedirect=true";}this.close();var A=new Ajax.Request(this.getServerCall(),{method:"post",parameters:C,onSuccess:this.showSubmitResult.bind(this),onFailure:this.alertException.bind(this)});},showSubmitResult:function(B){var A=this.handleMessage(B);if(!A){return ;}if(!this.newGoal){EventManager.fireEvent(Events.GOAL_EDITED);}},clearDialog:function(){Form.reset($(this.formId));var B=$$("div.validation");B.each(function(D,C){D.update("");});var A=$$("input.dialogInput");A.each(function(D,C){D.style.backgroundColor=ValidationMessageHandler.VALID_COLOR;});},checkAll:function(){var A=this.checkGoalName($("goalName"));if(!A){return false;}A=this.checkGoalValue($("goalValue"));if(!A){return false;}A=this.checkCompleteBy($(this.dialogPrefixId+"Date"));if(!A){return false;}return true;},ehCheckGoalName:function(B){var A=Event.element(B);this.checkGoalName(A);},checkGoalName:function(A){if($("goalType").value!="simple"){return true;}var B=FormValidator.validateGoalName(A.value);if(B==FormValidator.INVALID_LENGTH){ValidationMessageHandler.handleInvalidLength100("goalNameValidation",A);return false;}else{if(B==FormValidator.INVALID_EMPTY){ValidationMessageHandler.handleEmpty("goalNameValidation",A);return false;}else{ValidationMessageHandler.setValid("goalNameValidation",A);return true;}}},ehCheckGoalValue:function(B){var A=Event.element(B);this.checkGoalValue(A);},checkGoalValue:function(A){if($("goalType").value=="simple"){return true;}var B=FormValidator.validateDecimal(A.value);if(!B){ValidationMessageHandler.handleInvalidDecimal("goalValueValidation",A);}else{ValidationMessageHandler.setValid("goalValueValidation",A);}return B;},ehCheckCompleteBy:function(B){var A=Event.element(B);this.checkCompleteBy(A);},checkCompleteBy:function(A){var B=FormValidator.validateDate(A.value);if(!B){ValidationMessageHandler.handleInvalidDate("goalCompleteByValidation",A);}else{ValidationMessageHandler.setValid("goalCompleteByValidation",A);}return B;}});NewMessageDialog=Class.create();NewMessageDialog.prototype=Object.extend(new AbstractDialog(),{initialize:function(A){this.init(A);this.observeInputFields();},invoke:function(A){this.handleClick(A);},invokeReply:function(C){Event.stop(C);var B=Event.element(C).href;var A=B.split("replyto/");$("toUser").value=A[1];this.handleClick(C);},handleSubmit:function(E){Event.stop(E);var C=$(this.formId);var D=Form.serialize(C);var A="NewMessage";this.close();var B=new Ajax.Request(A,{method:"post",parameters:D,onSuccess:this.showSubmitResult.bind(this),onFailure:this.alertException.bind(this)});},showSubmitResult:function(A){this.handleMessage(A);},clearDialog:function(){Form.reset($(this.formId));$("usernameValidation").innerHTML="";},observeInputFields:function(){Event.observe($("toUser"),"blur",this.ehCheckUserName.bindAsEventListener(this));},ehCheckUserName:function(B){var A=Event.element(B);this.checkUserName(A,this.handleUserValidationResult.bind(this));},checkUserName:function(A,B){FormValidator.validateUser(A,B,"usernameValidation");},handleUserValidationResult:function(B,A){if(B==FormValidator.VALID){ValidationMessageHandler.setValid("usernameValidation",A);}else{if(B==FormValidator.INVALID_EMPTY){ValidationMessageHandler.handleEmpty("usernameValidation",A);}else{if(B==FormValidator.INVALID_LENGTH){ValidationMessageHandler.handleTooLong30("usernameValidation",A);}else{if(B==FormValidator.INVALID_CONTAINS_SPACES){ValidationMessageHandler.handleContainSpaces("usernameValidation",A);}else{if(B==FormValidator.INVALID_CHARACTERS){ValidationMessageHandler.handleInvalidCharacters("usernameValidation",A);}else{if(B==FormValidator.INVALID){ValidationMessageHandler.handleInvalidNewName("usernameValidation",A);}else{ValidationMessageHandler.handleInvalidNoI18N("usernameValidation",B,A);}}}}}}}});ShowElevationDialog=Class.create();ShowElevationDialog.prototype=Object.extend(new OkCancelDialog(),{initialize:function(){this.init("showElevation");this.addEventListeners("showElevationOk","showElevationCancel");},handleSubmit:function(A){Event.stop(A);this.close();EventManager.fireEvent(Events.SHOW_ELEVATION);}});WorkoutDialog=Class.create();WorkoutDialog.prototype=Object.extend(new AbstractDialog(),{initialize:function(dialogPrefixId,wid,routeList,favRouteList){this.init(dialogPrefixId);this.wid=wid;if(routeList){this.routeList=eval(routeList);}if(favRouteList){this.favRouteList=eval(favRouteList);}var sportDropdown=$("selectSport");var options=sportDropdown.options;this.sportMap=new Array();for(var i=0;i<options.length;i++){var option=options[i];var json=eval("("+option.getAttribute("json")+")");this.sportMap[option.value]=json;}this.handleUnit();this.calendar=new DatePicker(dialogPrefixId+"DatePickerCal",dialogPrefixId+"DateContainer",dialogPrefixId+"CalContainer",dialogPrefixId+"DatePicker",dialogPrefixId+"CloseCal",dialogPrefixId+"Date");Event.observe(sportDropdown,"change",this.handleUnit.bindAsEventListener(this));Event.observe(sportDropdown,"change",this.ehUpdateRouteList.bindAsEventListener(this));Event.observe($("selectRoute"),"change",this.routeChanged.bindAsEventListener(this));this.observeInputFields();},handleUnit:function(H){var J=$("selectSport");var E=J.selectedIndex;if(E==-1){return ;}var I=$("distanceUnit");I.update("");var C=J.options[E].value;var A=this.sportMap[C];var B=A.usunit;var D=A.metricunit;var G=document.createElement("select");G.id="distanceUnitSelection";G.name="distanceUnitSelection";var K=new Option(A.usunit,1);var F=new Option(A.metricunit,0);A.metric?F.selected=true:K.selected=true;I.appendChild(G);G.options[0]=K;G.options[1]=F;this.updateSpeedAndPace(H);Event.observe($("distanceUnitSelection"),"change",this.updateSpeedAndPace.bindAsEventListener(this));},observeInputFields:function(){Event.observe($("workoutDate"),"change",this.ehCheckDate.bindAsEventListener(this));Event.observe($("durationHH"),"change",this.ehCheckDuration.bindAsEventListener(this));Event.observe($("durationMM"),"change",this.ehCheckDuration.bindAsEventListener(this));Event.observe($("durationSS"),"change",this.ehCheckDuration.bindAsEventListener(this));Event.observe($("distance"),"change",this.ehCheckDistance.bindAsEventListener(this));Event.observe($("durationHH"),"change",this.updateSpeedAndPace.bindAsEventListener(this));Event.observe($("durationMM"),"change",this.updateSpeedAndPace.bindAsEventListener(this));Event.observe($("durationSS"),"change",this.updateSpeedAndPace.bindAsEventListener(this));Event.observe($("distance"),"change",this.updateSpeedAndPace.bindAsEventListener(this));Event.observe($("avghr"),"change",this.ehCheckHR.bindAsEventListener(this));},checkDate:function(A){var B=FormValidator.validateDate(A.value);if(!B){ValidationMessageHandler.handleInvalidDate("dateValidation",A);}else{ValidationMessageHandler.setValid("dateValidation",A);}return B;},ehCheckDate:function(B){var A=Event.element(B);this.checkDate(A);},checkDuration:function(A){var B=FormValidator.validateDoubleDigit(A.value);if(!B){ValidationMessageHandler.handleInvalidDoubleDigit("durationValidation",A);}else{ValidationMessageHandler.setValid("durationValidation",A);}return B;},ehCheckDuration:function(B){var A=Event.element(B);this.checkDuration(A);},checkDistance:function(A){if(!A.value){ValidationMessageHandler.setValid("distanceValidation",A);return true;}var B=FormValidator.validateDecimal(A.value);if(!B){ValidationMessageHandler.handleInvalidDecimal("distanceValidation",A);}else{ValidationMessageHandler.setValid("distanceValidation",A);}return B;},ehCheckDistance:function(B){var A=Event.element(B);this.checkDistance(A);},checkHR:function(A){var B=FormValidator.validateHr(A.value);if(!B){ValidationMessageHandler.handleInvalidHr("hrValidation",A);}else{ValidationMessageHandler.setValid("hrValidation",A);}return B;},ehCheckHR:function(B){var A=Event.element(B);this.checkHR(A);},updateSpeedAndPace:function(J){var B=($("distance")).value;if(!B||isNaN(B)){return ;}var C=($("durationHH")).value;var D=($("durationMM")).value;var L=($("durationSS")).value;if(!C&&!D&&!L){return ;}if(C&&isNaN(C)){return ;}if(D&&isNaN(D)){return ;}if(L&&isNaN(L)){return ;}var M=0;if(C){M+=(C*3600);}if(D){M+=(D*60);}if(L){M+=L*1;}if(M==0){return ;}var E=$("selectSport").value;var G=E=="swim"?M:M/3600;var P=$("distanceUnitSelection").value==0;var O="";if(P){O=E=="swim"?I18N.getMessage("jsMessage.unit.ms"):I18N.getMessage("jsMessage.unit.kmh");}else{O=E=="swim"?I18N.getMessage("jsMessage.unit.ydss"):I18N.getMessage("jsMessage.unit.mih");}var F=Math.round((B/G)*10)/10;$("avgSpeed").innerHTML=F+" "+O;var H="";if(P){H=E=="swim"?I18N.getMessage("jsMessage.unit.100m"):I18N.getMessage("jsMessage.unit.km");}else{H=E=="swim"?I18N.getMessage("jsMessage.unit.100yds"):I18N.getMessage("jsMessage.unit.mi");}var K=M/B;if(E=="swim"){K=K*100;}var N=Math.floor(K/60);var I=Math.round((K-N*60));if(I<10){I="0"+I;}var A=N+":"+I;$("avgPace").innerHTML=A+" / "+H;},checkAll:function(){if(!this.checkDate($("workoutDate"))){return false;}if(!this.checkDuration($("durationHH"))){return false;}if(!this.checkDuration($("durationMM"))){return false;}if(!this.checkDuration($("durationSS"))){return false;}if(!this.checkDistance($("distance"))){return false;}if(!this.checkHR($("avghr"))){return false;}return true;},handleSubmit:function(E){Event.stop(E);var A=this.checkAll();if(!A){return ;}var C=$(this.formId);var D=Form.serialize(C);D+="&isPlanned="+this.plan+"&isNew="+this.newWorkout;if(!this.newWorkout){D+="&wid="+this.wid;}this.close(E);var B=new Ajax.Request("EnterWorkout",{method:"post",parameters:D,onSuccess:this.showSubmitResult.bind(this),onFailure:this.alertException.bind(this)});},showSubmitResult:function(A){this.handleMessage(A);this.fireOkEvent(A);},invokeLog:function(A){this.newWorkout=true;this.plan=false;$("workoutHeaderLabel").update(I18N.getMessage("jsMessage.workoutDialog.header.log"));this._invoke(A);},invokePlan:function(A){this.newWorkout=true;this.plan=true;$("workoutHeaderLabel").update(I18N.getMessage("jsMessage.workoutDialog.header.plan"));this._invoke(A);},invokeLoggedEdit:function(A){Event.stop(A);this.plan=false;$("workoutHeaderLabel").update(I18N.getMessage("jsMessage.workoutDialog.header.editlog"));this.doEditRequest();},invokePlannedEdit:function(A){Event.stop(A);this.plan=true;$("workoutHeaderLabel").update(I18N.getMessage("jsMessage.workoutDialog.header.editplan"));this.doEditRequest();},doEditRequest:function(){var B="wid="+this.wid+"&isPlanned="+this.plan;var A="GetWorkout";var C=new Ajax.Request(A,{method:"get",parameters:B,onSuccess:this.showEditDialog.bind(this),onFailure:this.alertException.bind(this)});},showEditDialog:function(request){this.setValues(eval("("+request.responseText+")"));this.handleClick();},_invoke:function(A){Event.stop(A);this.calendar.init();this.handleUnit();this.handleClick(A);},setValues:function(B){this.newWorkout=false;$("selectSport").value=B.sport;this.handleUnit();this.updateRouteList(B.sport);$("workoutDate").value=B.date;$("distance").value=B.distance;if(B.distanceunit){$("distanceUnitSelection").value=0;}else{$("distanceUnitSelection").value=1;}$("notes").value=B.notes;var A=this.getDurationArray(B);if(A!=null){if(A.length>0){$("durationHH").value=A[0];}if(A.length>1){$("durationMM").value=A[1];}if(A.length>2){$("durationSS").value=A[2];}}if(B.avghr){$("avghr").value=B.avghr;}if(B.route){$("selectRoute").value=B.route.routeid;}if(B.intensity||B.intensity==0){$("intensity").value=B.intensity;}},getDurationArray:function(B){var A=B.duration;if(A!=null){return A.split(":");}return null;},clearDialog:function(){Form.reset($(this.formId));var B=$$("div.validation");B.each(function(D,C){D.innerHTML="";});var A=$$("input.dialogInput");A.each(function(D,C){D.style.backgroundColor=ValidationMessageHandler.VALID_COLOR;});},showDatePicker:function(A){Event.stop(A);this.calendar.show();},routeChanged:function(D){var B=Event.element(D);var C=B.options[B.selectedIndex];var F=C.getAttribute("distance");var A=C.getAttribute("metric");var E=$("selectSport").value;if(E=="swim"){if(A=="true"){$("distance").value=F*1000;}else{$("distance").value=Math.round(F*1093.6133);}}else{if(A=="true"){$("distance").value=F;}else{$("distance").value=Math.round(F*0.621371192*10)/10;}}if(A=="true"){$("distanceUnitSelection").value=0;}else{$("distanceUnitSelection").value=1;}this.updateSpeedAndPace();},ehUpdateRouteList:function(C){var A=Event.element(C);var B=A.options[A.selectedIndex];var D=B.value;this.updateRouteList(D);},updateRouteList:function(F){var A=$("selectRoute");A.options.length=1;if(this.routeList){var B=this.routeList.result;for(var D=0;D<B.length;D++){var C=B[D];if(C.sport==F){var E=new Option(C.name,C.routeid);E.setAttribute("distance",C.distance);E.setAttribute("metric",C.metric);A.options[A.options.length]=E;}}}if(this.favRouteList){var B=this.favRouteList.result;for(var D=0;D<B.length;D++){var C=B[D];if(C.sport==F){var E=new Option(C.name,C.routeid);E.setAttribute("distance",C.distance);E.setAttribute("metric",C.metric);A.options[A.options.length]=E;}}}},fireOkEvent:function(A){if(this.newWorkout){EventManager.fireEvent(Events.WORKOUT_ADDED);}else{EventManager.fireEvent(Events.WORKOUT_UPDATED);}}});UpdateWeightDialog=Class.create();UpdateWeightDialog.prototype=Object.extend(new AbstractDialog(),{initialize:function(B,A){this.init(B);this.metricUser=A;this.datePicker=new DatePicker(B+"DatePickerCal",B+"DateContainer",B+"CalContainer",B+"DatePicker",B+"CloseCal",B+"Date");this.observeInputFields();},invoke:function(A){Event.stop(A);this.datePicker.init();this.handleClick(A);},observeInputFields:function(){Event.observe($(this.dialogPrefixId+"Date"),"change",this.ehCheckWeightDate.bindAsEventListener(this));Event.observe($("weight"),"change",this.ehCheckWeight.bindAsEventListener(this));},handleSubmit:function(E){Event.stop(E);if(!this.checkAll()){return ;}var C=$(this.formId);var D=Form.serialize(C);this.weight=C.weight.value;this.metricWeightUnit=C.weightUnit.value==0;var A="EnterWeight";this.close();var B=new Ajax.Request(A,{method:"post",parameters:D,onSuccess:this.showSubmitResult.bind(this),onFailure:this.alertException.bind(this)});},showSubmitResult:function(D){var A=this.handleMessage(D);if(!A){return ;}EventManager.fireEvent(Events.WEIGHT_UPDATED);var C=" "+(this.metricUser?I18N.getMessage("jsMessage.unit.kg"):I18N.getMessage("jsMessage.unit.lbs"));var B=new Number(this.weight);B=B.toFixed(1);if(this.metricUser!=this.metricWeightUnit){if(this.metricUser){B=new Number(this.weight*0.45359237);B=B.toFixed(1);}else{B=new Number(this.weight/0.45359237);B=B.toFixed(1);}}$("profileWeight").update(B+C);},clearDialog:function(){Form.reset($(this.formId));},checkAll:function(){var A=this.checkWeightDate($(this.dialogPrefixId+"Date"));if(!A){return false;}return this.checkWeight($("weight"));},checkWeightDate:function(A){var B=FormValidator.validateDate(A.value);if(!B){ValidationMessageHandler.handleInvalidDate("weightDateValidation",A);}else{ValidationMessageHandler.setValid("weightDateValidation",A);}return B;},ehCheckWeightDate:function(B){var A=Event.element(B);this.checkWeightDate(A);},checkWeight:function(A){var B=FormValidator.validateDecimal(A.value);if(!B){ValidationMessageHandler.handleInvalidDecimal("weightValidation",A);}else{ValidationMessageHandler.setValid("weightValidation",A);}return B;},ehCheckWeight:function(B){var A=Event.element(B);this.checkWeight(A);}});ChallengeDialog=Class.create();ChallengeDialog.prototype=Object.extend(new AbstractDialog(),{CHALLENGE_UNIT_TEMPLATE_STR:'<option value="0">#{metricUnit}</option><option value="1">#{usUnit}</option>',initialize:function(A){this.init(A);this.UNIT_TEMPLATE=new Template(this.CHALLENGE_UNIT_TEMPLATE_STR);this.noRedirect=false;Event.observe($("challengeType"),"change",this.ehHandleTypeChange.bindAsEventListener(this));this.startDateCalendar=new DatePicker(A+"StartDatePickerCal",A+"StartDateContainer",A+"StartDateCalContainer",A+"StartDatePicker",A+"StartDateCloseCal",A+"StartDate");this.endDateCalendar=new DatePicker(A+"EndDatePickerCal",A+"EndDateContainer",A+"EndDateCalContainer",A+"EndDatePicker",A+"EndDateCloseCal",A+"EndDate");this.observeInputFields();},setNoRedirect:function(A){this.noRedirect=A;},observeInputFields:function(){Event.observe($("challengeSport"),"change",this.ehHandleSportChange.bindAsEventListener(this));Event.observe($("challengeName"),"change",this.ehCheckChallengeName.bindAsEventListener(this));Event.observe($("challengeValue"),"change",this.ehCheckChallengeValue.bindAsEventListener(this));Event.observe($(this.dialogPrefixId+"StartDate"),"change",this.ehCheckStartDate.bindAsEventListener(this));Event.observe($(this.dialogPrefixId+"EndDate"),"change",this.ehCheckEndDate.bindAsEventListener(this));},getServerCall:function(){if(this.newChallenge){return"NewChallenge";}return"EditChallenge";},invoke:function(B){this.newChallenge=true;var A=$("challengeType");A.enable();this.handleTypeChange(A.value);this.startDateCalendar.init();this.endDateCalendar.init();this.handleClick(B);},invokeEdit:function(E){Event.stop(E);var A=Event.element(E);var F=Event.element(E).id;var D=F.split("editChallenge_")[1];var C=D.split("_")[0];var B=D.split("_")[1];this.doEditRequest(C,B);},doEditRequest:function(C,B){var D="challengeId="+C+"&challengeType="+B;var A="GetChallenge";var E=new Ajax.Request(A,{method:"get",parameters:D,onSuccess:this.showEdit.bind(this),onFailure:this.alertException.bind(this)});},showEdit:function(request){this.setValues(eval("("+request.responseText+")"));this.handleClick(null);},setValues:function(B){this.newChallenge=false;this.challengeId=B.id;var A=$("challengeType");A.value=B.type;this.handleTypeChange(A.value);A.disable();$("challengeName").value=B.name;$("challengeValue").value=B.value;$("challengeValueUnit").value=B.unit;$("challengeValueFrequency").value=B.meassure;$(this.dialogPrefixId+"StartDate").value=B.startdate;$(this.dialogPrefixId+"EndDate").value=B.enddate;$("challengeSport").value=B.sport;$("challengeDescription").value=B.notes;$("challengeMinTime").value=B.mintime;},ehHandleTypeChange:function(B){var A=Event.element(B);this.handleTypeChange(A.value);},handleTypeChange:function(A){if(A=="time"){this.showTimeDialog();}else{if(A=="distance"){this.showDistanceDialog();}else{if(A=="weight"){this.showWeightDialog();}else{if(A=="frequency"){this.showFrequencyDialog();}else{if(A=="points"){this.showPointsDialog();}else{this.showSimpleDialog();}}}}}},ehHandleSportChange:function(A){var B=Event.element(A);this.handleSportChange(B.value);},handleSportChange:function(A){if($("challengeType").value!="distance"){return ;}if(A=="swim"){this.showUnits(I18N.getMessage("jsMessage.unit.m"),I18N.getMessage("jsMessage.unit.yds"));}else{this.showUnits(I18N.getMessage("jsMessage.unit.km"),I18N.getMessage("jsMessage.unit.mi"));}},showTimeDialog:function(){$("challengeValueUnit").hide();$("challengeValueUnitDiv").update(I18N.getMessage("jsMessage.challengeDialog.hours"));$("challengeValueLabel").update(I18N.getMessage("jsMessage.challengeDialog.time"));$("challengeSportDiv").show();$("challengeTimeDiv").show();$("challengeValueFrequency").show();$("challengeValueUnitDiv").show();},showDistanceDialog:function(){$("challengeValueLabel").update(I18N.getMessage("jsMessage.challengeDialog.distance"));$("challengeSportDiv").show();if($("challengeSport").value=="swim"){this.showUnits(I18N.getMessage("jsMessage.unit.m"),I18N.getMessage("jsMessage.unit.yds"));}else{this.showUnits(I18N.getMessage("jsMessage.unit.km"),I18N.getMessage("jsMessage.unit.mi"));}$("challengeTimeDiv").show();$("challengeValueFrequency").show();$("challengeValueUnitDiv").hide();},showWeightDialog:function(){$("challengeSportDiv").hide();$("challengeValueFrequency").hide();$("challengeValueUnitDiv").hide();this.showUnits(I18N.getMessage("jsMessage.unit.kg"),I18N.getMessage("jsMessage.unit.lbs"));$("challengeValueLabel").update(I18N.getMessage("jsMessage.challengeDialog.weight"));$("challengeTimeDiv").show();},showFrequencyDialog:function(){$("challengeValueUnit").hide();$("challengeValueUnitDiv").update(I18N.getMessage("jsMessage.challengeDialog.times"));$("challengeValueLabel").update(I18N.getMessage("jsMessage.challengeDialog.frequency"));$("challengeSportDiv").show();$("challengeTimeDiv").show();$("challengeValueFrequency").show();$("challengeValueUnitDiv").show();},showPointsDialog:function(){$("challengeValueLabel").update(I18N.getMessage("jsMessage.challengeDialog.points"));$("challengeSportDiv").hide();$("challengeTimeDiv").show();$("challengeValueFrequency").show();$("challengeValueUnitDiv").hide();},showSimpleDialog:function(){$("challengeSportDiv").hide();$("challengeTimeDiv").hide();},showUnits:function(B,D){var A=$("challengeValueUnit");A.update("");var C=this.UNIT_TEMPLATE.evaluate({metricUnit:B,usUnit:D});new Insertion.Bottom(A,C);A.show();},handleSubmit:function(D){Event.stop(D);if(!this.checkAll()){return ;}var B=$(this.formId);var C=Form.serialize(B);C+="&challengeValueUnit="+$("challengeValueUnit").value;if(!this.newChallenge){C+="&challengeId="+this.challengeId+"&challengeType="+$("challengeType").value;}if(this.noRedirect){C+="&noRedirect=true";}this.close();var A=new Ajax.Request(this.getServerCall(),{method:"post",parameters:C,onSuccess:this.showSubmitResult.bind(this),onFailure:this.alertException.bind(this)});},showSubmitResult:function(B){var A=this.handleMessage(B);if(!A){return ;}if(!this.newChallenge){window.location.reload();}},clearDialog:function(){Form.reset($(this.formId));var B=$$("div.validation");B.each(function(D,C){D.update("");});var A=$$("input.dialogInput");A.each(function(D,C){D.style.backgroundColor=ValidationMessageHandler.VALID_COLOR;});},checkAll:function(){var A=this.checkChallengeName($("challengeName"));if(!A){return false;}A=this.checkChallengeValue($("challengeValue"));if(!A){return false;}A=this.checkStartDate($(this.dialogPrefixId+"StartDate"));if(!A){return false;}A=this.checkEndDate($(this.dialogPrefixId+"EndDate"));if(!A){return false;}return true;},ehCheckChallengeName:function(B){var A=Event.element(B);this.checkChallengeName(A);},checkChallengeName:function(A){var B=FormValidator.validateGoalName(A.value);if(B==FormValidator.INVALID_LENGTH){ValidationMessageHandler.handleInvalidLength100("challengeNameValidation",A);return false;}else{if(B==FormValidator.INVALID_EMPTY){ValidationMessageHandler.handleEmpty("challengeNameValidation",A);return false;}else{ValidationMessageHandler.setValid("challengeNameValidation",A);return true;}}},ehCheckChallengeValue:function(B){var A=Event.element(B);this.checkChallengeValue(A);},checkChallengeValue:function(A){if($("challengeType").value=="simple"){return true;}var B=FormValidator.validateDecimal(A.value);if(!B){ValidationMessageHandler.handleInvalidDecimal("challengeValueValidation",A);}else{ValidationMessageHandler.setValid("challengeValueValidation",A);}return B;},ehCheckStartDate:function(B){var A=Event.element(B);this.checkStartDate(A);},checkStartDate:function(A){var B=FormValidator.validateDate(A.value);if(!B){ValidationMessageHandler.handleInvalidDate("challengeStartDateValidation",A);}else{ValidationMessageHandler.setValid("challengeStartDateValidation",A);}return B;},ehCheckEndDate:function(B){var A=Event.element(B);this.checkEndDate(A);},checkEndDate:function(A){var B=FormValidator.validateDate(A.value);if(!B){ValidationMessageHandler.handleInvalidDate("challengeEndDateValidation",A);}else{ValidationMessageHandler.setValid("challengeEndDateValidation",A);}return B;}});Events=Class.create();Events.prototype={initialize:function(){},WORKOUT_ADDED:"NEW_WORKOUT",UPDATE_WORKOUT:"UPDATE_WORKOUT",WORKOUT_UPDATED:"WORKOUT_UPDATED",DELETE_WORKOUT:"DELETE_WORKOUT",WORKOUT_DELETED:"DELETE_WORKOUT",SUMMARY_YEAR_CHANGED:"SUMMARY_YEAR_CHANGED",SUMMARY_MONTH_CHANGED:"SUMMARY_MONTH_CHANGED",SUMMARY_WEEK_CHANGED:"SUMMARY_WEEK_CHANGED",GOAL_ADDED:"GOAL_ADDED",GOAL_EDITED:"GOAL_EDITED",GOAL_DELETED:"GOAL_DELETED",THREAD_ADDED:"THREAD_ADDED",NOT_ENOUGH_ROUTE_POINTS:"NOT_ENOUGH_ROUTE_POINTS",SHOW_ELEVATION:"SHOW_ELEVATION",ELEVATION_REQUEST_ERROR:"ELEVATION_REQUEST_ERROR",CLEAR_ROUTE_ERROR:"CLEAR_ROUTE_ERROR",ROUTE_DELETED:"ROUTE_DELETED",ROUTE_EDITED:"ROUTE_EDITED",WORKOUT_COMMENT_ADDED:"WORKOUT_COMMENT_ADDED",WORKOUT_COMMENT_DELETED:"WORKOUT_COMMENT_DELETED",WORKOUT_COMMENT_EDITED:"WORKOUT_COMMENT_EDITED",WEIGHT_UPDATED:"WEIGHT_UPDATED"};EventManager=Class.create();EventManager.prototype={initialize:function(){Events=new Events();this.eventMap=new Array();},registerEventHandler:function(C,B){var A=this.eventMap[C];if(A==null){A=new Array();}A.push(B);this.eventMap[C]=A;},fireEvent:function(E){if(E==null){return ;}var A=this.eventMap[E];if(A==null){return ;}var B=new Array();for(var C=1;C<arguments.length;C++){B.push(arguments[C]);}for(var C=0;C<A.length;C++){var D=A[C];D.apply(null,B);}}};EventManager=new EventManager();LoadForumThreadList=Class.create();LoadForumThreadList.prototype=Object.extend(new ServerAction(),{THREAD_ROW_TEMPLATE_STR:'<tr class="forumThreadRow"><td><a href="ViewThread?threadId=#{threadId}&groupid=#{groupId}">#{title}</a></td><td><a href="Members?user=#{author}">#{author}</a></td><td>#{replies}</td><td>#{lastPostOn}<br>#{lastPostBy}</td></tr>',LAST_POST_BY_TEMPLATE_STR:'<a href="Members?user=#{lastPostBy}">#{lastPostBy}</a>',initialize:function(){var A=this.loadThreadList.bindAsEventListener(this);EventManager.registerEventHandler(Events.THREAD_ADDED,A);this.THREAD_ROW_TEMPLATE=new Template(this.THREAD_ROW_TEMPLATE_STR);this.LAST_POST_BY_TEMPLATE=new Template(this.LAST_POST_BY_TEMPLATE_STR);},loadThreadList:function(D,A){var C="groupId="+A;if(D){C+="&threadId="+D;}var B=new Ajax.Request("GetForumThreadList",{method:"get",parameters:C,onSuccess:this.showThreadList.bind(this),onFailure:this.alertException.bind(this)});},showThreadList:function(request){var threadListJSON=eval("("+request.responseText+")");var threads=threadListJSON.threads;var threadRows=$$("tr.forumThreadRow");for(var i=0;i<threadRows.length;i++){threadRows[i].remove();}var threadTable=$("groupForumThreadTable");for(var i=0;i<threads.length;i++){var thread=threads[i];var lastPostBy="";if(thread.lastpostby){lastPostBy=this.LAST_POST_BY_TEMPLATE.evaluate({lastPostBy:entityEncode(thread.lastpostby)});}var toInsert=this.THREAD_ROW_TEMPLATE.evaluate({threadId:entityEncode(thread.threadid),groupId:entityEncode(thread.groupId),title:entityEncode(thread.title),author:entityEncode(thread.author),replies:entityEncode(thread.replies),lastPostOn:entityEncode(thread.formattedlastposton),lastPostBy:entityEncode(lastPostBy)});new Insertion.Bottom(threadTable,toInsert);}}});LoadForumThreadList=new LoadForumThreadList();LoadRoutes=Class.create();LoadRoutes.prototype=Object.extend(new ServerAction(),{ROUTE_TEMPLATE_STR:'<div class="listentry"><div class="listdate">Created on #{createdOn} by <a href="members?user=#{userId} %>">#{userId}</a></div><div><a href="viewroute?routeId=#{id}">#{name}</a>#{distance} #{sport}</div><div>#{city} , #{country}</div><div>#{notes}</div></div>',initialize:function(){this.ROUTE_TEMPLATE=new Template(this.ROUTE_TEMPLATE_STR);},navigatePublicRoutes:function(A){this.navigate(A,false);},navigateUserRoutes:function(A){this.navigate(A,true);},navigate:function(G,B){Event.stop(G);scroll(0,0);var A=$("loadingArea");A.style.display="block";var D=Event.element(G);if(D.tagName=="IMG"){D=D.parentNode;}var F=D.href.split("Routes?")[1];var H="?"+F;if(B){H+="&isUserRoutes=true";}var C="FilterRoutes";var E=new Ajax.Request(C,{method:"get",parameters:H,onSuccess:this.showSearchResult.bind(this),onFailure:this.alertException.bind(this)});},clearResultArea:function(){var A=$("routesDiv");A.update("");},showSearchResult:function(request){var resultJSON=eval("("+request.responseText+")");var routes=resultJSON.result;this.clearResultArea();var routesDiv=$("routesDiv");for(var i=0;i<routes.length;i++){var route=routes[i];var toInsert=this.ROUTE_TEMPLATE.evaluate({createdOn:entityEncode(route.createdon),userId:entityEncode(route.userid),id:entityEncode(route.routeid),name:entityEncode(route.name),distance:entityEncode(route.converteddistance),sport:entityEncode(route.sport),city:entityEncode(route.city),country:entityEncode(route.country),notes:entityEncode(route.notes)});new Insertion.Bottom(routesDiv,toInsert);}var navigateFunction=resultJSON.publicRoutes?this.navigatePublicRoutes.bindAsEventListener(this):this.navigateUserRoutes.bindAsEventListener(this);var loadingArea=$("loadingArea");loadingArea.style.display="none";}});var LoadRoutes=new LoadRoutes();LoadSummary=Class.create();LoadSummary.prototype=Object.extend(new ServerAction(),{YEAR_TABLE_ID:"summaryTableYear",MONTH_TABLE_ID:"summaryTableMonth",WEEK_TABLE_ID:"summaryTableWeek",SUMMARY_ROW_TEMPLATE_STR:'<tr class="#{class}"><td>#{sport}</td><td>#{duration}</td><td>#{distance}</td></tr>',initialize:function(A){var B=this.loadSummary.bindAsEventListener(this);EventManager.registerEventHandler(Events.WORKOUT_ADDED,B);EventManager.registerEventHandler(Events.WORKOUT_UPDATED,B);EventManager.registerEventHandler(Events.WORKOUT_DELETED,B);EventManager.registerEventHandler(Events.SUMMARY_YEAR_CHANGED,this.loadYearSummary.bindAsEventListener(this));EventManager.registerEventHandler(Events.SUMMARY_MONTH_CHANGED,this.loadMonthSummary.bindAsEventListener(this));EventManager.registerEventHandler(Events.SUMMARY_WEEK_CHANGED,this.loadWeekSummary.bindAsEventListener(this));this.yearSummarySelector=new SummarySelector("previousYearSummary","nextYearSummary","yearSummarySelector",Events.SUMMARY_YEAR_CHANGED);this.monthSummarySelector=new SummarySelector("previousMonthSummary","nextMonthSummary","monthSummarySelector",Events.SUMMARY_MONTH_CHANGED);this.weekSummarySelector=new SummarySelector("previousWeekSummary","nextWeekSummary","weekSummarySelector",Events.SUMMARY_WEEK_CHANGED);Event.observe(window,"load",this.clearAllSelectElements.bindAsEventListener(this));this.serverCall=A;this.SUMMARY_ROW_TEMPLATE=new Template(this.SUMMARY_ROW_TEMPLATE_STR);},_loadSummary:function(E,B,C){if(C){var A=$(C);A.style.display="block";}else{$("workoutYearSpinner").style.display="block";$("workoutMonthSpinner").style.display="block";$("workoutWeekSpinner").style.display="block";}if(this.groupId){E+="&groupId="+this.groupId;}if(this.userId){E+="&userId="+this.userId;}var D=new Ajax.Request(this.serverCall,{method:"get",parameters:E,onSuccess:B,onFailure:this.alertException.bind(this)});},loadSummary:function(A){this._loadSummary("",this.showSummary.bind(this));this.loadWorkoutChart();},loadWorkoutChart:function(A){if(document.workoutDistributionChart&&document.workoutDistributionChart.SetVariable){document.workoutDistributionChart.SetVariable("update_url","GetWorkoutDistributionXml");}},loadYearSummary:function(E){Event.stop(E);var B=$("yearSummarySelector");var D=B.value;var C=D;if(!C){var A=new Date();C=A.getFullYear();}var F="year="+C;this._loadSummary(F,this.updateYearSummary.bind(this),"workoutYearSpinner");},loadMonthSummary:function(F){Event.stop(F);var H=$("monthSummarySelector");var C=H.value;var A=new Date();var D=A.getFullYear();var E=A.getMonth()+1;A.setDate(1);if(C){var B=C.split("-");D=B[0];E=B[1];A.setYear(D);A.setMonth(E-1);}var G="month="+C;this._loadSummary(G,this.updateMonthSummary.bind(this),"workoutMonthSpinner");},loadWeekSummary:function(E){Event.stop(E);var D=$("weekSummarySelector");var C=D.value;var A=new Date();if(C){var B=C.split("-");year=B[0];month=B[1];day=B[2];A.setYear(year);A.setMonth(month-1);A.setDate(day);}var F="week="+C;this._loadSummary(F,this.updateWeekSummary.bind(this),"workoutWeekSpinner");},clearSummaryTable:function(D){var C=$(D);var E=C.getElementsByTagName("tr");var B=new Array();for(var A=0;A<E.length;A++){var F=E[A];B.push(F);}for(var A=0;A<B.length;A++){var F=B[A];Element.remove(F);}},clearAllSelectElements:function(A){this.clearYearSelectElement();this.clearMonthSelectElement();this.clearWeekSelectElement();},clearYearSelectElement:function(){var A=new Date();var B=A.getFullYear();$("yearSummarySelector").value=B;this.yearSummarySelector.updateSelectorStyles();},clearMonthSelectElement:function(C){var B=new Date();var D=B.getFullYear();var E=B.getMonth()+1;var A="1";$("monthSummarySelector").value=D+"-"+E+"-"+A;this.monthSummarySelector.updateSelectorStyles();},clearWeekSelectElement:function(A){$("weekSummarySelector").value=this.getStartOfThisWeek();this.weekSummarySelector.updateSelectorStyles();},getStartOfThisWeek:function(){var C=new Date();var B=C.getDay();if(B==0){B=6;}else{B--;}C=YAHOO.widget.DateMath.subtract(C,YAHOO.widget.DateMath.DAY,B);var D=C.getFullYear();var E=C.getMonth()+1;var A=C.getDate();return D+"-"+E+"-"+A;},updateTable:function(I,C){this.clearSummaryTable(C);var N=I.children;var M=$(C);var F=M.getElementsByTagName("tbody")[0];var E=0;for(E=0;E<N.length;E++){var K=N[E];var D="";var B="";if(C==this.YEAR_TABLE_ID){D=K.ytddurationstring;B=K.ytddistancestring+" "+K.distanceunit;}else{if(C==this.MONTH_TABLE_ID){D=K.mtddurationstring;B=K.mtddistancestring+" "+K.distanceunit;}else{if(C==this.WEEK_TABLE_ID){D=K.wtddurationstring;B=K.wtddistancestring+" "+K.distanceunit;}}}var H=(E%2==0)?"evenStatTableRow":"oddStatTableRow";var J=this.SUMMARY_ROW_TEMPLATE.evaluate({"class":H,"sport":entityEncode(K.sport),"duration":entityEncode(D),"distance":entityEncode(B)});new Insertion.Bottom(F,J);}var L="";if(C==this.YEAR_TABLE_ID){L=I.ytdtotal;}else{if(C==this.MONTH_TABLE_ID){L=I.mtdtotal;}else{if(C==this.WEEK_TABLE_ID){L=I.wtdtotal;}}}var G="";if(C==this.YEAR_TABLE_ID){G=I.ytddistancetotal;}else{if(C==this.MONTH_TABLE_ID){G=I.mtddistancetotal;}else{if(C==this.WEEK_TABLE_ID){G=I.wtddistancetotal;}}}var H=(E%2==0)?"evenStatTableRowTotal":"oddStatTableRowTotal";var A=this.SUMMARY_ROW_TEMPLATE.evaluate({"class":H,"sport":"Total","duration":entityEncode(L),"distance":entityEncode(G)});new Insertion.Bottom(F,A);},updateYearSummary:function(request){var summaryJSON=eval("("+request.responseText+")");this.updateTable(summaryJSON,this.YEAR_TABLE_ID);var loadingArea=$("workoutYearSpinner");loadingArea.style.display="none";},updateYearSelector:function(B){$("yearSummarySelector").update("");var D=B.summaryyears;var A=new Date();for(var C=0;C<D.length;C++){$("yearSummarySelector").options[C]=new Option(D[C].year,D[C].year);if(A.getFullYear()==D[C].year){$("yearSummarySelector").options[C].selected=true;}}},updateMonthSummary:function(request){var summaryJSON=eval("("+request.responseText+")");this.updateTable(summaryJSON,this.MONTH_TABLE_ID);var loadingArea=$("workoutMonthSpinner");loadingArea.style.display="none";},updateMonthSelector:function(D){$("monthSummarySelector").update("");var A=D.summarymonths;var B=new Date();for(var C=0;C<A.length;C++){$("monthSummarySelector").options[C]=new Option(A[C].display,A[C].value);if(B.getFullYear()==A[C].year&&(B.getMonth()+1)==A[C].month){$("monthSummarySelector").options[C].selected=true;}}},updateWeekSummary:function(request){var summaryJSON=eval("("+request.responseText+")");this.updateTable(summaryJSON,this.WEEK_TABLE_ID);var loadingArea=$("workoutWeekSpinner");loadingArea.style.display="none";},updateWeekSelector:function(D){$("weekSummarySelector").update("");var E=D.summaryweeks;var B=new Date();var A=this.getStartOfThisWeek();for(var C=0;C<E.length;C++){$("weekSummarySelector").options[C]=new Option(E[C].display,E[C].value);if(A==E[C].value){$("weekSummarySelector").options[C].selected=true;}}},showSummary:function(request){var summaryJSON=eval("("+request.responseText+")");this.updateYearSelector(summaryJSON.yearsummary);this.yearSummarySelector.updateSelectorStyles();this.updateWeekSelector(summaryJSON.weeksummary);this.weekSummarySelector.updateSelectorStyles();this.updateMonthSelector(summaryJSON.monthsummary);this.monthSummarySelector.updateSelectorStyles();this.updateTable(summaryJSON.yearsummary,this.YEAR_TABLE_ID);this.updateTable(summaryJSON.monthsummary,this.MONTH_TABLE_ID);this.updateTable(summaryJSON.weeksummary,this.WEEK_TABLE_ID);$("workoutYearSpinner").style.display="none";$("workoutMonthSpinner").style.display="none";$("workoutWeekSpinner").style.display="none";},setGroupId:function(A){this.groupId=A;},setUserId:function(A){this.userId=A;}});RefreshWorkoutChart=Class.create();RefreshWorkoutChart.prototype={initialize:function(){var A=this.refreshChart.bindAsEventListener(this);},refreshChart:function(){var A=$("workoutChartImage");A.src="images/loading.gif";var B=new Date();var C=B.getTime();A.src="GetChartImage?nocache="+C.valueOf();}};var RefreshWorkoutChart=new RefreshWorkoutChart();AbstractWorkoutView=Class.create();AbstractWorkoutView.prototype=Object.extend(new ServerAction(),{initialize:function(){},init:function(){this.resultArea=$("resultArea");this.loadingArea=$("loadingMainArea");},handleClick:function(A){if(A!=null){Event.stop(A);}this.clearAll();this.__handleClick(A);},clearAll:function(){this.loadingArea.style.display="block";},clearResultArea:function(){this.resultArea.style.display="none";while(this.resultArea.hasChildNodes()){this.resultArea.removeChild(this.resultArea.firstChild);}},showResultArea:function(){this.loadingArea.style.display="none";this.resultArea.style.display="block";}});AbstractListView=Class.create();AbstractListView.prototype=Object.extend(new AbstractWorkoutView(),{LIST_NAV_TEMPLATE_STR:"#{previousLink}#{nextLink}",PREVIOUS_LINK_TEMPLATE_STR:'<a href="MyWorkouts?view=#{view}&#{parameters}" id="#{indicatorId}" class="leftIndicator">&lt;</a><a href="MyWorkouts?view=#{view}&#{parameters}" id="#{id}" style="float:left;">#{text}</a><div style="float:left;">&nbsp;</div>',NEXT_LINK_TEMPLATE_STR:'<a href="MyWorkouts?view=#{view}&#{parameters}" id="#{id}" style="float:left;">#{text}</a><a href="MyWorkouts?view=#{view}&#{parameters}" id="#{indicatorId}" class="rightIndicator">&gt;</a>	',LIST_ITEM_TEMPLATE_STR:'<div class="#{listEntryClass}" id=#{id}><div class="listdate">#{dateString}</div></div>',WORKOUT_ITEM_TEMPLATE_STR:'<div><div><div class=spacer></div><div class="loggedEventIcon"></div><div style="float:left;"><a href="viewworkout?wid=#{wid}" class="blogsport">#{sport}</a>&nbsp<span>#{formattedValues}</span></div><div class=spacer></div></div>#{notes}</div>',PLANNED_WORKOUT_ITEM_TEMPLATE_STR:'<div><div><div class=spacer></div><div class="plannedEventIcon"></div><div style="float:left;"><a href="viewworkout?wid=#{wid}&isPlanned=true" class="blogsport">#{sport}</a>&nbsp<span>#{formattedValues}</span></div><div class=spacer></div></div>#{notes}</div>',WORKOUT_NOTES_TEMPLATE_STR:'<div class="listworkoutnotes">#{notes}</div>',initListView:function(A,G,F,E,C,B){this.init();this.listId=A;this.navId=G;this.previousId=F;this.nextId=E;this.previousText=C;this.nextText=B;var D=this.handleClick.bindAsEventListener(this);EventManager.registerEventHandler(Events.WORKOUT_ADDED,D);EventManager.registerEventHandler(Events.WORKOUT_UPDATED,D);EventManager.registerEventHandler(Events.WORKOUT_DELETED,D);this.LIST_NAV_TEMPLATE=new Template(this.LIST_NAV_TEMPLATE_STR);this.PREVIOUS_LINK_TEMPLATE=new Template(this.PREVIOUS_LINK_TEMPLATE_STR);this.NEXT_LINK_TEMPLATE=new Template(this.NEXT_LINK_TEMPLATE_STR);this.LIST_ITEM_TEMPLATE=new Template(this.LIST_ITEM_TEMPLATE_STR);this.WORKOUT_ITEM_TEMPLATE=new Template(this.WORKOUT_ITEM_TEMPLATE_STR);this.WORKOUT_NOTES_TEMPLATE=new Template(this.WORKOUT_NOTES_TEMPLATE_STR);this.PLANNED_WORKOUT_ITEM_TEMPLATE=new Template(this.PLANNED_WORKOUT_ITEM_TEMPLATE_STR);},clearList:function(){var A=$(this.listId);A.update("");var B=$(this.navId);B.update("");},getView:function(){},getPreviousParameters:function(A){},getNextParameters:function(A){},showView:function(request){this.clearList();var listDiv=$(this.listId);list=eval("("+request.responseText+")");var insertPreviousLink="";if(list.showprevious){insertPreviousLink=this.PREVIOUS_LINK_TEMPLATE.evaluate({"view":entityEncode(this.getView()),"parameters":entityEncode(this.getPreviousParameters(list)),"id":entityEncode(this.previousId),"indicatorId":entityEncode(this.previousId+"Indicator"),"text":entityEncode(this.previousText)});}var insertNextLink="";if(list.shownext){insertNextLink=this.NEXT_LINK_TEMPLATE.evaluate({"view":entityEncode(this.getView()),"parameters":entityEncode(this.getNextParameters(list)),"id":entityEncode(this.nextId),"indicatorId":entityEncode(this.nextId+"Indicator"),"text":entityEncode(this.nextText)});}var insertNav=this.LIST_NAV_TEMPLATE.evaluate({"previousLink":insertPreviousLink,"nextLink":insertNextLink});new Insertion.Bottom($(this.navId),insertNav);if(list.showprevious){Event.observe($(this.previousId),"click",this.handleClick.bindAsEventListener(this));Event.observe($(this.previousId+"Indicator"),"click",this.handleClick.bindAsEventListener(this));}if(list.shownext){Event.observe($(this.nextId),"click",this.handleClick.bindAsEventListener(this));Event.observe($(this.nextId+"Indicator"),"click",this.handleClick.bindAsEventListener(this));}var days=list.children;for(var i=0;i<days.length;i++){var day=days[i];var listEntryClass=day.today?"todaylistentry":"listentry";var insertItem=this.LIST_ITEM_TEMPLATE.evaluate({"listEntryClass":listEntryClass,"dateString":entityEncode(day.datestring),"id":"listItem"+i});new Insertion.Bottom(listDiv,insertItem);this.addWorkouts(day.workouts,"listItem"+i,this.WORKOUT_ITEM_TEMPLATE);this.addWorkouts(day.plannedworkouts,"listItem"+i,this.PLANNED_WORKOUT_ITEM_TEMPLATE);}this.showResultArea();},addWorkouts:function(F,B,E){if(!F){return ;}for(var D=0;D<F.length;D++){var G=F[D];var A="";if(G.notes){A=this.WORKOUT_NOTES_TEMPLATE.evaluate({"notes":entityEncode(G.notes)});}var C=E.evaluate({"wid":G.wid,"sport":entityEncode(G.sport),"formattedValues":entityEncode(G.formattedvalues),"notes":A});new Insertion.Bottom($(B),C);}}});BlogView=Class.create();BlogView.prototype=Object.extend(new AbstractListView(),{initialize:function(F,A,G,E,D,C,B){this.initListView(A,G,E,D,C,B);this.page=F;},__handleClick:function(F){var G=1;var D="";if(F){try{var E=F.element();if(E.tagName!="A"){E=E.parentNode;}var C=E.getAttribute("href");var J=C.split("page=");var I=J[1].split("&");G=I[0];if(!G){G=1;}J=C.split("user=");if(J.length>1){I=J[1].split("&");D=I[0];if(!D){D="";}}}catch(H){}}var K="page="+G+"&user="+D;var B="GetWorkouts";var A=new Ajax.Request(B,{method:"get",parameters:K,onSuccess:this.showView.bind(this),onFailure:this.alertException.bind(this)});},getView:function(){return"list";},getPreviousParameters:function(A){return"page="+A.previous+"&user="+A.user;},getNextParameters:function(A){return"page="+A.next+"&user="+A.user;}});MonthSelector=Class.create();MonthSelector.prototype={MONTH_SELECTOR_TEMPLATE_STR:'<div id="monthSelectorClose" class="monthSelectorClose">X</div><table class="monthSelectorTable"><tr><td class="monthSelectorYear" colspan=3><div class="spacer"></div><div class="leftIndicator" id="monthSelectorPrevYear">&lt;</div><div id="monthSelectorYear" style="float:left;">#{year}</div><div class="rightIndicator" id="monthSelectorNextYear">&gt;</div><div class="spacer"></div></td></tr><tr><td><a href="" id="monthSelectorMonth_1">Jan</a></td><td><a href="" id="monthSelectorMonth_2">Feb</a></td><td><a href="" id="monthSelectorMonth_3">Mar</a></td></tr><tr><td><a href="" id="monthSelectorMonth_4">Apr</a></td><td><a href="" id="monthSelectorMonth_5">May</a></td><td><a href="" id="monthSelectorMonth_6">Jun</a></td></tr><tr><td><a href="" id="monthSelectorMonth_7">Jul</a></td><td><a href="" id="monthSelectorMonth_8">Aug</a></td><td><a href="" id="monthSelectorMonth_9">Sep</a></td></tr><tr><td><a href="" id="monthSelectorMonth_10">Oct</a></td><td><a href="" id="monthSelectorMonth_11">Nov</a></td><td><a href="" id="monthSelectorMonth_12">Dec</a></td></tr></table>',initialize:function(A){this.view=A;this.MONTH_SELECTOR_TEMPLATE=new Template(this.MONTH_SELECTOR_TEMPLATE_STR);},show:function(D){Event.stop(D);$("monthSelectorDiv").update("");var E="";var G="";this.user="";if(D!=null){var C=Event.element(D);var A=C.getAttribute("href");var H=A.split("month=");var F=H[1].split("&");E=F[0];if(!E){E="";}H=A.split("year=");if(H.length>1){F=H[1].split("&");G=F[0];if(!G){G="";}}H=A.split("user=");if(H.length>1){F=H[1].split("&");this.user=F[0];}}var I=this.MONTH_SELECTOR_TEMPLATE.evaluate({year:entityEncode(G)});new Insertion.Bottom($("monthSelectorDiv"),I);Event.observe($("monthSelectorPrevYear"),"click",this.prevYear.bindAsEventListener(this));Event.observe($("monthSelectorNextYear"),"click",this.nextYear.bindAsEventListener(this));Event.observe($("monthSelectorClose"),"click",this.close.bindAsEventListener(this));for(var B=1;B<13;B++){Event.observe($("monthSelectorMonth_"+B),"click",this.handleSelection.bindAsEventListener(this));}Effect.BlindDown($("monthSelectorDiv"));},nextYear:function(B){Event.stop(B);var A=($("monthSelectorYear").innerHTML)*1;A++;$("monthSelectorYear").update(A);},prevYear:function(B){Event.stop(B);var A=($("monthSelectorYear").innerHTML)*1;A--;$("monthSelectorYear").update(A);},close:function(A){if(A){Event.stop(A);}Effect.BlindUp($("monthSelectorDiv"));},handleSelection:function(D){Event.stop(D);var A=Event.element(D);var E=A.id;var C=E.replace("monthSelectorMonth_","");var B=$("monthSelectorYear").innerHTML;this.close();this.view.doMonthRequest(B,C,this.user);}};MonthView=Class.create();MonthView.prototype=Object.extend(new AbstractWorkoutView(),{ROW_TEMPLATE_STR:'<tr class="monthWeek" id=#{id}></tr>',TD_TEMPLATE_STR:'<td class=#{dayClass}><div class="monthDayContent"><div class="monthDate">#{dayInMonth}</div><div class="workoutContainer" id="wc_#{dayId}"></div><div class="workoutContainer" id="pwc_#{dayId}"></div></div></td>',WORKOUT_TEMPLATE_STR:'<div class="monthDayWorkout"><div class="spacer"></div><div class="loggedEventIcon"></div><div style="float:left;"><a id="#{wid}" href="viewworkout?wid=#{wid}">#{sport}</a></div><div class="spacer"></div></div>',PLANNED_WORKOUT_TEMPLATE_STR:'<div class="monthDayPlannedWorkout"><div class="spacer"></div><div class="plannedEventIcon"></div><div style="float:left;"><a id="#{wid}" href="viewworkout?wid=#{wid}&isPlanned=true">#{sport}</a></div><div class="spacer"></div></div>',initialize:function(){this.init();var A=this.handleClick.bindAsEventListener(this);EventManager.registerEventHandler(Events.WORKOUT_ADDED,A);EventManager.registerEventHandler(Events.WORKOUT_UPDATED,A);EventManager.registerEventHandler(Events.WORKOUT_DELETED,A);EventManager.registerEventHandler(Events.PLANNED_WORKOUT_ADDED,A);EventManager.registerEventHandler(Events.PLANNED_WORKOUT_UPDATED,A);EventManager.registerEventHandler(Events.PLANNED_WORKOUT_DELETED,A);this.ROW_TEMPLATE=new Template(this.ROW_TEMPLATE_STR);this.TD_TEMPLATE=new Template(this.TD_TEMPLATE_STR);this.WORKOUT_TEMPLATE=new Template(this.WORKOUT_TEMPLATE_STR);this.PLANNED_WORKOUT_TEMPLATE=new Template(this.PLANNED_WORKOUT_TEMPLATE_STR);var B=new MonthSelector(this);Event.observe($("monthHeader"),"click",B.show.bindAsEventListener(B));},__handleClick:function(D){var E="";var H="";var B="";if(D){try{var C=Event.element(D);if(C.tagName=="DIV"){C=C.parentNode;}var A=C.getAttribute("href");var I=A.split("month=");var G=I[1].split("&");E=G[0];if(!E){E="";}I=A.split("year=");if(I.length>1){G=I[1].split("&");H=G[0];if(!H){H="";}}I=A.split("user=");if(I.length>1){G=I[1].split("&");B=G[0];if(!B){B="";}}}catch(F){}}this.doMonthRequest(H,E,B);},doMonthRequest:function(C,F,A){var D="month="+F+"&year="+C;if(A){D+="&user="+URLUtil.encode(urldecode(A));}var B="GetMonth";var E=new Ajax.Request(B,{method:"get",parameters:D,onSuccess:this.showMonth.bind(this),onFailure:this.alertException.bind(this)});},clearMonthTable:function(){var A=$("monthTable");var D=A.getElementsByTagName("tr");var C=new Array();for(var B=0;B<D.length;B++){var E=D[B];if(E.className=="monthWeek"){C.push(E);}}for(var B=0;B<C.length;B++){var E=C[B];Element.remove(E);}},showMonth:function(request){var month=eval("("+request.responseText+")");var previousLink=$("previousWorkoutMonth");previousLink.href=previousLink.href.split("?")[0]+"?view=month&month="+month.previousmonth+"&year="+month.previousyear+"&user="+urlencode(month.user);var nextLink=$("nextWorkoutMonth");nextLink.href=nextLink.href.split("?")[0]+"?view=month&month="+month.nextmonth+"&year="+month.nextyear+"&user="+urlencode(month.user);$("monthHeader").update(entityEncode(month.formattedmonth));var weeks=month.children;this.clearMonthTable();var table=$("monthTable");var tbody=table.getElementsByTagName("tbody")[0];for(var i=0;i<weeks.length;i++){var week=weeks[i];var days=week.children;var rowInsert=this.ROW_TEMPLATE.evaluate({"id":"row_"+i});new Insertion.Bottom(tbody,rowInsert);for(j=1;j<=days.length;j++){var day=WeekUtil.getDay(days,j);var tdInsert=this.TD_TEMPLATE.evaluate({"dayInMonth":(day.dayinmonth>0?entityEncode(day.dayinmonth):""),"dayId":entityEncode(day.month+"-"+day.dayinmonth),"dayClass":entityEncode(day.today?"monthDayToday":"monthDay")});new Insertion.Bottom($("row_"+i),tdInsert);var date=day.dayinmonth;if(date!=-1){var workouts=day.workouts;if(workouts){for(var k=0;k<workouts.length;k++){var workout=workouts[k];var workoutInsert=this.WORKOUT_TEMPLATE.evaluate({"wid":workout.wid,"sport":entityEncode(workout.sport)});new Insertion.Bottom($("wc_"+day.month+"-"+day.dayinmonth),workoutInsert);}}var plannedWorkouts=day.plannedworkouts;if(plannedWorkouts){for(var k=0;k<plannedWorkouts.length;k++){var plannedWorkout=plannedWorkouts[k];var plannedWorkoutInsert=this.PLANNED_WORKOUT_TEMPLATE.evaluate({"wid":plannedWorkout.wid,"sport":entityEncode(plannedWorkout.sport)});new Insertion.Bottom($("pwc_"+day.month+"-"+day.dayinmonth),plannedWorkoutInsert);}}}}}this.showResultArea();}});ViewWorkoutView=Class.create();ViewWorkoutView.prototype=Object.extend(new ServerAction(),{COMMENT_TEMPLATE_STR:'<div id="commentText_#{cid}" class="workoutComment"><div class="workoutCommentEditContainer"><ul class="subNavList">#{editListItem}#{deleteListItem}</ul></div><div>#{comment}</div><div class="workoutCommentPostedBy">Posted by: <a href="members?user=#{userUrl}">#{user}</a> on #{commentTime}#{editedTime}</div></div>',EDITED_TIME_TEMPLATE_STR:"<br/>(Edited on #{editTime})",EDIT_LIST_ITEM_TEMPLATE_STR:'<li><a href="" id="editComment_#{cid}">Edit</a><img src="'+Context.STATIC_HOST+"/skin/"+Context.SKIN+"/images/centerarea/sub_subnav_divider.png?v="+Context.VERSION+'"/></li>',DELETE_LIST_ITEM_TEMPLATE_STR:'<li><a href="" id="deleteComment_#{cid}">Delete</a></li>',initialize:function(C,D,E,B,A){this.wid=C;this.workoutUser=D;this.loggedInUser=E;this.isPlanned=B;this.isMetric=A;EventManager.registerEventHandler(Events.WORKOUT_COMMENT_ADDED,this.loadComments.bindAsEventListener(this));EventManager.registerEventHandler(Events.WORKOUT_COMMENT_DELETED,this.loadComments.bindAsEventListener(this));EventManager.registerEventHandler(Events.WORKOUT_COMMENT_EDITED,this.loadComments.bindAsEventListener(this));EventManager.registerEventHandler(Events.WORKOUT_UPDATED,this.loadWorkout.bindAsEventListener(this));this.COMMENT_TEMPLATE=new Template(this.COMMENT_TEMPLATE_STR);this.EDITED_TIME_TEMPLATE=new Template(this.EDITED_TIME_TEMPLATE_STR);this.EDIT_LIST_ITEM_TEMPLATE=new Template(this.EDIT_LIST_ITEM_TEMPLATE_STR);this.DELETE_LIST_ITEM_TEMPLATE=new Template(this.DELETE_LIST_ITEM_TEMPLATE_STR);},loadWorkout:function(A){this.doLoad("GetWorkout");},doLoad:function(A){var C="wid="+this.wid;var B=new Ajax.Request(A,{method:"get",parameters:C,onSuccess:this.showUpdatedWorkout.bind(this),onFailure:this.alertException.bind(this)});},showUpdatedWorkout:function(request){var workout=eval("("+request.responseText+")");$("viewWorkoutDate").update(entityEncode(workout.date));$("viewWorkoutSport").update(entityEncode(workout.sport));if(workout.formattedduration){$("viewWorkoutDurationDiv").show();$("viewWorkoutDuration").update(entityEncode(workout.formattedduration));}else{$("viewWorkoutDurationDiv").hide();}if(workout.distancestring){$("viewWorkoutDistanceDiv").show();$("viewWorkoutDistance").update(entityEncode(workout.distancestring));}else{$("viewWorkoutDistanceDiv").hide();}if(workout.avghr&&workout.avghr>0){$("viewWorkoutAvgHRDiv").show();$("viewWorkoutHR").update(entityEncode(workout.avghr));}else{$("viewWorkoutAvgHRDiv").hide();}if(workout.avgspeedstring){$("viewWorkoutAvgSpeedDiv").show();$("viewWorkoutSpeed").update(entityEncode(workout.avgspeedstring));}else{$("viewWorkoutAvgSpeedDiv").hide();}if(workout.avgpacestring){$("viewWorkoutAvgPaceDiv").show();$("viewWorkoutPace").update(entityEncode(workout.avgpacestring));}else{$("viewWorkoutAvgPaceDiv").hide();}if(workout.notes){$("viewWorkoutNotesDiv").update(entityEncode(workout.notes));$("viewWorkoutNotesDiv").show();}else{$("viewWorkoutNotesDiv").hide();}if(workout.route){$("viewWorkoutRouteDiv").show();$("viewWorkoutRouteName").href="viewroute?routeId="+workout.route.routeid;$("viewWorkoutRouteName").update(entityEncode(workout.route.name));if(!viewRouteMap){viewRouteMap=new GMap2($("viewRouteMap"));viewRouteMap.addControl(new GScaleControl());viewRouteMap.addControl(new GLargeMapControl());viewRouteMap.addControl(new GMapTypeControl());}if(workout.route.polyline.elevation){$("routeElevationChartDiv").show();}else{$("routeElevationChartDiv").hide();}viewRouteMap.clearOverlays();viewWorkoutViewRoute=new ViewRoute(viewRouteMap,workout.route,false,false,this.isMetric,true);}if(workout.intensity||workout.intensity==0){$("viewWorkoutIntensity").update(entityEncode(workout.intensity));}},loadComments:function(B){var C="wid="+this.wid+"&isPlanned="+this.isPlanned;var A=new Ajax.Request("GetWorkoutComments",{method:"get",parameters:C,onSuccess:this.reloadComments.bind(this),onFailure:this.alertException.bind(this)});},reloadComments:function(request){var commentContainer=$("viewWorkoutComments");commentContainer.update("");var commentsJSON=eval("("+request.responseText+")");var comments=commentsJSON.children;for(var i=0;i<comments.length;i++){var comment=comments[i];var editListItem="";var canEdit=comment.fromuser==this.loggedInUser;if(canEdit){editListItem=this.EDIT_LIST_ITEM_TEMPLATE.evaluate({cid:comment.cid});}var deleteListItem="";var canDelete=(comment.fromuser==this.loggedInUser||this.loggedInUser==this.workoutuser);if(canDelete){deleteListItem=this.DELETE_LIST_ITEM_TEMPLATE.evaluate({cid:comment.cid});}var editedTime="";if(comment.formattededitedtime){editedTime=this.EDITED_TIME_TEMPLATE.evaluate({editTime:entityEncode(comment.formattededitedtime)});}var insertComment=this.COMMENT_TEMPLATE.evaluate({editListItem:editListItem,deleteListItem:deleteListItem,cid:entityEncode(comment.cid),comment:entityEncode(comment.comment),user:entityEncode(comment.fromuser),userUrl:urlencode(comment.fromuser),commentTime:entityEncode(comment.formattedcommenttime),editedTime:editedTime});new Insertion.Bottom(commentContainer,insertComment);if(canEdit){Event.observe($("editComment_"+comment.cid),"click",this.editComment.bindAsEventListener(this));}if(canDelete){Event.observe($("deleteComment_"+comment.cid),"click",this.deleteComment.bindAsEventListener(this));}}},deleteComment:function(C){Event.stop(C);var A=Event.element(C);var F=A.id;var E=F.replace("deleteComment_","");var D="cid="+E+"&isPlanned="+this.isPlanned;var B=new Ajax.Request("DeleteWorkoutComment",{method:"post",parameters:D,onSuccess:this.handleCommentDeleted.bind(this),onFailure:this.alertException.bind(this)});},handleCommentDeleted:function(request){var message=eval("("+request.responseText+")");if(message.ok){EventManager.fireEvent(Events.WORKOUT_COMMENT_DELETED);}this.handleMessage(request);},editComment:function(B){Event.stop(B);var A=Event.element(B);var D=A.id;var C=D.replace("editComment_","");commentDialog.invokeEdit(C);}});WeekView=Class.create();WeekView.prototype=Object.extend(new AbstractListView(),{initialize:function(A,F,E,D,C,B){this.initListView(A,F,E,D,C,B);},__handleClick:function(F){var L="";if(F){var E=Event.element(F);if(E.tagName!="A"){E=E.parentNode;}var C=E.getAttribute("href");var J=C.split("year=");var H=J[1].split("&");var I=H[0];J=C.split("month=");H=J[1].split("&");var G=H[0];J=C.split("day=");H=J[1].split("&");var K=H[0];var D="";J=C.split("user=");if(J.length>1){H=J[1].split("&");D=H[0];if(!D){D="";}}L="year="+I+"&month="+G+"&day="+K;if(D){L+="&user="+URLUtil.encode(urldecode(D));}}var B="GetWeek";var A=new Ajax.Request(B,{method:"get",parameters:L,onSuccess:this.showView.bind(this),onFailure:this.alertException.bind(this)});},getView:function(){return"week";},getPreviousParameters:function(A){return A.previous;},getNextParameters:function(A){return A.next;}});ViewGoalView=Class.create();ViewGoalView.prototype=Object.extend(new ServerAction(),{GOAL_HEADER_TEMPLATE_STR:'#{name} by <a href="members?user=#{user}">#{user}</a>',GOAL_TEMPLATE_STR:'<div class="actualSpecification">#{description}</div>#{comment}#{completeBy}',GOAL_COMMENT_TEMPLATE_STR:'<div class="goalComment">#{comment}</div>',GOAL_COMPLETE_BY_TEMPLATE_STR:'<div class="goalEndedBy">#{completeBy}</div>',initialize:function(B,A){this.goalId=B;this.goalType=A;this.GOAL_HEADER_TEMPLATE=new Template(this.GOAL_HEADER_TEMPLATE_STR);this.GOAL_TEMPLATE=new Template(this.GOAL_TEMPLATE_STR);this.GOAL_COMMENT_TEMPLATE=new Template(this.GOAL_COMMENT_TEMPLATE_STR);this.GOAL_COMPLETE_BY_TEMPLATE=new Template(this.GOAL_COMPLETE_BY_TEMPLATE_STR);EventManager.registerEventHandler(Events.GOAL_DELETED,this.loadGoal.bindAsEventListener(this));EventManager.registerEventHandler(Events.GOAL_EDITED,this.loadGoal.bindAsEventListener(this));},loadGoal:function(C){var A="goalId="+this.goalId+"&goalType="+this.goalType;var B=new Ajax.Request("GetGoal",{method:"get",parameters:A,onSuccess:this.showUpdatedGoal.bind(this),onFailure:this.alertException.bind(this)});},showUpdatedGoal:function(request){var goal=eval("("+request.responseText+")");var toInsertHeader=this.GOAL_HEADER_TEMPLATE.evaluate({name:entityEncode(goal.name),user:entityEncode(goal.user)});$("viewGoalHeader").update(toInsertHeader);var comment=goal.comment?this.GOAL_COMMENT_TEMPLATE.evaluate({comment:entityEncode(goal.comment)}):"";var completeBy=goal.completeby?this.GOAL_COMPLETE_BY_TEMPLATE.evaluate({completeBy:entityEncode(goal.completeby)}):"";var toInsert=this.GOAL_TEMPLATE.evaluate({description:entityEncode(goal.description),comment:comment,completeBy:completeBy});$("viewGoalDiv").update(toInsert);}});FlashChart=Class.create();FlashChart.prototype={initialize:function(D,C,A,B){this.xmlSource=B;this.so=new SWFObject(Context.STATIC_HOST+"/flashlib/xml_charts/charts.swf",D,C+"px",A+"px","6","#ffffff");this.so.addVariable("u",new Date().getTime());this.so.addVariable("stage_width",C);this.so.addVariable("stage_height",A);this.so.addVariable("v",Context.VERSION);this.so.addVariable("library_path",Context.STATIC_HOST+"/flashlib/xml_charts/charts_library");this.so.addVariable("xml_source",B);this.so.useExpressInstall(Context.STATIC_HOST+"/flashlib/expressinstall.swf");},render:function(A){this.so.write(A);},reload:function(A){if(A){A.SetVariable("update_url",this.xmlSource);}}};FeatureSlideShow=Class.create();FeatureSlideShow.prototype={initialize:function(){this.slideshow=SlideShow.create({pictureWidth:640,pictureHeight:480,capacity:1,mode:"horizontal"});this.slideshow.setFocusedIndex(0);this.slideshow.add(Context.STATIC_HOST+"/skin/"+Context.SKIN+"/images/screenshots/home.png",I18N.getMessage("jsMessage.slideshow.home"));this.slideshow.add(Context.STATIC_HOST+"/skin/"+Context.SKIN+"/images/screenshots/logWorkout.png",I18N.getMessage("jsMessage.slideshow.logWorkout"));this.slideshow.add(Context.STATIC_HOST+"/skin/"+Context.SKIN+"/images/screenshots/workoutViews.png",I18N.getMessage("jsMessage.slideshow.workoutViews"));this.slideshow.add(Context.STATIC_HOST+"/skin/"+Context.SKIN+"/images/screenshots/workoutDetail.png",I18N.getMessage("jsMessage.slideshow.workoutDetail"));this.slideshow.add(Context.STATIC_HOST+"/skin/"+Context.SKIN+"/images/screenshots/workoutSummary.png",I18N.getMessage("jsMessage.slideshow.workoutSummary"));this.slideshow.add(Context.STATIC_HOST+"/skin/"+Context.SKIN+"/images/screenshots/workoutRoute.png",I18N.getMessage("jsMessage.slideshow.workoutRoute"));this.slideshow.add(Context.STATIC_HOST+"/skin/"+Context.SKIN+"/images/screenshots/goalDetail.png",I18N.getMessage("jsMessage.slideshow.goalDetail"));this.slideshow.add(Context.STATIC_HOST+"/skin/"+Context.SKIN+"/images/screenshots/newGoal.png",I18N.getMessage("jsMessage.slideshow.newGoal"));this.slideshow.add(Context.STATIC_HOST+"/skin/"+Context.SKIN+"/images/screenshots/signUp.png",I18N.getMessage("jsMessage.slideshow.signUp"));Event.observe($("prevIndicator"),"click",this.previous.bind(this));Event.observe($("prev"),"click",this.previous.bind(this));Event.observe($("nextIndicator"),"click",this.next.bind(this));Event.observe($("next"),"click",this.next.bind(this));this.slideshow.registerCallback("afterChange",function(A,B){if(B==0){$("prevIndicator").hide();$("prev").hide();$("nextIndicator").show();$("next").show();}else{if(B==8){$("nextIndicator").hide();$("next").hide();$("prevIndicator").show();$("prev").show();}else{$("nextIndicator").show();$("next").show();$("prevIndicator").show();$("prev").show();}}});this.slideshow.setup("slideshowContainer",0);},next:function(A){Event.stop(A);this.slideshow.slideToNext();},previous:function(A){Event.stop(A);this.slideshow.slideToPrev();}};