
var APP_TITLE='Running Journal'
var ABBR_MILES='M';var ABBR_KM='km';var MILE_ABBR='M';var KM_ABBR='km';var MILES_TO_KM=1.609;var SORT_ASC='ASC';var SORT_DESC='DESC';var DELIMITER='\t';var STATUS_ACTIVE='A';var STATUS_INACTIVE='IA';var BLOG_STATUS_DRAFT='D';var BLOG_STATUS_LIVE='L';var MAIN_URL=location.protocol+'//'+location.host+localContextRoot;var RSS_URL=MAIN_URL+'/rss.xml';var GENDER_FEMALE='F';var COLOR_RED='red';var COLOR_PINK='#ffb6c1';var CAPTION_ADD='Add';var CAPTION_BACK='Back';var CAPTION_COPY='Copy';var CAPTION_DELETE='Delete';var CAPTION_EDIT='Edit';var CAPTION_UPDATE='Update';var CAPTION_VIEW='View';var CAPTION_HR='HR';var CAPTION_AVG='Avg.';var CAPTION_MAX='Max.';var CAPTION_ACCEPT='Accept';var CAPTION_ACTIVITY='Activity';var CAPTION_ACTIVITIES='Activities';var CAPTION_ADDRESS_1='Street Address';var CAPTION_ADDRESS_2='Alternative Address';var CAPTION_ADDRESS_3="Alternative Address";var CAPTION_ASSIGNED_TO='Assigned To';var CAPTION_ALL='All';var CAPTION_ALL_MONTHS='All Months';var CAPTION_ANONYMOUS='Anonymous';var CAPTION_APPROVE='Approve';var CAPTION_AUTHOR='Author';var CAPTION_AVERAGE_HEART_RATE='Avg. HR';var CAPTION_AVERAGE_PACE='Average Pace';var CAPTION_AVERAGE_RESTING_HR='Average Resting Heart Rate';var CAPTION_AVERAGE_RPM='Average RPM';var CAPTION_AVERAGE_RUN_HR='Average Heart Rate';var CAPTION_AVERAGE_WEIGHT='Average Weight';var CAPTION_BP_DIASTOLIC='Diastolic';var CAPTION_BP_SYSTOLIC='Systolic';var CAPTION_BIKE='Bike';var CAPTION_BIKE_BRAND='Brand';var CAPTION_BIKE_MODEL_TYPE='Model Type';var CAPTION_BIKES='Bikes';var CAPTION_BIOGRAPHY='Bio';var CAPTION_BLOG='Blog';var CAPTION_BLOGS='Blogs';var CAPTION_BLOOD_PRESSURE='Blood Pressure';var CAPTION_BODY='Body';var CAPTION_BODY_FAT_PERCENT='Body Fat Percentage';var CAPTION_CALORIES='Calories';var CAPTION_CAN_CREATE_TEAM_ROUTES='Can Create Team Routes';var CAPTION_CAN_CREATE_TEAM_WORKOUTS='Can Create Team Workouts';var CAPTION_CAN_EDIT_CALENDAR='Can Edit Calendar';var CAPTION_CAN_EDIT_LOG='Can Edit Log';var CAPTION_CAN_EDIT_PROFILE='Can Edit Profile';var CAPTION_CAN_INVITE_NEW_MEMBERS='Can Invite New Members';var CAPTION_CAN_SEND_TEAM_EMAILS='Can Send Team Emails';var CAPTION_CAN_VIEW_CALENDAR='Can View Calendar';var CAPTION_CAN_VIEW_LOG='Can View Log';var CAPTION_CAN_VIEW_PROFILE='Can View Profile';var CAPTION_CAN_VIEW_SUMMARY='Can View Summary';var CAPTION_CANCEL='Cancel';var CAPTION_CITY='City';var CAPTION_CODE='Code';var CAPTION_COMMENTS='Comments';var CAPTION_CONTACT='Contact';var CAPTION_CONTACTS='Contacts';var CAPTION_COUNT='Count';var CAPTION_COUNTRY='Country';var CAPTION_COURSE_TYPE='Course Type';var CAPTION_CREATED_DATE='Created';var CAPTION_CREATOR='Creator';var CAPTION_CURRENT_YEAR_WEEKLY_TOTALS='Currently Year\'s Weekly Totals';var CAPTION_DATAPOINT='Datapoint';var CAPTION_DATE_OF_BIRTH='Date Of Birth';var CAPTION_DAY='Day';var CAPTION_DECLINE='Decline';var CAPTION_DEFAULT_DISTANCE_UNIT='Default Distance Unit';var CAPTION_DEFAULT_TIME_OF_DAY='Default Time of Day';var CAPTION_DEFAULT_UNIT_TYPE='Default Unit Type';var CAPTION_DELETED='Deleted';var CAPTION_DESC='Description';var CAPTION_DISTANCE='Distance';var CAPTION_DISTANCE_DISPLAY='Distance Display As';var CAPTION_DISTANCE_KM='Distance (km)';var CAPTION_DISTANCE_MILES='Distance (miles)';var CAPTION_DISTANCE_USED='Distance Used';var CAPTION_DURATION='Duration (hh:mm:ss)';var CAPTION_DURATION_HOURS='Hours';var CAPTION_DURATION_MINUTES='Minutes';var CAPTION_DURATION_SECONDS='Seconds';var CAPTION_EFFORT_LEVEL='Effort Level';var CAPTION_EFFORT_LEVELS='Effort Levels';var CAPTION_EMAIL_ADDRESS='E-mail Address';var CAPTION_EXERCISE_DATE='Exercise Date';var CAPTION_EXERCISE_TYPE='Exercise';var CAPTION_EXPIRATION='Expiration';var CAPTION_EXPIRATION_KM='Expiration (km)';var CAPTION_EXPIRATION_MILES='Expiration (miles)';var CAPTION_EXPORT_AS='Export As';var CAPTION_EXTERNAL_INVITEES='Non-Running-Journal Invitees';var CAPTION_FIFTH_DATAPOINT='Fifth Datapoint';var CAPTION_FIRST_DATAPOINT='First Datapoint';var CAPTION_FIRST_DAY_OF_WEEK='First Day of Week';var CAPTION_FIRST_NAME='First Name';var CAPTION_FOCAL_MUSCLE_GROUPS='Focal Muscle Groups';var CAPTION_FOCUS='Focus';var CAPTION_FOURTH_DATAPOINT='Fourth Datapoint';var CAPTION_FRIEND='Friend';var CAPTION_FRIENDS='Friends';var CAPTION_GENDER='Gender';var CAPTION_HEART_RATE_AVG='Average Heart Rate';var CAPTION_HEART_RATE_AVG_MAX='Heart Rate<BR>Avg. / Max.';var CAPTION_HEART_RATE_LOG='Heart Rate Log';var CAPTION_HEART_RATE_MAX='Maximum Heart Rate';var CAPTION_HEART_RATE_MIN='Resting Heart Rate';var CAPTION_HEART_RATE_TARGET_MAX='Heart Rate Target Max';var CAPTION_HEART_RATE_TARGET_MIN='Heart Rate Target Min';var CAPTION_HR_AVG=CAPTION_HR+' '+CAPTION_AVG;var CAPTION_HR_MAX=CAPTION_HR+' '+CAPTION_MAX;var CAPTION_HR_MIN='Min. HR';var CAPTION_HUMIDITY='Humidity';var CAPTION_ID='ID';var CAPTION_IGNORE_DATE_VALUES='Ignore date values?';var CAPTION_INITIAL_INVITATION='Initial Invitation Sent On';var CAPTION_INSTRUCTOR='Instructor';var CAPTION_INTERVAL='By';var CAPTION_INVITOR='Invitor';var CAPTION_IS_ACTIVE='Is Active';var CAPTION_IS_FARTLEK='Is Fartlek';var CAPTION_IS_MAX_OUT='Maxed Out?';var CAPTION_IS_RACE='Is Race?';var CAPTION_IS_SEARCHABLE='Is Searchable';var CAPTION_IS_TRACK='Is Track';var CAPTION_KM='km';var CAPTION_LAST_CONTACTED_DATE='Last Contacted Date';var CAPTION_LAST_INITIATED_AFTER='Last Initiated After';var CAPTION_LAST_INITIATED_BEFORE='Last Initiated Before';var CAPTION_LAST_INITIATED_DATE='Last Initiated';var CAPTION_LAST_INVITATION='Last Invitation Sent On';var CAPTION_LAST_MODIFIED_DATE='Last Modified';var CAPTION_LAST_MODIFIER='Last Modifier';var CAPTION_LAST_NAME='Last Name';var CAPTION_LEGEND='Legend';var CAPTION_LOCATION='Location';var CAPTION_LOG_DATE='Log Date';var CAPTION_LOGIN='Login';var CAPTION_MARTIAL_ART_TYPE='Martial Art Style';var CAPTION_MAXIMUM_RPM='Maximum RPM';var CAPTION_ME='Me';var CAPTION_MEMBER='Member';var CAPTION_MEMBER_NAME='Member Name';var CAPTION_MEMBERSHIP_STANDING='Membership Standing';var CAPTION_MEN='Men';var CAPTION_MESSAGE='Message';var CAPTION_MIDDLE_INITIAL='Middle Initial';var CAPTION_MILES='Miles';var CAPTION_MODEL_NAME='Model Name';var CAPTION_MONTH='Month';var CAPTION_MONTHLY_TOTALS='Monthly Totals';var CAPTION_MUSCLE_GROUP='Muscle Group';var CAPTION_MY_NAME='My Name';var CAPTION_MY_STATUS='My Status';var CAPTION_NA='N/A';var CAPTION_NAME='Name';var CAPTION_NAME_TITLE='Name Title';var CAPTION_NO_SEARCH='No Search';var CAPTION_NONE='None';var CAPTION_NOT_SELECTED='Not Selected';var CAPTION_NOTICES='Notices';var CAPTION_OWNER='Owner';var CAPTION_PACE='Pace';var CAPTION_PASSWORD='Password';var CAPTION_PHONE='Phone';var CAPTION_PHONE_NUMBER='Phone Number';var CAPTION_POSTAL_CODE='Postal Code';var CAPTION_PRECIPITATION='Precipitation';var CAPTION_PREVIEW='Preview';var CAPTION_PREVIOUS_KM='Existing (km)';var CAPTION_PREVIOUS_MILES='Existing (miles)';var CAPTION_PREVIOUS_YEAR_WEEKLY_TOTALS='Previous Year\'s Weekly Totals';var CAPTION_PURCHASE_DATE='Purchase Date';var CAPTION_REFRESH='Refresh';var CAPTION_REJECT='Reject';var CAPTION_RELEASE_DATE='Release Date';var CAPTION_REMOVE='Remove';var CAPTION_REPETITIONS='Reps';var CAPTION_REPORT_ABUSE='Report Abuse';var CAPTION_REPORT_DATE='Report Date';var CAPTION_REPORTER='Reporter';var CAPTION_REQUESTER_NAME='Requester Name';var CAPTION_REPLY='Reply';var CAPTION_RESOLUTION_COMMENTS='Resolution Comments';var CAPTION_ROLE='Role';var CAPTION_ROUTE='Route';var CAPTION_ROUTES='Routes';var CAPTION_RPM_AVG_MAX='RPMs (Avg. / Max.)';var CAPTION_RUN='Run';var CAPTION_RUNS=CAPTION_RUN+'s';var CAPTION_RUN_DATE='Run Date';var CAPTION_RUNNING='Running';var CAPTION_RUNNING_ROUTE='Running Route';var CAPTION_SAVE_AND_ADD_REPEATS='Save & Add Repeats';var CAPTION_SAVE_AND_ADD_SPLITS='Save & Add Splits';var CAPTION_SCHEDULED='Scheduled';var CAPTION_SEARCH='Search';var CAPTION_SECOND_DATAPOINT='Second Datapoint';var CAPTION_SECRET='Secret';var CAPTION_SENDER='Sender';var CAPTION_SETS='Sets';var CAPTION_SHARE_JOURNAL='Share Journal';var CAPTION_SHOE='Shoe';var CAPTION_SHOES='Shoes';var CAPTION_SHOE_BRAND='Brand';var CAPTION_SHOE_MODEL_TYPE='Model Type';var CAPTION_SHOW='Show';var CAPTION_SHOW_ONLY_RACE='Show only races';var CAPTION_SIXTH_DATAPOINT='Sixth Datapoint';var CAPTION_SIZE='Size';var CAPTION_SKI='Ski';var CAPTION_SKIS='Skis';var CAPTION_SLEEP_LOG='Sleep Log';var CAPTION_SLEEP_QUALITY='Sleep Quality';var CAPTION_SNOW_CONDITION='Snow Condition';var CAPTION_SPLIT='Split';var CAPTION_SPLITS='Splits';var CAPTION_STATE='State/Province';var CAPTION_STATUS='Status';var CAPTION_STEPS='Steps';var CAPTION_STRENGTH_TRAINING='Strength Training';var CAPTION_SUBJECT='Subject';var CAPTION_SUBMIT='Submit';var CAPTION_SUBMITTING='Submitting ... Please wait ...';var CAPTION_SUBSCRIBE='Subscribe';var CAPTION_SURFACE_CONDITION='Surface Condition';var CAPTION_SWIM_STROKE='Swim Stroke';var CAPTION_TEAM='Team';var CAPTION_TEAM_LOCATION='Team Location';var CAPTION_TEAM_MEMBER='Team Member';var CAPTION_TEAM_MEMBERS='Team Members';var CAPTION_TEAM_MEMBER_TYPE='Team Member Type';var CAPTION_TEAM_MEMBER_TYPES='Team Member Types';var CAPTION_TEAM_NAME='Team Name';var CAPTION_TEAM_OWNER='Owner';var CAPTION_TEAM_TYPE='Team Type';var CAPTION_TEAMMATE='Teammate';var CAPTION_TEAMMATES='Teammates';var CAPTION_TEAMS='Teams';var CAPTION_TECHNIQUE='Technique';var CAPTION_TEMPERATURE='Temperature';var CAPTION_THIRD_DATAPOINT='Third Datapoint';var CAPTION_TIME_OF_DAY='Time of Day';var CAPTION_TITLE='Title';var CAPTION_TO='To';var CAPTION_TOTAL_DISTANCE='Total Distance';var CAPTION_TOTAL_TIME='Total Time';var CAPTION_TOTALS='Totals';var CAPTION_TRACK_CYCLES='Track Cycles';var CAPTION_TRAINING='Training';var CAPTION_TRAINING_DATE='Training Date';var CAPTION_TRAINING_TYPE='Training Type';var CAPTION_TYPE='Type';var CAPTION_URL='URL';var CAPTION_USAGE_DATE='Usage Date';var CAPTION_USER='User';var CAPTION_USERS='Users';var CAPTION_USER_NAME=CAPTION_EMAIL_ADDRESS;var CAPTION_VERIFY_EMAIL='Verify '+CAPTION_EMAIL_ADDRESS;var CAPTION_WARN_WHEN_EXPIRED='Warn When Expired';var CAPTION_WATER_TEMPERATURE='Water Temperature';var CAPTION_WATTAGE_AVG='Average Wattage';var CAPTION_WATTAGE_MAX='Maximum Wattage';var CAPTION_WATTAGE_AVG_MAX='Wattage (Avg. / Max.)';var CAPTION_WEB_SITE_URL='Team Website';var CAPTION_WEEK='Week';var CAPTION_WEEK_NUMBER='Week Number';var CAPTION_WEEKLY_TOTALS='Weekly Totals';var CAPTION_WEIGHT='Weight';var CAPTION_WEIGHT_LOG='Weight Log';var CAPTION_WEIGHT_UNIT='Weight Unit';var CAPTION_WHO='Who?';var CAPTION_WIND='Wind';var CAPTION_WOMEN='Women';var CAPTION_WORKOUT='Workout';var CAPTION_WORKOUTS='Workouts';var CAPTION_XTRAINING='X-training';var CAPTION_YEAR='Year';var CAPTION_YES='Yes';var CAPTION_YOGA_STYLE='Yoga Style';var CAPTION_YOUR_NAME='Your Name';var CAPTION_YOUR_RESPONSE='Your Response';var MAX_LEN_ADDRESS_1=64;var MAX_LEN_ADDRESS_2=64;var MAX_LEN_BIOGRAPHY=2500;var MAX_LEN_BODY_FAT_PERCENT=5;var MAX_LEN_CALORIES=4;var MAX_LEN_CITY=64;var MAX_LEN_CLIENT_CODE=10;var MAX_LEN_CLIENT_NAME=64;var MAX_LEN_CLIENT_SECRET=32;var MAX_LEN_DESC=64;var MAX_LEN_DISTANCE_VALUES=10;var MAX_LEN_DISTANCE_KM=MAX_LEN_DISTANCE_VALUES;var MAX_LEN_DISTANCE_MILES=MAX_LEN_DISTANCE_VALUES;var MAX_LEN_DURATION_HOURS=2;var MAX_LEN_DURATION_MINUTES=2;var MAX_LEN_DURATION_SECONDS=7;var MAX_LEN_EMAIL_ADDRESS=100;var MAX_LEN_EXPIRATION_KM=7;var MAX_LEN_EXPIRATION_MILES=7;var MAX_LEN_FIRST_NAME=20;var MAX_LEN_HEART_RATE_VALUES=3;var MAX_LEN_HEART_RATE_AVG=MAX_LEN_HEART_RATE_VALUES;var MAX_LEN_HEART_RATE_MAX=MAX_LEN_HEART_RATE_VALUES;var MAX_LEN_HEART_RATE_MIN=MAX_LEN_HEART_RATE_VALUES;var MAX_LEN_HEART_RATE_TARGET_MIN=MAX_LEN_HEART_RATE_VALUES;var MAX_LEN_HEART_RATE_TARGET_MAX=MAX_LEN_HEART_RATE_VALUES;var MAX_LEN_INSTRUCTOR=32;var MAX_LEN_LAST_NAME=25;var MAX_LEN_LIFT_WEIGHT=6;var MAX_LEN_MIDDLE_INITIAL=1;var MAX_LEN_MODEL_NAME=32;var MAX_LEN_PASSWORD=20;var MAX_LEN_PHONE_NUMBER=16;var MAX_LEN_POSTAL_CODE=16;var MAX_LEN_PREVIOUS_KM=7;var MAX_LEN_PREVIOUS_MILES=7;var MAX_LEN_REPETITIONS=5;var MAX_LEN_RPM=3;var MAX_LEN_SET_COMMENTS=128;var MAX_LEN_SHORT_COMMENTS=128;var MAX_LEN_STEPS=6;var MAX_LEN_SUBJECT=128;var MAX_LEN_TEAM_NAME=64;var MAX_LEN_TECHNIQUE=32;var MAX_LEN_TEMP=3;var MAX_LEN_TITLE=64;var MAX_LEN_URL=128;var MAX_LEN_USER_NAME=MAX_LEN_EMAIL_ADDRESS;var MAX_LEN_WATTAGE_AVG=4;var MAX_LEN_WATTAGE_MAX=4;var MAX_LEN_WEB_SITE_URL=128;var MAX_LEN_WEIGHT=6;var MAX_LEN_WIND=3;var PAGE_SIZE_HOME=5;var PAGE_SIZE_BLOG=10;var PAGE_SIZE_SMALL=20;var PAGE_SIZE_NORMAL=50;var PAGE_SIZE_LARGE=100;var SECTION_NAME_ADMIN='admin';var SECTION_NAME_HOME='home';var SECTION_NAME_RUNNING_ROUTES='runningRoutes';var SECTION_NAME_WORKOUTS='workouts';var SECTION_NAME_TRAINING='training';var SECTION_NAME_RUNS=SECTION_NAME_TRAINING;var SECTION_NAME_XTRAINING=SECTION_NAME_TRAINING;var SECTION_NAME_SHOES='shoes';var SECTION_NAME_BIKES=SECTION_NAME_SHOES;var SECTION_NAME_SKIS=SECTION_NAME_SHOES;var SECTION_NAME_TEAMS='teams';var SECTION_NAME_MY_PROFILE='myProfile';var SECTION_NAME_CONTACTS=SECTION_NAME_ADMIN;var SECTION_NAME_HELP='help';var SECTION_NAME_AD_PROGRAMS=SECTION_NAME_ADMIN;var TITLE_ADD_AD_PROGRAM='Add Ad Program';var TITLE_ADD_BIKE='Add Bike';var TITLE_ADD_BLOG='Add Blog';var TITLE_ADD_BLOG_COMMENT='Comment on this Blog Entry';var TITLE_ADD_BLOG_REPORT='Report Abuse';var TITLE_ADD_CLIENT='Add Client';var TITLE_ADD_CONTACT='Add Contact';var TITLE_ADD_EXERCISE='Add Strength Training Session';var TITLE_ADD_HEART_RATE_LOG='Add Heart Rate Log Entry';var TITLE_ADD_MENSTRUATION_LOG='Add Today\'s Cycle Entry';var TITLE_ADD_ROUTE='Add Route';var TITLE_ADD_RUN='Add Run';var TITLE_ADD_RUN_FUTURE='Schedule A Run';var TITLE_ADD_SHOE='Add Shoe';var TITLE_ADD_SKI='Add Ski';var TITLE_ADD_TEAM='Create Team';var TITLE_ADD_USER='Add User';var TITLE_ADD_WEIGHT_LOG='Add Weight Log Entry';var TITLE_ADD_SLEEP_LOG='Add Sleep Log Entry';var TITLE_ADD_WORKOUT='Add Workout';var TITLE_ADD_XTRAINING='Add X-training';var TITLE_BLOG_HOME='Blog Stop';var TITLE_BUG_REPORT='Bug Report';var TITLE_CHART_TRAINING='Chart My Training';var TITLE_COPY_AD_PROGRAM='Copy Ad Program';var TITLE_COPY_BIKE='Copy Bike';var TITLE_COPY_CLIENT='Copy Client';var TITLE_COPY_CONTACT='Copy Contact';var TITLE_COPY_EXERCISE='Copy Strength Training Session';var TITLE_COPY_ROUTE='Copy Route';var TITLE_COPY_RUN='Copy Run';var TITLE_COPY_RUN_FUTURE='Copy Scheduled Run';var TITLE_COPY_SHOE='Copy Shoe';var TITLE_COPY_SKI='Copy Ski';var TITLE_COPY_USER='Copy User';var TITLE_COPY_WORKOUT='Copy Workout';var TITLE_COPY_XTRAINING='Copy X-training';var TITLE_CROSS_TRAINING='Cross Training';var TITLE_DASHBOARD='My Dashboard';var TITLE_DEACTIVATE_BIKE_WARNING='Deactivate Bike Warning';var TITLE_DEACTIVATE_SHOE_WARNING='Deactivate Shoe Warning';var TITLE_DEACTIVATE_SKI_WARNING='Deactivate Ski Warning';var TITLE_DETAIL_EXERCISE='Strength Training Session';var TITLE_EDIT_AD_PROGRAM='Edit Ad Program';var TITLE_EDIT_BIKE='Edit Bike';var TITLE_EDIT_BLOG='Edit Blog';var TITLE_EDIT_BLOG_COMMENT='Edit Blog Comment';var TITLE_EDIT_BLOG_REPORT='Edit Abuse Report';var TITLE_EDIT_CLIENT='Edit Client';var TITLE_EDIT_CONTACT='Edit Contact';var TITLE_EDIT_EXERCISE='Edit Strength Training Session';var TITLE_EDIT_HEART_RATE_LOG='Edit Heart Rate Log Entry';var TITLE_EDIT_MENSTRUATION_LOG='Edit Today\'s Cycle Entry';var TITLE_EDIT_ROUTE='Edit Route';var TITLE_EDIT_RUN='Edit Run';var TITLE_EDIT_RUN_FUTURE='Edit Scheduled Run';var TITLE_EDIT_SLEEP_LOG='Edit Sleep Log Entry';var TITLE_EDIT_SHOE='Edit Shoe';var TITLE_EDIT_SKI='Edit Ski';var TITLE_EDIT_TEAM='Edit Team';var TITLE_EDIT_TEAM_MEMBER='Edit My Team Profile';var TITLE_EDIT_USER='Edit User';var TITLE_EDIT_USER_PROFILE='Edit My Profile';var TITLE_EDIT_WEIGHT_LOG='Edit Weight Log Entry';var TITLE_EDIT_WORKOUT='Edit Workout';var TITLE_EDIT_XTRAINING='Edit X-training';var TITLE_EMAIL_BLOG='E-mail Blog Entry';var TITLE_EXERCISE='Strength Training';var TITLE_EXPANDER='Expanded/Collapse';var TITLE_FEEDBACK='Feedback';var TITLE_FORGOT_PASSWORD='Forgot Password';var TITLE_GETTING_STARTED='Getting Started';var TITLE_HEART_RATE_LOG='Heart Rate Log';var TITLE_HOME_PAGE='Home Page';var TITLE_INTRO='Intro';var TITLE_INVITE_NEW_MEMBERS='Invite New Members';var TITLE_LEADER_BOARD='Leader Board';var TITLE_LEADER_BOARD_BY_YEAR='Leader Board By Year';var TITLE_LEADER_BOARD_BY_MONTH='Leader Board By Month';var TITLE_LEADER_BOARD_BY_WEEK='Leader Board By Week';var TITLE_LIST_AD_PROGRAMS='List Ad Programs';var TITLE_LIST_BIKES='List Bikes';var TITLE_LIST_BLOGS='List Blog Entries';var TITLE_LIST_BLOG_REPORTS='List Blog Abuse Reports';var TITLE_LIST_MY_BLOGS='My Blog Entries';var TITLE_LIST_CLIENTS='List Clients';var TITLE_LIST_CONTACTS='List Contacts';var TITLE_LIST_EFFORT_LEVELS='Edit Effort Levels';var TITLE_LIST_DISTANCE_UNITS='List Distance Units';var TITLE_LIST_TRAINING='List Training';var TITLE_LIST_RUN_DETAILS='List Run Splits';var TITLE_LIST_RECENT_TRAINING='List Recent Training';var TITLE_LIST_ROUTES='List Routes';var TITLE_LIST_SHOES='List Shoes';var TITLE_LIST_SKIS='List Skis';var TITLE_LIST_SEARCHED_COMMUNITY_TRAINING='List Searched Community Training';var TITLE_LIST_SEARCHED_TRAINING='List Searched Training';var TITLE_LIST_SEARCHED_TEAMS='List Searched Teams';var TITLE_LIST_MY_TEAMS='My Teams';var TITLE_LIST_TEAM_MEMBERS='List Team Members';var TITLE_LIST_TEAMS='List Teams';var TITLE_LIST_USERS='List Users';var TITLE_LIST_WORKOUTS='List Workouts';var TITLE_LIST_WORKOUT_DETAILS='List Workout Repeats';var TITLE_LIST_XTRAINING='List X-training';var TITLE_LIST_XTRAINING_DETAILS='List X-training Splits';var TITLE_LOGIN='Login';var TITLE_LOGOUT='Logout';var TITLE_MANAGE_TEAM_MEMBERS='Manage Team Members';var TITLE_MY_CALENDAR='My Calendar';var TITLE_NEW_TEAM_INVITATION='New Team Invitation';var TITLE_OPEN_FEEDBACK_REQUEST='Open Feedback Request';var TITLE_OPEN_FEEDBACK_REQUEST_COMPLETE='Feedback Sent';var TITLE_PR_CHARTING='PR Charting';var TITLE_PR_CHARTING_HELP=TITLE_PR_CHARTING+' Help';var TITLE_PREVIEW='Preview';var TITLE_REGISTER_USER='Register Me';var TITLE_REQUEST_TO_JOIN_TEAM='Request To Join Team';var TITLE_REPLY_BLOG_COMMENT='Reply to this Blog Comment';var TITLE_RUN_CALENDAR='My Calendar';var TITLE_RUN_CHART='Run Summary Chart';var TITLE_RUN_CHART_CRITERIA=TITLE_RUN_CHART;var TITLE_SEARCH_BLOGS='Search Blogs';var TITLE_SEARCH_CLIENTS='Search Clients';var TITLE_SEARCH_COMMUNITY='Search Community';var TITLE_SEARCH_COMMUNITY_TRAINING='Search The Community';var TITLE_SEARCH_TRAINING='Search/Export Training';var TITLE_SEARCH_TEAMS='Search Teams';var TITLE_SEARCH_USERS='Search Users';var TITLE_SEND_TEAM_EMAIL='Send Team E-mail';var TITLE_SHARE_TEAM_RESOURCES='Share Team Resources';var TITLE_SLEEP_LOG='Sleep Log';var TITLE_SUM_TRAINING_BY_YEAR='Summary By Year';var TITLE_SUM_TRAINING_BY_MONTH_AND_TYPE='Summary By Month & Type';var TITLE_SUM_TRAINING_BY_MONTH='Summary By Month';var TITLE_SUM_TRAINING_BY_WEEK_AND_TYPE='Summary By Week & Type';var TITLE_SUM_TRAINING_BY_WEEK='Summary By Week';var TITLE_SUPPORT_PAGE='Support';var TITLE_TEAM_HELP='Team Help';var TITLE_TEAM_TRAINING_SUMMARY='Team Training Summary';var TITLE_TEAM_SHARING='Share Resources With Team';var TITLE_TRAINING_SUMMARY='Training Summary';var TITLE_VIEW_BLOG='View Blog';var TITLE_VIEW_REQUESTS_TO_JOIN_TEAM='Requests To Join Team';var TITLE_VIEW_EXERCISE='View Strength Training';var TITLE_VIEW_RUN='View Run';var TITLE_VIEW_RUN_DETAILS='View Run Splits';var TITLE_VIEW_RUN_FUTURE='View Scheduled Run';var TITLE_VIEW_TEAM='View Team';var TITLE_VIEW_TEAM_INVITATION='View Team Invitation';var TITLE_VIEW_TEAM_INVITATIONS='View Team Invitations';var TITLE_VIEW_XTRAINING='View X-training';var TITLE_VIEW_XTRAINING_DETAILS='View X-training Splits';var COOKIE_NAME='name';var COOKIE_VALUE='value';var ICON_LEGEND_ON=true;var ICON_LEGEND_OFF=false;var ICON_LEGEND='iconLegend';

function AjaxHelper(){this.modules={};}
AjaxHelper.prototype.CONTENT_TYPE_POST='application/x-www-form-urlencoded; charset=utf-8';AjaxHelper.prototype.CONTENT_TYPE_XML='text/xml; charset=utf-16';AjaxHelper.prototype.getRequester=function()
{if(window.XMLHttpRequest)
return new XMLHttpRequest();return new ActiveXObject("Microsoft.XMLHTTP");}
AjaxHelper.prototype.asynchCall=function(url,callback)
{var req=this.getRequester();var me=this;req.open('POST',this.rootPath+url,true);req.onreadystatechange=function(){me.handleReadyStateChange(req,callback,url);}
req.send(null);}
AjaxHelper.prototype.asynchPostId=function(url,id,callback)
{this.asynchPostMap(url,{id:id},callback);}
AjaxHelper.prototype.asynchPostMap=function(url,map,callback)
{var data=this.createPostMapData(map);var req=this.getRequester();var me=this;req.open('POST',this.rootPath+url,true);req.setRequestHeader('Content-Type',this.CONTENT_TYPE_POST);req.onreadystatechange=function(){me.handleReadyStateChange(req,callback,url,map,data);}
req.send(data);}
AjaxHelper.prototype.handleReadyStateChange=function(req,callback,url,map,data)
{if(4!=req.readyState)
return;try
{var value=eval(req.responseText);callback.handleRequestData(value);if(window.onajaxcall)
window.onajaxcall(callback,value);}
catch(error)
{if(error.isNotAuthenticatedError)
{error.retryInfo={url:url,map:map,callback:callback};globalInfo.doLogin(error);}
else if(!error.message||!callback.handleRequestError)
globalInfo.handlePageError(error,url,data);else
callback.handleRequestError(error);}}
AjaxHelper.serializeParams=function(map)
{var data='';for(var id in map)
{var value=map[id];if(undefined==value)
continue;else if(undefined!=value.getTime)
{if(0<data.length)
data+='&';data+=id+'='+encodeURIComponent(value.getTime());}
else if((undefined!=value.length)&&(typeof(value)!='string'))
{for(var i=0;i<value.length;i++)
{if(0<data.length)
data+='&';data+=id+'='+encodeURIComponent(value[i]);}}
else
{if(0<data.length)
data+='&';data+=id+'='+encodeURIComponent(value);}}
return data;}
AjaxHelper.prototype.createPostMapData=function(map)
{return AjaxHelper.serializeParams(map);}
AjaxHelper.prototype.toXml=function(map)
{var data='<data count="1"><item>';for(var id in map)
{var value=map[id];if(undefined==value)
continue;data+='<'+id+'>';if(undefined!=this.cdataElements[id])
data+='<![CDATA['+value+']]>';else
data+=value;data+='</'+id+'>';}
return data+'</item></data>';}
AjaxHelper.prototype.convertChar=function(value)
{if(undefined==value)
return undefined;var output='';for(var i=0;i<value.length;i++)
{var c=value.charCodeAt(i);if(150<=c)
output+='&#'+c+';';else
output+=value.charAt(i);}
return output;}
AjaxHelper.prototype.convertAll=function(map)
{var value;for(var id in this.cdataElements)
if(undefined!=(value=map[id]))
map[id]=this.convertChar(value);return map;}
AjaxHelper.prototype.loadModule=function(url)
{if(this.modules[url])
return false;;var head=document.getElementsByTagName('head')[0];var elem=document.createElement('script');elem.type='text/javascript';elem.src=this.libPath+url+'?v='+appVersion;head.appendChild(elem);return(this.modules[url]=true);}
AjaxHelper.prototype.loadContent=function(url,callback)
{var req=this.getRequester();req.open('POST',this.contentPath+url,true);req.onreadystatechange=function(ev)
{if(4!=req.readyState)
return;callback.handleRequestData(req.responseText);}
req.send(null);}
function AjaxDataHandler(callback,criteria)
{this.callback=callback;this.criteria=criteria;}
AjaxDataHandler.prototype.handleRequestData=function(value)
{this.criteria.value=value;this.callback.doValue(this.criteria);}
function RepopulateSelectList(elem,header,value)
{this.elem=elem;this.header=header;this.value=value;}
RepopulateSelectList.prototype.handleRequestData=function(value)
{SelectList.repopulate(this.elem,value,this.header);if(this.value)
this.elem.value=this.value;}

function RunningJournalCaller(rootPath)
{this.rootPath=rootPath;this.libPath=rootPath+'/scripts';this.contentPath=rootPath+'/content';}
RunningJournalCaller.prototype=new AjaxHelper();RunningJournalCaller.prototype.URL_LOGIN='/Login.json';RunningJournalCaller.prototype.URL_REGISTER_USER='/RegisterUser.json';RunningJournalCaller.prototype.acceptTeamInvitation=function(id,callback)
{this.asynchPostId('/member/AcceptTeamInvitation.json',id,callback);}
RunningJournalCaller.prototype.addBike=function(record,callback)
{this.asynchPostMap('/member/AddBike.json',record,callback);}
RunningJournalCaller.prototype.addBlogComment=function(record,callback)
{this.asynchPostMap('/AddBlogComment.json',record,callback);}
RunningJournalCaller.prototype.addBlogReport=function(record,callback)
{this.asynchPostMap('/member/AddBlogReport.json',record,callback);}
RunningJournalCaller.prototype.addExercise=function(record,callback)
{this.asynchPostMap('/member/AddExercise.json',record,callback);}
RunningJournalCaller.prototype.addFeedback=function(record,callback)
{this.asynchPostMap('/member/AddFeedback.json',record,callback);}
RunningJournalCaller.prototype.addHeartRateLog=function(record,callback)
{this.asynchPostMap('/member/AddHeartRateLog.json',record,callback);}
RunningJournalCaller.prototype.addMenstruationLog=function(record,callback)
{this.asynchPostMap('/member/AddMenstruationLog.json',record,callback);}
RunningJournalCaller.prototype.addRoute=function(record,callback)
{this.asynchPostMap('/member/AddRoute.json',record,callback);}
RunningJournalCaller.prototype.addRun=function(record,callback)
{this.asynchPostMap('/member/AddRun.json',record,callback);}
RunningJournalCaller.prototype.addRunDetail=function(record,callback)
{this.asynchPostMap('/member/AddRunDetail.json',record,callback);}
RunningJournalCaller.prototype.addRunFutureDetail=function(record,callback)
{this.asynchPostMap('/member/AddRunFutureDetail.json',record,callback);}
RunningJournalCaller.prototype.addShoe=function(record,callback)
{this.asynchPostMap('/member/AddShoe.json',record,callback);}
RunningJournalCaller.prototype.addSki=function(record,callback)
{this.asynchPostMap('/member/AddSki.json',record,callback);}
RunningJournalCaller.prototype.addSleepLog=function(record,callback)
{this.asynchPostMap('/member/AddSleepLog.json',record,callback);}
RunningJournalCaller.prototype.addTeam=function(record,callback)
{this.asynchPostMap('/member/AddTeam.json',record,callback);}
RunningJournalCaller.prototype.addWeightLog=function(record,callback)
{this.asynchPostMap('/member/AddWeightLog.json',record,callback);}
RunningJournalCaller.prototype.addWorkout=function(record,callback)
{this.asynchPostMap('/member/AddWorkout.json',record,callback);}
RunningJournalCaller.prototype.addWorkoutDetail=function(record,callback)
{this.asynchPostMap('/member/AddWorkoutDetail.json',record,callback);}
RunningJournalCaller.prototype.addXtraining=function(record,callback)
{this.asynchPostMap('/member/AddXtraining.json',record,callback);}
RunningJournalCaller.prototype.addXtrainingDetail=function(record,callback)
{this.asynchPostMap('/member/AddXtrainingDetail.json',record,callback);}
RunningJournalCaller.prototype.approveRequestToJoinTeam=function(id,callback)
{this.asynchPostId('/member/ApproveRequestToJoinTeam.json',id,callback);}
RunningJournalCaller.prototype.changeTeamMemberType=function(id,typeId,callback)
{this.asynchPostMap('/member/ChangeTeamMemberType.json',{id:id,typeId:typeId},callback);}
RunningJournalCaller.prototype.countTeammates=function(callback)
{this.asynchCall('/member/CountTeammates.json',callback);}
RunningJournalCaller.prototype.deactivateBikeWarning=function(id,callback)
{this.asynchPostId('/member/DeactivateBikeWarning.json',id,callback);}
RunningJournalCaller.prototype.deactivateShoeWarning=function(id,callback)
{this.asynchPostId('/member/DeactivateShoeWarning.json',id,callback);}
RunningJournalCaller.prototype.deactivateSkiWarning=function(id,callback)
{this.asynchPostId('/member/DeactivateSkiWarning.json',id,callback);}
RunningJournalCaller.prototype.declineTeamInvitation=function(id,callback)
{this.asynchPostId('/member/DeclineTeamInvitation.json',id,callback);}
RunningJournalCaller.prototype.deleteBike=function(id,callback)
{this.asynchPostId('/member/DeleteBike.json',id,callback);}
RunningJournalCaller.prototype.deleteExercise=function(id,callback)
{this.asynchPostId('/member/DeleteExercise.json',id,callback);}
RunningJournalCaller.prototype.deleteHeartRateLog=function(id,callback)
{this.asynchPostId('/member/DeleteHeartRateLog.json',id,callback);}
RunningJournalCaller.prototype.deleteMenstruationLog=function(id,callback)
{this.asynchPostId('/member/DeleteMenstruationLog.json',id,callback);}
RunningJournalCaller.prototype.deleteRoute=function(id,callback)
{this.asynchPostId('/member/DeleteRoute.json',id,callback);}
RunningJournalCaller.prototype.deleteRun=function(id,callback)
{this.asynchPostId('/member/DeleteRun.json',id,callback);}
RunningJournalCaller.prototype.deleteRunDetail=function(record,callback)
{this.asynchPostMap('/member/DeleteRunDetail.json',record,callback);}
RunningJournalCaller.prototype.deleteRunFuture=function(id,callback)
{this.asynchPostId('/member/DeleteRunFuture.json',id,callback);}
RunningJournalCaller.prototype.deleteRunFutureDetail=function(record,callback)
{this.asynchPostMap('/member/DeleteRunFutureDetail.json',record,callback);}
RunningJournalCaller.prototype.deleteShoe=function(id,callback)
{this.asynchPostId('/member/DeleteShoe.json',id,callback);}
RunningJournalCaller.prototype.deleteSki=function(id,callback)
{this.asynchPostId('/member/DeleteSki.json',id,callback);}
RunningJournalCaller.prototype.deleteSleepLog=function(id,callback)
{this.asynchPostId('/member/DeleteSleepLog.json',id,callback);}
RunningJournalCaller.prototype.deleteTeamMember=function(id,callback)
{this.asynchPostId('/member/DeleteTeamMember.json',id,callback);}
RunningJournalCaller.prototype.deleteWeightLog=function(id,callback)
{this.asynchPostId('/member/DeleteWeightLog.json',id,callback);}
RunningJournalCaller.prototype.deleteWorkout=function(id,callback)
{this.asynchPostId('/member/DeleteWorkout.json',id,callback);}
RunningJournalCaller.prototype.deleteWorkoutDetail=function(record,callback)
{this.asynchPostMap('/member/DeleteWorkoutDetail.json',record,callback);}
RunningJournalCaller.prototype.deleteXtraining=function(id,callback)
{this.asynchPostId('/member/DeleteXtraining.json',id,callback);}
RunningJournalCaller.prototype.deleteXtrainingDetail=function(record,callback)
{this.asynchPostMap('/member/DeleteXtrainingDetail.json',record,callback);}
RunningJournalCaller.prototype.emailBlog=function(value,callback)
{this.asynchPostMap('/member/EmailBlog.json',value,callback);}
RunningJournalCaller.prototype.getBike=function(bikeId,callback)
{this.asynchPostId('/member/GetBike.json',bikeId,callback);}
RunningJournalCaller.prototype.getBlog=function(id,callback)
{this.asynchPostId('/GetBlog.json',id,callback);}
RunningJournalCaller.prototype.getBlogComment=function(id,callback)
{this.asynchPostId('/GetBlogComment.json',id,callback);}
RunningJournalCaller.prototype.getCalendar=function(filter,callback)
{this.asynchPostMap('/member/GetCalendar.json',filter,callback);}
RunningJournalCaller.prototype.getChartCriteria=function(filter,callback)
{this.asynchPostMap('/member/GetChartCriteria.json',filter,callback);}
RunningJournalCaller.prototype.getChartDatapoints=function(teammateId,callback)
{this.asynchPostMap('/member/GetChartDatapoints.json',{teammate:teammateId},callback);}
RunningJournalCaller.prototype.getEditBike=function(id,callback)
{this.asynchPostId('/member/GetEditBike.json',id,callback);}
RunningJournalCaller.prototype.getEditBlogComment=function(filter,callback)
{this.asynchPostMap('/GetEditBlogComment.json',filter,callback);}
RunningJournalCaller.prototype.getEditBlogReport=function(filter,callback)
{this.asynchPostMap('/member/GetEditBlogReport.json',filter,callback);}
RunningJournalCaller.prototype.getEditExercise=function(filter,callback)
{this.asynchPostMap('/member/GetEditExercise.json',filter,callback);}
RunningJournalCaller.prototype.getEditFeedback=function(filter,callback)
{this.asynchPostMap('/member/GetEditFeedback.json',filter,callback);}
RunningJournalCaller.prototype.getEditHeartRateLog=function(filter,callback)
{this.asynchPostMap('/member/GetEditHeartRateLog.json',filter,callback);}
RunningJournalCaller.prototype.getEditMenstruationLog=function(filter,callback)
{this.asynchPostMap('/member/GetEditMenstruationLog.json',filter,callback);}
RunningJournalCaller.prototype.getEditMyProfile=function(callback)
{this.asynchCall('/member/GetEditMyProfile.json',callback);}
RunningJournalCaller.prototype.getEditRoute=function(id,callback)
{this.asynchPostId('/member/GetEditRoute.json',id,callback);}
RunningJournalCaller.prototype.getEditRun=function(filter,callback)
{this.asynchPostMap('/member/GetEditRun.json',filter,callback);}
RunningJournalCaller.prototype.getEditShoe=function(id,callback)
{this.asynchPostId('/member/GetEditShoe.json',id,callback);}
RunningJournalCaller.prototype.getEditSki=function(id,callback)
{this.asynchPostId('/member/GetEditSki.json',id,callback);}
RunningJournalCaller.prototype.getEditSleepLog=function(filter,callback)
{this.asynchPostMap('/member/GetEditSleepLog.json',filter,callback);}
RunningJournalCaller.prototype.getEditTeam=function(id,callback)
{this.asynchPostId('/member/GetEditTeam.json',id,callback);}
RunningJournalCaller.prototype.getEditTeamMember=function(filter,callback)
{this.asynchPostMap('/member/GetEditTeamMember.json',filter,callback);}
RunningJournalCaller.prototype.getEditUser=function(id,callback)
{this.asynchPostId('/GetEditUser.json',id,callback);}
RunningJournalCaller.prototype.getEditWeightLog=function(filter,callback)
{this.asynchPostMap('/member/GetEditWeightLog.json',filter,callback);}
RunningJournalCaller.prototype.getEditWorkout=function(id,callback)
{this.asynchPostId('/member/GetEditWorkout.json',id,callback);}
RunningJournalCaller.prototype.getEditXtraining=function(filter,callback)
{this.asynchPostMap('/member/GetEditXtraining.json',filter,callback);}
RunningJournalCaller.prototype.getEffortLevel=function(id,callback)
{this.asynchPostId('/member/GetEffortLevel.json',id,callback);}
RunningJournalCaller.prototype.getEffortLevels=function(userId,callback)
{this.asynchPostMap('/member/GetEffortLevels.json',{teammate:userId},callback);}
RunningJournalCaller.prototype.getExercise=function(id,callback)
{this.asynchPostId('/member/GetExercise.json',id,callback);}
RunningJournalCaller.prototype.getExerciseTypes=function(muscleGroupId,callback)
{this.asynchPostId('/member/GetExerciseTypes.json',muscleGroupId,callback);}
RunningJournalCaller.prototype.getMe=function(callback)
{this.asynchCall('/GetMe.json',callback);}
RunningJournalCaller.prototype.getMembershipInvites=function(teamId,callback)
{this.asynchPostId('/member/GetMembershipInvites.json',teamId,callback);}
RunningJournalCaller.prototype.getMembershipRequests=function(callback)
{this.asynchCall('/member/GetMembershipRequests.json',callback);}
RunningJournalCaller.prototype.getNotices=function(callback)
{this.asynchCall('/member/GetNotices.json',callback);}
RunningJournalCaller.prototype.getRecentRuns=function(filter,callback)
{this.asynchPostMap('/member/GetRecentRuns.json',filter,callback);}
RunningJournalCaller.prototype.getRecentRunsByCommunity=function(filter,callback)
{this.asynchPostMap('/member/GetRecentRunsByCommunity.json',filter,callback);}
RunningJournalCaller.prototype.getRecentRunsByTeammates=function(filter,callback)
{this.asynchPostMap('/member/GetRecentRunsByTeammates.json',filter,callback);}
RunningJournalCaller.prototype.getRecentXtraining=function(filter,callback)
{this.asynchPostMap('/member/GetRecentXtraining.json',filter,callback);}
RunningJournalCaller.prototype.getRecentXtrainingByCommunity=function(filter,callback)
{this.asynchPostMap('/member/GetRecentXtrainingByCommunity.json',filter,callback);}
RunningJournalCaller.prototype.getRecentXtrainingByTeammates=function(filter,callback)
{this.asynchPostMap('/member/GetRecentXtrainingByTeammates.json',filter,callback);}
RunningJournalCaller.prototype.getRoute=function(id,callback)
{this.asynchPostId('/member/GetRoute.json',id,callback);}
RunningJournalCaller.prototype.getRoutes=function(userId,callback)
{this.asynchPostMap('/member/GetRoutes.json',{teammate:userId},callback);}
RunningJournalCaller.prototype.getRunDetails=function(parentId,callback)
{this.asynchPostMap('/member/GetRunDetails.json',{id:parentId},callback);}
RunningJournalCaller.prototype.getRunFutureDetails=function(parentId,runId,callback)
{this.asynchPostMap('/member/GetRunFutureDetails.json',{parentId:parentId,actualId:runId},callback);}
RunningJournalCaller.prototype.getRun=function(id,callback)
{this.asynchPostId('/member/GetRun.json',id,callback);}
RunningJournalCaller.prototype.getRunFuture=function(id,runId,callback)
{this.asynchPostMap('/member/GetRunFuture.json',{parentId:id,actualId:runId},callback);}
RunningJournalCaller.prototype.getSearchBlogs=function(filter,callback)
{this.asynchPostMap('/GetSearchBlogs.json',filter,callback);}
RunningJournalCaller.prototype.getSearchCommunityTraining=function(filter,callback)
{this.asynchPostMap('/member/GetSearchCommunityTraining.json',filter,callback);}
RunningJournalCaller.prototype.getSearchTeams=function(filter,callback)
{this.asynchPostMap('/member/GetSearchTeams.json',filter,callback);}
RunningJournalCaller.prototype.getSearchTraining=function(filter,callback)
{this.asynchPostMap('/member/GetSearchTraining.json',filter,callback);}
RunningJournalCaller.prototype.getSendTeamEmail=function(teamId,callback)
{this.asynchPostMap('/member/GetSendTeamEmail.json',{teamId:teamId},callback);}
RunningJournalCaller.prototype.getShoe=function(shoeId,callback)
{this.asynchPostId('/member/GetShoe.json',shoeId,callback);}
RunningJournalCaller.prototype.getSki=function(id,callback)
{this.asynchPostId('/member/GetSki.json',id,callback);}
RunningJournalCaller.prototype.getStates=function(countryId,callback)
{this.asynchPostMap('/GetStates.json',{id:countryId},callback);}
RunningJournalCaller.prototype.getTeam=function(id,callback)
{this.asynchPostId('/member/GetTeam.json',id,callback);}
RunningJournalCaller.prototype.getTeamMatesWithViewableCalendars=function(callback)
{this.asynchCall('/member/GetTeamMatesWithViewableCalendars.json',callback);}
RunningJournalCaller.prototype.getTeamMatesWithViewableLogs=function(callback)
{this.asynchCall('/member/GetTeamMatesWithViewableLogs.json',callback);}
RunningJournalCaller.prototype.getTeamMatesWithViewableSummaries=function(callback)
{this.asynchCall('/member/GetTeamMatesWithViewableSummaries.json',callback);}
RunningJournalCaller.prototype.getTeamMember=function(id,teamId,callback)
{this.asynchPostMap('/member/GetTeamMember.json',{id:id,teamId:teamId},callback);}
RunningJournalCaller.prototype.getTeamSharing=function(teamId,callback)
{this.asynchPostId('/member/GetTeamSharing.json',teamId,callback);}
RunningJournalCaller.prototype.getToday=function(callback){this.asynchCall('/GetToday.json',callback);}
RunningJournalCaller.prototype.getTrainingTotals=function(filter,callback)
{this.asynchPostMap('/member/GetTrainingTotals.json',filter,callback);}
RunningJournalCaller.prototype.getWeatherLocations=function(user,callback)
{this.asynchPostMap('/GetWeatherLocations.json',user,callback);}
RunningJournalCaller.prototype.getWorkoutDetails=function(parentId,callback)
{this.asynchPostMap('/member/GetWorkoutDetails.json',{id:parentId},callback);}
RunningJournalCaller.prototype.getWorkouts=function(userId,callback)
{this.asynchPostMap('/member/GetWorkouts.json',{teammate:userId},callback);}
RunningJournalCaller.prototype.getXtrainingDetails=function(parentId,callback)
{this.asynchPostMap('/member/GetXtrainingDetails.json',{id:parentId},callback);}
RunningJournalCaller.prototype.getXtraining=function(id,callback)
{this.asynchPostId('/member/GetXtraining.json',id,callback);}
RunningJournalCaller.prototype.getXtrainingType=function(id,callback)
{this.asynchPostId('/member/GetXtrainingType.json',id,callback);}
RunningJournalCaller.prototype.getXtrainingTypes=function(callback)
{this.asynchCall('/GetXtrainingTypes.json',callback);}
RunningJournalCaller.prototype.inviteNewMembers=function(value,callback)
{this.asynchPostMap('/member/InviteNewMembers.json',value,callback);}
RunningJournalCaller.prototype.leaderBoard=function(filter,callback)
{this.asynchPostMap('/member/LeaderBoard.json',filter,callback);}
RunningJournalCaller.prototype.leaderBoardByMonth=function(filter,callback)
{this.asynchPostMap('/member/LeaderBoardByMonth.json',filter,callback);}
RunningJournalCaller.prototype.leaderBoardByWeek=function(filter,callback)
{this.asynchPostMap('/member/LeaderBoardByWeek.json',filter,callback);}
RunningJournalCaller.prototype.leaderBoardByYear=function(filter,callback)
{this.asynchPostMap('/member/LeaderBoardByYear.json',filter,callback);}
RunningJournalCaller.prototype.listMyTeams=function(callback)
{this.asynchCall('/member/ListMyTeams.json',callback);}
RunningJournalCaller.prototype.login=function(params,callback)
{this.asynchPostMap(this.URL_LOGIN,params,callback);this.getToday({handleRequestData:function(value){TODAY=value.payload;}});}
RunningJournalCaller.prototype.logout=function(callback)
{this.asynchCall('/Logout.json',callback);if(document.all)
document.cookie='JSESSIONID=;path=/;expires=Thu, 01 Jan 1970 00:00:01 GMT';}
RunningJournalCaller.prototype.registerUser=function(record,callback)
{this.asynchPostMap(this.URL_REGISTER_USER,record,callback);}
RunningJournalCaller.prototype.rejectRequestToJoinTeam=function(id,callback)
{this.asynchPostId('/member/RejectRequestToJoinTeam.json',id,callback);}
RunningJournalCaller.prototype.requestToJoinTeam=function(teamId,callback)
{this.asynchPostId('/member/RequestToJoinTeam.json',teamId,callback);}
RunningJournalCaller.prototype.resetPassword=function(userName,callback)
{this.asynchPostMap('/ResetPassword.json',{userName:userName},callback);}
RunningJournalCaller.prototype.runChart=function(filter,callback)
{this.asynchPostMap('/member/RunChart.json',filter,callback);}
RunningJournalCaller.prototype.searchBikes=function(callback)
{this.asynchCall('/member/SearchBikes.json',callback);}
RunningJournalCaller.prototype.searchBlogs=function(filter,callback)
{this.asynchPostMap('/SearchBlogs.json',filter,callback);}
RunningJournalCaller.prototype.searchBlogComments=function(filter,callback)
{this.asynchPostMap('/SearchBlogComments.json',filter,callback);}
RunningJournalCaller.prototype.searchEffortLevels=function(callback)
{this.asynchCall('/member/SearchEffortLevels.json',callback);}
RunningJournalCaller.prototype.searchMenstruationLog=function(filter,callback)
{this.asynchPostMap('/member/SearchMenstruationLog.json',filter,callback);}
RunningJournalCaller.prototype.searchRoutes=function(callback)
{this.asynchCall('/member/SearchRoutes.json',callback);}
RunningJournalCaller.prototype.searchShoes=function(callback)
{this.asynchCall('/member/SearchShoes.json',callback);}
RunningJournalCaller.prototype.searchSkis=function(callback)
{this.asynchCall('/member/SearchSkis.json',callback);}
RunningJournalCaller.prototype.searchTeams=function(filter,callback)
{this.asynchPostMap('/member/SearchTeams.json',filter,callback);}
RunningJournalCaller.prototype.searchTeamMembers=function(filter,callback)
{this.asynchPostMap('/member/SearchTeamMembers.json',filter,callback);}
RunningJournalCaller.prototype.searchTraining=function(filter,callback)
{this.asynchPostMap('/member/SearchTraining.json',filter,callback);}
RunningJournalCaller.prototype.searchWorkouts=function(callback)
{this.asynchCall('/member/SearchWorkouts.json',callback);}
RunningJournalCaller.prototype.sendTeamEmail=function(value,callback)
{this.asynchPostMap('/member/SendTeamEmail.json',value,callback);}
RunningJournalCaller.prototype.setBike=function(record,callback)
{this.asynchPostMap('/member/SetBike.json',record,callback);}
RunningJournalCaller.prototype.setEffortLevel=function(record,callback)
{this.asynchPostMap('/member/SetEffortLevel.json',record,callback);}
RunningJournalCaller.prototype.setExercise=function(record,callback)
{this.asynchPostMap('/member/SetExercise.json',record,callback);}
RunningJournalCaller.prototype.setHeartRateLog=function(record,callback)
{this.asynchPostMap('/member/SetHeartRateLog.json',record,callback);}
RunningJournalCaller.prototype.setMenstruationLog=function(record,callback)
{this.asynchPostMap('/member/SetMenstruationLog.json',record,callback);}
RunningJournalCaller.prototype.setRoute=function(record,callback)
{this.asynchPostMap('/member/SetRoute.json',record,callback);}
RunningJournalCaller.prototype.setRun=function(record,callback)
{this.asynchPostMap('/member/SetRun.json',record,callback);}
RunningJournalCaller.prototype.setRunDetail=function(record,callback)
{this.asynchPostMap('/member/SetRunDetail.json',record,callback);}
RunningJournalCaller.prototype.setRunFutureDetail=function(record,callback)
{this.asynchPostMap('/member/SetRunFutureDetail.json',record,callback);}
RunningJournalCaller.prototype.setShoe=function(record,callback)
{this.asynchPostMap('/member/SetShoe.json',record,callback);}
RunningJournalCaller.prototype.setSki=function(record,callback)
{this.asynchPostMap('/member/SetSki.json',record,callback);}
RunningJournalCaller.prototype.setSleepLog=function(record,callback)
{this.asynchPostMap('/member/SetSleepLog.json',record,callback);}
RunningJournalCaller.prototype.setTeam=function(record,callback)
{this.asynchPostMap('/member/SetTeam.json',record,callback);}
RunningJournalCaller.prototype.setTeamMember=function(record,callback)
{this.asynchPostMap('/member/SetTeamMember.json',record,callback);}
RunningJournalCaller.prototype.setUser=function(record,callback)
{this.asynchPostMap('/member/SetUser.json',record,callback);}
RunningJournalCaller.prototype.setWeightLog=function(record,callback)
{this.asynchPostMap('/member/SetWeightLog.json',record,callback);}
RunningJournalCaller.prototype.setWorkout=function(record,callback)
{this.asynchPostMap('/member/SetWorkout.json',record,callback);}
RunningJournalCaller.prototype.setWorkoutDetail=function(record,callback)
{this.asynchPostMap('/member/SetWorkoutDetail.json',record,callback);}
RunningJournalCaller.prototype.setXtraining=function(record,callback)
{this.asynchPostMap('/member/SetXtraining.json',record,callback);}
RunningJournalCaller.prototype.setXtrainingDetail=function(record,callback)
{this.asynchPostMap('/member/SetXtrainingDetail.json',record,callback);}
RunningJournalCaller.prototype.shareTeamResources=function(value,callback)
{this.asynchPostMap('/member/ShareTeamResources.json',value,callback);}
RunningJournalCaller.prototype.sumRunsByMonth=function(filter,callback)
{this.asynchPostMap('/member/SumRunsByMonth.json',filter,callback);}
RunningJournalCaller.prototype.sumRunsByWeek=function(filter,callback)
{this.asynchPostMap('/member/SumRunsByWeek.json',filter,callback);}
RunningJournalCaller.prototype.sumRunsByYear=function(filter,callback)
{this.asynchPostMap('/member/SumRunsByYear.json',filter,callback);}
RunningJournalCaller.prototype.sumTeamTraining=function(filter,callback)
{this.asynchPostMap('/member/SumTeamTraining.json',filter,callback);}
RunningJournalCaller.prototype.sumTrainingByMonth=function(filter,callback)
{this.asynchPostMap('/member/SumTrainingByMonth.json',filter,callback);}
RunningJournalCaller.prototype.sumTrainingByWeek=function(filter,callback)
{this.asynchPostMap('/member/SumTrainingByWeek.json',filter,callback);}
RunningJournalCaller.prototype.sumTrainingByYear=function(filter,callback)
{this.asynchPostMap('/member/SumTrainingByYear.json',filter,callback);}
RunningJournalCaller.prototype.touch=function()
{this.asynchCall('/Login.json');}

function Calendar(body,callback)
{this.body=body;this.callback=callback;this.isOpen=false;}
Calendar.CSS_CONTAINER='calendarContainer';Calendar.getInstance=function(callback)
{var elem=document.createElement('div');elem.className=Calendar.CSS_CONTAINER;document.body.insertBefore(elem,document.body.firstChild);return new Calendar(elem,callback);}
Calendar.prototype.MONTHS=['January','February','March','April','May','June','July','August','September','October','November','December'];Calendar.prototype.LAST_DAYS=[31,28,31,30,31,30,31,31,30,31,30,31];Calendar.prototype.DAYS=['Sun','Mon','Tues','Wed','Thur','Fri','Sat'];Calendar.prototype.getDaysInMonth=function(month,year)
{if(1!=month)
return this.LAST_DAYS[month];var offset=(0==(year%4))?1:0;return this.LAST_DAYS[month]+offset;}
Calendar.prototype.create=function(name,value)
{var me=this,elem=Inputter.genTextBox(name,10);elem.className='calendar';elem.myDate=value;if(value)
elem.value=Formatter.toInputDate(value);elem.onfocus=function(ev){me.run(this,this.myDate);};elem.onchange=function(ev){try{this.myDate=(0==this.value.length)?undefined:Formatter.fromInputDate(this.value);}
catch(error){window.alert(error);elem=this;setTimeout(function(){elem.focus();},200);}};elem.getDate=function(){return(0<this.value.length)?this.myDate:undefined;};return elem;}
Calendar.prototype.run=function(elem,value)
{if(!elem.myDate)
elem.myDate=Formatter.today();elem.myCalDate=value?value:elem.myDate;elem.myCalendar=this;elem.onkeydown=this.elem_onKeyDown;this.addEventListener(elem,'blur',this.scheduleClose);this.body.innerHTML='';this.body.appendChild(this.generate(elem,this));this.open();Positioner.under(elem,this.body);}
Calendar.prototype.generate=function(elem,callback)
{var value=elem.myCalDate;var output=document.createElement('table');var tr,td,cells,rows=0;output.border=1;output.cellSpacing=0;output.cellPadding=2;tr=output.insertRow(rows++);tr.className='calendarCaption';td=tr.insertCell(0);td.colSpan=this.DAYS.length;td.appendChild(this.genHeader(elem,callback));tr=output.insertRow(rows++);tr.className='calendarHeader';for(var i=0;i<this.DAYS.length;i++)
{td=tr.insertCell(i);td.className='calendarHeader';td.appendChild(document.createTextNode(this.DAYS[i]));}
var today=value.getUTCDate();var when=new Date(value.getTime());when.setUTCDate(1);var dayOffset=when.getUTCDay();tr=output.insertRow(rows++);cells=0;if(0<dayOffset)
{td=tr.insertCell(cells++);td.colSpan=dayOffset;td.innerHTML='&nbsp;';td.className='calendarDay';}
var daysInMonth=this.getDaysInMonth(when.getUTCMonth(),when.getUTCFullYear());for(var i=1;i<=daysInMonth;i++)
{if(this.DAYS.length<=dayOffset)
{dayOffset=0;tr=output.insertRow(rows++);cells=0;}
var cssClass='calendarDay';if(today==i)
cssClass='calendarSelected';td=tr.insertCell(cells++);td.className=cssClass;td.appendChild(this.createAnchor(i,this.handleSelection,elem,callback,i));dayOffset++;}
if(this.DAYS.length>dayOffset)
{td=tr.insertCell(cells++);td.colSpan=this.DAYS.length-dayOffset;td.innerHTML='&nbsp;';td.className='calendarDay';}
tr=output.insertRow(rows++);tr.className='calendarFooter';td=tr.insertCell(0);td.colSpan=this.DAYS.length;td.appendChild(this.genFooter(elem,callback));return output;}
Calendar.prototype.genHeader=function(elem,callback)
{var value=elem.myCalDate;var output=document.createElement('table');output.border=0;output.cellSpacing=0;output.cellPadding=0;output.style.width='100%';var tr,td,rows=0;tr=output.insertRow(rows++);td=tr.insertCell(0);td.style.width='50%';td.className='calendarCaption';td.appendChild(this.createAnchor('&lt;',callback.changeMonth,elem,callback,-1));td.appendChild(this.createSpace());td.appendChild(document.createTextNode(this.MONTHS[value.getMonth()]));td.appendChild(this.createSpace());td.appendChild(this.createAnchor('&gt;',callback.changeMonth,elem,callback,1));td=tr.insertCell(1);td.style.width='50%';td.className='calendarCaption';td.appendChild(this.createAnchor('&lt;',callback.changeYear,elem,callback,-1));td.appendChild(this.createSpace());td.appendChild(document.createTextNode(value.getFullYear()));td.appendChild(this.createSpace());td.appendChild(this.createAnchor('&gt;',callback.changeYear,elem,callback,1));return output;}
Calendar.prototype.genFooter=function(elem,callback,value)
{var output=document.createElement('table');output.border=0;output.cellSpacing=0;output.cellPadding=0;output.style.width='100%';var tr,td,rows=0;tr=output.insertRow(rows++);td=tr.insertCell(0);td.style.width='50%';td.className='calendarFooter';td.appendChild(this.createAnchor('Today',callback.handleToday,elem,callback));td=tr.insertCell(1);td.style.width='50%';td.className='calendarFooter';td.appendChild(this.createAnchor('Close',callback.handleClose,elem,callback));return output;}
Calendar.prototype.createAnchor=function(caption,action,elem,callback,extra)
{var output=document.createElement('a');output.href='javascript:void(null)';output.myCalendar=callback;output.myElem=elem;output.myExtra=extra;output.innerHTML=caption;this.addEventListener(output,'click',callback.cancelClose);this.addEventListener(output,'click',action);this.addEventListener(output,'blur',callback.scheduleClose);return output;}
Calendar.prototype.createSpace=function()
{var output=document.createElement('span');output.innerHTML='&nbsp;&nbsp;';return output;}
Calendar.prototype.changeMonth=function(ev)
{var that=(this.myCalendar)?this:event.srcElement;var me=that.myCalendar;var elem=that.myElem;var tick=that.myExtra;elem.myCalDate.setMonth(elem.myCalDate.getMonth()+tick);me.run(elem,elem.myCalDate);}
Calendar.prototype.changeYear=function(ev)
{var that=(this.myCalendar)?this:event.srcElement;var me=that.myCalendar;var elem=that.myElem;var tick=that.myExtra;elem.myCalDate.setFullYear(elem.myCalDate.getFullYear()+tick);me.run(elem,elem.myCalDate);}
Calendar.prototype.handleSelection=function(ev)
{var that=(this.myCalendar)?this:event.srcElement;var me=that.myCalendar;var elem=that.myElem;elem.myDate.setUTCDate(that.myExtra);elem.value=Formatter.toInputDate(elem.myDate);me.handleSelection_(elem);}
Calendar.prototype.handleSelection_=function(elem)
{this.close();if(this.callback&&this.callback.handleCalendarSelect)
this.callback.handleCalendarSelect(elem);}
Calendar.prototype.handleToday=function(ev)
{var that=(this.myCalendar)?this:event.srcElement;var me=that.myCalendar;var elem=that.myElem;elem.myDate=Formatter.today();elem.value=Formatter.toInputDate(elem.myDate);me.handleSelection_(elem);}
Calendar.prototype.handleClose=function(ev)
{var that=(this.myCalendar)?this:event.srcElement;that.myCalendar.close();}
Calendar.prototype.open=function()
{this.continueWithClose=false;if(this.isOpen)
return;this.body.style.display='block';this.isOpen=true;ModalDialog.altSelectLists(true);if(this.callback&&this.callback.handleCalendarOpen)
this.callback.handleCalendarOpen();}
Calendar.prototype.close=function()
{if(!this.isOpen)
return;this.body.style.display='none';this.isOpen=false;ModalDialog.altSelectLists(false);if(this.callback&&this.callback.handleCalendarClose)
this.callback.handleCalendarClose();}
Calendar.prototype.cancelClose=function(ev)
{var that=(this.myCalendar)?this:event.srcElement;that.myCalendar.continueWithClose=false;}
Calendar.prototype.scheduleClose=function(ev)
{var that=(this.myCalendar)?this:event.srcElement;var me=that.myCalendar;me.continueWithClose=true;window.setTimeout(function(){if(me.continueWithClose)me.close();},1000);}
Calendar.prototype.addEventListener=function(target,type,action)
{if(target.addEventListener)
target.addEventListener(type,action,false);else
target.attachEvent('on'+type,action);}
Calendar.prototype.elem_onKeyDown=function(ev)
{if(KeyCode.KEY_ESCAPE==KeyCode.getCode(ev))
{this.myCalendar.close();return false;}
return true;}

function TrainingFutureFilter(parentId,actualId)
{this.parentId=parentId;this.actualId=actualId;}
function TrainingTotalsFilter(userId,trainingTypeId,periodDate,distanceUnitId)
{this.userId=userId;this.trainingTypeId=trainingTypeId;this.periodDate=periodDate;this.distanceUnitId=distanceUnitId;}

var Cookies=new Object();Cookies.getValue=function(name)
{var value=document.cookie.match('(^|;) ?'+name+'=([^;]*)(;|$)');if(value)
return unescape(value[2]);return undefined;}
Cookies.setValue=function(name,value,expires,path)
{var item=name+"="+escape(value);if(expires)
item+="; expires="+expires.toGMTString();if(!path)
path='/';item+="; path="+escape(path);document.cookie=item;}
Cookies.deleteValue=function(name,path)
{Cookies.setValue(name,'',new Date(0),path);}

function DropdownMenu(callback)
{this.callback=callback;}
DropdownMenu.prototype.CSS_MAIN=['dropdownMenu','dropdownSubMenu','dropdownSubMenu2'];DropdownMenu.prototype.CSS_SELECTED='selected';DropdownMenu.prototype.CSS_LI_END='dropdownMenuEnd';DropdownMenu.prototype.DELAY=500;DropdownMenu.SIDE_TOP=0;DropdownMenu.SIDE_RIGHT=1;DropdownMenu.SIDE_BOTTOM=2;DropdownMenu.SIDE_LEFT=3;DropdownMenu.prototype.doItems=function(items,body)
{this.run({items:items},body);}
DropdownMenu.prototype.run=function(criteria,body)
{this.openCount=0;this.openedItem={};criteria.body=body;criteria.body.appendChild(this.generate(criteria,this));}
DropdownMenu.prototype.generate=function(criteria)
{var output=this.genItems(criteria,criteria.items,0);output.myValue=criteria;return output;}
DropdownMenu.prototype.genItems=function(criteria,items,level,parent)
{var a,elem,output=document.createElement('ul');output.className=this.CSS_MAIN[level];var end=items.length-1;var callback=this;for(var i=0;i<items.length;i++)
{var item=items[i];item.level=level;item.parent=parent;output.appendChild(elem=document.createElement('li'));if(end==i)
elem.className=this.CSS_LI_END;elem.appendChild(a=item.anchor=document.createElement('a'));if(item.selected)
a.className=this.CSS_SELECTED;if(item.css)
a.className+=' '+item.css;a.href='javascript:void(null);';a.myItem=item;a.onclick=function(ev){callback.anchor_onClick(criteria,this);return false;};a.onmouseover=function(ev){callback.anchor_onMouseOver(criteria,this);return false;};a.onmouseout=function(ev){callback.anchor_onMouseOut(criteria,this);return false;};a.innerHTML=item.caption;}
return output;}
DropdownMenu.prototype.anchor_onClick=function(criteria,elem)
{for(var i=0;i<criteria.items.length;i++)
{var item=criteria.items[i];item.anchor.className=item.css?item.css:'';}
for(var item=elem.myItem;undefined!=item;item=item.parent)
{if(item.childElem)
this.closeItem(item);if(!item.parent)
item.anchor.className=this.CSS_SELECTED;}
this.callback.handleDropdownMenuSelect(elem.myItem);}
DropdownMenu.prototype.anchor_onMouseOver=function(criteria,elem)
{var item=elem.myItem;for(var parent=item;undefined!=parent;parent=parent.parent)
{if(!parent.myCloseEventId)
continue;window.clearTimeout(parent.myCloseEventId);parent.myCloseEventId=undefined;}
if(item.childElem||!item.children)
return;var coord=Positioner.getCoords(elem);if(this.openedItem[item.level])
this.closeItem(this.openedItem[item.level]);var output=item.childElem=this.genItems(criteria,item.children,item.level+1,item);if(DropdownMenu.SIDE_BOTTOM==item.side)
coord.y+=elem.offsetHeight;else if(DropdownMenu.SIDE_RIGHT==item.side)
coord.x+=elem.offsetWidth;Positioner.position(output,coord);this.hideSelects();this.openedItem[item.level]=item;document.body.insertBefore(output,document.body.firstChild);}
DropdownMenu.prototype.anchor_onMouseOut=function(criteria,elem)
{for(var item=elem.myItem;undefined!=item;item=item.parent)
{if(!item.childElem)
continue;item.myCloseEventId=this.setTimeout(item);}}
DropdownMenu.prototype.setTimeout=function(item)
{var me=this;return window.setTimeout(function(){me.closeItem(item);},this.DELAY);}
DropdownMenu.prototype.closeItem=function(item)
{if(!item.childElem)
return;document.body.removeChild(item.childElem);item.childElem=undefined;item.myCloseEventId=undefined;if(this.openedItem[item.level]==item)
this.openedItem[item.level]=undefined;this.showSelects();}
DropdownMenu.prototype.hideSelects=function()
{this.openCount++;if((1!=this.openCount)||(undefined==document.all))
return;var elems=document.getElementsByTagName('select');for(var i=0;i<elems.length;i++)
elems[i].style.visibility='hidden';}
DropdownMenu.prototype.showSelects=function()
{this.openCount--;if((0<this.openCount)||(undefined==document.all))
return;var elems=document.getElementsByTagName('select');for(var i=0;i<elems.length;i++)
elems[i].style.visibility='visible';}
function DropdownMenuItem(id,caption,selected,side,children,css)
{this.id=id;this.caption=caption;this.selected=selected;this.side=side;this.children=children;this.css=css;}

var Elements={}
Elements.addBreak=function(o)
{var a=document.createElement('br');o.appendChild(a);return a;}
Elements.addHR=function(o,className)
{this.addElem(o,'hr',className);}
Elements.addSpace=function(o)
{o.appendChild(document.createTextNode(' '));}
Elements.addSpan=function(o,className,text)
{return this.addElem(o,'span',className,text);}
Elements.addText=function(o,v)
{o.appendChild(document.createTextNode(v));}
Elements.addDiv=function(o,className,text)
{return this.addElem(o,'div',className,text);}
Elements.addElem=function(o,elemName,className,text)
{var e=document.createElement(elemName);if(className)
e.className=className;if(text)
e.innerHTML=Formatter.toDisplayable(text);o.appendChild(e);return e;}
Elements.genAnchor=function(elem,onclick,css)
{var a=document.createElement('a');a.href='javascript:void(null)';a.onclick=onclick;if(elem)
{var t=typeof(elem);if(('string'==t)||('number'==t))
a.innerHTML=elem;else
a.appendChild(elem);}
if(css)
a.className=css;return a;}
Elements.genImage=function(src,title)
{var o=document.createElement('img');o.src=localImagesPath+'/'+src;if(title)
o.title=title;return o;}

var Fader={interval:10,decrements:(document.all?10:2)};Fader.run=function(elem,callback)
{var me=this;elem.myOpacity=100;var id=setInterval(function(){elem.myOpacity-=me.decrements;if(0==elem.myOpacity)
{clearInterval(id);callback.handleFaderComplete(elem);}
else if(document.all)
elem.style.filter='alpha(opacity='+elem.myOpacity+')';else
elem.style.opacity=(elem.myOpacity/100);},me.interval);}

var FORMAT_DATE_INPUT='MM/DD/YYYY';function Formatter(){}
Formatter.SHORT_MONTHS=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sept','Oct','Nov','Dec'];Formatter.SHORT_DAYS=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'];Formatter.LONG_DAYS=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'];Formatter.REGEX_CARRIAGE_RETURN=/\r\n/g;Formatter.REGEX_NEW_LINE=/\n/g;Formatter.toDisplayable=function(v)
{if(undefined==v)
return'';else if('string'==typeof(v))
return v.replace(this.REGEX_CARRIAGE_RETURN,'<br />').replace(this.REGEX_NEW_LINE,'<br />');else if('boolean'==typeof(v))
return v?'Yes':'No';else if('date'==typeof(v))
return this.toDate(v);else
return v;}
Formatter.toList=function(v)
{if(!v||(0==v.length))
return'';var a=v[0];for(var i=1;i<v.length;i++)
a+=', '+v[i];return a;}
Formatter.parseInt=function(v)
{var num=parseInt(v);if(isNaN(num))
return undefined;return num;}
Formatter.parseFloat=function(v)
{var num=parseFloat(v);if(isNaN(num))
return undefined;return num;}
Formatter.toWebsite=function(url,caption)
{if(!url)
return undefined;var a=document.createElement('a');url=(url.toLowerCase().substr(0,4)!='http')?'http://'+url:url;if(!caption)
caption=url;a.href=url;a.target='_blank';Elements.addText(a,caption);return a;}
Formatter.toEmail=function(v)
{if(!v)
return undefined;var a=document.createElement('a');a.href='mailto:'+v;a.target='_blank';Elements.addText(a,v);return a;}
Formatter.toAddress=function(v)
{var add1=v.address1;var add2=v.address2;var city=v.city;var state=v.stateId;var zip=v.zip;var country=v.country;var countryId=v.countryId;if(!add1&&!add2&&!city&&!state&&!zip&&!country)
return undefined;var o=document.createElement('span');o.className='address';var f=function(o,v)
{Elements.addText(o,v);Elements.addBreak(o);}
if(add1)
f(o,add1);if(add2)
f(o,add2);if(city)
{Elements.addText(o,city);if(state)
Elements.addText(o,', ');else if(zip)
Elements.addSpace();else
Elements.addBreak(o);}
if(state)
f(o,state+' '+this.toDisplayable(zip));else if(zip)
f(o,zip);if((country)&&(countryId!=COUNTRY_DEFAULT))
f(o,country);return o;}
Formatter.today=function(){return new Date(TODAY.getTime());}
Formatter.getTimezoneOffset=function()
{if(!this.timezoneOffset)
{var date=new Date();date.setHours(0,0,0,0);this.timezoneOffset=(TODAY.getTime()-date.getTime())/3600000;}
return this.timezoneOffset;}
Formatter.fromInputDate=function(whenString)
{var v=whenString.split('/');if(2>v.length)
throw'parseInputDate: "'+whenString+'" is not a valid date (MM/DD/YYYY).';var month=parseInt(v[0],10);var day=parseInt(v[1],10);if(isNaN(month)||(1>month)||(12<month))
throw'parseInputDate: "'+whenString+'" - month part is not a valid (MM/DD/YYYY).';if(isNaN(day)||(1>day)||(31<day))
throw'parseInputDate: "'+whenString+'" - day part is not a valid (MM/DD/YYYY).';month--;if(3>v.length)
return new Date((new Date()).getFullYear(),month,day,this.getTimezoneOffset());else
{var year=parseInt(v[2]);if(isNaN(year)||(0>year))
throw'parseInputDate: "'+whenString+'" - year part is not a valid (MM/DD/YYYY).';if(51>year)
year+=2000;else if(100>year)
year+=1900;return new Date(year,month,day,this.getTimezoneOffset());}}
Formatter.toInputDate=function(v)
{return(v.getUTCMonth()+1)+'/'+v.getUTCDate()+'/'+v.getUTCFullYear();}
Formatter.toDate=function(v)
{if(!v)
return undefined;return this.SHORT_DAYS[v.getUTCDay()]+', '+this.SHORT_MONTHS[v.getUTCMonth()]+' '+v.getUTCDate()+', '+v.getUTCFullYear();}
Formatter.toFullDate=function(v)
{if(!v)
return undefined;return this.LONG_DAYS[v.getUTCDay()]+', '+this.SHORT_MONTHS[v.getUTCMonth()]+' '+v.getUTCDate()+', '+v.getUTCFullYear();}
Formatter.toTimestamp=function(v)
{if(undefined==v)
return undefined;var hours=v.getHours();var hours_=(hours==0)?12:(hours>12)?hours-12:hours;return this.SHORT_DAYS[v.getDay()]+', '+this.SHORT_MONTHS[v.getMonth()]+' '+v.getDate()+', '+v.getFullYear()+' '+this.prePad(hours_,2)+':'+this.prePad(v.getMinutes(),2)+':'+this.prePad(v.getSeconds(),2)+' '+(hours<12?'AM':'PM');}
Formatter.prePad=function(num,digits)
{var value=num+'';for(i=value.length;i<digits;i++)
value='0'+value;return value;}
Formatter.round=function(value,places)
{var div=Math.pow(10,places);return(Math.round(value*div)/div);}
Formatter.toNumber=function(value,places)
{if(undefined==value)
return undefined;return this.toNumber_(value,places);}
Formatter.toNumber_=function(value,places)
{value+='';x=value.split('.');x1=x[0];x2=x.length>1?x[1]:'';if(undefined!=places)
while(x2.length<places)
x2+='0';if(0<x2.length)
x2='.'+x2;var rgx=/(\d+)(\d{3})/;while(rgx.test(x1))
x1=x1.replace(rgx,'$1'+','+'$2');return x1+x2;}
Formatter.toRoundedNumber=function(value,places)
{if(undefined==value)
return undefined;return this.toRoundedNumber_(value,places);}
Formatter.toRoundedNumber_=function(value,places)
{return this.toNumber_(this.round(value,places));}
Formatter.toPercent=function(v)
{if(undefined==v)
return undefined;return this.toRoundedNumber_(v,2);}
Formatter.toPrice=function(v)
{if(undefined==v)
return undefined;return this.toRoundedNumber_(v,4);}
Formatter.toDistance=function(v)
{if(undefined==v)
return'';return this.toRoundedNumber_(v,3);}
Formatter.toWeight=function(v)
{if(undefined==v)
return'';return this.toRoundedNumber_(v,3);}
Formatter.toPace=function(v)
{if(!v)
return'';var o=v.minutes+':';if(10>v.seconds)
o+='0';return o+Math.floor(v.seconds)+'/'+v.distanceUnit;}
Formatter.toPaceMilesX=function(distance,hours,minutes,seconds)
{return this.toPaceMiles({distanceMiles:this.parseFloat(distance),durationHours:this.parseInt(hours),durationMinutes:this.parseInt(minutes),durationSeconds:this.parseFloat(seconds)});}
Formatter.toPaceMiles=function(v)
{v.distance=v.distanceMiles;return this.toPace_(v,MILE_ABBR);}
Formatter.toPaceKmX=function(distance,hours,minutes,seconds)
{return this.toPaceKm({distanceKm:this.parseFloat(distance),durationHours:this.parseInt(hours),durationMinutes:this.parseInt(minutes),durationSeconds:this.parseFloat(seconds)});}
Formatter.toPaceKm=function(v)
{v.distance=v.distanceKm;return this.toPace_(v,KM_ABBR);}
Formatter.toPaceX=function(distance,hours,minutes,seconds,abbr)
{return this.toPace_({distance:this.parseFloat(distance),durationHours:this.parseInt(hours),durationMinutes:this.parseInt(minutes),durationSeconds:this.parseFloat(seconds)},abbr);}
Formatter.toPace_=function(v,abbr)
{if(!v.distance||(0==v.distance))
return'';var totalSeconds=this.toTotalSeconds(v);if(0==totalSeconds)
return'';var pace=totalSeconds/this.parseFloat(v.distance);var paceMinutes=parseInt(pace/60);var paceSeconds=parseInt(pace%60);if(10>paceSeconds)
paceSeconds='0'+paceSeconds;return paceMinutes+':'+paceSeconds+'/'+abbr;}
Formatter.toTotalSeconds=function(v)
{var totalSeconds=0;if(v.durationHours)
totalSeconds+=(this.parseInt(v.durationHours)*3600);if(v.durationMinutes)
totalSeconds+=(this.parseInt(v.durationMinutes)*60);if(v.durationSeconds)
totalSeconds+=this.parseFloat(v.durationSeconds);return totalSeconds;}
Formatter.fromTotalSeconds=function(seconds)
{return this.toDuration(this.fromTotalSecondsX(seconds));}
Formatter.fromTotalSecondsX=function(seconds)
{return{durationHours:parseInt(seconds/3600),durationMinutes:parseInt((seconds%3600)/60),durationSeconds:(seconds%60)};}
Formatter.toDurationX=function(v)
{var seconds=(undefined==v.durationSeconds)?undefined:parseInt(v.durationSeconds);return this.toDuration_(v.durationHours)+':'+
this.toDuration_(v.durationMinutes)+':'+
this.toDuration_(seconds);}
Formatter.toDuration=function(v)
{var seconds=(undefined==v.durationSeconds)?undefined:this.round(v.durationSeconds,2);return this.toDuration_(v.durationHours)+':'+
this.toDuration_(v.durationMinutes)+':'+
this.toDuration_(seconds);}
Formatter.toDuration_=function(item)
{if(9<item)
return item;else if(0<item)
return'0'+item;return'00';}
Formatter.roundDistance=function(v)
{return(Math.round(v*1000)/1000);}
Formatter.toKm=function(miles)
{return this.roundDistance(miles*MILES_TO_KM);}
Formatter.toMiles=function(km)
{return this.roundDistance(km/MILES_TO_KM);}
Formatter.toAvgMax=function(avg,max)
{if(!avg&&!max)
return undefined;var o='';if(avg)
o+=avg;o+=' / ';if(max)
o+=max;return o;}
Formatter.toTemperature=function(v)
{if(!v.temperatureName&&!v.temp&&!v.tempUnitId)
return undefined;var o=v.temperatureName;var t=(v.temp)?v.temp+' &deg;'+v.tempUnitId:undefined;if(o)
{if(t)
o+=' &mdash; '+t;}
else if(t)
o=t;return o}
Formatter.toHumidity=function(v)
{if(!v.humidityName&&!v.humidity)
return undefined;var o=v.humidityName;var t=v.humidity?v.humidity+'%':undefined;if(o)
{if(t)
o+=' &mdash; '+t;}
else if(t)
o=t;return o;}
Formatter.toWind=function(v)
{if(!v.windName&&!v.wind&&!v.windUnitId)
return undefined;var o=v.windName;var t=(v.wind)?v.wind+' '+v.windUnitName+' / Hour':undefined;if(o)
{if(t)
o+=' &mdash; '+t;}
else if(t)
o=t;return o}
Formatter.shorten=function(v,max)
{if(!v)
return'';if(v.length<=max)
return v;return v.substr(0,max)+' ...';}
Formatter.concatEquipUsage=function(v)
{var o='';if(!v)
return o;if(v.distanceUsed)
o+=(this.toDistance(v.distanceUsed)+' '+v.distanceUnitAbbr);if(v.expiration)
o+=(' of '+this.toDistance(v.expiration)+' '+v.distanceUnitAbbr);return o;}

function window_onLoad()
{globalInfo.init();if(window.initPage)
initPage();}
var globalInfo={};globalInfo.MESSAGE_PASSWORD_RESET='Your password has been successfully reset. You should receive an e-mail '+'shortly with your new password. If you do not receive an e-mail, please contact us at support@running-journal.com.';globalInfo.handleDropdownMenuSelect=function(item)
{if((undefined==item.id)||(0==item.id.length))
return;Linker[item.id]();}
globalInfo.init=function()
{this.menuBody=document.getElementById('pageMenu');this.quickLinksBody=document.getElementById('quickLinks');Linker.init(document.getElementById('mainContent'),document.getElementById('home'),document.getElementById('pageTitle'),document.getElementById('pageNav'),document.getElementById('blogTitle'),document.getElementById('blogContent'));this.trainingTotalsHandler=new TrainingTotalsSimple(caller,TrainingTotalsSmall);this.menu=new DropdownMenu(this);this.quickLinksViewer=QuickLinksDOM;var me=this;caller.getMe({handleRequestData:function(value){me.run(value);}});var cred=Cookies.getValue('cred');if(cred)
this.setCred(cred);}
globalInfo.handlePageError=function(error,url,data)
{if(error.message)
window.alert(error.message);else
Linker.openBugReport(error,url,data);return true;}
globalInfo.run=function(user)
{this.setUser(user);this.createMenu();if(user)
Linker.upgradeHomePage();}
globalInfo.setUser=function(user)
{this.user=user;this.isAuthenticated=(undefined!=user);this.loadSideNav();if(user)
{if(user.isAdmin)
caller.loadModule('/admin.js');if(user.isAuthor)
caller.loadModule('/author.js');}}
globalInfo.openTrainingTotals=function(elem,userId,trainingTypeId)
{var body=document.createElement('div');this.trainingTotalsHandler.doNow(body,userId,trainingTypeId);Popup.open(elem,body);}
globalInfo.notify=function(record)
{var me=this;var f=function(){me.loadSideNav();if(record.shoeId)
caller.getShoe(record.shoeId,{handleRequestData:function(value){Linker.deactivateShoe(value);}});else if(record.bikeId)
caller.getBike(record.bikeId,{handleRequestData:function(value){Linker.deactivateBike(value);}});else if(record.skiId)
caller.getSki(record.skiId,{handleRequestData:function(value){Linker.deactivateSki(value);}});};setTimeout(f,2500);}
globalInfo.loadSideNav=function()
{var elem;this.quickLinksBody.innerHTML='';this.quickLinksBody.appendChild(elem=this.quickLinksViewer.generate({value:this},this));if(elem.myFirstField)
elem.myFirstField.focus();}
globalInfo.doLogin=function(error)
{var retryInfo=error.retryInfo;if(this.loginInfo)
{var me=this;caller.login(this.loginInfo,{handleRequestData:function(value)
{if(value)
caller.asynchPostMap(retryInfo.url,retryInfo.map,retryInfo.callback);else
me.openLogin(error);},handleRequestError:function(e){me.openLogin(error);}});}
else
this.openLogin(error);}
globalInfo.openLogin=function(error)
{var output;var retryInfo=error.retryInfo;ModalDialog.open(CAPTION_LOGIN,output=LoginDOM.generate({value:this},this));output.myFirstField.focus();output.handlePostLogin=function(){ModalDialog.close();caller.asynchPostMap(retryInfo.url,retryInfo.map,retryInfo.callback);}}
globalInfo.handleLoginCancel=function(){ModalDialog.close();}
globalInfo.handleForgotPassword=function(form)
{var me=this;caller.resetPassword(form.userName.value,{handleRequestData:function(value){if(value.payload)
{window.alert(me.MESSAGE_PASSWORD_RESET);if(form.handlePostLogin)
form.handlePostLogin();}},handleRequestError:function(error){window.alert(error.message);if(error.field)
form[error.field].focus();}});}
globalInfo.login=function(form)
{var me=this;var info={userName:form.userName.value,password:form.password.value};if(form.rememberMe)
info.rememberMe=form.rememberMe.checked;caller.login(info,{handleRequestData:function(value){if(!value)
{window.alert('The e-mail address or password is invalid.');form.userName.focus();}
else
{me.loginInfo=info;me.run(value);if(value.sessionId)
{me.setCred(value.sessionId);value.sessionId=undefined;}
if(form.handlePostLogin)
form.handlePostLogin();}},handleRequestError:function(error){window.alert(error.message);if(error.field)
form[error.field].focus();}});}
globalInfo.logout=function()
{caller.logout({handleRequestData:function(value){Cookies.deleteValue('cred');}});this.user=undefined;this.isAuthenticated=false;this.loginInfo=undefined;this.run();Linker.gotoHome();}
globalInfo.getNotices=function(table,viewer)
{caller.getNotices({handleRequestData:function(value){viewer.createNotices(value,table);}});}
globalInfo.setCred=function(value)
{var now=new Date();now.setMonth(now.getMonth()+1);Cookies.setValue('cred',value,now);}
globalInfo.getBaseMenu=function()
{return[new DropdownMenuItem('listRoutes','Routes & Workouts',false,DropdownMenu.SIDE_BOTTOM,[new DropdownMenuItem('listRoutes','Training Routes',false,DropdownMenu.SIDE_RIGHT,[new DropdownMenuItem('listRoutes',TITLE_LIST_ROUTES),new DropdownMenuItem('addRoute',TITLE_ADD_ROUTE)]),new DropdownMenuItem('listWorkouts','Workouts',false,DropdownMenu.SIDE_RIGHT,[new DropdownMenuItem('listWorkouts',TITLE_LIST_WORKOUTS),new DropdownMenuItem('addWorkout',TITLE_ADD_WORKOUT)])]),new DropdownMenuItem('gotoCalendar','My Training',false,DropdownMenu.SIDE_BOTTOM,[new DropdownMenuItem('listRecentTraining',TITLE_LIST_RECENT_TRAINING),new DropdownMenuItem('gotoCalendar',TITLE_MY_CALENDAR),new DropdownMenuItem('searchTraining',TITLE_SEARCH_TRAINING),new DropdownMenuItem('searchCommunityTraining',TITLE_SEARCH_COMMUNITY_TRAINING),new DropdownMenuItem('addRun',TITLE_ADD_RUN),new DropdownMenuItem('addXtraining',TITLE_ADD_XTRAINING,false,DropdownMenu.SIDE_RIGHT,[new DropdownMenuItem('addXBike','Bike Workout'),new DropdownMenuItem('addXSwim','Swim Workout'),new DropdownMenuItem('addXSpin','Spin Workout'),new DropdownMenuItem('addXWalk','Walk'),new DropdownMenuItem('addXStairMaster','Stair Master'),new DropdownMenuItem('addXElliptical','Elliptical'),new DropdownMenuItem('addXWaterRun','Water Run'),new DropdownMenuItem('addXRowMachine','Row Machine'),new DropdownMenuItem('addXInlineSkating','Inline Skating'),new DropdownMenuItem('addXYoga','Yoga Session'),new DropdownMenuItem('addXPilates','Pilates Session')]),new DropdownMenuItem('sumTrainingByYear','Training Summaries',false,DropdownMenu.SIDE_RIGHT,[new DropdownMenuItem('sumTrainingByYear',TITLE_SUM_TRAINING_BY_YEAR),new DropdownMenuItem('sumTrainingByMonth',TITLE_SUM_TRAINING_BY_MONTH),new DropdownMenuItem('sumTrainingByWeek',TITLE_SUM_TRAINING_BY_WEEK)]),new DropdownMenuItem('chartTraining',TITLE_CHART_TRAINING),new DropdownMenuItem('gotoDashboard',TITLE_DASHBOARD),new DropdownMenuItem('gotoLeaderBoard',TITLE_LEADER_BOARD)]),new DropdownMenuItem('listShoes','Shoes & Bikes',false,DropdownMenu.SIDE_BOTTOM,[new DropdownMenuItem('listShoes','Shoes',false,DropdownMenu.SIDE_RIGHT,[new DropdownMenuItem('listShoes',TITLE_LIST_SHOES),new DropdownMenuItem('addShoe',TITLE_ADD_SHOE)]),new DropdownMenuItem('listBikes','Bikes',false,DropdownMenu.SIDE_RIGHT,[new DropdownMenuItem('listBikes',TITLE_LIST_BIKES),new DropdownMenuItem('addBike',TITLE_ADD_BIKE)]),new DropdownMenuItem('listSkis','Skis',false,DropdownMenu.SIDE_RIGHT,[new DropdownMenuItem('listSkis',TITLE_LIST_SKIS),new DropdownMenuItem('addSki',TITLE_ADD_SKI)])]),new DropdownMenuItem('listMyTeams','Teams',false,DropdownMenu.SIDE_BOTTOM,[new DropdownMenuItem('listMyTeams',TITLE_LIST_MY_TEAMS),new DropdownMenuItem('addTeam',TITLE_ADD_TEAM),new DropdownMenuItem('searchTeams',TITLE_SEARCH_TEAMS),new DropdownMenuItem('gotoTeamHelp',TITLE_TEAM_HELP)]),new DropdownMenuItem('editMyProfile','My Profile',false,DropdownMenu.SIDE_BOTTOM,[new DropdownMenuItem('editMyProfile',TITLE_EDIT_USER_PROFILE),new DropdownMenuItem('listEffortLevels',TITLE_LIST_EFFORT_LEVELS)]),new DropdownMenuItem('gotoGettingStarted','Help',false,DropdownMenu.SIDE_BOTTOM,[new DropdownMenuItem('gotoGettingStarted',TITLE_GETTING_STARTED),new DropdownMenuItem('gotoPRChartingHelp',TITLE_PR_CHARTING),new DropdownMenuItem('gotoSupport',TITLE_SUPPORT_PAGE),new DropdownMenuItem('openFeedbackRequest',TITLE_FEEDBACK)])];}
globalInfo.getMenu=function()
{var value=this.getBaseMenu();if(this.isAuthenticated)
value[value.length]=new DropdownMenuItem('logout',TITLE_LOGOUT);else
value[value.length]=new DropdownMenuItem('registerUser',TITLE_REGISTER_USER);return value;}
globalInfo.createMenu=function()
{this.menuBody.innerHTML='';this.menu.doItems(this.getMenu(),this.menuBody);}

function Inputter(){}
Inputter.generate=function(name,type,isChecked)
{if(document.all)
{var checked=isChecked?' checked':'';return document.createElement('<input name="'+name+'" type="'+type+'"'+checked+' />');}
var output=document.createElement('input');if(window.isSafari)output.id=name;output.name=name;output.type=type;output.checked=isChecked;return output;}
Inputter.genButton=function(name,caption,onclick)
{var output=this.generate(name,'button');output.value=caption;if(undefined!=onclick)
output.onclick=onclick;return output;}
Inputter.genButtonX=function(name,caption,onclick,cssClass)
{var output=this.genButton(name,'',onclick);output.className=cssClass;if(caption)
output.title=caption;return output;}
Inputter.genCheckBox=function(name,value,isChecked)
{var output=this.generate(name,'checkbox',isChecked);output.value=value;return output;}
Inputter.genFileInput=function(name,maxLength,size)
{var output=this.generate(name,'file');if(undefined!=maxLength)
{output.maxLength=maxLength;output.size=size;}
return output;}
Inputter.genHidden=function(name,value)
{var output=this.generate(name,'hidden');if(undefined!=value)
output.value=value;return output;}
Inputter.genImage=function(name,src,onclick)
{var output=this.generate(name,'image');output.src=src;if(undefined!=onclick)
output.onclick=onclick;return output;}
Inputter.genMultiPartForm=function(action,target)
{var output;if(document.all)
output=document.createElement('<form method="post" enctype="multipart/form-data" />');else
{output=document.createElement('form');output.method='post';output.enctype='multipart/form-data';}
output.action=action;if(undefined!=target)
output.target=target;return output;}
Inputter.genPassword=function(name,maxLength,size)
{var output=this.generate(name,'password');output.maxLength=maxLength;output.size=size;return output;}
Inputter.genRadio=function(name,value,isChecked)
{var output=this.generate(name,'radio',isChecked);output.value=value;return output;}
Inputter.genReset=function(name,caption)
{var output=this.generate(name,'reset');output.value=caption;return output;}
Inputter.genSubmit=function(name,caption)
{var output=this.generate(name,'submit');output.value=caption;return output;}
Inputter.genSubmitX=function(name,caption,cssClass)
{var output=this.genSubmit(name,'');output.className=cssClass;if(caption)
output.title=caption;return output;}
Inputter.genTextArea=function(name,cols,rows)
{var output=undefined;if(document.all)
{output=document.createElement('<textarea name="'+name+'" />');}
else
{var output=document.createElement('textarea');if(window.isSafari)output.id=name;output.name=name;}
if(undefined!=cols)output.cols=cols;if(undefined!=rows)output.rows=rows;return output;}
Inputter.genTextBox=function(name,maxLength,size)
{var output=this.generate(name,'text');if(maxLength)
output.maxLength=maxLength;if(size)
output.size=size;return output;}

var KeyCode={}
KeyCode.KEY_NULL=0;KeyCode.KEY_BACKSPACE=8;KeyCode.KEY_TAB=9;KeyCode.KEY_ENTER=13;KeyCode.KEY_ESCAPE=27;KeyCode.KEY_SPACE=32;KeyCode.KEY_PAGE_UP=33;KeyCode.KEY_PAGE_DOWN=34;KeyCode.KEY_END=35;KeyCode.KEY_HOME=36;KeyCode.KEY_LEFT=37;KeyCode.KEY_UP=38;KeyCode.KEY_RIGHT=39;KeyCode.KEY_DOWN=40;KeyCode.KEY_PAREN_OPEN=40;KeyCode.KEY_PAREN_CLOSED=41;KeyCode.KEY_PLUS=43;KeyCode.KEY_HYPHEN=45;KeyCode.KEY_ZERO=48;KeyCode.KEY_NINE=57;KeyCode.getCode=function(ev)
{if(window.event)
return window.event.keyCode;if(ev)
return ev.keyCode;return undefined;}

var Linker={};Linker.TD_DISPLAY_VALUE=document.all?'block':'table-cell';Linker.init=function(mainContent,homeBody,titleBody,pageNav,blogTitle,blogContent)
{var me=this;caller.getXtrainingTypes({handleRequestData:function(value){me.xtrainingTypes=value;}});homeBody.myHome=true;this.mainContent=mainContent;this.homeBody=this.currentBody=homeBody;this.titleBody=titleBody;this.pageNav=pageNav;this.blogTitle=blogTitle;this.blogContent=blogContent;this.bannerLeft=document.getElementById('bannerLeft');this.pageMenu=document.getElementById('pageMenu');this.footer=document.getElementById('footer');this.bodies={};this.handlers={};homeBody.myTitle=this.titleBody.innerHTML;this.bodies[homeBody.myTitle]=homeBody;this.historyUrl=localContextRoot+'/history.html?';this.startHistory();var a=this.SHOW_BLOG_HOME={};a[TITLE_DASHBOARD]=true;a[TITLE_GETTING_STARTED]=true;a[TITLE_PR_CHARTING_HELP]=true;a[TITLE_SUPPORT_PAGE]=true;this.fillBlogHome();}
Linker.getBody=function(title)
{var value=this.bodies[title];if(!value)
{this.mainContent.appendChild(this.bodies[title]=value=document.createElement('div'));value.className='contentArea';value.myTitle=title;}
return value;}
Linker.upgradeHomePage=function()
{if(isIndexPage&&this.currentBody.myHome)
this.gotoDashboard();}
Linker.getContainer=function()
{var elem=document.createElement('div');elem.className='widgetPackage';return elem;}
Linker.show=function(handler,title)
{var body=this.getBody(title);handler.init(body);this.swap(body);this.lastHandler=handler;this.lastTitle=title;}
Linker.doFilter=function(handler,title,filter)
{var body=this.getBody(title);handler.filter(filter,body);this.swap(body);this.lastHandler=handler;this.lastTitle=title;}
Linker.doLast=function()
{if(!this.lastHandler)
{this.gotoHome();return;}
this.lastHandler.doLast();this.swap(this.getBody(this.lastTitle));this.inflateAnchors(this.currentBody);}
Linker.swapByTitle=function(title)
{this.swap(this.getBody(title));}
Linker.swap=function(body,noHistory)
{if(body.myTitle!=this.currentBody.myTitle)
this.currentBody.style.display='none';this.currentBody.myAnchors=this.removeChildren(this.pageNav);if(!noHistory)
this.addHistory(this.currentBody);body.style.display='block';this.currentBody=body;this.titleBody.innerHTML=body.myTitle;this.toggleBlogHome();}
Linker.toggleBlogHome=function()
{var b=this.currentBody;var on=(b.myHome||this.SHOW_BLOG_HOME[b.myTitle]||b.myShowBlogHome);var value=on?this.TD_DISPLAY_VALUE:'none';this.blogTitle.style.display=this.blogContent.style.display=value;this.adjustLayoutForBlog(on);if(on)
this.fillBlogHome();}
Linker.adjustLayoutForBlog=function(on)
{this.bannerLeft.colSpan=on?3:2;this.footer.colSpan=this.pageMenu.colSpan=(on?5:4);}
Linker.doStatic=function(title,url)
{var handler=this.handlers[title];if(!handler)
handler=this.handlers[title]={caller:caller,url:url,init:function(body)
{this.lastBody=body;if(!body.isAlreadyLoaded)
{ProgressBar.start(body);this.caller.loadContent(this.url,{handleRequestData:function(value){ProgressBar.turnOff(body);body.innerHTML=value;body.isAlreadyLoaded=true;}});}},doLast:function(){this.init(this.lastBody);}};this.show(handler,title);}
Linker.addAnchor=function(title)
{var a=document.createElement('a');this.pageNav.appendChild(a);a.href='javascript:void(null)';a.appendChild(document.createTextNode(title));return a;}
Linker.addBackAnchor=function()
{var me=this,elem=this.addAnchor('<< Back');elem.onclick=function(ev){me.doLast();return false;};return elem;}
Linker.addLegendAnchor=function(viewer,keepAlive,criteria,callback)
{var elem=this.addAnchor(CAPTION_LEGEND);elem.className='legend';elem.onmouseover=function(ev){Popup.open(this,viewer.generate(criteria,callback),true,keepAlive);};elem.onmouseout=function(ev){Popup.close();};elem.onclick=function(ev){return false;};return elem;}
Linker.addSearchTraining=function()
{var me=this;this.addAnchor(CAPTION_SEARCH).onclick=function(ev){me.openSearchTraining();};}
Linker.addSearchCommunityTraining=function()
{var me=this;this.addAnchor(TITLE_SEARCH_COMMUNITY).onclick=function(ev){me.openSearchCommunityTraining();};}
Linker.addSubscribeAnchor=function(creatorId)
{var a=this.addAnchor(CAPTION_SUBSCRIBE);a.className='rss';a.href=RSS_URL+(creatorId?'?creatorId='+creatorId:'');a.target='_new';return a;}
Linker.addXtrainingAnchor=function()
{var me=this;var b=this.addLegendAnchor(this.ListItemDOM,true,this.xtrainingTypes,{handleSelect:function(c,r)
{me.addXtraining(undefined,undefined,r.id);Popup.close();}});b.innerHTML=TITLE_ADD_XTRAINING;b.onclick=function(ev){me.addXtraining();};}
Linker.addBike=function(callback)
{var me=this,handler=this.getEditBikeHandler(TITLE_ADD_BIKE)
handler.callback.handleComplete=function(criteria){ModalDialog.close();if(callback)
callback(criteria.value.value);else
me.listBikes();};handler.doAdd(this.getContainer());}
Linker.addBlogComment=function(blogId)
{this.getEditBlogCommentHandler(TITLE_ADD_BLOG_COMMENT).doAdd(this.getContainer(),blogId);}
Linker.replyBlogComment=function(commentId)
{this.getEditBlogCommentHandler(TITLE_REPLY_BLOG_COMMENT).doReply(commentId,this.getContainer());}
Linker.addBlogReport=function(commentId)
{this.getEditBlogReportHandler(TITLE_ADD_BLOG_REPORT).doAdd(this.getContainer(),commentId);}
Linker.addExercise=function(when)
{var body=this.getBody(TITLE_ADD_EXERCISE);this.getEditExerciseHandler().doAdd(body,when);this.swap(body);this.addBackAnchor();}
Linker.addHeartRateLog=function(when)
{this.getEditHeartRateLogHandler(TITLE_ADD_HEART_RATE_LOG).doAdd(this.getContainer(),when);}
Linker.addMenstruationLog=function(when)
{this.getEditMenstruationLogHandler(TITLE_ADD_MENSTRUATION_LOG).doAdd(this.getContainer(),when);}
Linker.addRoute=function(callback)
{var me=this,handler=this.getEditRouteHandler(TITLE_ADD_ROUTE)
handler.callback.handleComplete=function(criteria){ModalDialog.close();if(callback)
callback(criteria.value.value);else
me.listRoutes();};handler.doAdd(this.getContainer());}
Linker.addRun=function(when,teammate)
{var isFuture=(when&&(when.getTime()>(new Date()).getTime()));var body=this.getBody(isFuture?TITLE_ADD_RUN_FUTURE:TITLE_ADD_RUN);this.getEditRunHandler().doAdd(body,when,teammate);this.swap(body);this.addBackAnchor();}
Linker.addShoe=function(callback)
{var me=this,handler=this.getEditShoeHandler(TITLE_ADD_SHOE)
handler.callback.handleComplete=function(criteria)
{ModalDialog.close();if(callback)
callback(criteria.value.value);else
me.listShoes();};handler.doAdd(this.getContainer());}
Linker.addSki=function(callback)
{var me=this,handler=this.getEditSkiHandler(TITLE_ADD_SKI)
handler.callback.handleComplete=function(criteria)
{ModalDialog.close();if(callback)
callback(criteria.value.value);else
me.listSkis();};handler.doAdd(this.getContainer());}
Linker.addSleepLog=function(when)
{this.getEditSleepLogHandler(TITLE_ADD_SLEEP_LOG).doAdd(this.getContainer(),when);}
Linker.addTeam=function()
{var body=this.getBody(TITLE_ADD_TEAM);this.getEditTeamHandler().doAdd(body);this.swap(body);this.addBackAnchor();}
Linker.addWeightLog=function(when)
{this.getEditWeightLogHandler(TITLE_ADD_WEIGHT_LOG).doAdd(this.getContainer(),when);}
Linker.addWorkout=function(callback)
{var me=this,handler=this.getEditWorkoutHandler(TITLE_ADD_WORKOUT,(undefined!=callback))
handler.callback.handleComplete=function(criteria){ModalDialog.close();var record=criteria.value.value;if(callback)
callback(record);else
{me.listWorkouts();if(record.isContinue)me.listWorkoutDetails(record.id);}};handler.doAdd(this.getContainer());}
Linker.addXtraining=function(when,teammate,typeId)
{var body=this.getBody(TITLE_ADD_XTRAINING);this.getEditXtrainingHandler().doAdd(body,when,teammate,typeId);this.swap(body);this.addBackAnchor();}
Linker.addXBike=function(when,teammate){this.addXtraining(when,teammate,'BIKE');}
Linker.addXSwim=function(when,teammate){this.addXtraining(when,teammate,'SWIM');}
Linker.addXSpin=function(when,teammate){this.addXtraining(when,teammate,'SPIN');}
Linker.addXWalk=function(when,teammate){this.addXtraining(when,teammate,'WALK');}
Linker.addXStairMaster=function(when,teammate){this.addXtraining(when,teammate,'STR');}
Linker.addXElliptical=function(when,teammate){this.addXtraining(when,teammate,'ELIP');}
Linker.addXWaterRun=function(when,teammate){this.addXtraining(when,teammate,'WRUN');}
Linker.addXRowMachine=function(when,teammate){this.addXtraining(when,teammate,'ROWM');}
Linker.addXInlineSkating=function(when,teammate){this.addXtraining(when,teammate,'ISKT');}
Linker.addXAerobics=function(when,teammate){this.addXtraining(when,teammate,'AERO');}
Linker.addXYoga=function(when,teammate){this.addXtraining(when,teammate,'YOGA');}
Linker.addXPilates=function(when,teammate){this.addXtraining(when,teammate,'PIL');}
Linker.addXSoccer=function(when,teammate){this.addXtraining(when,teammate,'SOC');}
Linker.addXCrossCountrySkiing=function(when,teammate){this.addXtraining(when,teammate,'XSKI');}
Linker.addXIceSkating=function(when,teammate){this.addXtraining(when,teammate,'ICESK');}
Linker.addXSkiing=function(when,teammate){this.addXtraining(when,teammate,'SKI');}
Linker.addXSnowshoeing=function(when,teammate){this.addXtraining(when,teammate,'SNSH');}
Linker.addXMartialArts=function(when,teammate){this.addXtraining(when,teammate,'MART');}
Linker.gotoCalendar=function()
{this.show(this.getCalendarHandler(),TITLE_MY_CALENDAR);this.addLegendAnchor(TrainingIconLegendDOM,true);}
Linker.chartTraining=function()
{this.show(this.getTrainingChartHandler(),TITLE_CHART_TRAINING);}
Linker.copyBike=function(id)
{this.getEditBikeHandler(TITLE_COPY_BIKE).doCopy(id,this.getContainer());}
Linker.copyRoute=function(id)
{this.getEditRouteHandler(TITLE_COPY_ROUTE).doCopy(id,this.getContainer());}
Linker.copyRun=function(id)
{var body=this.getBody(TITLE_COPY_RUN);this.getEditRunHandler().doCopy(id,body);this.swap(body);this.addBackAnchor();}
Linker.copyShoe=function(id)
{this.getEditShoeHandler(TITLE_COPY_SHOE).doCopy(id,this.getContainer());}
Linker.copySki=function(id)
{this.getEditSkiHandler(TITLE_COPY_SKI).doCopy(id,this.getContainer());}
Linker.copyWorkout=function(id)
{this.getEditWorkoutHandler(TITLE_COPY_WORKOUT).doCopy(id,this.getContainer());}
Linker.copyXtraining=function(id)
{var body=this.getBody(TITLE_COPY_XTRAINING);this.getEditXtrainingHandler().doCopy(id,body);this.swap(body);this.addBackAnchor();}
Linker.gotoDashboard=function()
{this.show(this.getDashboardHandler(),TITLE_DASHBOARD);var me=this;var a=this.addAnchor(CAPTION_REFRESH);a.className='refresh';a.onclick=function(ev){me.getDashboardHandler().doLast();};}
Linker.deactivateBike=function(record)
{if(!record.isExpired||!record.warnWhenExpired)
return;if(!window.confirm(record.desc+' has expired. To deactivate the warning, click OK to edit the '+CAPTION_BIKE+'.'))
return;var handler=this.getEditBikeHandler(TITLE_EDIT_BIKE);handler.callback.handleComplete=function(criteria){ModalDialog.close();};handler.doEdit(record.id,this.getContainer());}
Linker.deactivateShoe=function(record)
{if(!record.isExpired||!record.warnWhenExpired)
return;if(!window.confirm(record.desc+' has expired. To deactivate the warning, click OK to edit the '+CAPTION_SHOE+'.'))
return;var handler=this.getEditShoeHandler(TITLE_EDIT_SHOE);handler.callback.handleComplete=function(criteria){ModalDialog.close();};handler.doEdit(record.id,this.getContainer());}
Linker.deactivateSki=function(record)
{if(!record.isExpired||!record.warnWhenExpired)
return;if(!window.confirm(record.desc+' has expired. To deactivate the warning, click OK to edit the '+CAPTION_SKI+'.'))
return;var handler=this.getEditSkiHandler(TITLE_EDIT_SKI);handler.callback.handleComplete=function(criteria){ModalDialog.close();};handler.doEdit(record.id,this.getContainer());}
Linker.editBike=function(id)
{this.getEditBikeHandler(TITLE_EDIT_BIKE).doEdit(id,this.getContainer());}
Linker.editExercise=function(id)
{var body=this.getBody(TITLE_EDIT_EXERCISE);this.getEditExerciseHandler().doEdit(id,body);this.swap(body);this.addBackAnchor();}
Linker.editHeartRateLog=function(id)
{this.getEditHeartRateLogHandler(TITLE_EDIT_HEART_RATE_LOG).doEdit(id,this.getContainer());}
Linker.editMenstruationLog=function(id)
{this.getEditMenstruationLogHandler(TITLE_EDIT_MENSTRUATION_LOG).doEdit(id,this.getContainer());}
Linker.editMyProfile=function()
{var me=this,handler=this.getEditUserProfiler();handler.callback.redirect=function(){me.doLast();};var body=this.getBody(TITLE_EDIT_USER_PROFILE);handler.doMe(body);this.swap(body);this.addBackAnchor();}
Linker.editRoute=function(id)
{this.getEditRouteHandler(TITLE_EDIT_ROUTE).doEdit(id,this.getContainer());}
Linker.editRun=function(id)
{var body=this.getBody(TITLE_EDIT_RUN);this.getEditRunHandler().doEdit(id,body);this.swap(body);this.addBackAnchor();}
Linker.editRunFuture=function(id)
{var body=this.getBody(TITLE_EDIT_RUN_FUTURE);this.getEditRunHandler().doEditFuture(id,body);this.swap(body);this.addBackAnchor();}
Linker.editShoe=function(id)
{this.getEditShoeHandler(TITLE_EDIT_SHOE).doEdit(id,this.getContainer());}
Linker.editSki=function(id)
{this.getEditSkiHandler(TITLE_EDIT_SKI).doEdit(id,this.getContainer());}
Linker.editSleepLog=function(id)
{this.getEditSleepLogHandler(TITLE_EDIT_SLEEP_LOG).doEdit(id,this.getContainer());}
Linker.editTeam=function(id)
{var body=this.getBody(TITLE_EDIT_TEAM);this.getEditTeamHandler().doEdit(id,body);this.swap(body);this.addBackAnchor();}
Linker.editTeamMember=function(id)
{var body=this.getBody(TITLE_EDIT_TEAM_MEMBER);this.getEditTeamMemberHandler().doEdit(id,body);this.swap(body);this.addBackAnchor();}
Linker.editWeightLog=function(id)
{this.getEditWeightLogHandler(TITLE_EDIT_WEIGHT_LOG).doEdit(id,this.getContainer());}
Linker.editWorkout=function(id)
{this.getEditWorkoutHandler(TITLE_EDIT_WORKOUT).doEdit(id,this.getContainer());}
Linker.editXtraining=function(id)
{var body=this.getBody(TITLE_EDIT_XTRAINING);this.getEditXtrainingHandler().doEdit(id,body);this.swap(body);this.addBackAnchor();}
Linker.emailBlog=function(id)
{this.getEmailBlogHandler().doById(id,this.getContainer());}
Linker.exportTraining=function(filter)
{var extension=filter.exportReportTypeId.toLowerCase();var url=localContextRoot+'/member/ExportTraining.'+extension+'?'+AjaxHelper.serializeParams(filter);window.open(url);}
Linker.fillTrainingInfo=function(parent,body)
{var elem;var handler=parent.isRun?this.getDetailRunHandler():this.getDetailXtrainingHandler();var listHandler=parent.isRun?this.getListRunDetailsHandler():this.getListXtrainingDetailsHandler();body.appendChild(elem=document.createElement('div'));elem.className='widgetPackage';handler.doById(parent.id,elem);body.appendChild(elem=document.createElement('h3'));elem.innerHTML=CAPTION_SPLITS;body.appendChild(elem=document.createElement('div'));elem.className='widgetPackage';listHandler.doParent(parent.id,elem);}
Linker.gotoGettingStarted=function()
{this.doStatic(TITLE_GETTING_STARTED,'/gettingStarted.jsp');}
Linker.gotoHome=function()
{if(globalInfo.isAuthenticated)
this.gotoDashboard();else
this.swap(this.homeBody);}
Linker.inviteNewMembers=function(id)
{this.getInviteNewTeamMembersHandler(TITLE_INVITE_NEW_MEMBERS).doParent(id,this.getContainer());}
Linker.gotoLeaderBoard=function()
{this.show(this.getLeaderBoardHandler(),TITLE_LEADER_BOARD);}
Linker.listBikes=function()
{this.show(this.getListBikesHandler(),TITLE_LIST_BIKES);var me=this;this.addAnchor(TITLE_ADD_BIKE).onclick=function(ev){me.addBike();return false;};}
Linker.listBlogs=function(filter,title)
{if(!title)
title=TITLE_LIST_BLOGS;this.doFilter(this.getListBlogsHandler(),title,filter);var me=this;this.addAnchor(CAPTION_SEARCH).onclick=function(ev){me.openSearchBlogs(filter);};if(this.addBlog)
this.addAnchor(TITLE_ADD_BLOG).onclick=function(ev){me.addBlog();};this.addSubscribeAnchor();}
Linker.listRecentBlogs=function(){this.listBlogs({statusId:BLOG_STATUS_LIVE},TITLE_BLOG_HOME);}
Linker.fillBlogHome=function()
{this.getListBlogsMiniHandler().filter({statusId:BLOG_STATUS_LIVE},this.blogContent);}
Linker.listCommunityTraining=function(filter)
{this.doFilter(this.getListCommunityTrainingHandler(),TITLE_LIST_SEARCHED_COMMUNITY_TRAINING,filter);var me=this;this.addSearchTraining();this.addAnchor(TITLE_SEARCH_COMMUNITY).onclick=function(ev){me.openSearchCommunityTraining(filter);};this.addAnchor(TITLE_ADD_RUN).onclick=function(ev){me.addRun();};this.addXtrainingAnchor();}
Linker.listEffortLevels=function()
{this.show(this.getListEffortLevelsHandler(),TITLE_LIST_EFFORT_LEVELS);}
Linker.listRecentTraining=function()
{var h,me=this;this.show(h=this.getListTrainingHandler(),TITLE_LIST_RECENT_TRAINING);this.addSearchTraining();this.addSearchCommunityTraining();this.addAnchor(TITLE_ADD_RUN).onclick=function(ev){me.addRun();};this.addXtrainingAnchor();h.callback.handlePostLoad=function()
{caller.getTeamMatesWithViewableLogs({handleRequestData:function(value){var records=value.records;if(!records||(0==records.length))
return;var a=me.addLegendAnchor(TeammatesListDOM,true,value,{handleSelect:function(c,r)
{me.getListTrainingHandler().doRecent(r.id,me.currentBody);Popup.close();a.innerHTML=(r.id?r.name:CAPTION_TEAMMATES);}});a.innerHTML=CAPTION_TEAMMATES;}});h.callback.handlePostLoad=null;};}
Linker.listRecentTrainingX=function(userId,name)
{var body=this.getBody(name+'\'s '+CAPTION_TRAINING);this.getListTrainingHandler().doRecent(userId,body);this.swap(body);this.addBackAnchor();}
Linker.listRoutes=function()
{this.show(this.getListRoutesHandler(),TITLE_LIST_ROUTES);var me=this;this.addAnchor(TITLE_ADD_ROUTE).onclick=function(ev){me.addRoute();return false;};}
Linker.listRunDetails=function(parentId)
{var body=this.getBody(TITLE_LIST_RUN_DETAILS);this.getEditRunDetailsHandler().doParent(parentId,body);this.swap(body);this.addBackAnchor();}
Linker.listRunFutureDetails=function(parentId)
{var body=this.getBody(TITLE_LIST_RUN_DETAILS);this.getEditRunFutureDetailsHandler().doParent(parentId,body);this.swap(body);this.addBackAnchor();}
Linker.listShoes=function()
{this.show(this.getListShoesHandler(),TITLE_LIST_SHOES);var me=this;this.addAnchor(TITLE_ADD_SHOE).onclick=function(ev){me.addShoe();return false;};}
Linker.listSkis=function()
{this.show(this.getListSkisHandler(),TITLE_LIST_SKIS);var me=this;this.addAnchor(TITLE_ADD_SKI).onclick=function(ev){me.addSki();return false;};}
Linker.listMyTeams=function()
{this.show(this.getListTeamsHandler(),TITLE_LIST_MY_TEAMS);var me=this;this.addAnchor(CAPTION_SEARCH).onclick=function(ev){me.openSearchTeams();return false;};this.addAnchor(TITLE_ADD_TEAM).onclick=function(ev){me.addTeam();return false;};this.addLegendAnchor(TeamIconLegendDOM);}
Linker.listTeams=function(filter)
{this.doFilter(this.getListTeamsHandler(),TITLE_LIST_SEARCHED_TEAMS,filter);var me=this;this.addAnchor(CAPTION_SEARCH).onclick=function(ev){me.openSearchTeams(filter);};this.addAnchor(TITLE_ADD_TEAM).onclick=function(ev){me.addTeam();return false;};this.addLegendAnchor(TeamIconLegendDOM);}
Linker.listTeamMembers=function(id)
{var body=this.getBody(TITLE_LIST_TEAM_MEMBERS);this.getListTeamMembersHandler().doParent(id,body);this.swap(body);this.addBackAnchor();this.addLegendAnchor(TeamIconLegendDOM);}
Linker.listTraining=function(filter)
{this.doFilter(this.getListTrainingHandler(),TITLE_LIST_SEARCHED_TRAINING,filter);var me=this;this.addAnchor(CAPTION_SEARCH).onclick=function(ev){me.openSearchTraining(filter);};this.addSearchCommunityTraining();this.addAnchor(TITLE_ADD_RUN).onclick=function(ev){me.addRun();};this.addXtrainingAnchor();}
Linker.listWorkouts=function()
{this.show(this.getListWorkoutsHandler(),TITLE_LIST_WORKOUTS);var me=this;this.addAnchor(TITLE_ADD_WORKOUT).onclick=function(ev){me.addWorkout();return false;};}
Linker.listWorkoutDetails=function(parentId)
{var body=this.getBody(TITLE_LIST_WORKOUT_DETAILS);this.getListWorkoutDetailsHandler().doParent(parentId,body);this.swap(body);this.addBackAnchor();}
Linker.listXtrainingDetails=function(parentId)
{var body=this.getBody(TITLE_LIST_XTRAINING_DETAILS);this.getEditXtrainingDetailsHandler().doParent(parentId,body);this.swap(body);this.addBackAnchor();}
Linker.login=function(form){globalInfo.login(form);}
Linker.logout=function(){globalInfo.logout();}
Linker.manageTeamMembers=function(id)
{var body=this.getBody(TITLE_MANAGE_TEAM_MEMBERS);this.getEditTeamMembersHandler().doParent(id,body);this.swap(body);this.addBackAnchor();this.addLegendAnchor(TeamIconLegendDOM);}
Linker.openBugReport=function(message,url,payload)
{var value={message:message,url:url,payload:payload};this.getEditFeedbackHandler(TITLE_BUG_REPORT).doError(value,this.getContainer());}
Linker.openFeedbackRequest=function()
{this.getEditFeedbackHandler(TITLE_OPEN_FEEDBACK_REQUEST).open(this.getContainer());}
Linker.gotoPRChartingHelp=function()
{this.doStatic(TITLE_PR_CHARTING_HELP,'/prChartingHelp.jsp');}
Linker.registerUser=function()
{var me=this,handler=this.getEditUserProfiler();handler.callback.redirect=function(){me.gotoGettingStarted();};var body=this.getBody(TITLE_REGISTER_USER);handler.register(body);this.swap(body);this.addBackAnchor();}
Linker.requestToJoinTeam=function(record)
{if(!window.confirm('You have selected to send a Join Team Request to '+record.name+'. Click OK to continue.'))
return false;var me=this;caller.requestToJoinTeam(record.id,{handleRequestData:function(value){window.alert('Your request has been sent to '+record.name+'. You will be notified when it is accepted.');me.doLast();}});}
Linker.searchBlogs=function()
{var me=this;h=this.getSearchBlogsHandler();h.callback.handleComplete=function(c,f){this.finish(c,f);};h.callback.handlePostLoad=function(c,o){this.start(c,o);};h.callback.handleCancel=function(c){me.doLast();};this.show(h,TITLE_SEARCH_BLOGS);}
Linker.openSearchBlogs=function(filter)
{var me=this;h=this.getSearchBlogsHandler();h.callback.handleComplete=function(c,f){this.finish(c,f);ModalDialog.close();};h.callback.handlePostLoad=function(c,o){ModalDialog.open(TITLE_SEARCH_BLOGS,c.body);this.start(c,o);};h.callback.handleCancel=function(c){ModalDialog.close();};var b=this.getContainer();if(filter)
h.filter(filter,b);else
h.init(b);}
Linker.searchCommunityTraining=function()
{var me=this,handler=this.getSearchCommunityTrainingHandler();handler.callback.handleComplete=function(criteria,filter){this.finish(criteria,filter);};handler.callback.handlePostLoad=function(criteria,output){this.start(criteria,output);};handler.callback.handleCancel=function(criteria){me.doLast();};this.show(handler,TITLE_SEARCH_COMMUNITY_TRAINING);}
Linker.openSearchCommunityTraining=function(filter)
{var handler=this.getSearchCommunityTrainingHandler();handler.callback.handleComplete=function(criteria,filter){this.finish(criteria,filter);ModalDialog.close();};handler.callback.handlePostLoad=function(criteria,output){ModalDialog.open(TITLE_SEARCH_COMMUNITY_TRAINING,criteria.body);this.start(criteria,output);};handler.callback.handleCancel=function(criteria){ModalDialog.close();};var body=this.getContainer();if(filter)
handler.filter(filter,body);else
handler.init(body);}
Linker.searchTeams=function()
{var me=this,handler=this.getSearchTeamsHandler();handler.callback.handleComplete=function(criteria,filter){this.finish(criteria,filter);};handler.callback.handlePostLoad=function(criteria,output){this.start(criteria,output);};handler.callback.handleCancel=function(criteria){me.doLast();};this.show(handler,TITLE_SEARCH_TEAMS);}
Linker.openSearchTeams=function(filter)
{var me=this,handler=this.getSearchTeamsHandler();handler.callback.handleComplete=function(criteria,filter){this.finish(criteria,filter);ModalDialog.close();};handler.callback.handlePostLoad=function(criteria,output){ModalDialog.open(TITLE_SEARCH_TEAMS,criteria.body);this.start(criteria,output);};handler.callback.handleCancel=function(criteria){ModalDialog.close();};var body=this.getContainer();if(filter)
handler.filter(filter,body);else
handler.init(body);}
Linker.searchTraining=function()
{var me=this,handler=this.getSearchTrainingHandler();handler.callback.handleComplete=function(criteria,filter){this.finish(criteria,filter);};handler.callback.handlePostLoad=function(criteria,output){this.start(criteria,output);};handler.callback.handleCancel=function(criteria){me.doLast();};this.show(handler,TITLE_SEARCH_TRAINING);}
Linker.openSearchTraining=function(filter)
{var handler=this.getSearchTrainingHandler();handler.callback.handleComplete=function(criteria,filter){this.finish(criteria,filter);ModalDialog.close();};handler.callback.handlePostLoad=function(criteria,output){ModalDialog.open(TITLE_SEARCH_TRAINING,criteria.body);this.start(criteria,output);};handler.callback.handleCancel=function(criteria){ModalDialog.close();};var body=this.getContainer();if(filter)
handler.filter(filter,body);else
handler.init(body);}
Linker.sendTeamEmail=function(id)
{this.getSendTeamEmailHandler(TITLE_SEND_TEAM_EMAIL).doParent(id,this.getContainer());}
Linker.shareTeamResources=function(id)
{this.getShareTeamResourcesHandler(TITLE_SHARE_TEAM_RESOURCES).doParent(id,this.getContainer());}
Linker.sumTeamTraining=function(id)
{var body=this.getBody(TITLE_TEAM_TRAINING_SUMMARY);this.getTeamMemberSummaryHandler().doParent(id,body);this.swap(body);this.addBackAnchor();}
Linker.sumTrainingByYear=function()
{var body=this.getBody(TITLE_TRAINING_SUMMARY);this.getSumTrainingHandler().byYear(body);this.swap(body);}
Linker.sumTrainingByMonth=function()
{var body=this.getBody(TITLE_TRAINING_SUMMARY);this.getSumTrainingHandler().byMonth(body);this.swap(body);}
Linker.sumTrainingByWeek=function()
{var body=this.getBody(TITLE_TRAINING_SUMMARY);this.getSumTrainingHandler().byWeek(body);this.swap(body);}
Linker.gotoSupport=function()
{this.doStatic(TITLE_SUPPORT_PAGE,'/support.jsp');}
Linker.gotoTeamHelp=function()
{this.doStatic(TITLE_TEAM_HELP,'/teamHelp.jsp');}
Linker.viewBlog=function(record)
{var body=this.getBody(record.creatorName+'\'s '+CAPTION_BLOG);body.myShowBlogHome=true;this.getDetailBlogHandler().doById(record.id,body);this.swap(body);this.addBackAnchor();this.addSubscribeAnchor(record.creatorId);}
Linker.viewBlogById=function(id)
{var me=this;caller.getBlog(id,{handleRequestData:function(value){me.viewBlog(value);}});}
Linker.viewRequestsToJoinTeam=function()
{this.getMembershipRequestsHandler(TITLE_VIEW_REQUESTS_TO_JOIN_TEAM).init(this.getContainer());}
Linker.viewExercise=function(id)
{var body=this.getBody(TITLE_VIEW_EXERCISE);this.getDetailExerciseHandler().doById(id,body);this.swap(body);this.addBackAnchor();}
Linker.viewRun=function(id)
{var body=this.getBody(TITLE_VIEW_RUN);this.getDetailRunHandler().doById(id,body);this.swap(body);this.addBackAnchor();}
Linker.viewRunDetails=function(id)
{var body=this.getBody(TITLE_VIEW_RUN_DETAILS);this.getListRunDetailsHandler().doParent(id,body);this.swap(body);this.addBackAnchor();}
Linker.viewRunFuture=function(id)
{var body=this.getBody(TITLE_VIEW_RUN_FUTURE);this.getDetailRunFutureHandler().doById(id,body);this.swap(body);this.addBackAnchor();}
Linker.viewTeam=function(id)
{var body=this.getBody(TITLE_VIEW_TEAM);this.getDetailTeamHandler().doById(id,body);this.swap(body);this.addBackAnchor();}
Linker.viewTeamInvitation=function(id)
{this.getMembershipInvitesHandler(TITLE_VIEW_TEAM_INVITATION).doParent(id,this.getContainer());}
Linker.viewTeamInvitations=function()
{this.getMembershipInvitesHandler(TITLE_VIEW_TEAM_INVITATIONS).init(this.getContainer());}
Linker.viewXtraining=function(id)
{var body=this.getBody(TITLE_VIEW_XTRAINING);this.getDetailXtrainingHandler().doById(id,body);this.swap(body);this.addBackAnchor();}
Linker.viewXtrainingDetails=function(id)
{var body=this.getBody(TITLE_VIEW_XTRAINING_DETAILS);this.getListXtrainingDetailsHandler().doParent(id,body);this.swap(body);this.addBackAnchor();}
Linker.getCalendarHandler=function()
{if(!this.calendarHandler)
this.calendarHandler=new CalendarSimple(caller,CalendarDOM,this);return this.calendarHandler;}
Linker.getDashboardHandler=function()
{if(!this.dashboardHandler)
this.dashboardHandler=new DashboardSimple(caller,ListTrainingMini,10,this);return this.dashboardHandler;}
Linker.getDetailBlogHandler=function()
{if(!this.detailBlogHandler)
{var me=this;this.detailBlogHandler=new DetailBlogSimple(caller,DetailBlogDOM,{handleEmail:function(c){me.emailBlog(c.value.id);}});}
return this.detailBlogHandler;}
Linker.getDetailExerciseHandler=function()
{if(!this.detailExerciseHandler)
this.detailExerciseHandler=new DetailExerciseSimple(caller,DetailExerciseDOM);var me=this;this.detailExerciseHandler.callback={handleCancel:function(criteria){me.doLast();}};return this.detailExerciseHandler;}
Linker.getDetailRunHandler=function()
{if(!this.detailRunHandler)
this.detailRunHandler=new DetailRunSimple.getInstance(caller,DetailRunDOM,this);return this.detailRunHandler;}
Linker.getDetailRunFutureHandler=function()
{if(!this.detailRunFutureHandler)
this.detailRunFutureHandler=new DetailRunSimple.getFutureInstance(caller,DetailRunDOM,this);return this.detailRunFutureHandler;}
Linker.getDetailTeamHandler=function()
{if(!this.detailTeamHandler)
this.detailTeamHandler=new DetailTeamSimple(caller,DetailTeamDOM);return this.detailTeamHandler;}
Linker.getDetailXtrainingHandler=function()
{if(!this.detailXtrainingHandler)
this.detailXtrainingHandler=new DetailXtrainingSimple(caller,DetailXtrainingDOM,this);return this.detailXtrainingHandler;}
Linker.getEditBikeHandler=function(title)
{if(!this.editBikeHandler)
this.editBikeHandler=new EditEquipmentSimple.getBikeInstance(caller,EditEquipmentDOM);var me=this;this.editBikeHandler.callback={handleComplete:function(criteria){ModalDialog.close();me.getListBikesHandler().doLast();},handlePostLoad:function(criteria,o){ModalDialog.open(title,criteria.body);o.myFirstField.focus();},handleCancel:function(criteria){ModalDialog.close();}};return this.editBikeHandler;}
Linker.getEditBlogCommentHandler=function(title)
{if(!this.editBlogCommentHandler)
this.editBlogCommentHandler=new EditBlogCommentSimple(caller,EditBlogCommentDOM);var me=this;this.editBlogCommentHandler.callback={handleComplete:function(c){ModalDialog.close();me.getListBlogCommentsHandler().doLast();},handlePostLoad:function(c,o){ModalDialog.open(title,c.body);o.myFirstField.focus();},handleCancel:function(c){ModalDialog.close();}};return this.editBlogCommentHandler;}
Linker.getEditBlogReportHandler=function(title)
{if(!this.editBlogReportHandler)
this.editBlogReportHandler=new EditBlogReportSimple(caller,EditBlogReportDOM);var me=this;this.editBlogReportHandler.callback={handleComplete:function(c){ModalDialog.close();},handlePostLoad:function(c,o){ModalDialog.open(title,c.body);o.myFirstField.focus();},handleCancel:function(c){ModalDialog.close();}};return this.editBlogReportHandler;}
Linker.getEditExerciseHandler=function()
{if(!this.editExerciseHandler)
this.editExerciseHandler=new EditExerciseSimple(caller,EditExerciseDOM);var me=this;this.editExerciseHandler.callback={handleComplete:function(criteria){me.doLast();},handleCancel:function(criteria){me.doLast();}};return this.editExerciseHandler;}
Linker.getEditFeedbackHandler=function(title)
{if(!this.editFeedbackHandler)
this.editFeedbackHandler=new EditFeedbackSimple(caller,EditFeedbackDOM);var me=this;this.editFeedbackHandler.callback={handleComplete:function(criteria){ModalDialog.close();},handlePostLoad:function(criteria,o){ModalDialog.open(title,criteria.body);o.myFirstField.focus();},handleCancel:function(criteria){ModalDialog.close();}};return this.editFeedbackHandler;}
Linker.getEditHeartRateLogHandler=function(title)
{if(!this.editHeartRateLogHandler)
this.editHeartRateLogHandler=new EditHeartRateLogSimple(caller,EditHeartRateLogDOM);var me=this;this.editHeartRateLogHandler.callback={handleComplete:function(criteria){ModalDialog.close();me.doLast();},handlePostLoad:function(criteria,o){ModalDialog.open(title,criteria.body);o.myFirstField.focus();},handleCancel:function(criteria){ModalDialog.close();}};return this.editHeartRateLogHandler;}
Linker.getEditMenstruationLogHandler=function(title)
{if(!this.editMenstruationLogHandler)
this.editMenstruationLogHandler=new EditMenstruationLogSimple(caller,EditMenstruationLogDOM);var me=this;this.editMenstruationLogHandler.callback={handleComplete:function(criteria){ModalDialog.close();me.doLast();},handlePostLoad:function(criteria,o){ModalDialog.open(title,criteria.body);o.myFirstField.focus();},handleCancel:function(criteria){ModalDialog.close();}};return this.editMenstruationLogHandler;}
Linker.getEditRouteHandler=function(title)
{if(!this.editRouteHandler)
this.editRouteHandler=new EditRouteSimple(caller,EditRouteDOM);var me=this;this.editRouteHandler.callback={handleComplete:function(criteria){ModalDialog.close();me.getListRoutesHandler().doLast();},handlePostLoad:function(criteria,o){ModalDialog.open(title,criteria.body);o.myFirstField.focus();},handleCancel:function(criteria){ModalDialog.close();}};return this.editRouteHandler;}
Linker.getEditRunHandler=function()
{if(!this.editRunHandler)
this.editRunHandler=new EditTrainingSimple.getRunInstance(caller,EditRunDOM);var me=this;this.editRunHandler.callback={handleComplete:function(criteria)
{me.doLast();var record=criteria.value.value;globalInfo.notify(record);if(record.isContinue)
{if(record.trainingDate.getTime()>(new Date()).getTime())
me.listRunFutureDetails(record.id);else
me.listRunDetails(record.id);}},handlePostLoad:function(criteria,output){output.myFirstField.focus();},handleCancel:function(criteria){me.doLast();}};return this.editRunHandler;}
Linker.getEditRunDetailsHandler=function()
{if(!this.editRunDetailsHandler)
this.editRunDetailsHandler=new ListTrainingDetailsSimple.getRunInstance(caller,EditTrainingDetailsDOM,undefined,this);return this.editRunDetailsHandler;}
Linker.getEditRunFutureDetailsHandler=function()
{if(!this.editRunFutureDetailsHandler)
this.editRunFutureDetailsHandler=new ListTrainingDetailsSimple.getRunFutureInstance(caller,EditTrainingDetailsDOM,undefined,this);return this.editRunFutureDetailsHandler;}
Linker.getEditShoeHandler=function(title)
{if(!this.editShoeHandler)
this.editShoeHandler=new EditEquipmentSimple.getShoeInstance(caller,EditEquipmentDOM);var me=this;this.editShoeHandler.callback={handleComplete:function(criteria){ModalDialog.close();me.getListShoesHandler().doLast();},handlePostLoad:function(criteria,o){ModalDialog.open(title,criteria.body);o.myFirstField.focus();},handleCancel:function(criteria){ModalDialog.close();}};return this.editShoeHandler;}
Linker.getEditSkiHandler=function(title)
{if(!this.editSkiHandler)
this.editSkiHandler=new EditEquipmentSimple.getSkiInstance(caller,EditEquipmentDOM);var me=this;this.editSkiHandler.callback={handleComplete:function(criteria){ModalDialog.close();me.getListSkisHandler().doLast();},handlePostLoad:function(criteria,o){ModalDialog.open(title,criteria.body);o.myFirstField.focus();},handleCancel:function(criteria){ModalDialog.close();}};return this.editSkiHandler;}
Linker.getEditSleepLogHandler=function(title)
{if(!this.editSleepLogHandler)
this.editSleepLogHandler=new EditSleepLogSimple(caller,EditSleepLogDOM);var me=this;this.editSleepLogHandler.callback={handleComplete:function(criteria){ModalDialog.close();me.doLast();},handlePostLoad:function(criteria,o){ModalDialog.open(title,criteria.body);o.myFirstField.focus();},handleCancel:function(criteria){ModalDialog.close();}};return this.editSleepLogHandler;}
Linker.getEditTeamHandler=function()
{if(!this.editTeamHandler)
this.editTeamHandler=new EditTeamSimple(caller,EditTeamDOM);var me=this;this.editTeamHandler.callback={handleComplete:function(criteria){me.doLast();},handleCancel:function(criteria){me.doLast();}};return this.editTeamHandler;}
Linker.getEditTeamMemberHandler=function()
{var me=this;if(!this.editTeamMemberHandler)
this.editTeamMemberHandler=new EditTeamMemberSimple(caller,EditTeamMemberDOM,{handleComplete:function(criteria){me.doLast();},handleCancel:function(criteria){me.doLast();}});return this.editTeamMemberHandler;}
Linker.getEditTeamMembersHandler=function()
{if(!this.editTeamMembersHandler)
this.editTeamMembersHandler=new ListTeamMembersSimple(caller,EditTeamMembersDOM);return this.editTeamMembersHandler;}
Linker.getEditUserProfiler=function()
{if(!this.editUserProfiler)
this.editUserProfiler=new EditUserSimple(caller,EditUserDOM);var me=this;this.editUserProfiler.callback={handleComplete:function(criteria){var record=criteria.value.value;record.password=undefined;globalInfo.run(record);this.redirect();},handlePostLoad:function(criteria,output){output.myFirstField.focus();},handleCancel:function(criteria){me.doLast();}};return this.editUserProfiler;}
Linker.getEditWeightLogHandler=function(title)
{if(!this.editWeightLogHandler)
this.editWeightLogHandler=new EditWeightLogSimple(caller,EditWeightLogDOM);var me=this;this.editWeightLogHandler.callback={handleComplete:function(criteria){ModalDialog.close();me.doLast();},handlePostLoad:function(criteria,o){ModalDialog.open(title,criteria.body);o.myFirstField.focus();},handleCancel:function(criteria){ModalDialog.close();}};return this.editWeightLogHandler;}
Linker.getEditWorkoutHandler=function(title,noContinue)
{if(!this.editWorkoutHandler)
this.editWorkoutHandler=new EditWorkoutSimple(caller,EditWorkoutDOM);var me=this;this.editWorkoutHandler.callback={handleComplete:function(criteria){ModalDialog.close();me.getListWorkoutsHandler().doLast();var record=criteria.value.value;if(record.isContinue)me.listWorkoutDetails(record.id);},handlePostLoad:function(criteria,o)
{ModalDialog.open(title,criteria.body);o.myFirstField.focus();if(noContinue)o.addRepeats.style.display='none';},handleCancel:function(criteria){ModalDialog.close();}};return this.editWorkoutHandler;}
Linker.getEditXtrainingHandler=function()
{if(!this.editXtrainingHandler)
this.editXtrainingHandler=new EditTrainingSimple.getXtrainingInstance(caller,EditXtrainingDOM);var me=this;this.editXtrainingHandler.callback={handleComplete:function(criteria)
{me.doLast();var record=criteria.value.value;globalInfo.notify(record);if(record.isContinue)me.listXtrainingDetails(record.id);},handlePostLoad:function(criteria,output){output.myFirstField.focus();},handleCancel:function(criteria){me.doLast();}};return this.editXtrainingHandler;}
Linker.getEditXtrainingDetailsHandler=function()
{if(!this.editXtrainingDetailsHandler)
this.editXtrainingDetailsHandler=new ListTrainingDetailsSimple.getXtrainingInstance(caller,EditTrainingDetailsDOM,undefined,this);return this.editXtrainingDetailsHandler;}
Linker.getEmailBlogHandler=function()
{if(!this.emailBlogHandler)
this.emailBlogHandler=new EmailBlogSimple(caller,EmailBlogDOM,{handleComplete:function(c){ModalDialog.close();},handlePostLoad:function(c,o){ModalDialog.open(TITLE_EMAIL_BLOG,c.body);o.myFirstField.focus();},handleCancel:function(c){ModalDialog.close();}});return this.emailBlogHandler;}
Linker.getInviteNewTeamMembersHandler=function(title)
{if(!this.inviteNewTeamMembersHandler)
this.inviteNewTeamMembersHandler=new InviteNewTeamMembersSimple(caller,InviteNewTeamMembersDOM);var me=this;this.inviteNewTeamMembersHandler.callback={handlePostLoad:function(criteria,output){ModalDialog.open(title,criteria.body);output.myFirstField.focus();},handleComplete:function(criteria){ModalDialog.close();me.doLast();},handleCancel:function(criteria){ModalDialog.close();}};return this.inviteNewTeamMembersHandler;}
Linker.getLeaderBoardHandler=function()
{if(!this.leaderBoardHandler)
this.leaderBoardHandler=new LeaderBoardSimple(caller,LeaderBoardDOM);return this.leaderBoardHandler;}
Linker.getListBikesHandler=function()
{var me=this;if(!this.listBikesHandler)
this.listBikesHandler=new ListEquipmentSimple.getBikeInstance(caller,ListEquipmentDOM,PAGE_SIZE_NORMAL,{handleSelect:function(criteria,record){me.editBike(record.id,criteria);},copyRecord:function(criteria,record){me.copyBike(record.id,criteria);}});return this.listBikesHandler;}
Linker.getListBlogsHandler=function()
{if(!this.listBlogsHandler)
{var me=this;this.listBlogsHandler=new ListBlogsSimple(caller,ListBlogsDOM,PAGE_SIZE_BLOG,{handleSelect:function(c,r){me.viewBlog(r);},handleEdit:function(c,r){me.editBlog(r.id);}});}
return this.listBlogsHandler;}
Linker.getListBlogsMiniHandler=function()
{if(!this.listBlogsMiniHandler)
{var me=this;this.listBlogsMiniHandler=new ListBlogsSimple(caller,ListBlogsMini,PAGE_SIZE_HOME,{handleMore:function(c){me.listRecentBlogs();},handleSelect:function(c,r){me.viewBlog(r);}});}
return this.listBlogsMiniHandler;}
Linker.getListBlogCommentsHandler=function()
{if(!this.listBlogCommentsHandler)
{var me=this;this.listBlogCommentsHandler=new ListBlogCommentsSimple(caller,ListBlogCommentsDOM,PAGE_SIZE_BLOG,{handleEdit:function(c,r){me.editBlogComment(r.id);},handleReply:function(c,r){me.replyBlogComment(r.id);},handleReportAbuse:function(c,r){me.addBlogReport(r.id);}});}
return this.listBlogCommentsHandler;}
Linker.getListCommunityTrainingHandler=function()
{if(!this.listCommunityTrainingHandler)
this.listCommunityTrainingHandler=new ListTrainingSimple(caller,ListCommunityTrainingDOM,PAGE_SIZE_NORMAL);this.listCommunityTrainingHandler.callback=this.getListTrainingCallback();return this.listCommunityTrainingHandler;}
Linker.getListEffortLevelsHandler=function()
{if(!this.listEffortLevelsHandler)
this.listEffortLevelsHandler=new ListEffortLevelsSimple(caller,ListEffortLevelsDOM);return this.listEffortLevelsHandler;}
Linker.getListRoutesHandler=function()
{var me=this;if(!this.listRoutesHandler)
this.listRoutesHandler=new ListRoutesSimple(caller,ListRoutesDOM,PAGE_SIZE_NORMAL,{handleSelect:function(criteria,record){me.editRoute(record.id,criteria);},copyRecord:function(criteria,record){me.copyRoute(record.id,criteria);}});return this.listRoutesHandler;}
Linker.getListRunDetailsHandler=function()
{if(!this.listRunDetailsHandler)
this.listRunDetailsHandler=new ListTrainingDetailsSimple.getRunInstance(caller,ListTrainingDetailsDOM,undefined,this);return this.listRunDetailsHandler;}
Linker.getListShoesHandler=function()
{var me=this;if(!this.listShoesHandler)
this.listShoesHandler=new ListEquipmentSimple.getShoeInstance(caller,ListEquipmentDOM,PAGE_SIZE_NORMAL,{handleSelect:function(criteria,record){me.editShoe(record.id,criteria);},copyRecord:function(criteria,record){me.copyShoe(record.id,criteria);}});return this.listShoesHandler;}
Linker.getListSkisHandler=function()
{var me=this;if(!this.listSkisHandler)
this.listSkisHandler=new ListEquipmentSimple.getSkiInstance(caller,ListEquipmentDOM,PAGE_SIZE_NORMAL,{handleSelect:function(criteria,record){me.editSki(record.id,criteria);},copyRecord:function(criteria,record){me.copySki(record.id,criteria);}});return this.listSkisHandler;}
Linker.getListTeamsHandler=function()
{if(!this.listTeamsHandler)
this.listTeamsHandler=new ListTeamsSimple(caller,ListTeamsDOM,this);return this.listTeamsHandler;}
Linker.getListTeamMembersHandler=function()
{if(!this.listTeamMembersHandler)
this.listTeamMembersHandler=new ListTeamMembersSimple(caller,ListTeamMembersDOM);return this.listTeamMembersHandler;}
Linker.getListTrainingCallback=function()
{var me=this;return{handleSelect:function(criteria,record)
{if(criteria.value.isReadOnly)
{if(record.isRun)
me.viewRun(record.id,criteria);else
me.viewXtraining(record.id,criteria);}
else
{if(record.isRun)
me.editRun(record.id);else
me.editXtraining(record.id);}},copyRecord:function(criteria,record){if(record.isRun)me.copyRun(record.id);else me.copyXtraining(record.id);},showDetails:function(criteria,record)
{if(criteria.value.isReadOnly)
{if(record.isRun)
me.viewRunDetails(record.id,criteria);else
me.viewXtrainingDetails(record.id,criteria);}
else
{if(record.isRun)
me.listRunDetails(record.id);else
me.listXtrainingDetails(record.id);}},fillTrainingInfo:function(record,elem){me.fillTrainingInfo(record,elem);}};}
Linker.getListTrainingHandler=function()
{if(!this.listTrainingHandler)
this.listTrainingHandler=new ListTrainingSimple(caller,ListTrainingDOM,PAGE_SIZE_NORMAL);this.listTrainingHandler.callback=this.getListTrainingCallback();return this.listTrainingHandler;}
Linker.getListWorkoutsHandler=function()
{var me=this;if(!this.listWorkoutsHandler)
this.listWorkoutsHandler=new ListWorkoutsSimple(caller,ListWorkoutsDOM,PAGE_SIZE_NORMAL,{handleSelect:function(criteria,record){me.editWorkout(record.id,criteria);},copyRecord:function(criteria,record){me.copyWorkout(record.id,criteria);},showDetails:function(criteria,record){me.listWorkoutDetails(record.id,criteria);}});return this.listWorkoutsHandler;}
Linker.getListWorkoutDetailsHandler=function()
{if(!this.listWorkoutDetailsHandler)
this.listWorkoutDetailsHandler=new ListTrainingDetailsSimple.getWorkoutInstance(caller,EditTrainingDetailsDOM);return this.listWorkoutDetailsHandler;}
Linker.getListXtrainingDetailsHandler=function()
{if(!this.listXtrainingDetailsHandler)
this.listXtrainingDetailsHandler=new ListTrainingDetailsSimple.getXtrainingInstance(caller,ListTrainingDetailsDOM,undefined,this);return this.listXtrainingDetailsHandler;}
Linker.getMembershipInvitesHandler=function(title)
{if(!this.membershipInvitesHandler)
this.membershipInvitesHandler=new MembershipInvitesSimple(caller,MembershipInvitesDOM);this.membershipInvitesHandler.callback={handlePostLoad:function(criteria,output){ModalDialog.open(title,criteria.body);},handleCancel:function(criteria){ModalDialog.close();globalInfo.notify({});}};return this.membershipInvitesHandler;}
Linker.getMembershipRequestsHandler=function(title)
{if(!this.membershipRequestsHandler)
this.membershipRequestsHandler=new MembershipRequestsSimple(caller,MembershipRequestsDOM);this.membershipRequestsHandler.callback={handlePostLoad:function(criteria,output){ModalDialog.open(title,criteria.body);},handleCancel:function(criteria){ModalDialog.close();globalInfo.notify({});}};return this.membershipRequestsHandler;}
Linker.getSearchBlogsHandler=function()
{if(!this.searchBlogsHandler)
{var me=this;this.searchBlogsHandler=new SearchBlogsSimple(caller,SearchBlogsDOM,{start:function(c,o){o.myFirstField.focus();},finish:function(c,f){me.listBlogs(f);}});}
return this.searchBlogsHandler;}
Linker.getSearchCommunityTrainingHandler=function()
{if(!this.searchCommunityTrainingHandler)
{var me=this;this.searchCommunityTrainingHandler=new SearchCommunityTrainingSimple(caller,SearchCommunityTrainingDOM,{start:function(criteria,output){output.myFirstField.focus();},finish:function(criteria,filter){me.listCommunityTraining(filter);}});}
return this.searchCommunityTrainingHandler;}
Linker.getSearchTeamsHandler=function()
{if(!this.searchTeamsHandler)
{var me=this;this.searchTeamsHandler=new SearchTeamsSimple(caller,SearchTeamsDOM,{start:function(criteria,output){output.myFirstField.focus();},finish:function(criteria,filter){me.listTeams(filter);}});}
return this.searchTeamsHandler;}
Linker.getSearchTrainingHandler=function()
{if(!this.searchTrainingHandler)
{var me=this;this.searchTrainingHandler=new SearchTrainingSimple(caller,SearchTrainingDOM,{start:function(criteria,output){output.myFirstField.focus();},finish:function(criteria,filter){if(filter.exportReportTypeId)
me.exportTraining(filter);else
me.listTraining(filter);}});}
return this.searchTrainingHandler;}
Linker.getSendTeamEmailHandler=function(title)
{if(!this.sendTeamEmailHandler)
this.sendTeamEmailHandler=new SendTeamEmailSimple(caller,SendTeamEmailDOM);var me=this;this.sendTeamEmailHandler.callback={handleComplete:function(criteria){ModalDialog.close();},handlePostLoad:function(criteria,output)
{ModalDialog.open(title,criteria.body);output.myFirstField.focus();},handleCancel:function(criteria){ModalDialog.close();}};return this.sendTeamEmailHandler;}
Linker.getShareTeamResourcesHandler=function(title)
{if(!this.shareTeamResourcesHandler)
this.shareTeamResourcesHandler=new ShareTeamResourcesSimple(caller,ShareTeamResourcesDOM);var me=this;this.shareTeamResourcesHandler.callback={handlePostLoad:function(criteria,output){ModalDialog.open(title,criteria.body);},handleComplete:function(criteria){ModalDialog.close();},handleCancel:function(criteria){ModalDialog.close();}};return this.shareTeamResourcesHandler;}
Linker.getSumTrainingHandler=function()
{if(!this.sumTrainingHandler)
this.sumTrainingHandler=new SumTrainingSimple(caller,SumTrainingDOM);return this.sumTrainingHandler;}
Linker.getTeamMemberSummaryHandler=function()
{if(!this.teamMemberSummaryHandler)
this.teamMemberSummaryHandler=new TeamMemberSummarySimple(caller,TeamMemberSummaryDOM,this);return this.teamMemberSummaryHandler;}
Linker.getTrainingChartHandler=function()
{if(!this.trainingChartHandler)
this.trainingChartHandler=new TrainingChartSimple(caller,TrainingChartDOM);return this.trainingChartHandler;}
Linker.removeChildren=function(parent)
{var nodes=parent.childNodes,a=[];while(0<parent.childNodes.length)
a[a.length]=parent.removeChild(nodes[0]);return a;}
Linker.inflateAnchors=function(body)
{var a=this.currentBody.myAnchors;if(a&&(0<a.length))
for(var i=0;i<a.length;i++)
this.pageNav.appendChild(a[i]);}
Linker.openNotImplementedYet=function()
{window.alert('This has not been implemented yet since the redesign. It will be up shortly, though. Sorry for the inconvenience.')}
Linker.startHistory=function()
{var me=this,elem;this.backer=elem=document.createElement('iframe');if(document.all)
elem.attachEvent('onload',function(){me.handleBack(event.srcElement.contentWindow.location);});else
elem.onload=function(ev){me.handleBack(this.contentWindow.location);};elem.width=elem.height=elem.framewidth=0;elem.style.display='none';document.body.appendChild(elem);this.history=[];}
Linker.addHistory=function(body)
{this.history.push(body);this.backer.src=this.historyUrl+escape(body.myTitle);this.ignoreBackerOnLoad=true;}
Linker.handleBack=function(loc)
{if(this.ignoreBackerOnLoad)
{this.ignoreBackerOnLoad=false;return;}
var body=this.history.pop();if(!body)
return;this.swap(body,true);this.inflateAnchors(body);}
Linker.ListItemDOM={};Linker.ListItemDOM.generate=function(criteria,callback)
{var o=document.createElement('div');var r,a,records=criteria.records;for(var i=0;i<records.length;i++)
{r=records[i];o.appendChild(a=Elements.genAnchor(CAPTION_ADD+' '+r.desc,function(ev){callback.handleSelect(criteria,this.myRecord);return false;}))
a.myRecord=r;}
return o;}

var ModalDialog=new Object();ModalDialog.CSS_SHIELD='modalShield';ModalDialog.CSS_POPUP='modalDialog';ModalDialog.shield=undefined;ModalDialog.popup=new Array();ModalDialog.ZINDEX=100;ModalDialog.open=function(caption,body)
{this.genShield();this.altSelectLists(true);this.run(new ModalDialogCriteria(caption),body);}
ModalDialog.close=function()
{if(!this.shield)
return;document.body.removeChild(this.popup.pop());if(0==this.popup.length)
{this.shield.style.display='none';this.altSelectLists(false);}}
ModalDialog.run=function(criteria,body)
{var output=this.getPopup();var table=document.createElement('table');table.className=this.CSS_POPUP;var tr=table.insertRow(0);tr.className='modalDialogHeader';var td=tr.insertCell(0);td.className='modalDialogCaption';td.appendChild(document.createTextNode(criteria.caption));td=tr.insertCell(1);td.className='modalDialogActions';var a=document.createElement('a');a.href='javascript:void(null);';a.myCallback=this;a.onclick=this.close_onClick;a.appendChild(document.createTextNode('X'));td.appendChild(a);tr=table.insertRow(1);td=tr.insertCell(0);td.className='modalDialogContainer';td.colSpan=2;td.appendChild(body);output.innerHTML='';output.appendChild(table);output.style.display='block';Positioner.center(output);return output;}
ModalDialog.genShield=function()
{if(undefined==this.shield)
this.shield=this.genBody(this.CSS_SHIELD);var coords=Positioner.getBodyDimensions();this.shield.style.width=coords.x+'px';this.shield.style.height=coords.y+'px';this.shield.style.display='block';}
ModalDialog.getPopup=function()
{var output=this.genBody(this.CSS_POPUP);output.style.zIndex=this.ZINDEX+this.popup.length;this.popup.push(output);return output;}
ModalDialog.genBody=function(className)
{var output=document.createElement('div');output.className=className;document.body.insertBefore(output,document.body.firstChild);return output;}
ModalDialog.altSelectLists=function(hide)
{if(!document.all)
return;var items=document.body.getElementsByTagName('select');var newValue=(hide)?'hidden':'visible';for(var i=0;i<items.length;i++)
items[i].style.visibility=newValue;}
ModalDialog.close_onClick=function(ev)
{this.myCallback.close();}
function ModalDialogCriteria(caption){this.caption=caption;}

var MultiSelectList={}
MultiSelectList.CSS='multiselect';MultiSelectList.SIZE=10;MultiSelectList.HEIGHT_FACTOR=20;MultiSelectList.generate=function(name,values,selection,size)
{var elem,output=document.createElement('div');output.className=this.CSS;output.style.height=this.calcHeight(size);if(!values||(0==values.length))
return output;var items={};if(selection)
for(var i=0;i<selection.length;i++)
items[selection[i]]=true;for(var i=0;i<values.length;i++)
{if(0<i)
output.appendChild(document.createElement('br'));var record=values[i];output.appendChild(Inputter.genCheckBox(name,record.id,items[record.id]));output.appendChild(document.createTextNode(' '+record.desc));}
return output;}
MultiSelectList.calcHeight=function(size)
{return(((size)?size:this.SIZE)*this.HEIGHT_FACTOR)+'px';}
MultiSelectList.retrieve=function(items)
{if(!items)
return undefined;if(!items.length)
return items.checked?items.value:undefined;var values=[];for(var i=0;i<items.length;i++)
if(items[i].checked)
values[values.length]=items[i].value;return values;}

var Pager={}
Pager.SIZE=15;Pager.OFFSET=7;Pager.generate=function(criteria,callback)
{var value=criteria.value.isListingValue?criteria.value:criteria.value.value;var output=document.createElement('span');if(1>=value.pages)
return output;output.appendChild(document.createTextNode('Page: '));if(1<value.page)
{output.appendChild(this.createAnchor('prev',callback,criteria,value.page-1));output.appendChild(document.createTextNode(' '));}
var s=1,e=value.pages;if(this.SIZE<e)
{s=value.page-this.OFFSET;if(1>s)
s=1;e=s+this.SIZE-1;if(value.pages<e)
{e=value.pages;s=e-this.SIZE+1;}}
for(var i=s;i<=e;i++)
{output.appendChild(document.createTextNode(' '));if(i==value.page)
output.appendChild(document.createTextNode(i));else
output.appendChild(this.createAnchor(i,callback,criteria,i));}
output.appendChild(document.createTextNode(' '));if(value.pages>value.page)
{output.appendChild(document.createTextNode(' '));output.appendChild(this.createAnchor('next',callback,criteria,value.page+1));}
return output;}
Pager.createAnchor=function(caption,callback,criteria,newPage)
{return Elements.genAnchor(caption,function(ev){callback.handlePaging(criteria,newPage);});}

function Positioner(){}
function CoordInfo(x,y)
{this.x=x;this.y=y;}
Positioner.getBodyDimensions=function(){return new CoordInfo(document.body.offsetWidth,document.body.offsetHeight);}
Positioner.getCoords=function(elem)
{var value=new CoordInfo(0,0);while(elem.offsetParent&&('BODY'!=elem.tagName.toUpperCase()))
{var position=elem.style.position;if((undefined!=position)&&('absolute'==position.toLowerCase()))
{value.x+=parseInt(elem.style.left);value.y+=parseInt(elem.style.top);return value;}
else
{value.x+=elem.offsetLeft;value.y+=elem.offsetTop;}
elem=elem.offsetParent;}
value.x+=elem.offsetLeft;value.y+=elem.offsetTop;return value;}
Positioner.position=function(elem,coord)
{elem.style.position='absolute';elem.style.left=coord.x+'px';elem.style.top=coord.y+'px';}
Positioner.center=function(elem)
{var topper=document.all?document.documentElement:window;var clientWidth=(window.innerWidth)?window.innerWidth:topper.clientWidth;var clientHeight=(window.innerHeight)?window.innerHeight:topper.clientHeight;var scrollLeft=document.all?topper.scrollLeft:topper.scrollX;var scrollTop=document.all?topper.scrollTop:topper.scrollY;this.position(elem,new CoordInfo(((clientWidth-elem.offsetWidth)/2)+scrollLeft,((clientHeight-elem.offsetHeight)/2)+scrollTop));}
Positioner.rightOf=function(base,elem)
{var coord=this.getCoords(base);var topper=document.all?document.documentElement:window;var clientHeight=(window.innerHeight)?window.innerHeight:topper.clientHeight;var scrollTop=document.all?topper.scrollTop:topper.scrollY;if((scrollTop+clientHeight)<(coord.y+elem.offsetHeight))
coord.y-=((coord.y+elem.offsetHeight)-(scrollTop+clientHeight));coord.x+=base.offsetWidth;this.position(elem,coord);}
Positioner.under=function(base,elem)
{var coord=this.getCoords(base);coord.y+=base.offsetHeight;this.position(elem,coord);}
Positioner.underX=function(base,elem)
{var coord=this.getCoords(base);coord.y+=base.offsetHeight;coord.x-=(elem.offsetWidth-base.offsetWidth);if(0>coord.x)
coord.x=0;this.position(elem,coord);}

var Popup={}
Popup.CSS='popupInfo';Popup.CSS_LEGEND='popupLegend';Popup.DELAY=500;Popup.open=function(base,elem,legend,keepAlive)
{if(!this.body)
{this.body=document.createElement('div');document.body.insertBefore(this.body,document.body.firstChild);}
var a=this.body;if(a.myTimeoutId)
{window.clearTimeout(a.myTimeoutId);this.close();}
if(a.firstChild)
a.removeChild(a.firstChild);a.className=legend?this.CSS_LEGEND:this.CSS;a.appendChild(elem);a.style.display='block';if(legend)
Positioner.underX(base,a);else
Positioner.rightOf(base,a);if(keepAlive)
{a.myIsOpened=true;a.myBase=base;var me=this;base.onmouseout=a.onmouseout=function(ev)
{if(!a.myIsOpened)
return;a.myTimeoutId=window.setTimeout(function(){me.close();},me.DELAY);};base.onmouseover=a.onmouseover=function(ev)
{if(a.myTimeoutId)
{window.clearTimeout(a.myTimeoutId);a.myTimeoutId=undefined;}
if(a.myBase!=base)
a.myIsOpened=false;if(a.myIsOpened)
return;me.open(base,elem,legend,keepAlive);}}}
Popup.close=function()
{var a=this.body;a.style.display='none';a.onmouseover=a.onmouseout=null;a.myTimeoutId=undefined;a.myIsOpened=false;}

var ProgressBar={}
ProgressBar.CAPTION='Loading';ProgressBar.INTERVAL=2000;ProgressBar.MAX_INTERVALS=20;ProgressBar.start=function(body)
{var e,me=this;body.progressBarBody=e=document.createElement('blockquote');e.innerHTML=this.CAPTION+' ...';if(body.firstChild)
body.removeChild(body.firstChild);body.appendChild(e);body.progressBarOn=true;body.progressBarCount=0;body.progressBarIntervalId=window.setInterval(function(){me.handleInterval(body);},this.INTERVAL);}
ProgressBar.turnOff=function(body)
{if(!body.progressBarOn)
return;window.clearInterval(body.progressBarIntervalId);body.progressBarIntervalId=undefined;body.progressBarOn=false;}
ProgressBar.handleInterval=function(body)
{if(!body.progressBarOn)
return;if(this.MAX_INTERVALS<=body.progressBarCount)
{this.turnOff(body);if(this.TIMEOUT_MESSAGE)
body.progressBarBody.innerHTML=this.TIMEOUT_MESSAGE;return;}
body.progressBarBody.innerHTML=body.progressBarBody.innerHTML+'.';body.progressBarCount++;}

function SelectList(){}
SelectList.create=function(name)
{if(document.all)
return document.createElement('<select name="'+name+'" />');var output=document.createElement('select');if(window.isSafari)
output.id=name;output.name=name;return output;}
SelectList.repopulate=function(elem,value,header)
{var options=elem.options;options.length=0;if(undefined!=header)
options[0]=new Option(header,'');this.populate(options,value);}
SelectList.populate=function(options,value)
{var records=value.records;if(undefined==records)
return;for(var i=0;i<records.length;i++)
{var record=records[i];options[options.length]=new Option(record.desc,record.id);}}
SelectList.generate=function(name,values,header)
{var output=this.create(name);var options=output.options;if(undefined!=header)
options[0]=new Option(header,'');var value={records:values};this.populate(options,value);return output;}

function DetailSimple(){}
DetailSimple.prototype.COLOR_FLICKER=COLOR_PINK;DetailSimple.prototype.filter=function(filter,body)
{this.run({filter:filter},body);}
DetailSimple.prototype.doLast=function(){this.run(this.lastCriteria);}
DetailSimple.prototype.run=function(criteria,body)
{if(body)
criteria.body=body;else
body=criteria.body;ProgressBar.start(body);this.makeCall(criteria.filter,new AjaxDataHandler(this,criteria));this.lastCriteria=criteria;}
DetailSimple.prototype.doValue=function(criteria)
{var output,body=criteria.body;ProgressBar.turnOff(body);body.removeChild(body.firstChild);body.appendChild(output=this.viewer.generate(criteria,this));if(this.handlePostLoad)
this.handlePostLoad(criteria,output);if(this.callback&&this.callback.handlePostLoad)
this.callback.handlePostLoad(criteria,output);}
DetailSimple.prototype.flicker=function(elem)
{var bgcolor=elem.style.backgroundColor;elem.style.backgroundColor='#FFB6C1';setTimeout(function(){elem.style.backgroundColor=bgcolor;},500);}
DetailSimple.prototype.createUpdateCallback=function(criteria,form,record)
{var me=this;return{handleRequestData:function(value){if(me.viewer.genComplete)
{criteria.response=value.payload;criteria.body.innerHTML='';criteria.body.appendChild(me.viewer.genComplete(criteria,me));setTimeout(function(){me.callback.handleComplete(criteria);},5000);}
else
{record.id=value.payload;me.callback.handleComplete(criteria);}},handleRequestError:function(error){if(form.showActionButtons);form.showActionButtons();if(error.message)
{window.alert(error.message);if(error.field&&form[error.field])
form[error.field].focus();}
else
window.alert(error);}};}

function ListingSimple(){}
ListingSimple.TR_DISPLAY_VALUE=document.all?'block':'table-row';ListingSimple.iconCollapse=new Image();ListingSimple.iconExpand=new Image();ListingSimple.prototype.COLOR_FLICKER=COLOR_RED;ListingSimple.showRow=function(elem,flag)
{elem.style.display=flag?this.TR_DISPLAY_VALUE:'none';}
ListingSimple.prototype.filter=function(filter,body)
{if(!filter.pageSize&&this.pageSize)
filter.pageSize=this.pageSize;this.run({filter:filter},body);}
ListingSimple.prototype.doLast=function(){this.run(this.lastCriteria);}
ListingSimple.prototype.run=function(criteria,body)
{if(body)
criteria.body=body;else
body=criteria.body;ProgressBar.start(body);this.makeCall(criteria.filter,new AjaxDataHandler(this,criteria));this.lastCriteria=criteria;}
ListingSimple.prototype.doValue=function(criteria)
{var output,body=criteria.body;ProgressBar.turnOff(body);body.removeChild(body.firstChild);body.appendChild(output=this.viewer.generate(criteria,this));if(this.handlePostLoad)
this.handlePostLoad(criteria,output);if(this.callback&&this.callback.handlePostLoad)
this.callback.handlePostLoad(criteria,output);}
ListingSimple.prototype.handlePaging=function(criteria,newPage)
{if(!newPage)
return;criteria.filter.page=newPage;this.run(criteria);}
ListingSimple.prototype.handleSort=function(criteria,value,sortField,sortDefaultDir)
{var filter=criteria.filter;filter.sortOn=sortField;if(value.sortOn==sortField)
filter.sortDir=SORT_DESC==value.sortDir?SORT_ASC:SORT_DESC;else
filter.sortDir=sortDefaultDir;this.run(criteria);}
ListingSimple.prototype.flicker=function(elem)
{var parent=elem.parentNode?elem.parentNode:elem;parent.oldBgColor=parent.style.backgroundColor;parent.style.backgroundColor=this.COLOR_FLICKER;setTimeout(function(){parent.style.backgroundColor=parent.oldBgColor;},500);}
ListingSimple.prototype.confirmDelete=function(value)
{return window.confirm("Are you sure you want to delete the selected "+"record. Click OK to continue.");}
ListingSimple.prototype.setRowVisibility=function(elem,flag)
{ListingSimple.showRow(elem,flag);}

function BaseDetailMini(){}
BaseDetailMini.prototype.createTable=function()
{var output=document.createElement('table');output.className='miniDetail';return output;}
BaseDetailMini.prototype.outputRow=function(table,caption,value)
{if(undefined==value)
return;if((undefined!=value.substr)&&(50<value.length))
value=value.substr(0,50)+'...';var cell,output=table.insertRow(table.rows.length);cell=output.insertCell(0);cell.className='miniCaption';cell.innerHTML=caption;cell=output.insertCell(1);cell.className='miniValue';cell.innerHTML=value;return output;}

function DetailDOM(){}
DetailDOM.prototype.CSS_TABLE='detail';DetailDOM.prototype.CSS_HEADER_GAP='detailHeaderGap';DetailDOM.prototype.CSS_HEADER='detailHeader';DetailDOM.prototype.CSS_CAPTION='detailCaptionX';DetailDOM.prototype.CSS_VALUE='detailValue';DetailDOM.prototype.CSS_ACTION='detailAction';DetailDOM.prototype.createForm=function(criteria,callback)
{var a=document.createElement('form');a.className='widgetPackage';a.hideActionButtons=function()
{if(!this.myActions)
return;this.myActions.style.display='none';this.myWaitMessage.className='waitMessageShow';}
a.showActionButtons=function()
{if(!this.myActions)
return;this.myActions.style.display='block';this.myWaitMessage.className='waitMessageHide';}
if(callback)
a.onsubmit=function(ev){callback.handleSubmit(criteria,this);this.hideActionButtons();return false;};return a;}
DetailDOM.prototype.createTable=function()
{var o=document.createElement('table');o.className=this.CSS_TABLE;o.style.width='100%';return o;}
DetailDOM.prototype.createHeader=function(table,caption,colSpan)
{if(!colSpan)colSpan=2;var o=table.insertRow(table.rows.length);var c=o.insertCell(0);c.colSpan=colSpan;c.className=this.CSS_HEADER_GAP;o=table.insertRow(table.rows.length);c=o.insertCell(0);c.colSpan=colSpan;c.className=this.CSS_HEADER;c.innerHTML=caption+':';return o;}
DetailDOM.prototype.createCaption=function(row,index,caption,isRequired)
{var o=row.insertCell(index);o.className=this.CSS_CAPTION;o.innerHTML=caption;if(isRequired)
o.appendChild(document.createTextNode('*'));return o;}
DetailDOM.prototype.createValue=function(row,value)
{var o=row.insertCell(row.cells.length);o.className=this.CSS_VALUE;if(value)
o.innerHTML=value;return o;}
DetailDOM.prototype.createField=function(row,index,field,value)
{var o=row.insertCell(index);o.className=this.CSS_VALUE;o.appendChild(field);if(value)
field.value=value;return o;}
DetailDOM.prototype.createRow=function(table,caption,value)
{var o=table.insertRow(table.rows.length);this.createCaption(o,0,caption);o.myValueCell=this.createValue(o,value);return o;}
DetailDOM.prototype.createRowX=function(table,caption,isRequired,field,value)
{var o=table.insertRow(table.rows.length);o.myCaptionCell=this.createCaption(o,0,caption,isRequired);o.myValueCell=this.createField(o,1,field,value);return o;}
DetailDOM.prototype.createAction=function(table,colSpan)
{if(!colSpan)
colSpan=2;var f=table.parentNode;var o=table.insertRow(table.rows.length);var c=o.insertCell(0);c.colSpan=colSpan;c.className=this.CSS_ACTION;f.myWaitMessage=Elements.addDiv(c,'waitMessageHide',CAPTION_SUBMITTING);return(f.myActions=Elements.addDiv(c));}
DetailDOM.prototype.validateMax=function(e,max)
{var i,v=e.value;var p=e.parentNode;var o=p.myWarning;if((0==v.length)||isNaN(i=parseInt(v))||(max>=i))
{if(o)
o.style.display='none';}
else if(o)
o.style.display='block';else
o=p.myWarning=Elements.addDiv(p,'warning','Please check this value. It appears to be too large to be valid.');}

function ListingDOM(){}
ListingDOM.prototype.CSS_TABLE='listing';ListingDOM.prototype.CSS_CAPTION='listingCaption';ListingDOM.prototype.CSS_TOTALS='totals';ListingDOM.prototype.CSS_ROWS=['listingOdd','listingEven'];ListingDOM.prototype.CSS_FIELD='listingCaption';ListingDOM.prototype.CAPTION_NO_DATA_FOUND='No data found.';ListingDOM.prototype.CSS_COLLAPSE='iconCollapse';ListingDOM.prototype.CSS_EXPAND='iconExpand';ListingDOM.prototype.createNoDataFound=function()
{return document.createTextNode(this.CAPTION_NO_DATA_FOUND);}
ListingDOM.prototype.createTable=function()
{var output=document.createElement('table');output.className=this.CSS_TABLE;return output;}
ListingDOM.prototype.createCaption=function(table,criteria,value,callback)
{var cells=table.rows[0].cells.length;var left=Math.floor(cells/2);var right=left+(cells-(left*2));var o={};o.header=this.createCaption_(table.createTHead(),criteria,value,callback,left,right);o.footer=this.createCaption_(table.createTFoot(),criteria,value,callback,left,right);return o;}
ListingDOM.prototype.createCaption_=function(output,criteria,value,callback,left,right)
{var html,cell,row,o={};row=output.insertRow(0);cell=o.leftCell=row.insertCell(0);cell.className='left';cell.colSpan=left;if(1==value.totalRecords)
html='1 '+value.singular;else
{html=value.totalRecords+' '+value.plural;if(1<value.pages)
html+=' (Page '+value.page+' of '+value.pages+')';}
cell.innerHTML=html;cell=o.rightCell=row.insertCell(1);cell.className='right';cell.colSpan=right;cell.appendChild(Pager.generate(criteria,callback));return o;}
ListingDOM.prototype.createHeaderRow=function(table,rows)
{var a=table.insertRow(rows);a.className=this.CSS_CAPTION;return a;}
ListingDOM.prototype.createHeaderCell=function(row,cells,caption,sortField,sortDefaultDir,criteria,value,callback)
{var o=row.insertCell(cells);o.className=this.CSS_CAPTION;if(sortField)
{var css;if(value.sortOn==sortField)
css=(value.sortDir==SORT_DESC)?'sortDescending':'sortAscending';o.appendChild(Elements.genAnchor(caption,function(ev){callback.handleSort(criteria,value,sortField,sortDefaultDir);return false;},css));}
else if(caption)
o.innerHTML=caption;return o;}
ListingDOM.prototype.createDetailCell=function(row,cells,value)
{var output=row.insertCell(cells);output.className=row.className;if(undefined!=value)
output.innerHTML=value;return output;}
ListingDOM.prototype.getRowCss=function(i){return this.CSS_ROWS[i%2];}
ListingDOM.prototype.toggle=function(elem,expand){elem.className=expand?this.CSS_EXPAND:this.CSS_COLLAPSE;}

var CalendarDOM={}
CalendarDOM.CSS='trainingCalendar';CalendarDOM.CSS_FUTURE='future';CalendarDOM.MONTHS=Calendar.prototype.MONTHS;CalendarDOM.LAST_DAYS=Calendar.prototype.LAST_DAYS;CalendarDOM.DAYS=Formatter.LONG_DAYS;CalendarDOM.CAPTION_NA='NA';CalendarDOM.getDaysInMonth=Calendar.prototype.getDaysInMonth;CalendarDOM.generate=function(criteria,callback)
{var filter=criteria.filter;var date=filter.date;var model=criteria.value;var p,div,elem,row,cell,cells,rows=0,o=document.createElement('table');o.className=this.CSS;row=o.insertRow(rows++);row.className='header';this.appendHeader(row,criteria,callback,date);row=o.insertRow(rows++);row.className='caption';for(var i=0;i<this.DAYS.length;i++)
{cell=row.insertCell(i);cell.className='caption';Elements.addText(cell,this.DAYS[i]);}
var today=date.getUTCDate();var when=new Date(filter.fromDate.getTime());var cells=when.getUTCDay();row=o.insertRow(rows++);if(0<cells)
{cell=row.insertCell(0);cell.colSpan=cells;cell.innerHTML='&nbsp;';cell.className='day';}
var daysInMonth=filter.toDate.getUTCDate();for(var i=1;i<=daysInMonth;i++)
{when.setUTCDate(i);var myDate=new Date(when.getTime());if(this.DAYS.length<=cells)
{row=o.insertRow(rows++);cells=0;}
cell=row.insertCell(row.cells.length);cell.className='day';if(today==i)
cell.className+=' selected';div=Elements.addDiv(cell,'day');Elements.addDiv(div,'date',i);Elements.addBreak(div);elem=Elements.addBreak(div);if(model.canEditLog)
{elem.className='date';div.appendChild(p=document.createElement('p'));p.appendChild(elem=Inputter.genButtonX('addRun',TITLE_ADD_RUN,function(ev){callback.handleAddRun(criteria,this);},'iconAddRun'));elem.myDate=myDate;this.addSpace(p);p.appendChild(elem=Inputter.genButtonX('addXtraining',TITLE_ADD_XTRAINING,function(ev){callback.handleAddXtraining(criteria,this);},'iconAddXtraining'));elem.myDate=myDate;}
this.appendTraining(div,myDate,model.runValues,criteria,callback,false,model.canEditLog);this.appendTraining(div,myDate,model.runFutureValues,criteria,callback,true,model.canEditLog);this.appendTraining(div,myDate,model.xtrainingValues,criteria,callback,false,model.canEditLog);if(!this.appendExercise(div,myDate,model.exerciseValues,criteria,callback,model.canEdit)&&model.canEdit)
{div.appendChild(p=document.createElement('p'));p.appendChild(elem=Inputter.genButtonX('addExercise',TITLE_ADD_EXERCISE,function(ev){callback.handleAddExercise(criteria,this);},'iconExercise'));elem.myDate=myDate;}
this.appendHeartRateInfo(div,myDate,model.heartRateValues,criteria,callback,model.isSelf);if(model.isSelf)
{this.appendWeightInfo(div,myDate,model.weightValues,criteria,callback);if(model.trackCycles)
this.appendMenstruationInfo(div,myDate,model.menstruationValues,criteria,callback);}
this.appendSleepInfo(div,myDate,model.sleepValues,criteria,callback,model.isSelf);cells++;}
if(this.DAYS.length>cells)
{cell=row.insertCell(cells);cell.colSpan=this.DAYS.length-cells;cell.innerHTML='&nbsp;';cell.className='day';}
return o;}
CalendarDOM.appendHeader=function(row,criteria,callback,date)
{var elem,month=date.getMonth(),model=criteria.value;var cell=row.insertCell(0);cell.className='left';cell.appendChild(Elements.genAnchor('&lt;',function(ev){callback.handleChangeMonth(criteria,month-1);}));this.addSpace(cell);cell.appendChild(elem=SelectList.generate('month',model.monthOptions));elem.value=month;elem.onchange=function(ev){callback.handleChangeMonth(criteria,this.value);};this.addSpace(cell);cell.appendChild(Elements.genAnchor('&gt;',function(ev){callback.handleChangeMonth(criteria,month+1);}));Elements.addSpan(cell,undefined,'&nbsp;&nbsp;&mdash;&nbsp;&nbsp;');cell.appendChild(Elements.genAnchor('&lt;&lt;',function(ev){callback.handleChangeYear(criteria,-1);}));this.addSpace(cell);Elements.addText(cell,date.getFullYear());this.addSpace(cell);cell.appendChild(Elements.genAnchor('&gt;&gt;',function(ev){callback.handleChangeYear(criteria,1);}));if(model.teammateOptions&&(0<model.teammateOptions.length))
{cell.colSpan=3;cell=row.insertCell(1);cell.colSpan=4;cell.className='right';cell.appendChild(elem=SelectList.generate('teammate',model.teammateOptions,CAPTION_ME))
elem.onchange=function(ev){callback.handleChangeTeammate(criteria,this);};var teammate=criteria.filter.teammate;if(teammate)
elem.value=teammate;}
else
cell.colSpan=this.DAYS.length;}
CalendarDOM.appendTraining=function(div,when,values,criteria,callback,isFuture,canEdit)
{if(!values||(0==values.length))
return;var p,elem,img,time=when.getUTCDate(),caption=canEdit?CAPTION_EDIT:CAPTION_VIEW;for(var i=0;i<values.length;i++)
{var value=values[i];var trainingTime=value.trainingDate.getUTCDate();if(time>trainingTime)
continue;else if(time<trainingTime)
return;div.appendChild(p=document.createElement('p'));p.appendChild(elem=document.createElement('a'));elem.myRecord=value;if(canEdit)
elem.onclick=function(ev){callback.handleEditTraining(criteria,this);};else
elem.onclick=function(ev){callback.handleViewTraining(criteria,this);};var me=this;elem.onmouseover=function(ev){me.elem_onmouseover(this,this.myRecord);};elem.onmouseout=function(ev){me.elem_onmouseout(this,this.myRecord);};elem.appendChild(Elements.genImage(value.typeIconSrc,caption+' '+value.typeName));Elements.addSpace(elem);elem.appendChild(Elements.genImage(value.timeOfDayIconSrc,caption+' '+value.typeName));Elements.addSpace(elem);if(isFuture)
elem.className=this.CSS_FUTURE;if(value.distanceMiles)
Elements.addText(elem,Formatter.toDistance(value.distanceMiles)+value.distanceAbbr);else if(value.distanceKm)
Elements.addText(elem,Formatter.toDistance(value.distanceKm)+value.distanceAbbr);else if(0<value.totalSeconds)
Elements.addText(elem,Formatter.toDuration(value));}}
CalendarDOM.appendExercise=function(div,when,values,criteria,callback,canEdit)
{if(!values||(0==values.length))
return false;var found=false;var p,elem,img,time=when.getUTCDate(),caption=canEdit?CAPTION_EDIT:CAPTION_VIEW;for(var i=0;i<values.length;i++)
{var value=values[i];var exerciseTime=value.exerciseDate.getUTCDate();if(time>exerciseTime)
continue;else if(time<exerciseTime)
return found;found=true;div.appendChild(p=document.createElement('p'));p.appendChild(elem=document.createElement('a'));elem.myRecord=value;if(canEdit)
elem.onclick=function(ev){callback.handleEditExercise(criteria,this);};else
elem.onclick=function(ev){callback.handleViewExercise(criteria,this);};var me=this;elem.onmouseover=function(ev){me.exercise_onmouseover(this,this.myRecord);};elem.onmouseout=function(ev){me.elem_onmouseout(this,this.myRecord);};elem.appendChild(Elements.genImage('icon_barbell.gif',caption+' '+TITLE_EXERCISE));Elements.addSpace(elem);elem.appendChild(Elements.genImage(value.timeOfDayIconSrc,caption+' '+TITLE_EXERCISE));Elements.addSpace(elem);if(0<value.setCount)
Elements.addText(elem,value.setCount+' '+CAPTION_SETS);else if(value.focus&&(0<value.focus.length))
Elements.addText(elem,value.focus[0]+' ...');}
return found;}
CalendarDOM.appendHeartRateInfo=function(div,when,values,criteria,callback,canEdit)
{var img=Elements.genImage('icon_heart.gif',TITLE_HEART_RATE_LOG);var p,elem,value=this.findLogValue(values,when);if(value)
{div.appendChild(p=elem=document.createElement('p'));if(canEdit)
{p.appendChild(elem=Elements.genAnchor(img,function(ev){callback.handleEditHeartRate(criteria,this);}));elem.title=img.title=TITLE_EDIT_HEART_RATE_LOG;elem.myRecord=value;}
else
p.appendChild(img);if(value.heartRateMin||value.heartRateMax)
Elements.addText(elem,' '+this.toDisplayable(value.heartRateMin)+' / '+
this.toDisplayable(value.heartRateMax));if(value.bpSystolic&&value.bpDiastolic)
{div.appendChild(p=document.createElement('p'));p.appendChild(Elements.genImage('icon_blood_pressure.gif',CAPTION_BLOOD_PRESSURE));Elements.addText(p,' '+value.bpSystolic+' / '+value.bpDiastolic);}}
else if(canEdit)
{div.appendChild(p=document.createElement('p'));p.appendChild(elem=Elements.genAnchor(img,function(ev){callback.handleAddHeartRate(criteria,this);}));elem.title=img.title=TITLE_ADD_HEART_RATE_LOG;elem.myDate=when;}}
CalendarDOM.appendWeightInfo=function(div,when,values,criteria,callback)
{var img=Elements.genImage('icon_scale.gif');var p,elem,value=this.findLogValue(values,when);div.appendChild(p=document.createElement('p'));if(value)
{p.appendChild(elem=Elements.genAnchor(img,function(ev){callback.handleEditWeight(criteria,this);}));img.title=elem.title=TITLE_EDIT_WEIGHT_LOG;elem.myRecord=value;if(value.weight||value.bodyFatPercent)
Elements.addText(elem,' '+
(value.weight?Formatter.toWeight(value.weight)+value.weightUnitId:this.CAPTION_NA)+' / '+
(value.bodyFatPercent?Formatter.toPercent(value.bodyFatPercent)+'%':this.CAPTION_NA));}
else
{p.appendChild(elem=Elements.genAnchor(img,function(ev){callback.handleAddWeight(criteria,this);}));img.title=elem.title=TITLE_ADD_WEIGHT_LOG;elem.myDate=when;}}
CalendarDOM.appendSleepInfo=function(div,when,values,criteria,callback,canEdit)
{var img=Elements.genImage('icon_sleep.gif',TITLE_SLEEP_LOG);var p,elem,value=this.findLogValue(values,when);if(value)
{div.appendChild(p=elem=document.createElement('p'));if(canEdit)
{p.appendChild(elem=Elements.genAnchor(img,function(ev){callback.handleEditSleep(criteria,this);}));elem.title=img.title=TITLE_EDIT_SLEEP_LOG;elem.myRecord=value;}
else
p.appendChild(img);if(value.sleepQualityName)
elem.title=img.title=value.sleepQualityName;if(value.durationHours||value.durationMinutes)
Elements.addText(elem,' '+Formatter.toDuration_(value.durationHours)+':'+
Formatter.toDuration_(value.durationMinutes));else
Elements.addText(elem,' '+CAPTION_NA);}
else if(canEdit)
{div.appendChild(p=document.createElement('p'));p.appendChild(elem=Elements.genAnchor(img,function(ev){callback.handleAddSleep(criteria,this);}));elem.title=img.title=TITLE_ADD_SLEEP_LOG;elem.myDate=when;}}
CalendarDOM.appendMenstruationInfo=function(div,when,values,criteria,callback)
{var img=Elements.genImage('icon_cycles.gif');var p,elem,value=this.findLogValue(values,when);div.appendChild(p=document.createElement('p'));if(value)
{p.appendChild(elem=Elements.genAnchor(img,function(ev){callback.handleEditMenstruation(criteria,this);}));img.title=elem.title=TITLE_EDIT_MENSTRUATION_LOG;elem.myRecord=value;if(value.comments)
{var comments=value.comments;if(10<comments.length)
comments=comments.substr(0,10)+' ...';Elements.addText(elem,' '+comments);}
else
{Elements.addText(elem,' '+CAPTION_YES);elem.className=this.CSS_FUTURE;}}
else
{p.appendChild(elem=Elements.genAnchor(img,function(ev){callback.handleAddMenstruation(criteria,this);}));img.title=elem.title=TITLE_ADD_MENSTRUATION_LOG;elem.myDate=when;}}
CalendarDOM.findLogValue=function(values,when)
{if(!values||(0==values.length))
return undefined;var time=when.getUTCDate();for(var i=0;i<values.length;i++)
if(time==values[i].logDate.getUTCDate())
return values[i];return undefined;}
CalendarDOM.addSpace=function(o)
{Elements.addSpan(o,undefined,'&nbsp;&nbsp;');}
CalendarDOM.toDisplayable=function(value)
{if(value)
return value;return this.CAPTION_NA;}
CalendarDOM.elem_onmouseover=function(elem,record)
{var viewer=record.isRun?DetailRunMini:DetailXtrainingMini;Popup.open(elem,viewer.generate({value:record}));}
CalendarDOM.exercise_onmouseover=function(elem,record)
{Popup.open(elem,DetailExerciseMini.generate({value:record}));}
CalendarDOM.elem_onmouseout=function(elem,record)
{Popup.close();}

var DetailBlogDOM=new DetailDOM();DetailBlogDOM.generate=function(criteria,callback)
{var value=criteria.value;var date=value.releaseDate?value.releaseDate:value.createdDate;var e,o=document.createElement('div');o.className='widgetPackage';Elements.addSpan(o,'blogTitle',value.title);e=Elements.addDiv(o,'byline',Formatter.toTimestamp(date)+'&nbsp;&mdash;&nbsp;'+value.creatorName);if(value.isLive&&criteria.filter.isAuthenticated)
{Elements.addSpan(e,'byline','&nbsp;&mdash;&nbsp;');e.appendChild(Elements.genAnchor('E-mail this Blog Entry',function(ev){callback.handleEmail(criteria);}));}
Elements.addBreak(o);Elements.addDiv(o,'blogEntry',value.contents);if(value.bio)
{Elements.addBreak(o);Elements.addDiv(o,'bio',value.bio);}
Elements.addBreak(o);Elements.addSpan(o,'h2','From the Community&nbsp;&nbsp;&nbsp;&nbsp;');o.appendChild(Elements.genAnchor('Add Your Comment',function(ev){Linker.addBlogComment(value.id);},'blogAdd'));Elements.addBreak(o);Elements.addBreak(o);Linker.getListBlogCommentsHandler().doParent(value.id,Elements.addDiv(o));Elements.addBreak(o);o.appendChild(Elements.genAnchor('Add Your Comment',function(ev){Linker.addBlogComment(value.id);},'blogAdd'));return o;}

var DetailExerciseDOM=new DetailDOM();DetailExerciseDOM.generate=function(criteria,callback)
{var me=this;var v=criteria.value;var elem,cell,row,rows=0,o=this.createTable();this.createHeader(o,'Basic Information',4);rows=o.rows.length;row=o.insertRow(rows++);this.createCaption(row,0,CAPTION_EXERCISE_DATE);this.createValue(row,Formatter.toDate(v.exerciseDate));this.createCaption(row,2,CAPTION_TIME_OF_DAY);this.createValue(row,v.timeOfDayName);row=o.insertRow(rows++);this.createCaption(row,0,CAPTION_FOCAL_MUSCLE_GROUPS).rowSpan=2;cell=this.createValue(row);cell.rowSpan=2;if(v.focusNames&&(0<v.focusNames.length))
{for(var i=0;i<v.focusNames.length;i++)
{Elements.addSpan(cell,undefined,v.focusNames[i]);Elements.addBreak(cell);}}
else
cell.innerHTML=CAPTION_NONE;this.createCaption(row,2,CAPTION_HEART_RATE_AVG);this.createValue(row,v.heartRateAvg);row=o.insertRow(rows++);this.createCaption(row,0,CAPTION_HEART_RATE_MAX);this.createValue(row,v.heartRateMax);row=o.insertRow(rows++);this.createCaption(row,0,CAPTION_COMMENTS);this.createValue(row,v.comments).colSpan=3;this.createHeader(o,CAPTION_SETS,4);rows=o.rows.length;row=o.insertRow(rows++);cell=this.createValue(row);cell.colSpan=4;cell.appendChild(ListingExerciseSetsDOM.generate(v.sets));return o;}
ListingExerciseSetsDOM={};ListingExerciseSetsDOM=new ListingDOM();ListingExerciseSetsDOM.generate=function(records)
{if(!records||(0==records.length))
return this.createNoDataFound();var row,o=this.createTable();row=o.insertRow(0);row.className=ListingDOM.prototype.CSS_CAPTION;this.createHeaderCell(row,0,CAPTION_MUSCLE_GROUP);this.createHeaderCell(row,1,CAPTION_EXERCISE_TYPE);this.createHeaderCell(row,2,CAPTION_REPETITIONS);this.createHeaderCell(row,3,CAPTION_WEIGHT);this.createHeaderCell(row,4,'HR (Avg. / Max.)');this.createHeaderCell(row,5,CAPTION_IS_MAX_OUT);this.createHeaderCell(row,6,CAPTION_COMMENTS);for(var i=0;i<records.length;i++)
{var record=records[i];row=o.insertRow(i+1);row.className=this.getRowCss(i);this.createDetailCell(row,0,record.muscleGroupName);this.createDetailCell(row,1,record.exerciseTypeName);this.createDetailCell(row,2,record.repetitions);this.createDetailCell(row,3,record.weight?record.weight+' '+record.weightUnitId:undefined);this.createDetailCell(row,4,record.heartRateAvg||record.heartRateMax?Formatter.toDisplayable(record.heartRateAvg)+' / '+Formatter.toDisplayable(record.heartRateMax):undefined);this.createDetailCell(row,5,Formatter.toDisplayable(record.isMaxOut));this.createDetailCell(row,6,Formatter.toDisplayable(record.comments));}
return o;}

var DetailExerciseMini=new BaseDetailMini();DetailExerciseMini.generate=function(criteria,callback)
{var v=criteria.value;var o=this.createTable();this.outputRow(o,CAPTION_TIME_OF_DAY,v.timeOfDayName);this.outputRow(o,CAPTION_FOCUS,Formatter.toList(v.focus));this.outputRow(o,CAPTION_HEART_RATE_AVG,v.heartRateAvg);this.outputRow(o,CAPTION_HEART_RATE_MAX,v.heartRateMax);this.outputRow(o,CAPTION_HEART_RATE_TARGET_MIN,v.heartRateTargetMin);this.outputRow(o,CAPTION_HEART_RATE_TARGET_MAX,v.heartRateTargetMax);this.outputRow(o,CAPTION_SETS,v.setCount);this.outputRow(o,CAPTION_COMMENTS,v.comments);return o;}

var DetailRunDOM=new DetailDOM();DetailRunDOM.generate=function(criteria,callback)
{var v=criteria.value;var cell,elem,o=this.createTable();this.createHeader(o,'Basic Information');this.createRow(o,CAPTION_MEMBER_NAME,Formatter.toDisplayable(v.userFullName));o.myTrainingDate=this.createRow(o,CAPTION_RUN_DATE,Formatter.toFullDate(v.trainingDate)).myValueCell;o.myTimeOfDayName=this.createRow(o,CAPTION_TIME_OF_DAY,Formatter.toDisplayable(v.timeOfDayName)).myValueCell;o.myRouteName=this.createRow(o,CAPTION_RUNNING_ROUTE,Formatter.toDisplayable(v.routeName)).myValueCell;o.myEffortLevelName=this.createRow(o,CAPTION_EFFORT_LEVEL,Formatter.toDisplayable(v.effortLevelName)).myValueCell;o.myWorkoutName=this.createRow(o,CAPTION_WORKOUT,Formatter.toDisplayable(v.workoutName)).myValueCell;o.myShoeName=cell=this.createRow(o,CAPTION_SHOE,Formatter.toDisplayable(v.shoeName)).myValueCell;if(undefined!=v.shoeId)
{cell.appendChild(elem=document.createElement('span'));elem.innerHTML='&nbsp;&nbsp;&nbsp;&nbsp;';cell.appendChild(elem=document.createElement('span'));elem.className='detailCaption';elem.innerHTML='Usage: ';cell.appendChild(elem=o.myShoeUsage=document.createElement('span'));elem.className='pace';}
o.myCalories=this.createRow(o,CAPTION_CALORIES,Formatter.toDisplayable(v.calories)).myValueCell;o.myDistanceMiles=cell=this.createRow(o,CAPTION_DISTANCE_MILES,Formatter.toDistance(v.distanceMiles)).myValueCell;if(undefined!=v.distanceMiles)
{cell.appendChild(elem=document.createElement('span'));elem.innerHTML='&nbsp;&nbsp;&nbsp;&nbsp;';cell.appendChild(elem=document.createElement('span'));elem.className='detailCaption';elem.innerHTML=CAPTION_PACE+': &nbsp;';cell.appendChild(elem=document.createElement('span'));elem.className='pace';elem.innerHTML=Formatter.toPace(v.paceMiles);cell.appendChild(elem=document.createElement('span'));elem.innerHTML='&nbsp;&nbsp;';cell.appendChild(elem=document.createElement('span'));elem.className='detailCaption';elem.innerHTML=CAPTION_DISTANCE_KM+': &nbsp;';cell.appendChild(elem=document.createElement('span'));elem.className='pace';elem.innerHTML=Formatter.toKm(v.distanceMiles);;}
o.myDistanceKm=cell=this.createRow(o,CAPTION_DISTANCE_KM,Formatter.toDisplayable(v.distanceKm)).myValueCell;if(undefined!=v.distanceKm)
{cell.appendChild(elem=document.createElement('span'));elem.innerHTML='&nbsp;&nbsp;&nbsp;&nbsp;';cell.appendChild(elem=document.createElement('span'));elem.className='detailCaption';elem.innerHTML=CAPTION_PACE+': &nbsp;';cell.appendChild(elem=document.createElement('span'));elem.className='pace';elem.innerHTML=Formatter.toPace(v.paceKm);cell.appendChild(elem=document.createElement('span'));elem.innerHTML='&nbsp;&nbsp;';cell.appendChild(elem=document.createElement('span'));elem.className='detailCaption';elem.innerHTML=CAPTION_DISTANCE_MILES+': &nbsp;';cell.appendChild(elem=document.createElement('span'));elem.className='pace';elem.innerHTML=Formatter.toMiles(v.distanceKm);;}
o.myDuration=this.createRow(o,CAPTION_DURATION,Formatter.toDuration(v)).myValueCell;this.createHeader(o,'Heart Rate');o.myHeartRateAvg=this.createRow(o,CAPTION_HEART_RATE_AVG,Formatter.toDisplayable(v.heartRateAvg)).myValueCell;o.myHeartRateMax=this.createRow(o,CAPTION_HEART_RATE_MAX,Formatter.toDisplayable(v.heartRateMax)).myValueCell;o.myHeartRateTargetMin=this.createRow(o,CAPTION_HEART_RATE_TARGET_MIN,Formatter.toDisplayable(v.heartRateTargetMin)).myValueCell;o.myHeartRateTargetMax=this.createRow(o,CAPTION_HEART_RATE_TARGET_MAX,Formatter.toDisplayable(v.heartRateTargetMax)).myValueCell;this.createHeader(o,'Weather & Conditions');o.myTemperatureName=this.createRow(o,CAPTION_TEMPERATURE,Formatter.toTemperature(v)).myValueCell;o.myHumidityName=this.createRow(o,CAPTION_HUMIDITY,Formatter.toHumidity(v)).myValueCell;o.myPrecipitationName=this.createRow(o,CAPTION_PRECIPITATION,Formatter.toDisplayable(v.precipitationName)).myValueCell;o.myWindName=this.createRow(o,CAPTION_WIND,Formatter.toWind(v)).myValueCell;o.mySurfaceConditionName=this.createRow(o,CAPTION_SURFACE_CONDITION,Formatter.toDisplayable(v.surfaceConditionName)).myValueCell;o.myComments=this.createRow(o,CAPTION_COMMENTS,Formatter.toDisplayable(v.comments)).myValueCell;return o;}

var DetailRunMini=new BaseDetailMini();DetailRunMini.generate=function(criteria,callback)
{var v=criteria.value;var o=this.createTable();this.outputRow(o,CAPTION_MEMBER_NAME,v.userFullName);this.outputRow(o,CAPTION_TIME_OF_DAY,v.timeOfDayName);this.outputRow(o,CAPTION_RUNNING_ROUTE,v.routeName);this.outputRow(o,CAPTION_EFFORT_LEVEL,v.effortLevelName);this.outputRow(o,CAPTION_WORKOUT,v.workoutName);this.outputRow(o,CAPTION_SHOE,v.shoeName);this.outputRow(o,CAPTION_CALORIES,v.calories);if(undefined!=v.distanceMiles)
{var distance=Formatter.toDistance(v.distanceMiles);if(undefined!=v.paceMiles)
distance+=' &mdash; Pace: '+Formatter.toPace(v.paceMiles);this.outputRow(o,CAPTION_DISTANCE_MILES,distance);}
if(undefined!=v.distanceKm)
{var distance=Formatter.toDistance(v.distanceKm);if(undefined!=v.paceKm)
distance+=' &mdash; Pace: '+Formatter.toPace(v.paceKm);this.outputRow(o,CAPTION_DISTANCE_KM,distance);}
this.outputRow(o,CAPTION_DURATION,Formatter.toDuration(v));this.outputRow(o,CAPTION_HEART_RATE_AVG,v.heartRateAvg);this.outputRow(o,CAPTION_HEART_RATE_MAX,v.heartRateMax);this.outputRow(o,CAPTION_HEART_RATE_TARGET_MIN,v.heartRateTargetMin);this.outputRow(o,CAPTION_HEART_RATE_TARGET_MAX,v.heartRateTargetMax);this.outputRow(o,CAPTION_TEMPERATURE,Formatter.toTemperature(v));this.outputRow(o,CAPTION_HUMIDITY,Formatter.toHumidity(v));this.outputRow(o,CAPTION_PRECIPITATION,v.precipitationName);this.outputRow(o,CAPTION_WIND,Formatter.toWind(v));this.outputRow(o,CAPTION_SURFACE_CONDITION,v.surfaceConditionName);this.outputRow(o,CAPTION_COMMENTS,v.comments);return o;}

var DetailTeamDOM=new DetailDOM();DetailTeamDOM.generate=function(criteria,callback)
{var v=criteria.value;var cell,row,rows,t,o=document.createElement('div');o.className='widgetPackage';o.appendChild(t=this.createTable());var f=Formatter.toDisplayable;this.createHeader(t,'Basic Information',2);this.createRow(t,CAPTION_NAME,v.name);this.createRow(t,CAPTION_OWNER,v.ownerName);this.createRow(t,CAPTION_TYPE,v.typeName);this.createRow(t,CAPTION_CITY,f(v.city));this.createRow(t,CAPTION_STATE,f(v.stateName));this.createRow(t,CAPTION_COUNTRY,f(v.countryName));row=this.createRow(t,CAPTION_WEB_SITE_URL);if(v.webSiteUrl)
row.myValueCell.appendChild(Formatter.toWebsite(v.webSiteUrl));this.createRow(t,CAPTION_IS_ACTIVE,f(v.isActive));this.createRow(t,CAPTION_IS_SEARCHABLE,f(v.isSearchable));this.createRow(t,CAPTION_COMMENTS,v.comments);var access=v.access;var colSpan=access.length+1;o.appendChild(t=this.createTable());this.createHeader(t,'Access rights (who can see/edit what)',colSpan);rows=t.rows.length;row=t.insertRow(rows++);row.insertCell(0);for(var i=0;i<access.length;i++)
this.createHeaderCell(row,i+1,access[i].memberTypeName);this.createAccessCells(t.insertRow(rows++),access,CAPTION_CAN_VIEW_PROFILE,'canViewProfile');this.createAccessCells(t.insertRow(rows++),access,CAPTION_CAN_EDIT_PROFILE,'canEditProfile');this.createAccessCells(t.insertRow(rows++),access,CAPTION_CAN_VIEW_LOG,'canViewLog');this.createAccessCells(t.insertRow(rows++),access,CAPTION_CAN_EDIT_LOG,'canEditLog');this.createAccessCells(t.insertRow(rows++),access,CAPTION_CAN_VIEW_CALENDAR,'canViewCalendar');this.createAccessCells(t.insertRow(rows++),access,CAPTION_CAN_EDIT_CALENDAR,'canEditCalendar');this.createAccessCells(t.insertRow(rows++),access,CAPTION_CAN_VIEW_SUMMARY,'canViewSummary');this.createHeader(t,'Permissions (who can do what)',colSpan);rows=t.rows.length;row=t.insertRow(rows++);row.insertCell(0);for(var i=0;i<access.length;i++)
this.createHeaderCell(row,i+1,access[i].memberTypeName);this.createAuthCells(t.insertRow(rows++),access,CAPTION_CAN_CREATE_TEAM_ROUTES,'canCreateTeamRoutes');this.createAuthCells(t.insertRow(rows++),access,CAPTION_CAN_CREATE_TEAM_WORKOUTS,'canCreateTeamWorkouts');this.createAuthCells(t.insertRow(rows++),access,CAPTION_CAN_SEND_TEAM_EMAILS,'canSendTeamEmails');this.createAuthCells(t.insertRow(rows++),access,CAPTION_CAN_INVITE_NEW_MEMBERS,'canInviteNewMembers');return o;}
DetailTeamDOM.createHeaderCell=function(row,cells,caption)
{var a=row.insertCell(cells);a.className=this.CSS_HEADER;a.innerHTML=caption;return a;}
DetailTeamDOM.createAccessCells=function(row,access,caption,name)
{this.createCaption(row,0,caption);for(var i=0;i<access.length;i++)
this.createValue(row,access[i][name]);}
DetailTeamDOM.createAuthCells=function(row,access,caption,name)
{this.createCaption(row,0,caption);for(var i=0;i<access.length;i++)
this.createValue(row,Formatter.toDisplayable(access[i][name])).className='listingCheckBox';}

var DetailXtrainingDOM=new DetailDOM();DetailXtrainingDOM.generate=function(criteria,callback)
{var v=criteria.value;var type=v.type;var cell,elem,o=this.createTable();this.createHeader(o,'Basic Information');this.createRow(o,CAPTION_MEMBER_NAME,Formatter.toDisplayable(v.userFullName));this.createRow(o,CAPTION_TRAINING_TYPE,Formatter.toDisplayable(type.desc));this.createRow(o,CAPTION_TRAINING_DATE,Formatter.toFullDate(v.trainingDate));this.createRow(o,CAPTION_TIME_OF_DAY,Formatter.toDisplayable(v.timeOfDayName));if(type.showDistanceInfo)
this.createRow(o,CAPTION_RUNNING_ROUTE,Formatter.toDisplayable(v.routeName));this.createRow(o,CAPTION_EFFORT_LEVEL,Formatter.toDisplayable(v.effortLevelName));this.createRow(o,CAPTION_WORKOUT,Formatter.toDisplayable(v.workoutName));if(type.showBikeInfo)
{cell=this.createRow(o,CAPTION_BIKE,Formatter.toDisplayable(v.bikeName)).myValueCell;if(v.bikeId)
{cell.appendChild(elem=document.createElement('span'));elem.innerHTML='&nbsp;&nbsp;&nbsp;&nbsp;';cell.appendChild(elem=document.createElement('span'));elem.className='detailCaption';elem.innerHTML='Usage: ';cell.appendChild(elem=o.myBikeUsage=document.createElement('span'));elem.className='pace';}}
if(type.showSkiInfo)
{cell=this.createRow(o,CAPTION_SKI,Formatter.toDisplayable(v.skiName)).myValueCell;if(v.skiId)
{cell.appendChild(elem=document.createElement('span'));elem.innerHTML='&nbsp;&nbsp;&nbsp;&nbsp;';cell.appendChild(elem=document.createElement('span'));elem.className='detailCaption';elem.innerHTML='Usage: ';cell.appendChild(elem=o.mySkiUsage=document.createElement('span'));elem.className='pace';}}
if(type.showSwimStrokeInfo)
this.createRow(o,CAPTION_SWIM_STROKE,Formatter.toDisplayable(v.swimStrokeName));if(type.showYogaInfo)
this.createRow(o,CAPTION_YOGA_STYLE,Formatter.toDisplayable(v.yogaStyleName));if(type.showMartialArtInfo)
{this.createRow(o,CAPTION_MARTIAL_ART_TYPE,Formatter.toDisplayable(v.martialArtTypeName));this.createRow(o,CAPTION_TECHNIQUE,Formatter.toDisplayable(v.technique));this.createRow(o,CAPTION_INSTRUCTOR,Formatter.toDisplayable(v.instructor));}
if(type.isMachine)
this.createRow(o,CAPTION_WATTAGE_AVG_MAX,Formatter.toAvgMax(v.wattageAvg,v.wattageMax));if(type.showRotationInfo)
this.createRow(o,CAPTION_RPM_AVG_MAX,Formatter.toAvgMax(v.rpmAvg,v.rpmMax));if(type.isMachine)
this.createRow(o,CAPTION_CALORIES,Formatter.toNumber(v.calories));if(type.showSteps)
this.createRow(o,CAPTION_STEPS,Formatter.toNumber(v.steps));if(type.showDistanceInfo)
{cell=this.createRow(o,CAPTION_DISTANCE_MILES,Formatter.toDistance(v.distanceMiles)).myValueCell;if(undefined!=v.distanceMiles)
{cell.appendChild(elem=document.createElement('span'));elem.innerHTML='&nbsp;&nbsp;&nbsp;&nbsp;';cell.appendChild(elem=document.createElement('span'));elem.className='detailCaption';elem.innerHTML=CAPTION_PACE+': &nbsp;';cell.appendChild(elem=document.createElement('span'));elem.className='pace';elem.innerHTML=Formatter.toPace(v.paceMiles);cell.appendChild(elem=document.createElement('span'));elem.innerHTML='&nbsp;&nbsp;';cell.appendChild(elem=document.createElement('span'));elem.className='detailCaption';elem.innerHTML=CAPTION_DISTANCE_KM+': &nbsp;';cell.appendChild(elem=document.createElement('span'));elem.className='pace';elem.innerHTML=Formatter.toKm(v.distanceMiles);;}
cell=this.createRow(o,CAPTION_DISTANCE_KM,Formatter.toDisplayable(v.distanceKm)).myValueCell;if(undefined!=v.distanceKm)
{cell.appendChild(elem=document.createElement('span'));elem.innerHTML='&nbsp;&nbsp;&nbsp;&nbsp;';cell.appendChild(elem=document.createElement('span'));elem.className='detailCaption';elem.innerHTML=CAPTION_PACE+': &nbsp;';cell.appendChild(elem=document.createElement('span'));elem.className='pace';elem.innerHTML=Formatter.toPace(v.paceKm);cell.appendChild(elem=document.createElement('span'));elem.innerHTML='&nbsp;&nbsp;';cell.appendChild(elem=document.createElement('span'));elem.className='detailCaption';elem.innerHTML=CAPTION_DISTANCE_MILES+': &nbsp;';cell.appendChild(elem=document.createElement('span'));elem.className='pace';elem.innerHTML=Formatter.toMiles(v.distanceKm);;}}
this.createRow(o,CAPTION_DURATION,Formatter.toDuration(v));this.createHeader(o,'Heart Rate');this.createRow(o,CAPTION_HEART_RATE_AVG,Formatter.toDisplayable(v.heartRateAvg));this.createRow(o,CAPTION_HEART_RATE_MAX,Formatter.toDisplayable(v.heartRateMax));this.createRow(o,CAPTION_HEART_RATE_TARGET_MIN,Formatter.toDisplayable(v.heartRateTargetMin));this.createRow(o,CAPTION_HEART_RATE_TARGET_MAX,Formatter.toDisplayable(v.heartRateTargetMax));this.createHeader(o,'Weather & Conditions');if(!type.showAirWeatherInfo)
this.createRow(o,CAPTION_WATER_TEMPERATURE,Formatter.toDisplayable(v.waterTemperatureName));else
{this.createRow(o,CAPTION_TEMPERATURE,Formatter.toTemperature(v));this.createRow(o,CAPTION_HUMIDITY,Formatter.toHumidity(v));}
if(!type.isIndoor)
{this.createRow(o,CAPTION_PRECIPITATION,Formatter.toDisplayable(v.precipitationName));this.createRow(o,CAPTION_WIND,Formatter.toWind(v));if(!type.showSnowInfo)
this.createRow(o,CAPTION_SURFACE_CONDITION,Formatter.toDisplayable(v.surfaceConditionName));}
if(type.showSnowInfo)
this.createRow(o,CAPTION_SNOW_CONDITION,Formatter.toDisplayable(v.snowConditionName));this.createRow(o,CAPTION_COMMENTS,Formatter.toDisplayable(v.comments));return o;}

var DetailXtrainingMini=new BaseDetailMini();DetailXtrainingMini.generate=function(criteria,callback)
{var v=criteria.value;var t=v.type;var o=this.createTable();this.outputRow(o,CAPTION_MEMBER_NAME,v.userFullName);this.outputRow(o,CAPTION_TRAINING_TYPE,t.desc);this.outputRow(o,CAPTION_TIME_OF_DAY,v.timeOfDayName);if(t.showDistanceInfo)
this.outputRow(o,CAPTION_ROUTE,v.routeName);this.outputRow(o,CAPTION_EFFORT_LEVEL,v.effortLevelName);this.outputRow(o,CAPTION_WORKOUT,v.workoutName);if(t.showBikeInfo)
this.outputRow(o,CAPTION_BIKE,v.bikeName);if(t.showSkiInfo)
this.outputRow(o,CAPTION_SKI,v.skiName);if(t.showSwimStrokeInfo)
this.outputRow(o,CAPTION_SWIM_STROKE,v.swimStrokeName);if(t.showYogaInfo)
this.outputRow(o,CAPTION_YOGA_STYLE,v.yogaStyleName);if(t.showMartialArtInfo)
{this.outputRow(o,CAPTION_MARTIAL_ART_TYPE,v.martialArtTypeName);this.outputRow(o,CAPTION_TECHNIQUE,v.technique);this.outputRow(o,CAPTION_INSTRUCTOR,v.instructor);}
if(t.isMachine)
this.outputRow(o,CAPTION_WATTAGE_AVG_MAX,Formatter.toAvgMax(v.wattageAvg,v.wattageMax));if(t.showRotationInfo)
this.outputRow(o,CAPTION_RPM_AVG_MAX,Formatter.toAvgMax(v.rpmAvg,v.rpmMax));if(t.isMachine)
this.outputRow(o,CAPTION_CALORIES,Formatter.toNumber(v.calories));if(t.showSteps)
this.outputRow(o,CAPTION_STEPS,Formatter.toNumber(v.steps));if(t.showDistanceInfo)
{if(undefined!=v.distanceMiles)
{var distance=Formatter.toDistance(v.distanceMiles);if(undefined!=v.paceMiles)
distance+=' &mdash; Pace: '+Formatter.toPace(v.paceMiles);this.outputRow(o,CAPTION_DISTANCE_MILES,distance);}
if(undefined!=v.distanceKm)
{var distance=Formatter.toDistance(v.distanceKm);if(undefined!=v.paceKm)
distance+=' &mdash; Pace: '+Formatter.toPace(v.paceKm);this.outputRow(o,CAPTION_DISTANCE_KM,distance);}}
this.outputRow(o,CAPTION_DURATION,Formatter.toDuration(v));this.outputRow(o,CAPTION_HEART_RATE_AVG,v.heartRateAvg);this.outputRow(o,CAPTION_HEART_RATE_MAX,v.heartRateMax);this.outputRow(o,CAPTION_HEART_RATE_TARGET_MIN,v.heartRateTargetMin);this.outputRow(o,CAPTION_HEART_RATE_TARGET_MAX,v.heartRateTargetMax);if(!t.showAirWeatherInfo)
{this.outputRow(o,CAPTION_WATER_TEMPERATURE,v.waterTemperatureName);}
else
{this.outputRow(o,CAPTION_TEMPERATURE,Formatter.toTemperature(v));this.outputRow(o,CAPTION_HUMIDITY,Formatter.toHumidity(v));}
if(!t.isIndoor)
{this.outputRow(o,CAPTION_PRECIPITATION,v.precipitationName);this.outputRow(o,CAPTION_WIND,Formatter.toWind(v));if(!t.showSnowInfo)
this.outputRow(o,CAPTION_SURFACE_CONDITION,v.surfaceConditionName);}
if(t.showSnowInfo)
this.outputRow(o,CAPTION_SNOW_CONDITION,v.snowConditionName);this.outputRow(o,CAPTION_COMMENTS,v.comments);return o;}

var EditBlogCommentDOM=new DetailDOM();EditBlogCommentDOM.generate=function(criteria,callback)
{var model=criteria.value;var filter=criteria.filter;var value=model.value;var r,rows=0,t,o=this.createForm(criteria,callback);o.appendChild(t=this.createTable());this.createRowX(t,CAPTION_TITLE,true,o.myFirstField=Inputter.genTextBox('title',64,50),value.title);if((filter.isAdd&&!model.isAuthenticated)||(filter.isEdit&&!value.creatorId))
{this.createRowX(t,CAPTION_MY_NAME,false,Inputter.genTextBox('fullName',32,30),value.fullName);this.createRowX(t,CAPTION_EMAIL_ADDRESS,false,Inputter.genTextBox('emailAddress',100,40),value.emailAddress);}
this.createRowX(t,CAPTION_URL,false,Inputter.genTextBox('url',128,50),value.url);this.createRowX(t,CAPTION_COMMENTS,true,Inputter.genTextArea('contents',60,6),value.contents);r=this.createAction(t);r.appendChild(Inputter.genSubmit('submitter',CAPTION_SUBMIT));Elements.addSpace(r);r.appendChild(Inputter.genButton('preview',CAPTION_PREVIEW,function(ev){callback.handlePreview(criteria,this.form);}));Elements.addSpace(r);r.appendChild(Inputter.genButton('canceler',CAPTION_CANCEL,function(ev){callback.handleCancel(criteria,this.form);}));return o;}
EditBlogCommentDOM.preview=function(criteria,callback)
{var model=criteria.value;var filter=criteria.filter;var value=model.value;var r,rows=0,t,o=this.createForm(criteria,callback);o.myPreviewPage=true;o.appendChild(t=this.createTable());this.createRow(t,CAPTION_TITLE,value.title);if((filter.isAdd&&!model.isAuthenticated)||(filter.isEdit&&!value.creatorId))
{this.createRow(t,CAPTION_MY_NAME,value.fullName);this.createRow(t,CAPTION_EMAIL_ADDRESS,value.emailAddress);}
this.createRow(t,CAPTION_URL,value.url);Elements.addDiv(this.createRow(t,CAPTION_COMMENTS).myValueCell,'dialogComments',value.contents);if(!criteria.complete)
{r=this.createAction(t);r.appendChild(Inputter.genSubmit('submitter',CAPTION_SUBMIT));Elements.addSpace(r);r.appendChild(Inputter.genButton('back',CAPTION_BACK,function(ev){callback.handleBack(criteria,this.form);}));Elements.addSpace(r);r.appendChild(Inputter.genButton('canceler',CAPTION_CANCEL,function(ev){callback.handleCancel(criteria,this.form);}));}
return o;}
EditBlogCommentDOM.genComplete=function(criteria,callback)
{criteria.complete=true;return this.preview(criteria,callback);}

var EditBlogReportDOM=new DetailDOM();EditBlogReportDOM.generate=function(criteria,callback)
{var model=criteria.value;var filter=criteria.filter;var value=model.value;var r,t,o=this.createForm(criteria,callback);o.appendChild(t=this.createTable());this.createRowX(t,CAPTION_MESSAGE,true,o.myFirstField=Inputter.genTextArea('contents',60,6),value.contents);r=this.createAction(t);r.appendChild(Inputter.genSubmit('submitter',CAPTION_SUBMIT));r.appendChild(document.createTextNode(' '));r.appendChild(Inputter.genButton('canceler',CAPTION_CANCEL,function(ev){callback.handleCancel(criteria,this.form);}));return o;}
EditBlogReportDOM.genComplete=function(criteria,callback)
{var o=document.createElement('div');Elements.addDiv(o,undefined,'Thank you for your feedback.');Elements.addBreak(o);Elements.addDiv(o,'dialogComments',criteria.value.value.contents);return o;}

var EditEquipmentDOM=new DetailDOM();EditEquipmentDOM.generate=function(criteria,callback)
{var m=criteria.value;var v=m.value;var c,t,o=this.createForm(criteria,callback);o.appendChild(t=this.createTable());this.createRowX(t,CAPTION_PURCHASE_DATE,true,Calendar.getInstance().create('purchaseDate',v.purchaseDate));this.createRowX(t,CAPTION_BIKE_BRAND,true,SelectList.generate('brand',m.brands),v.brandId);this.createRowX(t,CAPTION_MODEL_NAME,true,o.myFirstField=Inputter.genTextBox('modelName',MAX_LEN_MODEL_NAME,MAX_LEN_MODEL_NAME),v.modelName);this.createRowX(t,CAPTION_BIKE_MODEL_TYPE,true,SelectList.generate('modelType',m.modelTypes),v.modelTypeId);this.createRowX(t,CAPTION_PREVIOUS_MILES,false,Inputter.genTextBox('previousMiles',MAX_LEN_PREVIOUS_MILES,MAX_LEN_PREVIOUS_MILES),v.previousMiles);this.createRowX(t,CAPTION_PREVIOUS_KM,false,Inputter.genTextBox('previousKm',MAX_LEN_PREVIOUS_KM,MAX_LEN_PREVIOUS_KM),v.previousKm);this.createRowX(t,CAPTION_EXPIRATION_MILES,false,Inputter.genTextBox('expirationMiles',MAX_LEN_EXPIRATION_MILES,MAX_LEN_EXPIRATION_MILES),v.expirationMiles);this.createRowX(t,CAPTION_EXPIRATION_KM,false,Inputter.genTextBox('expirationKm',MAX_LEN_EXPIRATION_KM,MAX_LEN_EXPIRATION_KM),v.expirationKm);this.createRowX(t,CAPTION_WARN_WHEN_EXPIRED+'?',false,Inputter.genCheckBox('warnWhenExpired',1,v.warnWhenExpired));this.createRowX(t,CAPTION_IS_ACTIVE+'?',false,Inputter.genCheckBox('isActive',1,v.isActive));c=this.createAction(t);c.appendChild(Inputter.genSubmit('submitter',CAPTION_SUBMIT));Elements.addSpace(c);c.appendChild(Inputter.genButton('canceler',CAPTION_CANCEL,function(ev){callback.handleCancel(criteria);}))
return o;}

var EditExerciseDOM=new DetailDOM();EditExerciseDOM.generate=function(criteria,callback)
{var me=this;var model=criteria.value;var value=model.value;var cal=Calendar.getInstance();var elem,cell,row,rows=0,t,o=this.createForm(criteria,callback);o.appendChild(t=this.createTable());this.createHeader(t,'Basic Information',4);rows=t.rows.length;row=t.insertRow(rows++);this.createCaption(row,0,CAPTION_EXERCISE_DATE,true);this.createField(row,1,cal.create('exerciseDate',value.exerciseDate));this.createCaption(row,2,CAPTION_TIME_OF_DAY,true);this.createField(row,3,SelectList.generate('timeOfDay',model.timeOfDayOptions),value.timeOfDayId);row=t.insertRow(rows++);this.createCaption(row,0,CAPTION_FOCAL_MUSCLE_GROUPS).rowSpan=2;this.createField(row,1,MultiSelectList.generate('focus',model.muscleGroupOptions,value.focus,4)).rowSpan=2;this.createCaption(row,2,CAPTION_HEART_RATE_AVG);this.createField(row,3,Inputter.genTextBox('heartRateAvg',MAX_LEN_HEART_RATE_AVG,MAX_LEN_HEART_RATE_AVG),value.heartRateAvg);row=t.insertRow(rows++);this.createCaption(row,0,CAPTION_HEART_RATE_MAX);this.createField(row,1,Inputter.genTextBox('heartRateMax',MAX_LEN_HEART_RATE_MAX,MAX_LEN_HEART_RATE_MAX),value.heartRateMax);row=t.insertRow(rows++);this.createCaption(row,0,CAPTION_COMMENTS);this.createField(row,1,Inputter.genTextArea('comments',60,6),value.comments).colSpan=3;this.createHeader(t,CAPTION_SETS,4);rows=t.rows.length;row=t.insertRow(rows++);cell=row.insertCell(0);cell.colSpan=2;cell.rowSpan=2;cell.className=this.CSS_VALUE;cell.appendChild(elem=SelectList.generate('muscleGroup',model.muscleGroupOptions,CAPTION_MUSCLE_GROUP));elem.onchange=function(ev){callback.handleChangeMuscleGroup(this);};Elements.addBreak(cell);cell.appendChild(elem=SelectList.generate('exerciseType',model.typeOptions,CAPTION_EXERCISE_TYPE));Elements.addBreak(cell);cell.appendChild(document.createTextNode(CAPTION_REPETITIONS+'/'+CAPTION_WEIGHT+' '));cell.appendChild(Inputter.genTextBox('reps',MAX_LEN_REPETITIONS,2));cell.appendChild(document.createTextNode(' / '));cell.appendChild(Inputter.genTextBox('weight',MAX_LEN_LIFT_WEIGHT,2));cell.appendChild(document.createTextNode(' '));cell.appendChild(elem=SelectList.generate('weightUnit',model.weightUnitOptions));elem.value=model.defaultWeightUnitId;Elements.addBreak(cell);cell.appendChild(document.createTextNode(CAPTION_HR+' '+CAPTION_AVG+'/'+CAPTION_MAX+' '));cell.appendChild(Inputter.genTextBox('hrAvg',MAX_LEN_HEART_RATE_AVG,3));cell.appendChild(document.createTextNode(' / '));cell.appendChild(Inputter.genTextBox('hrMax',MAX_LEN_HEART_RATE_MAX,3));Elements.addBreak(cell);cell.appendChild(document.createTextNode(CAPTION_IS_MAX_OUT+' '));cell.appendChild(Inputter.genCheckBox('isMaxOut',1,false));Elements.addBreak(cell);Elements.addBreak(cell);cell.appendChild(document.createTextNode(CAPTION_COMMENTS));Elements.addBreak(cell);cell.appendChild(Inputter.genTextArea('setComments',30,4));Elements.addBreak(cell);Elements.addBreak(cell);cell.appendChild(Inputter.genButton('editSet','Add Set',function(ev){me.handleEditSet(this);}));cell.appendChild(document.createTextNode(' '));cell.appendChild(elem=Inputter.genButton('copySet','Copy Set',function(ev){me.handleEditSet(this,true);}));elem.style.visibility='hidden';cell=row.insertCell(1);cell.colSpan=2;cell.appendChild(Inputter.genButton('moveUp','Up',function(ev){me.handleMove(this,-1);}));cell.appendChild(document.createTextNode(' '));cell.appendChild(Inputter.genButton('moveDown','Down',function(ev){me.handleMove(this,1);}));cell.appendChild(document.createTextNode(' '));cell.appendChild(Inputter.genButton('remove','Remove',function(ev){me.handleRemove(this);}));cell.appendChild(document.createTextNode(' '));cell.appendChild(Inputter.genButton('clear','Clear All',function(ev){me.handleClear(this);}));cell.className='nowrap';row=t.insertRow(rows++);cell=row.insertCell(0);cell.colSpan=2;cell.appendChild(elem=SelectList.create('sets'));elem.style.width='100%';elem.size=15;elem.onchange=function(ev){me.handleChangeSets(this);};elem.myCallback=callback;if(value.sets&&(0<value.sets.length))
{var option,options=elem.options;for(var i=0;i<value.sets.length;i++)
{var set=value.sets[i];options[i]=option=new Option(set.desc);option.mySet=set;}}
this.createHeader(t,'Actions',4);rows=t.rows.length;cell=this.createAction(t,4);cell.appendChild(Inputter.genSubmit('submitter',CAPTION_SUBMIT));if(criteria.filter.isEdit)
{cell.appendChild(document.createTextNode(' '));cell.appendChild(Inputter.genButton('copier',CAPTION_COPY,function(ev){callback.handleCopy(criteria,this.form);}));cell.appendChild(document.createTextNode(' '));cell.appendChild(Inputter.genButton('deleter',CAPTION_DELETE,function(ev){callback.handleDelete(criteria,value);}));}
cell.appendChild(document.createTextNode(' '));cell.appendChild(Inputter.genButton('canceler',CAPTION_CANCEL,function(ev){callback.handleCancel(criteria);}));return o;}
EditExerciseDOM.createSetOption=function(form)
{var avail=this.available;if(1>form.exerciseType.selectedIndex)
throw{message:'Please select an exercise.',field:form.exerciseType};var record={isMaxOut:form.isMaxOut.checked};record.muscleGroupId=form.muscleGroup.value;record.exerciseTypeId=form.exerciseType.value;record.exerciseTypeName=form.exerciseType.options[form.exerciseType.selectedIndex].text;record.repetitions=form.reps.value;record.weight=form.weight.value;record.weightUnitId=form.weightUnit.value;if(avail(record.weight))
record.weightUnitName=form.weightUnit.options[form.weightUnit.selectedIndex].text;record.heartRateAvg=form.hrAvg.value;record.heartRateMax=form.hrMax.value;record.comments=form.setComments.value;if(!avail(record.repetitions)||isNaN(parseInt(record.repetitions)))
throw{message:'Please provide the number of repetitions.',field:form.reps};var caption=(record.isMaxOut?'MAX':'REP')+':'+' '+record.repetitions+' '+record.exerciseTypeName+
(avail(record.weight)?' X '+record.weight+' '+record.weightUnitId:'')+
(avail(record.heartRateAvg)||avail(record.heartRateMax)?' HR ('+this.fromNull(record.heartRateAvg)+'/'+this.fromNull(record.heartRateMax)+')':'')+
(avail(record.comments)?' - '+record.comments:'');var option=new Option(caption);option.mySet=record;return option;}
EditExerciseDOM.handleEditSet=function(elem,copy)
{var form=elem.form;var sets=form.sets;var options=sets.options;var index=copy?options.length:sets.selectedIndex;if(0>index)
index=options.length;try
{options[index]=this.createSetOption(form);form.reps.focus();this.handleChangeSets(sets);}
catch(error)
{if(error.message)
{window.alert(error.message);error.field.focus();}
else
window.alert(error);}}
EditExerciseDOM.handleMove=function(button,dir)
{var elem=button.form.sets;var index=elem.selectedIndex;var options=elem.options;var newIndex=index+dir;if((0>index)||(0>newIndex)||(options.length<=newIndex))
return;var old_=options[index];var new_=options[newIndex];var old=new Option(old_.text);old.mySet=old_.mySet;var newer=new Option(new_.text);newer.mySet=new_.mySet;options[index]=newer;options[newIndex]=old;elem.selectedIndex=newIndex;}
EditExerciseDOM.handleRemove=function(button)
{var elem=button.form.sets;var index=elem.selectedIndex;if(-1<index)
elem.options[index]=null;this.handleChangeSets(elem);}
EditExerciseDOM.handleClear=function(button)
{var elem=button.form.sets;elem.options.length=0;this.handleChangeSets(elem);}
EditExerciseDOM.handleChangeSets=function(elem)
{var form=elem.form;var index=elem.selectedIndex;form.copySet.style.visibility=(0>index)?'hidden':'visible';form.editSet.value=(0>index)?'Add Set':'Edit Set';if(-1<index)
{var fix=function(a){return(a?a:'');};var record=elem.options[index].mySet;form.muscleGroup.value=record.muscleGroupId;elem.myCallback.handleChangeMuscleGroup(form.muscleGroup,record.exerciseTypeId);form.reps.value=fix(record.repetitions);form.weight.value=fix(record.weight);form.weightUnit.value=fix(record.weightUnitId);form.hrAvg.value=fix(record.heartRateAvg);form.hrMax.value=fix(record.heartRateMax);form.setComments.value=fix(record.comments);form.isMaxOut.checked=record.isMaxOut;}}
EditExerciseDOM.available=function(value){return(value&&(0<value.length));}
EditExerciseDOM.fromNull=function(value){return(value&&(0<value.length)?value:'NA');}

var EditFeedbackDOM=new DetailDOM();EditFeedbackDOM.generate=function(criteria,callback)
{var model=criteria.value;var v=model.value;var isBugReport=(undefined!=criteria.filter.error);var e,t,o=this.createForm(criteria,callback);if(isBugReport)
{Elements.addText(o,'We are sorry, but the '+APP_TITLE+' has experienced an unexpected error.');Elements.addBreak(o);Elements.addText(o,'In order for us to fix the problem as quickly as possible, please briefly');Elements.addBreak(o);Elements.addText(o,'describe what you were doing. Thank you.');}
else
{Elements.addText(o,'Do you have a suggestion? Have you found a bug?');Elements.addBreak(o);Elements.addBreak(o);Elements.addText(o,'We are interested to hear from you. Please tell us how you feel about the '+APP_TITLE+'.');}
Elements.addBreak(o);Elements.addBreak(o);o.appendChild(t=this.createTable());this.createRowX(t,CAPTION_TYPE,true,o.myFirstField=SelectList.generate('typeId',model.feedbackTypeOptions),v.typeId);this.createRowX(t,CAPTION_COMMENTS,true,Inputter.genTextArea('comments',60,6),v.comments);e=this.createAction(t);e.appendChild(Inputter.genSubmit('submitter',CAPTION_SUBMIT));Elements.addSpace(e);e.appendChild(Inputter.genButton('canceler',CAPTION_CANCEL,function(ev){callback.handleCancel(criteria,this.form);}));return o;}
EditFeedbackDOM.genComplete=function(criteria,callback)
{var v=criteria.response;var e,o=this.createTable();o.className+=' feedback';e=o.insertRow(0).insertCell(0);e.colSpan=2;e.innerHTML='Thank you. Your feedback has been forwarded to our support.<br /><br />'+'We will respond to your feedback shortly.<br /><br />';this.createRow(o,CAPTION_TYPE,v.typeName);Elements.addDiv(this.createRow(o,CAPTION_COMMENTS).myValueCell,'dialogComments',v.comments);return o;}

var EditHeartRateLogDOM=new DetailDOM();EditHeartRateLogDOM.generate=function(criteria,callback)
{var model=criteria.value;var v=model.value;var cal=Calendar.getInstance();var e,c,row,t,o=this.createForm(criteria,callback);o.appendChild(t=this.createTable());this.createRowX(t,CAPTION_LOG_DATE,true,cal.create('logDate',v.logDate));this.createRowX(t,CAPTION_HEART_RATE_MIN,false,o.myFirstField=Inputter.genTextBox('heartRateMin',MAX_LEN_HEART_RATE_MIN,MAX_LEN_HEART_RATE_MIN),v.heartRateMin);this.createRowX(t,CAPTION_HEART_RATE_MAX,false,Inputter.genTextBox('heartRateMax',MAX_LEN_HEART_RATE_MAX,MAX_LEN_HEART_RATE_MAX),v.heartRateMax);row=this.createRowX(t,CAPTION_BLOOD_PRESSURE,false,Inputter.genTextBox('bpSystolic',3,3),v.bpSystolic);c=row.myCaptionCell;Elements.addBreak(c);Elements.addText(c,CAPTION_BP_SYSTOLIC+' / '+CAPTION_BP_DIASTOLIC);c=row.myValueCell;Elements.addText(c,' / ');c.appendChild(e=Inputter.genTextBox('bpDiastolic',3,3));if(v.bpDiastolic)
e.value=v.bpDiastolic;c=this.createAction(t);c.appendChild(Inputter.genSubmit('submitter',CAPTION_SUBMIT));if(criteria.filter.isEdit)
{Elements.addSpace(c);c.appendChild(Inputter.genButton('deleter',CAPTION_DELETE,function(ev){callback.handleDelete(criteria,v);}));}
Elements.addSpace(c);c.appendChild(Inputter.genButton('canceler',CAPTION_CANCEL,function(ev){callback.handleCancel(criteria);}));return o;}

var EditMenstruationLogDOM=new DetailDOM();EditMenstruationLogDOM.generate=function(criteria,callback)
{var m=criteria.value;var v=m.value;var cal=Calendar.getInstance();var e,t,o=this.createForm(criteria,callback);o.appendChild(t=this.createTable());this.createRowX(t,CAPTION_LOG_DATE,true,cal.create('logDate',v.logDate));this.createRowX(t,CAPTION_COMMENTS,false,o.myFirstField=Inputter.genTextArea('comments',60,3),v.comments);e=this.createAction(t);e.appendChild(Inputter.genSubmit('submitter',CAPTION_SUBMIT));if(criteria.filter.isEdit)
{Elements.addSpace(e);e.appendChild(Inputter.genButton('deleter',CAPTION_DELETE,function(ev){callback.handleDelete(criteria,v);}));}
Elements.addSpace(e);e.appendChild(Inputter.genButton('canceler',CAPTION_CANCEL,function(ev){callback.handleCancel(criteria);}));return o;}

var EditRouteDOM=new DetailDOM();EditRouteDOM.generate=function(criteria,callback)
{var m=criteria.value;var v=m.value;var e,t,o=this.createForm(criteria,callback);o.appendChild(t=this.createTable());this.createRowX(t,CAPTION_NAME,true,o.myFirstField=Inputter.genTextBox('desc',MAX_LEN_DESC,50),v.desc);this.createRowX(t,CAPTION_DISTANCE_MILES,false,Inputter.genTextBox('distanceMiles',MAX_LEN_DISTANCE_MILES,MAX_LEN_DISTANCE_MILES),v.distanceMiles);this.createRowX(t,CAPTION_DISTANCE_KM,false,Inputter.genTextBox('distanceKm',MAX_LEN_DISTANCE_KM,MAX_LEN_DISTANCE_KM),v.distanceKm);this.createRowX(t,CAPTION_TYPE,false,SelectList.generate('typeId',m.typeOptions,CAPTION_NONE),v.typeId);this.createRowX(t,CAPTION_IS_RACE,false,Inputter.genCheckBox('isRace',1,v.isRace));this.createRowX(t,CAPTION_COMMENTS,false,Inputter.genTextArea('comments',60,6),v.comments);if(m.teamOptions&&(0<m.teamOptions.length))
this.createRowX(t,CAPTION_TEAMS,false,MultiSelectList.generate('teams',m.teamOptions,v.sharedTeamIds,4));e=this.createAction(t);e.appendChild(Inputter.genSubmit('submitter',CAPTION_SUBMIT));e.appendChild(document.createTextNode(' '));e.appendChild(Inputter.genButton('canceler',CAPTION_CANCEL,function(ev){callback.handleCancel(criteria);}))
return o;}

var EditRunDOM=new DetailDOM();EditRunDOM.generate=function(criteria,callback)
{var model=criteria.value;var value=model.value;var me=this;var cal=Calendar.getInstance();var span,a,elem,cell,row,rows=0,t,o=this.createForm(criteria,callback);o.appendChild(t=this.createTable());this.createHeader(t,'Basic Information');if(model.teammate)
this.createRow(t,CAPTION_NAME,value.userFullName);rows=t.rows.length;row=t.insertRow(rows++);this.createCaption(row,0,CAPTION_RUN_DATE,true);o.myTrainingDate=this.createField(row,1,cal.create('trainingDate',value.trainingDate));row=t.insertRow(rows++);this.createCaption(row,0,CAPTION_TIME_OF_DAY,true);o.myTimeOfDayName=this.createField(row,1,o.myFirstField=SelectList.generate('timeOfDay',model.timeOfDayOptions),value.timeOfDayId);row=t.insertRow(rows++);cell=this.createCaption(row,0,CAPTION_RUNNING_ROUTE);Elements.addSpace(cell);cell.appendChild(a=Elements.genAnchor('add',function(ev){callback.handleAddRoute(criteria,this);},'caption'));o.myRouteName=this.createField(row,1,elem=a.mySelect=SelectList.generate('route',model.routeOptions,CAPTION_NONE),value.routeId);elem.onchange=function(ev){callback.handleChangeRoute(criteria,this);};row=t.insertRow(rows++);this.createCaption(row,0,CAPTION_EFFORT_LEVEL);o.myEffortLevelName=this.createField(row,1,elem=SelectList.generate('effortLevel',model.effortLevelOptions,CAPTION_NONE),value.effortLevelId);elem.onchange=function(ev){callback.handleChangeEffortLevel(criteria,this);};row=t.insertRow(rows++);cell=this.createCaption(row,0,CAPTION_WORKOUT);Elements.addSpace(cell);cell.appendChild(elem=Elements.genAnchor('add',function(ev){callback.handleAddWorkout(criteria,this);},'caption'));o.myWorkoutName=this.createField(row,1,elem.mySelect=SelectList.generate('workout',model.workoutOptions,CAPTION_NONE),value.workoutId);row=t.insertRow(rows++);cell=this.createCaption(row,0,CAPTION_SHOE);Elements.addSpace(cell);cell.appendChild(a=Elements.genAnchor('add',function(ev){callback.handleAddShoe(criteria,this);},'caption'));o.myShoeName=cell=this.createField(row,1,elem=a.mySelect=SelectList.generate('shoe',model.shoeOptions,CAPTION_NONE),value.shoeId);elem.onchange=function(ev){callback.handleChangeShoe(criteria,this);};Elements.addText(cell,' Usage ');o.myShoeUsage=Elements.addSpan(cell,'pace');row=t.insertRow(rows++);this.createCaption(row,0,CAPTION_CALORIES);o.myCalories=this.createField(row,1,Inputter.genTextBox('calories',MAX_LEN_CALORIES,MAX_LEN_CALORIES),value.calories);var b=(undefined!=value.distanceMiles);row=t.insertRow(rows++);this.createCaption(row,0,CAPTION_DISTANCE_MILES);o.myDistanceMiles=cell=this.createField(row,1,elem=Inputter.genTextBox('distanceMiles',MAX_LEN_DISTANCE_MILES,MAX_LEN_DISTANCE_MILES),Formatter.toDistance(value.distanceMiles));elem.onchange=function(ev){callback.handleChangeInfo(criteria,this);me.validateMax(this,100);};span=o.myDistanceMiles=Elements.addSpan(cell,undefined,'&nbsp;&nbsp;'+CAPTION_PACE+': &nbsp;');span.style.display=b?'inline':'none';o.myPaceMiles=Elements.addSpan(span,'pace',(value.paceMiles?Formatter.toPace(value.paceMiles):undefined));Elements.addSpan(span,undefined,'&nbsp;&nbsp;'+CAPTION_DISTANCE_KM+': &nbsp;');o.milesToKm=Elements.addSpan(span,'pace',(b?Formatter.toDistance(Formatter.toKm(value.distanceMiles)):undefined));b=(undefined!=value.distanceKm);row=t.insertRow(rows++);this.createCaption(row,0,CAPTION_DISTANCE_KM);o.myDistanceKm=cell=this.createField(row,1,elem=Inputter.genTextBox('distanceKm',MAX_LEN_DISTANCE_KM,MAX_LEN_DISTANCE_KM),Formatter.toDistance(value.distanceKm));elem.onchange=function(ev){callback.handleChangeInfo(criteria,this);me.validateMax(this,100);};span=o.myDistanceKm=Elements.addSpan(cell,undefined,'&nbsp;&nbsp;'+CAPTION_PACE+': &nbsp;');span.style.display=b?'inline':'none';o.myPaceKm=Elements.addSpan(span,'pace',(value.paceKm?Formatter.toPace(value.paceKm):undefined));Elements.addSpan(span,undefined,'&nbsp;&nbsp;'+CAPTION_DISTANCE_MILES+': &nbsp;');o.kmToMiles=Elements.addSpan(span,'pace',(b?Formatter.toDistance(Formatter.toMiles(value.distanceKm)):undefined));row=t.insertRow(rows++);this.createCaption(row,0,CAPTION_DURATION);o.myDuration=cell=this.createField(row,1,elem=Inputter.genTextBox('durationHours',MAX_LEN_DURATION_HOURS,MAX_LEN_DURATION_HOURS),value.durationHours);elem.onchange=function(ev){callback.handleChangeInfo(criteria,this);me.validateMax(this,10);};Elements.addText(cell,' : ');cell.appendChild(elem=Inputter.genTextBox('durationMinutes',MAX_LEN_DURATION_MINUTES,MAX_LEN_DURATION_MINUTES));if(value.durationMinutes)
elem.value=value.durationMinutes;elem.onchange=function(ev){callback.handleChangeInfo(criteria,this);};Elements.addText(cell,' : ');cell.appendChild(elem=Inputter.genTextBox('durationSeconds',MAX_LEN_DURATION_SECONDS,MAX_LEN_DURATION_SECONDS));if(value.durationSeconds)
elem.value=value.durationSeconds;elem.onchange=function(ev){callback.handleChangeInfo(criteria,this);};this.createHeader(t,'Heart Rate');rows=t.rows.length;row=t.insertRow(rows++);this.createCaption(row,0,CAPTION_HEART_RATE_AVG);o.myHeartRateAvg=this.createField(row,1,Inputter.genTextBox('heartRateAvg',MAX_LEN_HEART_RATE_AVG,MAX_LEN_HEART_RATE_AVG),value.heartRateAvg);row=t.insertRow(rows++);this.createCaption(row,0,CAPTION_HEART_RATE_MAX);o.myHeartRateMax=this.createField(row,1,Inputter.genTextBox('heartRateMax',MAX_LEN_HEART_RATE_MAX,MAX_LEN_HEART_RATE_MAX),value.heartRateMax);row=t.insertRow(rows++);this.createCaption(row,0,CAPTION_HEART_RATE_TARGET_MIN);o.myHeartRateTargetMin=this.createField(row,1,Inputter.genTextBox('heartRateTargetMin',MAX_LEN_HEART_RATE_TARGET_MIN,MAX_LEN_HEART_RATE_TARGET_MIN),value.heartRateTargetMin);row=t.insertRow(rows++);this.createCaption(row,0,CAPTION_HEART_RATE_TARGET_MAX);o.myHeartRateTargetMax=this.createField(row,1,Inputter.genTextBox('heartRateTargetMax',MAX_LEN_HEART_RATE_TARGET_MAX,MAX_LEN_HEART_RATE_TARGET_MAX),value.heartRateTargetMax);this.createHeader(t,'Weather &amp; Conditions');rows=t.rows.length;row=t.insertRow(rows++);this.createCaption(row,0,CAPTION_TEMPERATURE);o.myTemperatureName=cell=this.createField(row,1,SelectList.generate('temperatureId',model.temperatureOptions,CAPTION_NOT_SELECTED),value.temperatureId);Elements.addSpace(cell);this.addInput(cell,Inputter.genTextBox('temp',MAX_LEN_TEMP,MAX_LEN_TEMP),value.temp);Elements.addSpace(cell);this.addInput(cell,SelectList.generate('tempUnitId',model.tempUnitOptions),value.tempUnitId);row=t.insertRow(rows++);this.createCaption(row,0,CAPTION_HUMIDITY);o.myHumidityName=cell=this.createField(row,1,SelectList.generate('humidityId',model.humidityOptions,CAPTION_NOT_SELECTED),value.humidityId);Elements.addSpace(cell);this.addInput(cell,Inputter.genTextBox('humidity',MAX_LEN_TEMP,MAX_LEN_TEMP),value.humidity);Elements.addText(cell,' %');row=t.insertRow(rows++);this.createCaption(row,0,CAPTION_PRECIPITATION);o.myPrecipitationName=this.createField(row,1,SelectList.generate('precipitationId',model.precipitationOptions,CAPTION_NOT_SELECTED),value.precipitationId);row=t.insertRow(rows++);this.createCaption(row,0,CAPTION_WIND);o.myWindName=cell=this.createField(row,1,SelectList.generate('windId',model.windOptions,CAPTION_NOT_SELECTED),value.windId);Elements.addSpace(cell);this.addInput(cell,Inputter.genTextBox('wind',MAX_LEN_TEMP,MAX_LEN_TEMP),value.wind);Elements.addSpace(cell);this.addInput(cell,SelectList.generate('windUnitId',model.distanceUnitOptions),value.windUnitId);Elements.addText(cell,' / Hour');row=t.insertRow(rows++);this.createCaption(row,0,CAPTION_SURFACE_CONDITION);o.mySurfaceConditionName=this.createField(row,1,SelectList.generate('surfaceConditionId',model.surfaceConditionOptions,CAPTION_NOT_SELECTED),value.surfaceConditionId);row=t.insertRow(rows++);this.createCaption(row,0,CAPTION_COMMENTS);o.myComments=this.createField(row,1,Inputter.genTextArea('comments',60,6),value.comments);cell=this.createAction(t);cell.appendChild(Inputter.genSubmit('submitter',CAPTION_SUBMIT));Elements.addSpace(cell);cell.appendChild(Inputter.genButton('addRepeats',CAPTION_SAVE_AND_ADD_SPLITS,function(ev){var form=this.form;form.saveAndAddSplits=true;form.onsubmit(ev);}));if(criteria.filter.isEdit)
{Elements.addSpace(cell);cell.appendChild(Inputter.genButton('deleter',CAPTION_DELETE,function(ev){callback.handleDelete(criteria,value);}));}
Elements.addSpace(cell);cell.appendChild(Inputter.genButton('canceler',CAPTION_CANCEL,function(ev){callback.handleCancel(criteria,this.form);}));return o;}
EditRunDOM.addInput=function(o,e,v)
{o.appendChild(e);if(v)
e.value=v;}

var EditSleepLogDOM=new DetailDOM();EditSleepLogDOM.generate=function(criteria,callback)
{var m=criteria.value;var v=m.value;var cal=Calendar.getInstance();var e,t,o=this.createForm(criteria,callback);o.appendChild(t=this.createTable());this.createRowX(t,CAPTION_LOG_DATE,true,cal.create('logDate',v.logDate));this.createRowX(t,CAPTION_SLEEP_QUALITY,false,o.myFirstField=SelectList.generate('sleepQuality',m.sleepQualityOptions,CAPTION_NONE),v.sleepQualityId);this.createRowX(t,CAPTION_DURATION_HOURS,false,Inputter.genTextBox('durationHours',MAX_LEN_DURATION_HOURS,MAX_LEN_DURATION_HOURS),v.durationHours);this.createRowX(t,CAPTION_DURATION_MINUTES,false,Inputter.genTextBox('durationMinutes',MAX_LEN_DURATION_MINUTES,MAX_LEN_DURATION_MINUTES),v.durationMinutes);e=this.createAction(t);e.appendChild(Inputter.genSubmit('submitter',CAPTION_SUBMIT));if(criteria.filter.isEdit)
{Elements.addSpace(e);e.appendChild(Inputter.genButton('deleter',CAPTION_DELETE,function(ev){callback.handleDelete(criteria,v);}));}
Elements.addSpace(e);e.appendChild(Inputter.genButton('canceler',CAPTION_CANCEL,function(ev){callback.handleCancel(criteria);}));return o;}

var EditTeamDOM=new DetailDOM();EditTeamDOM.generate=function(criteria,callback)
{var m=criteria.value;var value=m.value;var elem,cell,row,rows,t,o=this.createForm(criteria,callback);o.appendChild(t=this.createTable());this.createHeader(t,'Basic Information',2);rows=t.rows.length;this.createRowX(t,CAPTION_NAME,true,o.myFirstField=Inputter.genTextBox('desc',MAX_LEN_DESC,MAX_LEN_DESC),value.name);this.createRowX(t,CAPTION_TYPE,true,SelectList.generate('typeId',m.typeOptions),value.typeId);this.createRowX(t,CAPTION_CITY,false,Inputter.genTextBox('city',MAX_LEN_CITY,MAX_LEN_CITY),value.city);this.createRowX(t,CAPTION_STATE,false,SelectList.generate('state',m.stateOptions),value.stateId);this.createRowX(t,CAPTION_COUNTRY,true,elem=SelectList.generate('country',m.countryOptions),value.countryId);elem.onchange=function(ev){callback.handleChangeCountry(criteria,elem);};e=this.createRowX(t,CAPTION_WEB_SITE_URL,false,Inputter.genTextBox('webSiteUrl',MAX_LEN_WEB_SITE_URL,50),value.webSiteUrl).myValueCell;e.insertBefore(document.createTextNode('http://'),e.firstChild);this.createRowX(t,CAPTION_IS_ACTIVE,false,Inputter.genCheckBox('isActive',1,value.isActive));this.createRowX(t,CAPTION_IS_SEARCHABLE,false,Inputter.genCheckBox('isSearchable',1,value.isSearchable));this.createRowX(t,CAPTION_COMMENTS,false,Inputter.genTextArea('comments',60,6),value.comments);var access=value.access;if(!value.accessTypes)
{value.accessTypes=new Array(access.length);for(var i=0;i<access.length;i++)
value.accessTypes[i]={id:access[i].id,memberTypeId:access[i].memberTypeId};}
var colSpan=access.length+1;o.appendChild(t=this.createTable());this.createHeader(t,'Access rights (who can see/edit what)',colSpan);rows=t.rows.length;row=t.insertRow(rows++);row.insertCell(0);for(var i=0;i<access.length;i++)
this.createHeaderCell(row,i+1,access[i].memberTypeName);this.createAccessCells(t.insertRow(rows++),access,m,CAPTION_CAN_VIEW_PROFILE,'canViewProfile');this.createAccessCells(t.insertRow(rows++),access,m,CAPTION_CAN_EDIT_PROFILE,'canEditProfile');this.createAccessCells(t.insertRow(rows++),access,m,CAPTION_CAN_VIEW_LOG,'canViewLog');this.createAccessCells(t.insertRow(rows++),access,m,CAPTION_CAN_EDIT_LOG,'canEditLog');this.createAccessCells(t.insertRow(rows++),access,m,CAPTION_CAN_VIEW_CALENDAR,'canViewCalendar');this.createAccessCells(t.insertRow(rows++),access,m,CAPTION_CAN_EDIT_CALENDAR,'canEditCalendar');this.createAccessCells(t.insertRow(rows++),access,m,CAPTION_CAN_VIEW_SUMMARY,'canViewSummary');this.createHeader(t,'Permissions (who can do what)',colSpan);rows=t.rows.length;row=t.insertRow(rows++);row.insertCell(0);for(var i=0;i<access.length;i++)
this.createHeaderCell(row,i+1,access[i].memberTypeName);this.createAuthCells(t.insertRow(rows++),access,CAPTION_CAN_CREATE_TEAM_ROUTES,'canCreateTeamRoutes');this.createAuthCells(t.insertRow(rows++),access,CAPTION_CAN_CREATE_TEAM_WORKOUTS,'canCreateTeamWorkouts');this.createAuthCells(t.insertRow(rows++),access,CAPTION_CAN_SEND_TEAM_EMAILS,'canSendTeamEmails');this.createAuthCells(t.insertRow(rows++),access,CAPTION_CAN_INVITE_NEW_MEMBERS,'canInviteNewMembers');cell=this.createAction(t);cell.appendChild(Inputter.genSubmit('submitter',CAPTION_SUBMIT));cell.appendChild(document.createTextNode(' '));cell.appendChild(Inputter.genButton('canceler',CAPTION_CANCEL,function(ev){callback.handleCancel(criteria);}))
return o;}
EditTeamDOM.createHeaderCell=function(row,cells,caption)
{var a=row.insertCell(cells);a.className=this.CSS_HEADER;a.innerHTML=caption;return a;}
EditTeamDOM.createAccessCells=function(row,access,model,caption,name)
{this.createCaption(row,0,caption);for(var i=0;i<access.length;i++)
{var elem,item=access[i];this.createField(row,i+1,elem=SelectList.generate(name,model.accessTypeOptions),item[name]);elem.myItem=item;}}
EditTeamDOM.createAuthCells=function(row,access,caption,name)
{this.createCaption(row,0,caption);for(var i=0;i<access.length;i++)
{var elem,item=access[i],cell=row.insertCell(i+1);cell.className='listingCheckBox';cell.appendChild(elem=Inputter.genCheckBox(name,1,item[name]));elem.myItem=item;}}

var EditTeamMemberDOM=new DetailDOM();EditTeamMemberDOM.generate=function(criteria,callback)
{var model=criteria.value;var v=model.value;var e,t,o=this.createForm(criteria,callback);o.appendChild(t=this.createTable());this.createHeader(t,'Basic Information');this.createRow(t,CAPTION_MEMBER_NAME,v.memberName);this.createRow(t,CAPTION_TEAM_NAME,v.teamName);this.createRow(t,CAPTION_TEAM_MEMBER_TYPE,v.memberTypeName);this.createHeader(t,'Restrict other members\' access to my information (Note: Forced Access can override this)');this.createRowX(t,CAPTION_CAN_VIEW_PROFILE,false,Inputter.genCheckBox('canViewProfile',1,v.canViewProfile));this.createRowX(t,CAPTION_CAN_EDIT_PROFILE,false,Inputter.genCheckBox('canEditProfile',1,v.canEditProfile));this.createRowX(t,CAPTION_CAN_VIEW_LOG,false,Inputter.genCheckBox('canViewLog',1,v.canViewLog));this.createRowX(t,CAPTION_CAN_EDIT_LOG,false,Inputter.genCheckBox('canEditLog',1,v.canEditLog));this.createRowX(t,CAPTION_CAN_VIEW_CALENDAR,false,Inputter.genCheckBox('canViewCalendar',1,v.canViewCalendar));this.createRowX(t,CAPTION_CAN_EDIT_CALENDAR,false,Inputter.genCheckBox('canEditCalendar',1,v.canEditCalendar));this.createRowX(t,CAPTION_CAN_VIEW_SUMMARY,false,Inputter.genCheckBox('canViewSummary',1,v.canViewSummary));this.createHeader(t,'What can you do');this.createRow(t,CAPTION_CAN_CREATE_TEAM_ROUTES,Formatter.toDisplayable(v.canCreateTeamRoutes));this.createRow(t,CAPTION_CAN_CREATE_TEAM_WORKOUTS,Formatter.toDisplayable(v.canCreateTeamWorkouts));this.createRow(t,CAPTION_CAN_SEND_TEAM_EMAILS,Formatter.toDisplayable(v.canSendTeamEmails));this.createRow(t,CAPTION_CAN_INVITE_NEW_MEMBERS,Formatter.toDisplayable(v.canInviteNewMembers));this.createHeader(t,'Status Information');if(v.isPending)
this.createRow(t,CAPTION_STATUS,v.statusName);else if(v.isOwner)
this.createRow(t,CAPTION_IS_ACTIVE,Formatter.toDisplayable(v.isActive));else
this.createRowX(t,CAPTION_IS_ACTIVE,false,Inputter.genCheckBox('isActive',1,v.isActive));e=this.createAction(t);e.appendChild(Inputter.genSubmit('submitter',CAPTION_SUBMIT));Elements.addSpace(e);e.appendChild(Inputter.genButton('canceler',CAPTION_CANCEL,function(ev){callback.handleCancel(criteria);}))
return o;}

var EditTeamMembersDOM=new ListingDOM();EditTeamMembersDOM.generate=function(criteria,callback)
{var filter=criteria.filter;var model=criteria.value;var value=model.value;var myself=model.myself;var elem,cell,cells=0,row,rows=0,t,o=document.createElement('form');o.className='widgetPackage';o.appendChild(elem=document.createElement('h3'));elem.innerHTML=CAPTION_TEAM+': '+myself.teamName;o.appendChild(document.createTextNode(CAPTION_SHOW+' '));o.appendChild(elem=SelectList.generate('status',model.statusOptions,CAPTION_ALL));elem.onchange=function(ev){callback.handleChangeStatus(criteria,this);};if(filter.statusId)
elem.value=filter.statusId;Elements.addBreak(o);Elements.addBreak(o);var records=value.records;if(!records||(0==records.length))
{o.appendChild(this.createNoDataFound());return o;}
o.appendChild(t=this.createTable());row=this.createHeaderRow(t,rows++);this.createHeaderCell(row,0).colSpan=3;(cell=this.createHeaderCell(row,1,'Restrictions to Member Optional Permissions')).colSpan=7;cell.className='listingCaptionCenter';this.createHeaderCell(row,2).colSpan=2;row=this.createHeaderRow(t,rows++);this.createHeaderCell(row,cells++);this.createHeaderCell(row,cells++);this.createHeaderCell(row,cells++,CAPTION_MEMBER_NAME);this.createHeaderCell(row,cells++,CAPTION_CAN_VIEW_PROFILE);this.createHeaderCell(row,cells++,CAPTION_CAN_EDIT_PROFILE);this.createHeaderCell(row,cells++,CAPTION_CAN_VIEW_LOG);this.createHeaderCell(row,cells++,CAPTION_CAN_EDIT_LOG);this.createHeaderCell(row,cells++,CAPTION_CAN_VIEW_CALENDAR);this.createHeaderCell(row,cells++,CAPTION_CAN_EDIT_CALENDAR);this.createHeaderCell(row,cells++,CAPTION_CAN_VIEW_SUMMARY);this.createHeaderCell(row,cells++,CAPTION_STATUS);this.createHeaderCell(row,cells++,CAPTION_ROLE);for(var i=0;i<records.length;i++)
{var record=records[i];cells=0;row=t.insertRow(rows++);row.className=this.getRowCss(i);this.createDetailCell(row,cells++).appendChild(Elements.genImage(record.typeIconSource,record.typeName));this.createDetailCell(row,cells++).appendChild(elem=Inputter.genButtonX('delete',CAPTION_DELETE,function(ev){callback.handleDelete(criteria,this);},'iconDelete'));elem.myRecord=record;this.createDetailCell(row,cells++).appendChild(elem=Formatter.toEmail(record.emailAddress));elem.innerHTML=record.memberName;this.createAuthCell(row,cells++,record.canViewProfile);this.createAuthCell(row,cells++,record.canEditProfile);this.createAuthCell(row,cells++,record.canViewLog);this.createAuthCell(row,cells++,record.canEditLog);this.createAuthCell(row,cells++,record.canViewCalendar);this.createAuthCell(row,cells++,record.canEditCalendar);this.createAuthCell(row,cells++,record.canViewSummary);this.createDetailCell(row,cells++,record.statusName);this.createDetailCell(row,cells++).appendChild(elem=SelectList.generate('typeId',model.typeOptions));elem.myRecord=record;elem.value=record.typeId;elem.onchange=function(ev){callback.handleChangeType(criteria,this);};}
return o;}
EditTeamMembersDOM.createAuthCell=function(row,cells,value)
{this.createDetailCell(row,cells,Formatter.toDisplayable(value)).className+=' listingCheckBox';}

var EditTrainingDetailsDOM=new ListingDOM();EditTrainingDetailsDOM.generate=function(criteria,callback)
{var records=criteria.value.records;var totalMiles=0,totalKm=0,totalSeconds=0;var elem,cell,cells=0,row,rows=0,t,o=document.createElement('form');o.className='widgetPackage';o.appendChild(elem=document.createElement('h3'));elem.innerHTML=criteria.value.parentName;o.appendChild(t=this.createTable());o.myCriteria=criteria;o.myCallback=callback;o.myRecords=records;t.myCount=records.length;t.myRows=[];t.myHrColSpan=2;o.myTable=t;row=t.myFirstRow=t.insertRow(rows++);row.className=this.CSS_CAPTION;this.createHeaderCell(row,cells++);this.createHeaderCell(row,cells++,CAPTION_MILES);this.createHeaderCell(row,cells++,CAPTION_KM);this.createHeaderCell(row,cells++,CAPTION_DURATION);this.createHeaderCell(row,cells++,CAPTION_HR_AVG);this.createHeaderCell(row,cells++,CAPTION_HR_MAX);this.createHeaderCell(row,cells++,CAPTION_COMMENTS);this.createHeaderCell(row,cells++,CAPTION_PACE);if(!records)
records=[];for(var i=0;i<records.length;i++)
{cells=0;var record=records[i];row=t.myRows[i]=t.insertRow(rows++);row.myRecord=record;row.className=this.getRowCss(i);cell=this.createDetailCell(row,cells++);cell.className=cell.className+' nowrap';cell.appendChild(document.createTextNode(' '));cell.appendChild(elem=Inputter.genButtonX('deleteRecord','Delete',function(ev){callback.handleDelete(criteria,this.myRecord);},'iconDelete'));elem.myRecord=record;this.createDetailCell(row,cells++).appendChild(elem=Inputter.genTextBox('distanceMiles',MAX_LEN_DISTANCE_MILES,4));elem.myRecord=record;elem.onchange=this.elem_onChange;if(record.distanceMiles)
{totalMiles+=record.distanceMiles;elem.value=record.distanceMiles;}
this.createDetailCell(row,cells++).appendChild(elem=Inputter.genTextBox('distanceKm',MAX_LEN_DISTANCE_KM,4));elem.myRecord=record;elem.onchange=this.elem_onChange;if(record.distanceKm)
{totalKm+=record.distanceKm;elem.value=record.distanceKm;}
cell=this.createDetailCell(row,cells++);cell.className+=' nowrap';cell.appendChild(elem=Inputter.genTextBox('durationHours',MAX_LEN_DURATION_HOURS,2));elem.myRecord=record;elem.onchange=this.elem_onChange;if(record.durationHours)
{totalSeconds+=(3600*record.durationHours);elem.value=record.durationHours;}
cell.appendChild(document.createTextNode(':'));cell.appendChild(elem=Inputter.genTextBox('durationMinutes',MAX_LEN_DURATION_MINUTES,2));elem.myRecord=record;elem.onchange=this.elem_onChange;if(record.durationMinutes)
{totalSeconds+=(60*record.durationMinutes);elem.value=record.durationMinutes;}
cell.appendChild(document.createTextNode(':'));cell.appendChild(elem=Inputter.genTextBox('durationSeconds',MAX_LEN_DURATION_SECONDS,4));elem.myRecord=record;elem.onchange=this.elem_onChange;if(record.durationSeconds)
{totalSeconds+=record.durationSeconds;elem.value=record.durationSeconds;}
this.createDetailCell(row,cells++).appendChild(elem=Inputter.genTextBox('heartRateAvg',MAX_LEN_HEART_RATE_AVG,3));elem.myRecord=record;elem.onchange=this.elem_onChange;elem.value=Formatter.toDisplayable(record.heartRateAvg);this.createDetailCell(row,cells++).appendChild(elem=Inputter.genTextBox('heartRateMax',MAX_LEN_HEART_RATE_MAX,3));elem.myRecord=record;elem.onchange=this.elem_onChange;elem.value=Formatter.toDisplayable(record.heartRateMax);this.createDetailCell(row,cells++).appendChild(elem=Inputter.genTextBox('comments',MAX_LEN_SHORT_COMMENTS,20));elem.myRecord=record;elem.onchange=this.elem_onChange;elem.value=Formatter.toDisplayable(record.comments);row.myPace=this.createDetailCell(row,cells,record.paceMiles?Formatter.toPace(record.paceMiles):record.paceKm?Formatter.toPace(record.paceKm):'');}
if(0<records.length)
{cells=0;row=t.myLastRow=t.insertRow(rows++);row.className=this.CSS_TOTALS;this.createDetailCell(row,cells++,CAPTION_TOTALS);cell=o.myTotalMiles=this.createDetailCell(row,cells++,totalMiles>0?Formatter.toDistance(totalMiles)+ABBR_MILES:undefined);cell.className+=' listingDistance';cell=o.myTotalKm=this.createDetailCell(row,cells++,totalKm>0?Formatter.toDistance(totalKm)+ABBR_KM:undefined);cell.className+=' listingDistance';var totals=Formatter.fromTotalSecondsX(totalSeconds);totals.distanceMiles=totalMiles;totals.distanceKm=totalKm;cell=o.myTotalDuration=this.createDetailCell(row,cells++,Formatter.toDuration(totals));cell.className+=' listingDuration';this.createDetailCell(row,cells++).colSpan=4;cells=0;row=t.insertRow(rows++);row.className=this.CSS_TOTALS;this.createDetailCell(row,cells++,CAPTION_PACE);cell=o.myPaceMiles=this.createDetailCell(row,cells++,Formatter.toPaceMiles(totals));cell.className+=' listingDistance';cell=o.myPaceKm=this.createDetailCell(row,cells++,Formatter.toPaceKm(totals));cell.className+=' listingDistance';this.createDetailCell(row,cells++);this.createDetailCell(row,cells++,'Count: '+records.length).colSpan=4;}
cells=0;row=t.insertRow(rows++);if(!t.myLastRow)
t.myLastRow=row;row.className=this.CSS_TOTALS;this.createDetailCell(row,cells++,CAPTION_ADD);this.createDetailCell(row,cells++).appendChild(elem=Inputter.genTextBox('distanceMilesX',MAX_LEN_DISTANCE_MILES,4));this.createDetailCell(row,cells++).appendChild(elem=Inputter.genTextBox('distanceKmX',MAX_LEN_DISTANCE_KM,4));cell=this.createDetailCell(row,cells++);cell.appendChild(elem=Inputter.genTextBox('durationHoursX',MAX_LEN_DURATION_HOURS,2));cell.appendChild(document.createTextNode(':'));cell.appendChild(elem=Inputter.genTextBox('durationMinutesX',MAX_LEN_DURATION_MINUTES,2));cell.appendChild(document.createTextNode(':'));cell.appendChild(elem=Inputter.genTextBox('durationSecondsX',MAX_LEN_DURATION_SECONDS,4));this.createDetailCell(row,cells++).appendChild(elem=Inputter.genTextBox('heartRateAvgX',MAX_LEN_HEART_RATE_AVG,3));this.createDetailCell(row,cells++).appendChild(elem=Inputter.genTextBox('heartRateMaxX',MAX_LEN_HEART_RATE_MAX,3));this.createDetailCell(row,cells++).appendChild(elem=Inputter.genTextBox('commentsX',MAX_LEN_SHORT_COMMENTS,20));this.createDetailCell(row,cells).appendChild(elem=Inputter.genButton('adder',CAPTION_ADD,function(ev){callback.handleAdd(criteria,o);}));return o;}
EditTrainingDetailsDOM.elem_onChange=function(ev)
{this.form.myCallback.handleUpdate(this);}
EditTrainingDetailsDOM.recalc=function(elem)
{var record=elem.myRecord;var paceCell=elem.parentNode.parentNode.myPace;var pace=Formatter.toPaceMiles(record);if(!pace||(0==pace.length))
pace=Formatter.toPaceKm(record);paceCell.innerHTML=pace;var form=elem.form;var totalMiles=0;var totalKm=0;var totalSeconds=0;var records=form.myRecords;for(var i=0;i<records.length;i++)
{record=records[i];if(record.distanceMiles)
totalMiles+=Formatter.parseFloat(record.distanceMiles);if(record.distanceKm)
totalKm+=Formatter.parseFloat(record.distanceKm);if(record.durationHours)
totalSeconds+=(3600*Formatter.parseInt(record.durationHours));if(record.durationMinutes)
totalSeconds+=(60*Formatter.parseInt(record.durationMinutes));if(record.durationSeconds)
totalSeconds+=Formatter.parseFloat(record.durationSeconds);}
var totals=Formatter.fromTotalSecondsX(totalSeconds);totals.distanceMiles=totalMiles;totals.distanceKm=totalKm;form.myTotalMiles.innerHTML=(0<totalMiles)?Formatter.toDistance(totalMiles)+ABBR_MILES:'';form.myTotalKm.innerHTML=(0<totalKm)?Formatter.toDistance(totalKm)+ABBR_KM:'';form.myTotalDuration.innerHTML=Formatter.toDuration(totals);form.myPaceMiles.innerHTML=Formatter.toPaceMiles(totals);form.myPaceKm.innerHTML=Formatter.toPaceKm(totals);}

var EditUserDOM=new DetailDOM();EditUserDOM.generate=function(criteria,callback)
{if(!this.cal)
this.cal=Calendar.getInstance();;var m=criteria.value;var v=m.value;var a,e,t,o=this.createForm(criteria,callback);o.appendChild(t=this.createTable());e=this.createRowX(t,CAPTION_EMAIL_ADDRESS,true,o.myFirstField=Inputter.genTextBox('emailAddress',MAX_LEN_EMAIL_ADDRESS,50),v.emailAddress).myValueCell;Elements.addBreak(e);Elements.addSpan(e,'footnote','Your e-mail address is also your login name.');this.createRowX(t,CAPTION_PASSWORD,true,Inputter.genPassword('password',MAX_LEN_PASSWORD,20));this.createRowX(t,'Confirm '+CAPTION_PASSWORD,true,Inputter.genPassword('confirmPassword',MAX_LEN_PASSWORD,20));this.createRowX(t,CAPTION_FIRST_NAME,true,Inputter.genTextBox('firstName',MAX_LEN_FIRST_NAME,MAX_LEN_FIRST_NAME),v.firstName);this.createRowX(t,CAPTION_MIDDLE_INITIAL,false,Inputter.genTextBox('middleInitial',MAX_LEN_MIDDLE_INITIAL,MAX_LEN_MIDDLE_INITIAL),v.middleInitial);this.createRowX(t,CAPTION_LAST_NAME,true,Inputter.genTextBox('lastName',MAX_LEN_LAST_NAME,MAX_LEN_LAST_NAME),v.lastName);this.createRowX(t,CAPTION_CITY,false,Inputter.genTextBox('city',MAX_LEN_CITY,50),v.city);this.createRowX(t,CAPTION_STATE,true,SelectList.generate('state',m.stateOptions),v.stateId);this.createRowX(t,CAPTION_COUNTRY,true,e=SelectList.generate('country',m.countryOptions),v.countryId);e.onchange=function(ev){callback.handleCountryChange(criteria,this);};e=this.createRowX(t,CAPTION_POSTAL_CODE,false,Inputter.genTextBox('postalCode',16,10),v.postalCode).myValueCell;a=Elements.addDiv(e,'footnote','Needed for Weather Helper. For non-USA residents click ');a.appendChild(Elements.genAnchor('here',function(ev){callback.openWeatherLocations(criteria,o);return false;}));Elements.addText(a,' to get your weather location.');e=o.myWeatherLocation=this.createRowX(t,'Weather Location',false,a=SelectList.create('weatherLocation'));e.style.display='none';a.onchange=function(ev){this.form.postalCode.value=this.value;};this.createRowX(t,CAPTION_GENDER,true,a=SelectList.generate('gender',m.genderOptions),v.genderId);a.onchange=function(ev){callback.handleGenderChange(criteria,this);return false;};e=o.myTrackCycles=this.createRowX(t,CAPTION_TRACK_CYCLES,false,Inputter.genCheckBox('trackCycles',1,v.trackCycles));callback.showGenderInfo(a);this.createRowX(t,CAPTION_DATE_OF_BIRTH,true,this.cal.create('dateOfBirth',v.dateOfBirth));this.createRowX(t,CAPTION_DEFAULT_TIME_OF_DAY,false,SelectList.generate('defaultTimeOfDay',m.timeOfDayOptions,CAPTION_NONE),v.defaultTimeOfDayId);this.createRowX(t,CAPTION_DEFAULT_UNIT_TYPE,true,SelectList.generate('defaultUnitType',m.unitTypeOptions),v.defaultUnitTypeId);this.createRowX(t,CAPTION_FIRST_DAY_OF_WEEK,true,SelectList.generate('firstDayOfWeek',m.dayOfWeekOptions),v.firstDayOfWeekId);this.createRowX(t,CAPTION_SHARE_JOURNAL,false,Inputter.genCheckBox('shareJournal',1,v.shareJournal));this.createRowX(t,'Enable Weather Helper?',false,Inputter.genCheckBox('hasInstantWeather',1,v.hasInstantWeather));this.createRowX(t,CAPTION_BIOGRAPHY,false,Inputter.genTextArea('biography',60,6),v.biography);if(criteria.filter.isEdit)
{this.createRow(t,CAPTION_CREATED_DATE,Formatter.toTimestamp(v.createdDate));this.createRow(t,CAPTION_LAST_MODIFIED_DATE,Formatter.toTimestamp(v.lastModifiedDate));}
e=this.createAction(t);e.appendChild(Inputter.genSubmit('submitter',CAPTION_SUBMIT));Elements.addSpace(e);e.appendChild(Inputter.genButton('canceler',CAPTION_CANCEL,function(ev){callback.handleCancel(criteria,this.form);}));return o;}

var EditWeightLogDOM=new DetailDOM();EditWeightLogDOM.generate=function(criteria,callback)
{var m=criteria.value;var v=m.value;var cal=Calendar.getInstance();var e,t,o=this.createForm(criteria,callback);o.appendChild(t=this.createTable());this.createRowX(t,CAPTION_LOG_DATE,true,cal.create('logDate',v.logDate));this.createRowX(t,CAPTION_WEIGHT,false,o.myFirstField=Inputter.genTextBox('weight',MAX_LEN_WEIGHT,MAX_LEN_WEIGHT),v.weight);this.createRowX(t,CAPTION_WEIGHT_UNIT,false,SelectList.generate('weightUnit',m.weightUnitOptions),v.weightUnitId);e=this.createRowX(t,CAPTION_BODY_FAT_PERCENT,false,Inputter.genTextBox('bodyFatPercent',MAX_LEN_BODY_FAT_PERCENT,MAX_LEN_BODY_FAT_PERCENT),v.bodyFatPercent).myValueCell;Elements.addText(e,' (example ==> 23.5)');e=this.createAction(t);e.appendChild(Inputter.genSubmit('submitter',CAPTION_SUBMIT));if(criteria.filter.isEdit)
{Elements.addSpace(e);e.appendChild(Inputter.genButton('deleter',CAPTION_DELETE,function(ev){callback.handleDelete(criteria,v);}));}
Elements.addSpace(e);e.appendChild(Inputter.genButton('canceler',CAPTION_CANCEL,function(ev){callback.handleCancel(criteria);}));return o;}

var EditWorkoutDOM=new DetailDOM();EditWorkoutDOM.generate=function(criteria,callback)
{var m=criteria.value;var v=m.value;var e,t,o=this.createForm(criteria,callback);o.appendChild(t=this.createTable());this.createRowX(t,CAPTION_NAME,true,o.myFirstField=Inputter.genTextBox('desc',MAX_LEN_DESC,50),v.desc);this.createRowX(t,CAPTION_IS_FARTLEK,false,Inputter.genCheckBox('isFartlek',1,v.isFartlek));this.createRowX(t,CAPTION_IS_TRACK,false,Inputter.genCheckBox('isTrack',1,v.isTrack));this.createRowX(t,CAPTION_COMMENTS,false,Inputter.genTextArea('comments',60,6),v.comments);if(m.teamOptions&&(0<m.teamOptions.length))
this.createRowX(t,CAPTION_TEAMS,false,MultiSelectList.generate('teams',m.teamOptions,v.sharedTeamIds,4));e=this.createAction(t);e.appendChild(Inputter.genSubmit('submitter',CAPTION_SUBMIT));Elements.addSpace(e);e.appendChild(Inputter.genButton('addRepeats',CAPTION_SAVE_AND_ADD_REPEATS,function(ev){this.form.saveAndAddRepeats=true;this.form.onsubmit(ev);}))
Elements.addSpace(e);e.appendChild(Inputter.genButton('canceler',CAPTION_CANCEL,function(ev){callback.handleCancel(criteria);}))
return o;}

var EditXtrainingDOM=new DetailDOM();EditXtrainingDOM.generate=function(criteria,callback)
{var model=criteria.value;var value=model.value;var me=this;var cal=Calendar.getInstance();var span,a,elem,cell,row,rows=0,t,o=this.createForm(criteria,callback);o.appendChild(t=this.createTable());this.createHeader(t,'Basic Information');if(model.teammate)
this.createRow(t,CAPTION_NAME,value.userFullName);rows=t.rows.length;row=t.insertRow(rows++);this.createCaption(row,0,CAPTION_TRAINING_TYPE,true);o.myType=this.createField(row,1,elem=o.myFirstField=SelectList.generate('typeId',model.typeOptions),value.typeId);elem.onchange=function(ev){callback.handleChangeType(criteria,this);};row=t.insertRow(rows++);this.createCaption(row,0,CAPTION_TRAINING_DATE,true);o.myTrainingDate=this.createField(row,1,cal.create('trainingDate',value.trainingDate));row=t.insertRow(rows++);this.createCaption(row,0,CAPTION_TIME_OF_DAY,true);o.myTimeOfDayName=this.createField(row,1,SelectList.generate('timeOfDay',model.timeOfDayOptions),value.timeOfDayId);row=o.rowRoute=t.insertRow(rows++);o.myRouteName=cell=this.createCaption(row,0,CAPTION_RUNNING_ROUTE);Elements.addSpace(cell);cell.appendChild(a=Elements.genAnchor('add',function(ev){callback.handleAddRoute(criteria,this);},'caption'));this.createField(row,1,elem=a.mySelect=SelectList.generate('route',model.routeOptions,CAPTION_NONE),value.routeId);elem.onchange=function(ev){callback.handleChangeRoute(criteria,this);};row=t.insertRow(rows++);this.createCaption(row,0,CAPTION_EFFORT_LEVEL);o.myEffortLevelName=this.createField(row,1,elem=SelectList.generate('effortLevel',model.effortLevelOptions,CAPTION_NONE),value.effortLevelId);elem.onchange=function(ev){callback.handleChangeEffortLevel(criteria,this);};row=t.insertRow(rows++);cell=this.createCaption(row,0,CAPTION_WORKOUT);Elements.addSpace(cell);cell.appendChild(elem=Elements.genAnchor('add',function(ev){callback.handleAddWorkout(criteria,this);},'caption'));o.myWorkoutName=this.createField(row,1,elem.mySelect=SelectList.generate('workout',model.workoutOptions,CAPTION_NONE),value.workoutId);row=o.rowBike=t.insertRow(rows++);cell=this.createCaption(row,0,CAPTION_BIKE);Elements.addSpace(cell);cell.appendChild(a=Elements.genAnchor('add',function(ev){callback.handleAddBike(criteria,this);},'caption'));o.myBikeName=cell=this.createField(row,1,elem=a.mySelect=SelectList.generate('bikeId',model.bikeOptions,CAPTION_NONE),value.bikeId);elem.onchange=function(ev){callback.handleChangeBike(criteria,this);};Elements.addText(cell,' Usage ');o.myBikeUsage=Elements.addSpan(cell,'pace');row=o.rowSki=t.insertRow(rows++);cell=this.createCaption(row,0,CAPTION_SKI);Elements.addSpace(cell);cell.appendChild(a=Elements.genAnchor('add',function(ev){callback.handleAddSki(criteria,this);},'caption'));o.mySkiName=cell=this.createField(row,1,elem=a.mySelect=SelectList.generate('skiId',model.skiOptions,CAPTION_NONE),value.skiId);elem.onchange=function(ev){callback.handleChangeSki(criteria,this);};Elements.addText(cell,' Usage ');o.mySkiUsage=Elements.addSpan(cell,'pace');row=o.rowSwimStroke=t.insertRow(rows++);this.createCaption(row,0,CAPTION_SWIM_STROKE);this.createField(row,1,SelectList.generate('swimStroke',model.swimStrokeOptions,'Multiple'),value.swimStrokeId);row=o.rowYogaStyle=t.insertRow(rows++);this.createCaption(row,0,CAPTION_YOGA_STYLE);this.createField(row,1,SelectList.generate('yogaStyleId',model.yogaStyleOptions,CAPTION_NONE),value.yogaStyleId);row=o.rowMartialArtType=t.insertRow(rows++);this.createCaption(row,0,CAPTION_MARTIAL_ART_TYPE);this.createField(row,1,SelectList.generate('martialArtTypeId',model.martialArtTypeOptions,CAPTION_NONE),value.martialArtTypeId);row=o.rowTechnique=t.insertRow(rows++);this.createCaption(row,0,CAPTION_TECHNIQUE);o.myTechnique=this.createField(row,1,Inputter.genTextBox('technique',MAX_LEN_TECHNIQUE,MAX_LEN_TECHNIQUE),value.technique);row=o.rowInstructor=t.insertRow(rows++);this.createCaption(row,0,CAPTION_INSTRUCTOR);o.myInstructor=this.createField(row,1,Inputter.genTextBox('instructor',MAX_LEN_INSTRUCTOR,MAX_LEN_INSTRUCTOR),value.instructor);row=o.rowWattage=t.insertRow(rows++);this.createCaption(row,0,CAPTION_WATTAGE_AVG_MAX);o.myWattage=cell=this.createField(row,1,Inputter.genTextBox('wattageAvg',MAX_LEN_WATTAGE_AVG,MAX_LEN_WATTAGE_AVG),value.wattageAvg);Elements.addText(cell,' / ');this.addInput(cell,Inputter.genTextBox('wattageMax',MAX_LEN_WATTAGE_MAX,MAX_LEN_WATTAGE_MAX),value.wattageMax);row=o.rowRpm=t.insertRow(rows++);this.createCaption(row,0,CAPTION_RPM_AVG_MAX);o.myRpm=cell=this.createField(row,1,Inputter.genTextBox('rpmAvg',MAX_LEN_RPM,MAX_LEN_RPM),value.rpmAvg);Elements.addText(cell,' / ');this.addInput(cell,Inputter.genTextBox('rpmMax',MAX_LEN_RPM,MAX_LEN_RPM),value.rpmMax);row=o.rowCalories=t.insertRow(rows++);this.createCaption(row,0,CAPTION_CALORIES);o.myCalories=this.createField(row,1,Inputter.genTextBox('calories',MAX_LEN_CALORIES,MAX_LEN_CALORIES),value.calories);row=o.rowSteps=t.insertRow(rows++);this.createCaption(row,0,CAPTION_STEPS);o.mySteps=this.createField(row,1,Inputter.genTextBox('steps',MAX_LEN_STEPS,MAX_LEN_STEPS),value.steps);var b=(undefined!=value.distanceMiles);row=o.rowDistanceMiles=t.insertRow(rows++);this.createCaption(row,0,CAPTION_DISTANCE_MILES);o.myDistanceMiles=cell=this.createField(row,1,elem=Inputter.genTextBox('distanceMiles',MAX_LEN_DISTANCE_MILES,MAX_LEN_DISTANCE_MILES),Formatter.toDistance(value.distanceMiles));elem.onchange=function(ev){callback.handleChangeInfo(criteria,this);me.validateMax(this,200);};span=o.myDistanceMiles=Elements.addSpan(cell,undefined,'&nbsp;&nbsp;'+CAPTION_PACE+': &nbsp;');span.style.display=b?'inline':'none';o.myPaceMiles=Elements.addSpan(span,'pace',(value.paceMiles?Formatter.toPace(value.paceMiles):undefined));Elements.addSpan(span,undefined,'&nbsp;&nbsp;'+CAPTION_DISTANCE_KM+': &nbsp;');o.milesToKm=Elements.addSpan(span,'pace',(b?Formatter.toDistance(Formatter.toKm(value.distanceMiles)):undefined));b=(undefined!=value.distanceKm);row=o.rowDistanceKm=t.insertRow(rows++);this.createCaption(row,0,CAPTION_DISTANCE_KM);o.myDistanceKm=cell=this.createField(row,1,elem=Inputter.genTextBox('distanceKm',MAX_LEN_DISTANCE_KM,MAX_LEN_DISTANCE_KM),Formatter.toDistance(value.distanceKm));elem.onchange=function(ev){callback.handleChangeInfo(criteria,this);me.validateMax(this,300);};span=o.myDistanceKm=Elements.addSpan(cell,undefined,'&nbsp;&nbsp;'+CAPTION_PACE+': &nbsp;');span.style.display=b?'inline':'none';o.myPaceKm=Elements.addSpan(span,'pace',(value.paceKm?Formatter.toPace(value.paceKm):undefined));Elements.addSpan(span,undefined,'&nbsp;&nbsp;'+CAPTION_DISTANCE_MILES+': &nbsp;');o.kmToMiles=Elements.addSpan(span,'pace',(b?Formatter.toDistance(Formatter.toMiles(value.distanceKm)):undefined));row=t.insertRow(rows++);this.createCaption(row,0,CAPTION_DURATION);o.myDuration=cell=this.createField(row,1,elem=Inputter.genTextBox('durationHours',MAX_LEN_DURATION_HOURS,MAX_LEN_DURATION_HOURS),value.durationHours);elem.onchange=function(ev){callback.handleChangeInfo(criteria,this);me.validateMax(this,15);};Elements.addText(cell,' : ');cell.appendChild(elem=Inputter.genTextBox('durationMinutes',MAX_LEN_DURATION_MINUTES,MAX_LEN_DURATION_MINUTES));if(value.durationMinutes)
elem.value=value.durationMinutes;elem.onchange=function(ev){callback.handleChangeInfo(criteria,this);};Elements.addText(cell,' : ');cell.appendChild(elem=Inputter.genTextBox('durationSeconds',MAX_LEN_DURATION_SECONDS,MAX_LEN_DURATION_SECONDS));if(value.durationSeconds)
elem.value=value.durationSeconds;elem.onchange=function(ev){callback.handleChangeInfo(criteria,this);};this.createHeader(t,'Heart Rate');rows=t.rows.length;row=t.insertRow(rows++);this.createCaption(row,0,CAPTION_HEART_RATE_AVG);o.myHeartRateAvg=this.createField(row,1,Inputter.genTextBox('heartRateAvg',MAX_LEN_HEART_RATE_AVG,MAX_LEN_HEART_RATE_AVG),value.heartRateAvg);row=t.insertRow(rows++);this.createCaption(row,0,CAPTION_HEART_RATE_MAX);o.myHeartRateMax=this.createField(row,1,Inputter.genTextBox('heartRateMax',MAX_LEN_HEART_RATE_MAX,MAX_LEN_HEART_RATE_MAX),value.heartRateMax);row=t.insertRow(rows++);this.createCaption(row,0,CAPTION_HEART_RATE_TARGET_MIN);o.myHeartRateTargetMin=this.createField(row,1,Inputter.genTextBox('heartRateTargetMin',MAX_LEN_HEART_RATE_TARGET_MIN,MAX_LEN_HEART_RATE_TARGET_MIN),value.heartRateTargetMin);row=t.insertRow(rows++);this.createCaption(row,0,CAPTION_HEART_RATE_TARGET_MAX);o.myHeartRateTargetMax=this.createField(row,1,Inputter.genTextBox('heartRateTargetMax',MAX_LEN_HEART_RATE_TARGET_MAX,MAX_LEN_HEART_RATE_TARGET_MAX),value.heartRateTargetMax);this.createHeader(t,'Weather &amp; Conditions');rows=t.rows.length;row=o.rowTemperature=t.insertRow(rows++);this.createCaption(row,0,CAPTION_TEMPERATURE);o.myTemperatureName=cell=this.createField(row,1,SelectList.generate('temperatureId',model.temperatureOptions,CAPTION_NOT_SELECTED),value.temperatureId);Elements.addSpace(cell);this.addInput(cell,Inputter.genTextBox('temp',MAX_LEN_TEMP,MAX_LEN_TEMP),value.temp);Elements.addSpace(cell);this.addInput(cell,SelectList.generate('tempUnitId',model.tempUnitOptions),value.tempUnitId);row=o.rowWaterTemperature=t.insertRow(rows++);this.createCaption(row,0,CAPTION_WATER_TEMPERATURE);o.myWaterTemperatureName=this.createField(row,1,SelectList.generate('waterTemperatureId',model.waterTemperatureOptions,CAPTION_NOT_SELECTED),value.waterTemperatureId);row=o.rowHumidity=t.insertRow(rows++);this.createCaption(row,0,CAPTION_HUMIDITY);o.myHumidityName=cell=this.createField(row,1,SelectList.generate('humidityId',model.humidityOptions,CAPTION_NOT_SELECTED),value.humidityId);Elements.addSpace(cell);this.addInput(cell,Inputter.genTextBox('humidity',MAX_LEN_TEMP,MAX_LEN_TEMP),value.humidity);Elements.addText(cell,' %');row=o.rowPrecipitation=t.insertRow(rows++);this.createCaption(row,0,CAPTION_PRECIPITATION);o.myPrecipitationName=this.createField(row,1,SelectList.generate('precipitationId',model.precipitationOptions,CAPTION_NOT_SELECTED),value.precipitationId);row=o.rowWind=t.insertRow(rows++);this.createCaption(row,0,CAPTION_WIND);o.myWindName=cell=this.createField(row,1,SelectList.generate('windId',model.windOptions,CAPTION_NOT_SELECTED),value.windId);Elements.addSpace(cell);this.addInput(cell,Inputter.genTextBox('wind',MAX_LEN_TEMP,MAX_LEN_TEMP),value.wind);Elements.addSpace(cell);this.addInput(cell,SelectList.generate('windUnitId',model.distanceUnitOptions),value.windUnitId);Elements.addText(cell,' / Hour');row=o.rowSurfaceCondition=t.insertRow(rows++);this.createCaption(row,0,CAPTION_SURFACE_CONDITION);o.mySurfaceConditionName=this.createField(row,1,SelectList.generate('surfaceConditionId',model.surfaceConditionOptions,CAPTION_NOT_SELECTED),value.surfaceConditionId);row=o.rowSnowCondition=t.insertRow(rows++);this.createCaption(row,0,CAPTION_SNOW_CONDITION);o.mySnowConditionName=this.createField(row,1,SelectList.generate('snowConditionId',model.snowConditionOptions,CAPTION_NOT_SELECTED),value.snowConditionId);row=t.insertRow(rows++);this.createCaption(row,0,CAPTION_COMMENTS);o.myComments=this.createField(row,1,Inputter.genTextArea('comments',60,6),value.comments);cell=this.createAction(t);cell.appendChild(Inputter.genSubmit('submitter',CAPTION_SUBMIT));Elements.addSpace(cell);cell.appendChild(Inputter.genButton('addRepeats',CAPTION_SAVE_AND_ADD_SPLITS,function(ev){var form=this.form;form.saveAndAddSplits=true;form.onsubmit(ev);}));if(criteria.filter.isEdit)
{Elements.addSpace(cell);cell.appendChild(Inputter.genButton('deleter',CAPTION_DELETE,function(ev){callback.handleDelete(criteria,value);}));}
Elements.addSpace(cell);cell.appendChild(Inputter.genButton('canceler',CAPTION_CANCEL,function(ev){callback.handleCancel(criteria,this.form);}));return o;}
EditXtrainingDOM.addInput=EditRunDOM.addInput;

var EmailBlogDOM=new DetailDOM();EmailBlogDOM.generate=function(criteria,callback)
{var me=this;var value=criteria.value;var elem,cell,row,rows=0,t,o=this.createForm();o.onsubmit=function(ev){me.handleAdd(this);return false;};o.innerHTML='Add one or more e-mail addresses to the list below.';Elements.addBreak(o);Elements.addBreak(o);o.appendChild(t=this.createTable());this.createRow(t,CAPTION_TITLE,value.title);this.createRow(t,CAPTION_AUTHOR,value.creatorName);rows=t.rows.length;cell=this.createRowX(t,CAPTION_EMAIL_ADDRESS,true,o.myFirstField=Inputter.genTextBox('email',MAX_LEN_EMAIL_ADDRESS,30)).myValueCell;Elements.addSpan(cell,undefined,'&nbsp;&nbsp;');cell.appendChild(Inputter.genSubmit('adder',CAPTION_ADD));this.createAction(t).innerHTML='&nbsp;';rows=t.rows.length;row=t.insertRow(rows++);this.createField(row,0,elem=document.createElement('b')).colSpan=2;elem.innerHTML='Recipients';row=t.insertRow(rows++);this.createField(row,0,elem=SelectList.create('recipients')).colSpan=2;elem.size=6;elem.style.width='100%';elem.onchange=function(ev){this.form.remover.disabled=(0>this.selectedIndex);};row=t.insertRow(rows++);cell=this.createField(row,0,elem=Inputter.genButton('remover',CAPTION_REMOVE,function(ev)
{var a=this.form.recipients;var i=a.selectedIndex;if(-1<i)a.options[i]=null;if(a.options.length>i)a.selectedIndex=i;else if(-1<(i-1))a.selectedIndex=i-1;else this.disabled=true;}));elem.disabled=true;cell.colSpan=2;cell.style.textAlign='right';cell=this.createAction(t);cell.appendChild(Inputter.genButton('submitter',CAPTION_SUBMIT,function(ev){callback.handleSubmit(criteria,this.form);}));cell.appendChild(document.createTextNode(' '));cell.appendChild(Inputter.genButton('canceler',CAPTION_CANCEL,function(ev){callback.handleCancel(criteria,this.form);}));return o;}
EmailBlogDOM.handleAdd=function(form)
{try
{var email=form.email;if(0==email.value.length)
throw{message:'Please provide an '+CAPTION_EMAIL_ADDRESS+'.',field:email};var options=form.recipients.options;options[options.length]=new Option(email.value,email.value);email.value='';email.focus();}
catch(error)
{window.alert(error.message);error.field.focus();}}

var InviteNewTeamMembersDOM=new DetailDOM();InviteNewTeamMembersDOM.generate=function(criteria,callback)
{var me=this;var value=criteria.value;var elem,cell,row,rows=0,t,o=this.createForm();o.onsubmit=function(ev){me.handleAdd(this);return false;};o.innerHTML='Add one or more potential team members to the list below.<br />'+'If a potential member is already a '+APP_TITLE+' member, you only need<br />'+'to supply their e-mail address. Otherwise also include both their first and last names.';Elements.addBreak(o);Elements.addBreak(o);o.appendChild(t=this.createTable());this.createRow(t,CAPTION_TEAM_NAME,value.name);this.createRow(t,CAPTION_TEAM_OWNER,value.ownerName);this.createRowX(t,CAPTION_EMAIL_ADDRESS,true,o.myFirstField=Inputter.genTextBox('email',MAX_LEN_EMAIL_ADDRESS,30));this.createRowX(t,CAPTION_FIRST_NAME,false,Inputter.genTextBox('firstName',MAX_LEN_FIRST_NAME,MAX_LEN_FIRST_NAME));this.createRowX(t,CAPTION_LAST_NAME,false,Inputter.genTextBox('lastName',MAX_LEN_LAST_NAME,MAX_LEN_LAST_NAME));this.createAction(t).appendChild(Inputter.genSubmit('adder',CAPTION_ADD));this.createAction(t).innerHTML='&nbsp;';rows=t.rows.length;row=t.insertRow(rows++);this.createField(row,0,elem=document.createElement('b')).colSpan=2;elem.innerHTML='New Team Members';row=t.insertRow(rows++);this.createField(row,0,elem=SelectList.create('newMembers')).colSpan=2;elem.size=6;elem.style.width='100%';elem.onchange=function(ev){this.form.remover.disabled=(0>this.selectedIndex);};row=t.insertRow(rows++);cell=this.createField(row,0,elem=Inputter.genButton('remover',CAPTION_REMOVE,function(ev)
{var a=this.form.newMembers;var i=a.selectedIndex;if(-1<i)a.options[i]=null;if(a.options.length>i)a.selectedIndex=i;else if(-1<(i-1))a.selectedIndex=i-1;else this.disabled=true;}));elem.disabled=true;cell.colSpan=2;cell.style.textAlign='right';cell=this.createAction(t);cell.appendChild(Inputter.genButton('submitter',CAPTION_SUBMIT,function(ev){var f=this.form;callback.handleSubmit(criteria,f);f.hideActionButtons();}));cell.appendChild(document.createTextNode(' '));cell.appendChild(Inputter.genButton('canceler',CAPTION_CANCEL,function(ev){callback.handleCancel(criteria,this.form);}));return o;}
InviteNewTeamMembersDOM.handleAdd=function(form)
{try
{var email=form.email;if(0==email.value.length)
throw{message:'Please provide an '+CAPTION_EMAIL_ADDRESS+'.',field:email};var id=email.value;var caption=email.value;var firstName=form.firstName.value;if(0<firstName.length)
{var lastName=form.lastName;if(0==lastName.value.length)
throw{message:'Please provide a '+CAPTION_LAST_NAME+'.',field:lastName};id+=DELIMITER+firstName+DELIMITER+lastName.value;caption+=' - '+firstName+' '+lastName.value;}
var options=form.newMembers.options;options[options.length]=new Option(caption,id);email.value='';form.firstName.value='';form.lastName.value='';email.focus();}
catch(error)
{window.alert(error.message);error.field.focus();}}

var LeaderBoardDOM=new ListingDOM();LeaderBoardDOM.generate=function(criteria,callback)
{var filter=criteria.filter;var model=criteria.value;var value=model.value;var action,elem,cell,row,rows=0,t,o=document.createElement('form');o.className='widgetPackage';o.appendChild(t=this.createTable());row=t.insertRow(rows++);cell=row.insertCell(0);cell.colSpan=2;cell.className=this.CSS_FIELD+' nowrap';if(model.periodOptions)
{cell.appendChild(elem=SelectList.generate('period',model.periodOptions));if(model.period)
elem.value=model.period;elem.onchange=function(ev){callback.handleChangePeriod(criteria,this);return false;};cell.appendChild(document.createTextNode(' '));}
cell.appendChild(elem=Elements.genAnchor('&lt;&lt;',function(ev){callback.handleChangeYear(criteria,value.year-1);return false;}));elem.className='year';cell.appendChild(document.createTextNode(' '+value.year+' '));cell.appendChild(elem=Elements.genAnchor('&gt;&gt;',function(ev){callback.handleChangeYear(criteria,value.year+1);return false;}));elem.className='year';cell.appendChild(document.createTextNode(' '));cell.appendChild(elem=SelectList.generate('distanceUnit',model.distanceUnitOptions,CAPTION_DEFAULT_DISTANCE_UNIT));elem.onchange=function(ev){callback.handleChangeDistanceUnit(criteria,this);};if(filter.distanceUnitId)
elem.value=filter.distanceUnitId;cell.appendChild(document.createTextNode(' '));cell.appendChild(elem=SelectList.generate('trainingType',model.typeOptions));elem.onchange=function(ev){callback.handleChangeType(criteria,this);};if(filter.trainingTypeId)
elem.value=filter.trainingTypeId;row=this.createHeaderRow(t,rows++);this.createHeaderCell(row,0,CAPTION_MEN);this.createHeaderCell(row,1,CAPTION_WOMEN);if(value.malesByYear&&value.femalesByYear)
{elem=CAPTION_YEAR+' &mdash; '+value.year;action=function(ev){callback.toYear(criteria,this);return false;};row=t.insertRow(rows++);cell=row.insertCell(0);cell.className='top';cell.appendChild(this.genDetails(criteria,callback,value.malesByYear,elem,action));cell=row.insertCell(1);cell.className='top';cell.appendChild(this.genDetails(criteria,callback,value.femalesByYear,elem,action));}
if(value.malesByMonth&&value.femalesByMonth)
{elem=CAPTION_MONTH+' &mdash; '+value.monthName;action=function(ev){callback.toMonth(criteria,this);return false;};row=t.insertRow(rows++);cell=row.insertCell(0);cell.className='top';cell.appendChild(this.genDetails(criteria,callback,value.malesByMonth,elem,action));cell=row.insertCell(1);cell.className='top';cell.appendChild(this.genDetails(criteria,callback,value.femalesByMonth,elem,action));}
if(value.malesByWeek&&value.femalesByWeek)
{elem=CAPTION_WEEK+' &mdash; '+Formatter.toDate(value.weekEnding);action=function(ev){callback.toWeek(criteria,this);return false;};row=t.insertRow(rows++);cell=row.insertCell(0);cell.className='top';cell.appendChild(this.genDetails(criteria,callback,value.malesByWeek,elem,action));cell=row.insertCell(1);cell.className='top';cell.appendChild(this.genDetails(criteria,callback,value.femalesByWeek,elem,action));}
return o;}
LeaderBoardDOM.genDetails=function(criteria,callback,records,caption,action)
{var value=criteria.value.value;var userId=value.currentUserId;var showDistanceInfo=value.showDistanceInfo;var elem,cell,row,rows=0,o=this.createTable();o.className+=' fill';row=this.createHeaderRow(o,rows++);this.createHeaderCell(row,0,caption).colSpan=2;cell=this.createHeaderCell(row,1);cell.className+=' right nowrap';cell.appendChild(elem=document.createElement('a'));elem.href='javascript:void(null)';elem.className='more';elem.innerHTML=value.byAll?'More &gt;&gt;':'&lt;&lt; Less';elem.onclick=value.byAll?action:function(ev){callback.toAll(criteria,this);return false;};if(0==records.length)
{row=o.insertRow(rows++);cell=row.insertCell(0);cell.colSpan=3;cell.appendChild(this.createNoDataFound());return o;}
for(var i=0;i<records.length;i++)
{var record=records[i];row=o.insertRow(rows++);row.className=this.getRowCss(i)+(userId==record.id?'Bold':'');this.createDetailCell(row,0,(i+1)+'. '+record.fullName).className+=' nowrap';this.createDetailCell(row,1,record.location);this.createDetailCell(row,2,(showDistanceInfo?Formatter.toDistance(record.training):Formatter.fromTotalSeconds(record.training)));}
return o;}

var ListBlogCommentsDOM={}
ListBlogCommentsDOM.SORTS=[{caption:'Newest',sortOn:'createdDate',sortDir:SORT_DESC},{caption:'Oldest',sortOn:'createdDate',sortDir:SORT_ASC}];ListBlogCommentsDOM.ROWS=['blogEven','blogOdd'];ListBlogCommentsDOM.generate=function(criteria,callback)
{var model=criteria.value;var value=model.value;var records=value.records;var isAdmin=model.isAdmin;var e,a,o=document.createElement('div');o.className='widgetPackage';if(!records||(0==records.length))
{o.appendChild(document.createTextNode('There are no comments for this blog entry yet.'));return o;}
o.appendChild(e=document.createElement('div'));e.appendChild(a=document.createElement('span'));Elements.addSpan(a,undefined,'Sort By: ');this.addSorts(a,value,criteria,callback);a=Elements.addSpan(e,'blogPager');a.appendChild(Pager.generate(criteria,callback));Elements.addBreak(o);for(var i=0;i<records.length;i++)
{var record=records[i];a=Elements.addDiv(o,this.ROWS[i%2]);Elements.addSpan(a,'blogTitle',record.title);this.addLink(a,CAPTION_REPLY,function(ev){callback.handleReply(criteria,this.myRecord);},record);this.addLink(a,CAPTION_REPORT_ABUSE,function(ev){callback.handleReportAbuse(criteria,this.myRecord);},record);if(isAdmin)
{this.addLink(a,CAPTION_EDIT,function(ev){callback.handleEdit(criteria,this.myRecord);},record);if(record.isDeleted)
{a.appendChild(document.createTextNode(' '));Elements.addSpan(a,'blogStatusRevoked',CAPTION_DELETED);}
else
this.addLink(a,CAPTION_DELETE,function(ev){callback.handleDelete(criteria,this.myRecord);},record);}
var byline=Formatter.toTimestamp(record.createdDate);if(record.creatorName)
byline+='&nbsp;&mdash;&nbsp;'+record.creatorName;else if(record.fullName)
byline+='&nbsp;&mdash;&nbsp;'+record.fullName;else
byline+='&nbsp;&mdash;&nbsp;'+CAPTION_ANONYMOUS;e=Elements.addDiv(a,'byline',byline);if(record.url)
{Elements.addSpan(e,undefined,'&nbsp;&mdash;&nbsp;');e.appendChild(Formatter.toWebsite(record.url));}
Elements.addBreak(a);Elements.addDiv(a,'blogEntry',record.contents);}
Elements.addBreak(o);e=Elements.addDiv(o,'blogPager');e.appendChild(Pager.generate(criteria,callback));return o;}
ListBlogCommentsDOM.addLink=function(a,caption,action,record)
{var e;a.appendChild(document.createTextNode(' ['));a.appendChild(e=Elements.genAnchor(caption,action,'blogAction'));a.appendChild(document.createTextNode(']'));e.myRecord=record;}
ListBlogCommentsDOM.addSorts=function(o,value,criteria,callback)
{var e;for(var i=0;i<this.SORTS.length;i++)
{if(0<i)
o.appendChild(document.createTextNode(' | '));var item=this.SORTS[i];if((item.sortOn==value.sortOn)&&(item.sortDir==value.sortDir))
Elements.addSpan(o,'blogSortSelected',item.caption);else
{o.appendChild(e=Elements.genAnchor(item.caption,function(ev){callback.handleSort(criteria,this.myItem);},'blogSort'));e.myItem=item;}}}

var ListBlogsDOM={}
ListBlogsDOM.SORTS=[{caption:'Newest',sortOn:'releaseDate',sortDir:SORT_DESC},{caption:'Oldest',sortOn:'releaseDate',sortDir:SORT_ASC},{caption:'Author',sortOn:'author',sortDir:SORT_ASC},{caption:'Title',sortOn:'title',sortDir:SORT_ASC}];ListBlogsDOM.ROWS=['blogEven','blogOdd'];ListBlogsDOM.generate=function(criteria,callback)
{var model=criteria.value;var value=model.value;var records=value.records;var e,a,o=document.createElement('div');o.className='widgetPackage';if(!records||(0==records.length))
{o.appendChild(document.createTextNode('No search results found.'));return o;}
o.appendChild(e=document.createElement('div'));e.appendChild(a=document.createElement('span'));Elements.addSpan(a,undefined,'Sort By: ');this.addSorts(a,value,criteria,callback);a=Elements.addSpan(e,'blogPager');a.appendChild(Pager.generate(criteria,callback));Elements.addBreak(o);for(var i=0;i<records.length;i++)
{var record=records[i];var isAuthor=(model.isAuthor&&(model.userId==record.creatorId));var canAuthor=(model.isAdmin||(isAuthor&&!record.isRevoked));a=Elements.addDiv(o,this.ROWS[i%2]);a.appendChild(e=Elements.genAnchor(record.title,function(ev){callback.handleSelect(criteria,this.myRecord);},'blogTitle'));e.myRecord=record;if(canAuthor)
{a.appendChild(document.createTextNode(' ['));a.appendChild(e=Elements.genAnchor(CAPTION_EDIT,function(ev){callback.handleEdit(criteria,this.myRecord);},'blogAction'));a.appendChild(document.createTextNode(']'));e.myRecord=record;}
if(!record.isRevoked&&(model.isAdmin||(isAuthor&&(!record.releaseDate))))
{a.appendChild(document.createTextNode(' ['));a.appendChild(e=Elements.genAnchor(CAPTION_DELETE,function(ev){callback.handleDelete(criteria,this.myRecord);},'blogAction'));a.appendChild(document.createTextNode(']'));e.myRecord=record;}
if(isAuthor||model.isAdmin)
Elements.addSpan(a,record.isRevoked?'blogStatusRevoked':'blogStatus','&nbsp;&mdash;&nbsp;'+record.statusName);var date=record.releaseDate?record.releaseDate:record.createdDate;Elements.addDiv(a,'byline',Formatter.toTimestamp(date)+'&nbsp;&mdash;&nbsp;'+record.creatorName+'&nbsp;&mdash;&nbsp;'+record.numberOfComments+' comments');a.appendChild(e=document.createElement('div'));e.className='blogEntry';e.innerHTML=record.contents;}
Elements.addBreak(o);e=Elements.addDiv(o,'blogPager');e.appendChild(Pager.generate(criteria,callback));return o;}
ListBlogsDOM.addSorts=function(o,value,criteria,callback)
{var e;for(var i=0;i<this.SORTS.length;i++)
{if(0<i)
o.appendChild(document.createTextNode(' | '));var item=this.SORTS[i];if((item.sortOn==value.sortOn)&&(item.sortDir==value.sortDir))
Elements.addSpan(o,'blogSortSelected',item.caption);else
{o.appendChild(e=Elements.genAnchor(item.caption,function(ev){callback.handleSort(criteria,this.myItem);},'blogSort'));e.myItem=item;}}}

var ListBlogsMini={}
ListBlogsMini.ROWS=['blogEven','blogOdd'];ListBlogsMini.generate=function(criteria,callback)
{var model=criteria.value;var value=model.value;var records=value.records;var e,a,o=document.createElement('div');o.className='widgetPackage';if(!records||(0==records.length))
{o.appendChild(document.createTextNode('No search results found.'));return o;}
for(var i=0;i<records.length;i++)
{var record=records[i];a=Elements.addDiv(o,this.ROWS[i%2]);a.appendChild(e=Elements.genAnchor(record.title,function(ev){callback.handleSelect(criteria,this.myRecord);},'blogTitle'));e.myRecord=record;var date=record.releaseDate?record.releaseDate:record.createdDate;Elements.addDiv(a,'byline',Formatter.toTimestamp(date));Elements.addDiv(a,'byline',record.creatorName+'&nbsp;&mdash;&nbsp;'+record.numberOfComments+'&nbsp;comments');a.appendChild(e=document.createElement('div'));e.className='blogEntry';e.innerHTML=record.contents;}
Elements.addBreak(o);o.appendChild(e=document.createElement('a'));e.className='rssX';e.href=RSS_URL;e.target='_new';e.innerHTML=CAPTION_SUBSCRIBE
o.appendChild(Elements.genAnchor('See More >>',function(ev){callback.handleMore(criteria);},'blogMore'));return o;}

var ListCommunityTrainingDOM=new ListingDOM();ListCommunityTrainingDOM.generate=function(criteria,callback)
{var model=criteria.value;var value=model.value;var records=value.records;if(!records||(0==records.length))
return this.createNoDataFound(criteria,callback);var elem,cell,cells=0,row,rows=0,table,o=this.createTable();o.appendChild(table=document.createElement('tbody'));row=table.insertRow(rows++);this.createHeaderCell(row,cells++);this.createHeaderCell(row,cells++,CAPTION_TRAINING_DATE,'trainingDate',SORT_DESC,criteria,value,callback);this.createHeaderCell(row,cells++,CAPTION_NAME,'name',SORT_ASC,criteria,value,callback);this.createHeaderCell(row,cells++,CAPTION_LOCATION,'country',SORT_ASC,criteria,value,callback);this.createHeaderCell(row,cells++,CAPTION_ROUTE,'route',SORT_ASC,criteria,value,callback);this.createHeaderCell(row,cells++,CAPTION_DISTANCE,'distance',SORT_DESC,criteria,value,callback);this.createHeaderCell(row,cells++,CAPTION_DURATION,'duration',SORT_DESC,criteria,value,callback);this.createHeaderCell(row,cells++,CAPTION_PACE);for(var i=0;i<records.length;i++)
{cells=0;var expander,css,record=records[i];row=table.insertRow(rows++);row.className=css=this.getRowCss(i);var distance=record.distanceMiles?record.distanceMiles:record.distanceKm;cell=this.createDetailCell(row,cells++);cell.className+=' nowrap';cell.appendChild(expander=Inputter.genButtonX('expander',TITLE_EXPANDER,function(ev){callback.toggle(criteria,this);},this.CSS_EXPAND));expander.myRecord=record;expander.isExpanded=false;expander.isFilled=false;cell.appendChild(document.createTextNode(' '));cell.appendChild(elem=Inputter.genButtonX('showDetails','Show Splits',function(ev){callback.showDetails(criteria,this.myRecord);},'iconDetails'));elem.myRecord=record;cell=this.createDetailCell(row,cells++);cell.className+=' nowrap';cell.appendChild(elem=document.createElement('a'));elem.href='javascript:void(null);';elem.innerHTML=Formatter.toDate(record.trainingDate);elem.myRecord=record;elem.onclick=function(ev){callback.handleSelect(criteria,this.myRecord);};cell.appendChild(document.createTextNode(' '));cell.appendChild(elem=document.createElement('a'));elem.href='javascript:void(null);';elem.myRecord=record;elem.onclick=function(ev){callback.handleSelect(criteria,this.myRecord);};elem.style.textDecoration='none';elem.appendChild(Elements.genImage(record.timeOfDayIconSrc,record.timeOfDayName));elem.appendChild(document.createTextNode(' '));elem.appendChild(Elements.genImage(record.typeIconSrc,record.typeName));this.createDetailCell(row,cells++,record.userFullName);this.createDetailCell(row,cells++,record.userLocation);this.createDetailCell(row,cells++,record.routeName);this.createDetailCell(row,cells++,distance?distance+record.distanceAbbr:undefined);this.createDetailCell(row,cells++,Formatter.toDuration(record));this.createDetailCell(row,cells++,Formatter.toPace(record.pace));expander.myRow=row=table.insertRow(rows++);row.className=css;row.style.display='none';expander.myCell=cell=row.insertCell(0);cell.colSpan=cells;cell.className=css+'Container';}
this.createCaption(o,criteria,value,callback);return o;}

var ListEffortLevelsDOM=new ListingDOM();ListEffortLevelsDOM.generate=function(criteria,callback)
{var value=criteria.value;var records=value.records;if(!records||(0==records.length))
this.createNoDataFound(criteria,callback);var elem,cell,cells=0,row,rows=0,t,o=document.createElement('form');o.className='widgetPackage';o.appendChild(t=this.createTable());row=t.insertRow(rows++);this.createHeaderCell(row,cells++,CAPTION_DESC);this.createHeaderCell(row,cells++,CAPTION_HEART_RATE_MIN);this.createHeaderCell(row,cells++,CAPTION_HEART_RATE_MAX);for(var i=0;i<records.length;i++)
{cells=0;var record=records[i];row=t.insertRow(rows++);row.className=this.getRowCss(i);this.createFieldCell(row,cells++,elem=Inputter.genTextBox('desc',MAX_LEN_DESC,30),record,record.desc,criteria,callback);this.createFieldCell(row,cells++,elem=Inputter.genTextBox('heartRateMin',MAX_LEN_HEART_RATE_MIN,MAX_LEN_HEART_RATE_MIN),record,record.heartRateMin,criteria,callback).className+=' listingHR';this.createFieldCell(row,cells++,elem=Inputter.genTextBox('heartRateMax',MAX_LEN_HEART_RATE_MAX,MAX_LEN_HEART_RATE_MAX),record,record.heartRateMax,criteria,callback).className+=' listingHR';}
return o;}
ListEffortLevelsDOM.createFieldCell=function(row,cells,field,record,value,criteria,callback)
{var o=row.insertCell(cells);o.className=row.className;o.appendChild(field);field.onchange=function(ev){callback.handleChange(criteria,field,record);};if(value)
field.value=value;return o;}

var ListEquipmentDOM=new ListingDOM();ListEquipmentDOM.generate=function(criteria,callback)
{var value=criteria.value;var records=value.records;if(!records||(0==records.length))
return this.createNoDataFound(criteria,callback);var elem,cell,cells=0,row,rows=0,o=this.createTable();row=o.insertRow(rows++);row.className=this.CSS_CAPTION;this.createHeaderCell(row,cells++);this.createHeaderCell(row,cells++,CAPTION_PURCHASE_DATE);this.createHeaderCell(row,cells++,CAPTION_BIKE_BRAND);this.createHeaderCell(row,cells++,CAPTION_MODEL_NAME);this.createHeaderCell(row,cells++,CAPTION_BIKE_MODEL_TYPE);this.createHeaderCell(row,cells++,CAPTION_EXPIRATION);this.createHeaderCell(row,cells++,CAPTION_DISTANCE_USED);this.createHeaderCell(row,cells++,'Warn?');this.createHeaderCell(row,cells++,CAPTION_IS_ACTIVE+'?');for(var i=0;i<records.length;i++)
{record=records[i];cells=0;row=o.insertRow(rows++);row.className=this.getRowCss(i);cell=this.createDetailCell(row,cells++);cell.className=cell.className+' nowrap';cell.appendChild(elem=Inputter.genButtonX('copyRecord','Copy',function(ev){callback.copyRecord(criteria,this.myRecord);},'iconCopy'));elem.myRecord=record;cell.appendChild(document.createTextNode(' '));cell.appendChild(elem=Inputter.genButtonX('deleteRecord','Delete',function(ev){callback.handleDelete(criteria,this.myRecord);},'iconDelete'));elem.myRecord=record;cell=this.createDetailCell(row,cells++);cell.className+=' nowrap';cell.appendChild(elem=Elements.genAnchor(Formatter.toDate(record.purchaseDate),function(ev){callback.handleSelect(criteria,this.myRecord);return false;}));elem.myRecord=record;this.createDetailCell(row,cells++,Formatter.toDisplayable(record.brandName));this.createDetailCell(row,cells++,Formatter.toDisplayable(record.modelName));this.createDetailCell(row,cells++,Formatter.toDisplayable(record.modelTypeName));this.createDetailCell(row,cells++,record.expiration?Formatter.toDistance(record.expiration)+
Formatter.toDisplayable(record.distanceUnitAbbr):undefined);this.createDetailCell(row,cells++,record.distanceUsed?Formatter.toDistance(record.distanceUsed)+
Formatter.toDisplayable(record.distanceUnitAbbr):undefined);cell=this.createDetailCell(row,cells++);cell.appendChild(elem=Inputter.genCheckBox('warnWhenExpired',1,record.warnWhenExpired))
cell.className+=' listingCheckBox';elem.myRecord=record;elem.onclick=function(ev){this.myRecord.warnWhenExpired=this.checked;callback.handleChange(criteria,this);};cell=this.createDetailCell(row,cells++);cell.appendChild(elem=Inputter.genCheckBox('isActive',1,record.isActive))
cell.className+=' listingCheckBox';elem.myRecord=record;elem.onclick=function(ev){this.myRecord.isActive=this.checked;callback.handleChange(criteria,this);};}
return o;}
ListEquipmentDOM.createNoDataFound=function(c,cb)
{var v=c.value.singular;var o=document.createElement('div');o.innerHTML='Keep track of your '+v+' usage. '+'Click <a href="javascript:Linker.add'+v+'()">here</a> to add your first '+v+'.';return o;}

var ListRoutesDOM=new ListingDOM();ListRoutesDOM.generate=function(criteria,callback)
{var value=criteria.value;var records=value.records;if(!records||(0==records.length))
return this.createNoDataFound(criteria,callback);var elem,cell,cells=0,row,rows=0,o=this.createTable();row=o.insertRow(rows++);row.className=this.CSS_CAPTION;this.createHeaderCell(row,cells++);this.createHeaderCell(row,cells++,CAPTION_NAME);this.createHeaderCell(row,cells++,CAPTION_DISTANCE_MILES);this.createHeaderCell(row,cells++,CAPTION_DISTANCE_KM);this.createHeaderCell(row,cells++,CAPTION_TYPE);this.createHeaderCell(row,cells++,CAPTION_IS_RACE);for(var i=0;i<records.length;i++)
{cells=0;var record=records[i];row=o.insertRow(rows++);row.className=this.getRowCss(i);cell=this.createDetailCell(row,cells++);cell.className=cell.className+' nowrap';cell.appendChild(elem=Inputter.genButtonX('copyRecord','Copy',function(ev){callback.copyRecord(criteria,this.myRecord);},'iconCopy'));elem.myRecord=record;cell.appendChild(document.createTextNode(' '));cell.appendChild(elem=Inputter.genButtonX('deleteRecord','Delete',function(ev){callback.deleteRecord(criteria,this.myRecord);},'iconDelete'));elem.myRecord=record;cell=this.createDetailCell(row,cells++);cell.appendChild(elem=Elements.genAnchor(record.desc,function(ev){callback.handleSelect(criteria,this.myRecord);return false;}));elem.myRecord=record;this.createDetailCell(row,cells++,Formatter.toDistance(record.distanceMiles));this.createDetailCell(row,cells++,Formatter.toDistance(record.distanceKm));this.createDetailCell(row,cells++,Formatter.toDisplayable(record.typeName));this.createDetailCell(row,cells++,Formatter.toDisplayable(record.isRace));}
return o;}
ListRoutesDOM.createNoDataFound=function(c,cb)
{var o=document.createElement('div');o.innerHTML='A route describes a course that an activity traverses. '+'Routes can be everyday circuits or specific races. Setup your races '+'as routes and you can track your PRs. To see more about tracking your PRs '+'click <a href="javascript:Linker.gotoPRChartingHelp()">here</a>.<br /><br />'+'Routes can also be shared with teammates. To find out more click '+'<a href="javascript:Linker.gotoTeamHelp()">here</a>.<br /><br />'+'Click <a href="javascript:Linker.addRoute()">here</a> to add your first route.';return o;}

var ListTeamMembersDOM=new ListingDOM();ListTeamMembersDOM.generate=function(criteria,callback)
{var filter=criteria.filter;var model=criteria.value;var value=model.value;var myself=model.myself;var elem,cell,cells=0,row,rows=0,t,o=document.createElement('form');o.className='widgetPackage';o.appendChild(elem=document.createElement('h3'));elem.innerHTML=CAPTION_TEAM+': '+myself.teamName;o.appendChild(document.createTextNode(CAPTION_SHOW+' '));o.appendChild(elem=SelectList.generate('status',model.statusOptions,CAPTION_ALL));elem.onchange=function(ev){callback.handleChangeStatus(criteria,this);};if(filter.statusId)
elem.value=filter.statusId;o.appendChild(document.createElement('br'));o.appendChild(document.createElement('br'));var records=value.records;if(!records||(0==records.length))
{o.appendChild(this.createNoDataFound());return o;}
o.appendChild(t=this.createTable());row=this.createHeaderRow(t,rows++);this.createHeaderCell(row,cells++);this.createHeaderCell(row,cells++,CAPTION_MEMBER_NAME);if(myself.canSendTeamEmails)
this.createHeaderCell(row,cells++,CAPTION_EMAIL_ADDRESS);this.createHeaderCell(row,cells++,CAPTION_STATUS);for(var i=0;i<records.length;i++)
{var record=records[i];cells=0;row=t.insertRow(rows++);row.className=this.getRowCss(i);this.createDetailCell(row,cells++).appendChild(Elements.genImage(record.typeIconSource,record.typeName));this.createDetailCell(row,cells++,record.memberName);if(myself.canSendTeamEmails)
this.createDetailCell(row,cells++).appendChild(Formatter.toEmail(record.emailAddress));this.createDetailCell(row,cells++,record.statusName);}
return o;}

var ListTeamsDOM=new ListingDOM();ListTeamsDOM.generate=function(criteria,callback)
{var value=criteria.value;var records=value.records;if(!records||(0==records.length))
{if(!criteria.myTeams)
return this.createNoDataFound();else
return this.genHome(criteria,callback);}
var elem,cell,cells=0,row,rows=0,tbody,o=this.createTable();o.appendChild(tbody=document.createElement('tbody'));row=this.createHeaderRow(tbody,rows++);this.createHeaderCell(row,cells++);this.createHeaderCell(row,cells++);this.createHeaderCell(row,cells++,CAPTION_NAME);this.createHeaderCell(row,cells++,CAPTION_OWNER);this.createHeaderCell(row,cells++,CAPTION_LOCATION);this.createHeaderCell(row,cells++,CAPTION_TYPE);this.createHeaderCell(row,cells++,CAPTION_MY_STATUS);for(var i=0;i<records.length;i++)
{var record=records[i];cells=0;row=tbody.insertRow(rows++);row.className=this.getRowCss(i);cell=this.createDetailCell(row,cells++);if(record.memberTypeIconSrc)
{cell.appendChild(elem=document.createElement('a'));elem.href='javascript:void(null)';elem.appendChild(Elements.genImage(record.memberTypeIconSrc,record.memberType));elem.onclick=function(ev){callback.handleMember(criteria,this);return false;};elem.myRecord=record;}
else
this.appendButton(cell,'iconRequest',TITLE_REQUEST_TO_JOIN_TEAM,function(ev){callback.handleRequest(criteria,this);},record);cell.appendChild(document.createTextNode(' '));cell=this.createDetailCell(row,cells++);cell.className+=' nowrap';if(record.canInviteNewMembers)
this.appendButton(cell,'iconInvite',TITLE_INVITE_NEW_MEMBERS,function(ev){callback.handleInvite(criteria,this);},record);if(record.waitingForMember)
this.appendButton(cell,'iconRsvp',TITLE_VIEW_TEAM_INVITATION,function(ev){callback.handleRsvp(criteria,this);},record);if(record.canSendTeamEmails)
this.appendButton(cell,'iconEmail',TITLE_SEND_TEAM_EMAIL,function(ev){callback.handleEmail(criteria,this);},record);if(record.isActive)
{this.appendButton(cell,'iconDetails',TITLE_LIST_TEAM_MEMBERS,function(ev){callback.handleListMembers(criteria,this);},record);this.appendButton(cell,'iconShared',TITLE_SHARE_TEAM_RESOURCES,function(ev){callback.handleShareResources(criteria,this);},record);this.appendButton(cell,'iconReport',TITLE_TEAM_TRAINING_SUMMARY,function(ev){callback.handleMemberSummary(criteria,this);},record);}
if(!record.isOwner)
this.appendButton(cell,'iconDelete','Cancel Membership',function(ev){callback.handleCancelMembership(criteria,this);},record);this.createDetailCell(row,cells++).appendChild(elem=document.createElement('a'));elem.href='javascript:void(null)';elem.innerHTML=record.name;elem.onclick=function(ev){callback.handleSelect(criteria,this);return false;};elem.myRecord=record;this.createDetailCell(row,cells++,record.owner);this.createDetailCell(row,cells++,record.location);this.createDetailCell(row,cells++,record.typeName);this.createDetailCell(row,cells++,(record.memberStatus?record.memberStatus:'Not a Member'));}
this.createCaption(o,criteria,value,callback);return o;}
ListTeamsDOM.genHome=function(criteria,callback)
{var o=document.createElement('div');o.className='staticContent';o.innerHTML='You are not yet part of a team. To join a team:'+'<ul>'+'<li><a href="javascript:Linker.searchTeams()">Search</a> for teams in your area.'+'   If you find a team that fits your needs, request to join it online.'+'</li>'+'<li>Tell your coach about the Running Journal. Your coach can create'+'    a team, then, invite members.'+'</li>'+'<li><a href="javascript:Linker.addTeam()">Create</a> your own team! Once created,'+'    invite members to join.'+'</li>'+'</ul>'+'To find out more about teams, click <a href="javascript:Linker.gotoTeamHelp()">here</a>.';return o;}
ListTeamsDOM.appendButton=function(elem,css,title,action,record)
{var a;elem.appendChild(a=Inputter.genButtonX(css,title,action,css));a.myRecord=record;elem.appendChild(document.createTextNode(' '));}

var ListTrainingDOM=new ListingDOM();ListTrainingDOM.generate=function(criteria,callback)
{var model=criteria.value;var value=model.value;var records=value.records;if(!records||(0==records.length))
return this.createNoDataFoundX(criteria,callback);var elem,cell,cells=0,row,rows=0,table,output=this.createTable();output.appendChild(table=document.createElement('tbody'));row=table.insertRow(rows++);this.createHeaderCell(row,cells++);this.createHeaderCell(row,cells++,CAPTION_TRAINING_DATE,'trainingDate',SORT_DESC,criteria,value,callback);this.createHeaderCell(row,cells++,CAPTION_ROUTE,'route',SORT_ASC,criteria,value,callback);this.createHeaderCell(row,cells++,CAPTION_EFFORT_LEVEL+'/<br />'+CAPTION_WORKOUT);this.createHeaderCell(row,cells++,CAPTION_DISTANCE,'distance',SORT_DESC,criteria,value,callback);this.createHeaderCell(row,cells++,CAPTION_DURATION,'duration',SORT_DESC,criteria,value,callback);this.createHeaderCell(row,cells++,CAPTION_PACE);this.createHeaderCell(row,cells++,CAPTION_AVERAGE_HEART_RATE,'heartRateAvg',SORT_DESC,criteria,value,callback);for(var i=0;i<records.length;i++)
{cells=0;var expander,css,record=records[i];row=table.insertRow(rows++);row.className=css=this.getRowCss(i);var distance=record.distanceMiles?record.distanceMiles:record.distanceKm;cell=this.createDetailCell(row,cells++);cell.className+=' nowrap';cell.appendChild(expander=Inputter.genButtonX('expander',TITLE_EXPANDER,function(ev){callback.toggle(criteria,this);},this.CSS_EXPAND));expander.myRecord=record;expander.isExpanded=false;expander.isFilled=false;if(!model.isReadOnly)
{cell.appendChild(document.createTextNode(' '));cell.appendChild(elem=Inputter.genButtonX('copyRecord','Copy',function(ev){callback.handleCopy(criteria,this.myRecord);},'iconCopy'));elem.myRecord=record;cell.appendChild(document.createTextNode(' '));cell.appendChild(elem=Inputter.genButtonX('deleteRecord','Delete',function(ev){callback.handleDelete(criteria,this.myRecord);},'iconDelete'));elem.myRecord=record;}
cell.appendChild(document.createTextNode(' '));cell.appendChild(elem=Inputter.genButtonX('showDetails','Show Splits',function(ev){callback.showDetails(criteria,this.myRecord);},'iconDetails'));elem.myRecord=record;cell=this.createDetailCell(row,cells++);cell.className+=' nowrap';cell.appendChild(elem=Elements.genAnchor(Formatter.toDate(record.trainingDate),function(ev){callback.handleSelect(criteria,this.myRecord);return false;}));elem.myRecord=record;Elements.addSpace(cell);cell.appendChild(elem=Elements.genAnchor(undefined,function(ev){callback.handleSelect(criteria,this.myRecord);return false;}));elem.myRecord=record;elem.style.textDecoration='none';elem.appendChild(Elements.genImage(record.timeOfDayIconSrc,record.timeOfDayName));Elements.addSpace(elem);elem.appendChild(Elements.genImage(record.typeIconSrc,record.typeName));this.createDetailCell(row,cells++,record.routeName);this.createDetailCell(row,cells++,record.workoutName?record.workoutName:record.effortLevelName);this.createDetailCell(row,cells++,distance?Formatter.toDistance(distance)+record.distanceAbbr:undefined);this.createDetailCell(row,cells++,Formatter.toDuration(record));this.createDetailCell(row,cells++,Formatter.toPace(record.pace));this.createDetailCell(row,cells++,record.heartRateAvg);expander.myRow=row=table.insertRow(rows++);row.className=css;row.style.display='none';expander.myCell=cell=row.insertCell(0);cell.colSpan=cells;cell.className=css+'Container';}
this.createCaption(output,criteria,value,callback);return output;}
ListTrainingDOM.createNoDataFoundX=function(c,cb)
{var f=c.filter;if(!f.doingRecent||!f.currentUser)
return this.createNoDataFound(c,cb);var o=document.createElement('div');o.innerHTML='If you\'re looking to log your first run, click <a href="javascript:Linker.addRun()">here</a>.<br /><br />'+'If you\'re want to log your first cross-training session, click <a href="javascript:Linker.addXtraining()">here</a>.<br /><br />'+'If you would prefer a calendar view, click <a href="javascript:Linker.gotoCalendar()">here</a>.';return o;}

var ListTrainingDetailsDOM=new ListingDOM();ListTrainingDetailsDOM.generate=function(criteria,callback)
{var value=criteria.value;var records=value.records;if((undefined==records)||(0==records.length))
return this.createNoDataFound();var row,cell,rows=0,cells=0,o=this.createTable();o.myCount=records.length;o.myRows=[];o.myTable=o;o.myHrColSpan=1;row=o.myFirstRow=o.insertRow(rows++);row.className=this.CSS_CAPTION;this.createHeaderCell(row,cells++);this.createHeaderCell(row,cells++,CAPTION_DISTANCE).colSpan=2;this.createHeaderCell(row,cells++,CAPTION_DURATION);this.createHeaderCell(row,cells++,CAPTION_HEART_RATE_AVG_MAX);this.createHeaderCell(row,cells++,CAPTION_COMMENTS);this.createHeaderCell(row,cells++,CAPTION_PACE);var totals={distanceMiles:0,distanceKm:0,durationHours:0,durationMinutes:0,durationSeconds:0};for(var i=0;i<records.length;i++)
{var record=records[i];if(undefined!=record.distanceMiles)
totals.distanceMiles+=record.distanceMiles;if(undefined!=record.distanceKm)
totals.distanceKm+=record.distanceKm;if(undefined!=record.durationHours)
totals.durationHours+=record.durationHours;if(undefined!=record.durationMinutes)
totals.durationMinutes+=record.durationMinutes;if(undefined!=record.durationSeconds)
totals.durationSeconds+=record.durationSeconds;cells=0;row=o.myRows[i]=o.insertRow(rows++);row.className=this.getRowCss(i);this.createDetailCell(row,cells++);this.createDetailCell(row,cells++,Formatter.toDistance(record.distanceMiles)+MILE_ABBR).className+=' listingDistance';this.createDetailCell(row,cells++,Formatter.toDistance(record.distanceKm)+KM_ABBR).className=' listingDistance';this.createDetailCell(row,cells++,Formatter.toDuration(record)).className=' listingDuration';this.createDetailCell(row,cells++,Formatter.toDisplayable(record.heartRateAvg)+' / '+
Formatter.toDisplayable(record.heartRateMax)).className=' listingHR';this.createDetailCell(row,cells++,Formatter.toDisplayable(record.comments));cell=this.createDetailCell(row,cells++);if(undefined!=record.paceMiles)
cell.innerHTML=Formatter.toPace(record.paceMiles);else if(undefined!=record.paceKm)
cell.innerHTML=Formatter.toPace(record.paceKm);}
cells=0;row=o.myLastRow=o.insertRow(rows++);cell=row.insertCell(cells++);cell.className='totals';cell.innerHTML=CAPTION_TOTALS+'&nbsp;&nbsp;';cell=row.insertCell(cells++);cell.className='totals listingDistance';cell.innerHTML=Formatter.toDistance(totals.distanceMiles)+MILE_ABBR;cell=row.insertCell(cells++);cell.className='totals listingDistance';cell.innerHTML=Formatter.toDistance(totals.distanceKm)+KM_ABBR;cell=row.insertCell(cells++);cell.className='totals listingDuration';cell.innerHTML=Formatter.fromTotalSeconds(Formatter.toTotalSeconds(totals));cell=row.insertCell(cells++);cell.colSpan=3;cells=0;row=o.insertRow(rows++);cell=row.insertCell(cells++);cell.className='totals';cell.innerHTML=CAPTION_PACE;cell=row.insertCell(cells++);cell.className='totals listingDistance';cell.innerHTML=Formatter.toPaceMiles(totals);cell=row.insertCell(cells++);cell.className='totals listingDistance';cell.innerHTML=Formatter.toPaceKm(totals);cell=row.insertCell(cells++);cell.colSpan=4;row=o.insertRow(rows++);cell=row.insertCell(0);cell.colSpan=7;cell.className='totals';cell.innerHTML=CAPTION_COUNT+': '+value.records.length;return o;}

var ListTrainingMini=new ListingDOM();ListTrainingMini.generate=function(criteria,callback)
{var me=this;var value=criteria;var records=value.records;if(!records||(0==records.length))
return this.createNoDataFound();var elem,cell,row,rows=0,o=this.createTable();o.style.width='100%';for(var i=0;i<records.length;i++)
{var record=records[i];var distance=record.distanceMiles?record.distanceMiles:record.distanceKm;row=o.insertRow(rows++);row.className=this.getRowCss(i);cell=this.createDetailCell(row,0).appendChild(elem=Elements.genAnchor(undefined,function(ev){callback.handleSelect(this);return false;}));elem.appendChild(document.createTextNode(Formatter.toDate(record.trainingDate)+' '));elem.appendChild(Elements.genImage(record.timeOfDayIconSrc,record.timeOfDayName));elem.appendChild(document.createTextNode(' '));elem.appendChild(Elements.genImage(record.typeIconSrc,record.typeName));elem.myRecord=record;elem.onmouseover=function(ev){me.elem_onmouseover(this,this.myRecord);};elem.onmouseout=function(ev){me.elem_onmouseout(this,this.myRecord);};this.createDetailCell(row,1).appendChild(elem=Elements.genAnchor(record.userFullName,function(ev){var r=this.myRecord;Linker.listRecentTrainingX(r.userId,r.userFullName);return false;}));elem.myRecord=record;elem.onmouseover=function(ev){me.user_onmouseover(this,this.myRecord);};elem.onmouseout=function(ev){me.elem_onmouseout(this,this.myRecord);};this.createDetailCell(row,2,distance?Formatter.toDistance(distance)+record.distanceAbbr:undefined);this.createDetailCell(row,3,Formatter.toDuration(record));}
return o;}
ListTrainingMini.elem_onmouseover=function(elem,record)
{var viewer=record.isRun?DetailRunMini:DetailXtrainingMini;Popup.open(elem,viewer.generate({value:record}));}
ListTrainingMini.elem_onmouseout=function(elem,record)
{Popup.close();}
ListTrainingMini.user_onmouseover=function(elem,record)
{globalInfo.openTrainingTotals(elem,record.userId,record.typeId);}

var ListWorkoutsDOM=new ListingDOM();ListWorkoutsDOM.generate=function(criteria,callback)
{var value=criteria.value;var records=value.records;if(!records||(0==records.length))
return this.createNoDataFound(criteria,callback);var elem,cell,cells=0,row,rows=0,o=this.createTable();row=o.insertRow(rows++);row.className=this.CSS_CAPTION;this.createHeaderCell(row,cells++);this.createHeaderCell(row,cells++,CAPTION_NAME);this.createHeaderCell(row,cells++,CAPTION_COMMENTS);for(var i=0;i<records.length;i++)
{cells=0;var record=records[i];row=o.insertRow(rows++);row.className=this.getRowCss(i);cell=this.createDetailCell(row,cells++);cell.className=cell.className+' nowrap';cell.appendChild(elem=Inputter.genButtonX('copyRecord','Copy',function(ev){callback.copyRecord(criteria,this.myRecord);},'iconCopy'));elem.myRecord=record;cell.appendChild(document.createTextNode(' '));cell.appendChild(elem=Inputter.genButtonX('deleteRecord','Delete',function(ev){callback.deleteRecord(criteria,this.myRecord);},'iconDelete'));elem.myRecord=record;cell.appendChild(document.createTextNode(' '));cell.appendChild(elem=Inputter.genButtonX('showDetails','Show Repeats',function(ev){callback.showDetails(criteria,this.myRecord);},'iconDetails'));elem.myRecord=record;cell=this.createDetailCell(row,cells++);cell.appendChild(elem=Elements.genAnchor(record.desc,function(ev){callback.handleSelect(criteria,this.myRecord);return false;}));elem.myRecord=record;cell=this.createDetailCell(row,cells++,record.comments);}
return o;}
ListWorkoutsDOM.createNoDataFound=function(c,cb)
{var o=document.createElement('div');o.innerHTML='A workout is a template that defines the repeats/splits that make up '+'the intervals of a training session. Workout templates streamline the entry of '+'splits for an activity by prefilling the basic details &mdash; distance, time, and/or heart '+'rate.<br /><br />'+'Coaches, create workouts and share them with your team. To find out more, click '+'<a href="javascript:Linker.gotoTeamHelp()">here</a>.<br /><br />'+'Click <a href="javascript:Linker.addWorkout()">here</a> to add your first workout.'
return o;}

var LoginDOM=new DetailDOM();LoginDOM.generate=function(criteria,callback)
{var v=criteria.value;var e,row,t,o=this.createForm();o.onsubmit=function(ev){callback.login(this);return false;};o.appendChild(t=this.createTable());this.createRowX(t,CAPTION_USER_NAME,false,e=o.myFirstField=Inputter.genTextBox('userName',MAX_LEN_USER_NAME,25));if(v.user)
e.value=v.user.emailAddress;this.createRowX(t,CAPTION_PASSWORD,false,Inputter.genPassword('password',MAX_LEN_PASSWORD,20));e=this.createAction(t);e.appendChild(Inputter.genSubmit('submitter',CAPTION_LOGIN));Elements.addSpace(e);e.appendChild(Inputter.genButton('canceler',CAPTION_CANCEL,function(ev){callback.handleLoginCancel();}));Elements.addSpace(e);e.appendChild(Elements.genAnchor(TITLE_FORGOT_PASSWORD,function(ev){callback.handleForgotPassword(o);return false;}));if(!window.noRememberMe)
{row=t.insertRow(t.rows.length);row.insertCell(0).className=this.CSS_ACTION;e=row.insertCell(1);e.className=this.CSS_ACTION;e.appendChild(Inputter.genCheckBox('rememberMe',1,false));Elements.addText(e,' Remember Me');}
return o;}

var MembershipInvitesDOM=new ListingDOM();MembershipInvitesDOM.generate=function(criteria,callback)
{var value=criteria.value;var records=value.records;if(!records||(0==records.length))
return this.createNoDataFound();var plural=(1<records.length);var elem,cell,row,rows=0,t,o=document.createElement('form');o.className='widgetPackage';o.innerHTML='The following team'+(plural?'s have':' has')+' invited you to join '+'their organization'+(plural?'(s)':'')+' listed below.<br />Please select to accept or decline the invitation'+
(plural?'s':'')+'.';o.appendChild(document.createElement('br'));o.appendChild(document.createElement('br'));o.appendChild(t=this.createTable());row=this.createHeaderRow(t,rows++);this.createHeaderCell(row,0,CAPTION_TEAM);this.createHeaderCell(row,1,CAPTION_OWNER);this.createHeaderCell(row,2,CAPTION_LOCATION);this.createHeaderCell(row,3,CAPTION_ACCEPT+' / '+CAPTION_DECLINE);for(var i=0;i<records.length;i++)
{var r=records[i];row=t.insertRow(rows++);row.className=this.getRowCss(i);this.createDetailCell(row,0,r.teamName);this.createDetailCell(row,1,r.teamOwnerName);this.createDetailCell(row,2,r.teamLocation);cell=this.createDetailCell(row,3);cell.appendChild(elem=Inputter.genButton('accept',CAPTION_ACCEPT,function(ev){callback.handleAccept(criteria,this);}));elem.myRecord=r;elem.myIndex=i;cell.appendChild(document.createTextNode(' '));cell.appendChild(elem=Inputter.genButton('decline',CAPTION_DECLINE,function(ev){callback.handleDecline(criteria,this);}));elem.myRecord=r;elem.myIndex=i;}
cell=t.insertRow(rows++).insertCell(0);cell.colSpan=4;cell.className=this.CSS_ACTION;Elements.addBreak(cell);cell.appendChild(Inputter.genButton('canceler',CAPTION_CANCEL,function(ev){callback.handleCancel(criteria,this);}));return o;}

var MembershipRequestsDOM=new ListingDOM();MembershipRequestsDOM.generate=function(criteria,callback)
{var value=criteria.value;var records=value.records;if(!records||(0==records.length))
return this.createNoDataFound();var plural=(1<records.length);var elem,cell,row,rows=0,t,o=document.createElement('form');o.className='widgetPackage';o.innerHTML='The following '+(plural?'people have':'person has')+' requested to join '+'the team'+(plural?'(s)':'')+' listed below.<br />Please select to approve or reject the request'+
(plural?'s':'')+'.';o.appendChild(document.createElement('br'));o.appendChild(document.createElement('br'));o.appendChild(t=this.createTable());row=this.createHeaderRow(t,rows++);this.createHeaderCell(row,0,CAPTION_NAME);this.createHeaderCell(row,1,CAPTION_EMAIL_ADDRESS);this.createHeaderCell(row,2,CAPTION_TEAM);this.createHeaderCell(row,3,CAPTION_APPROVE+' / '+CAPTION_REJECT);for(var i=0;i<records.length;i++)
{var r=records[i];row=t.insertRow(rows++);row.className=this.getRowCss(i);this.createDetailCell(row,0,r.memberName);this.createDetailCell(row,1,r.emailAddress);this.createDetailCell(row,2,r.teamName);cell=this.createDetailCell(row,3);cell.appendChild(elem=Inputter.genButton('approve',CAPTION_APPROVE,function(ev){callback.handleApprove(criteria,this);}));elem.myRecord=r;elem.myIndex=i;cell.appendChild(document.createTextNode(' '));cell.appendChild(elem=Inputter.genButton('reject',CAPTION_REJECT,function(ev){callback.handleReject(criteria,this);}));elem.myRecord=r;elem.myIndex=i;}
cell=t.insertRow(rows++).insertCell(0);cell.colSpan=4;cell.className=this.CSS_ACTION;Elements.addBreak(cell);cell.appendChild(Inputter.genButton('canceler',CAPTION_CANCEL,function(ev){callback.handleCancel(criteria,this);}));return o;}

var QuickLinksDOM={}
QuickLinksDOM.generate=function(criteria,callback)
{var value=criteria.value;var elem,row,cell,o=document.createElement('table');var r=function(){return o.rows.length;};o.className='quickLinks';if(value.isAuthenticated)
{this.createHeader(o,r(),'Running Totals');cell=o.insertRow(r()).insertCell(0);cell.className='quickLinks';callback.trainingTotalsHandler.doNow(cell);callback.getNotices(o,this);if(value.user.isAdmin)
{this.createHeader(o,r(),'Administration');this.createDetail(o,r(),'Search Users','searchUsers');this.createDetail(o,r(),'Search Blog Abuse Reports','listBlogReports');this.createDetail(o,r(),TITLE_SEARCH_CLIENTS,'searchClients');this.createDetail(o,r(),TITLE_ADD_CLIENT,'addClient');}
if(value.user.isAuthor)
{this.createHeader(o,r(),'Author');this.createDetail(o,r(),'Add New Blog Entry','addBlog');this.createDetail(o,r(),'Show My Blog','listMyBlogs');}}
else
{this.createHeader(o,r(),'Login');cell=o.insertRow(r()).insertCell(0);cell.className='quickLinks';cell.appendChild(elem=this.createLoginForm(value,callback));o.myFirstField=elem.myFirstField;}
this.createHeader(o,r(),'Blog Stop');this.createDetail(o,r(),'Recent Blog Talk','listRecentBlogs');this.createDetail(o,r(),'Search Blogs','searchBlogs');this.createHeader(o,r(),'New');this.createDetail(o,r(),TITLE_DASHBOARD,'gotoDashboard','&nbsp;&mdash; see who\'s training on your team.');this.createDetail(o,r(),'Leader Board','gotoLeaderBoard','&nbsp;&mdash; see who the running/X-training leaders are.');this.createDetail(o,r(),'X-training','gotoCalendar','&nbsp;is here. Keep all your cardio and strength training in one place.');cell=o.insertRow(r()).insertCell(0).className='quickLinksSpacer';this.createHeader(o,r(),'Quick Links');if(!value.isAuthenticated)
this.createDetail(o,r(),'Register Me','registerUser');this.createDetail(o,r(),'List Recent Training','listRecentTraining');cell=this.createDetail(o,r(),'My Calendar ','gotoCalendar').myAnchor;cell.appendChild(elem=document.createElement('span'));elem.className='quickLinksSmall';elem.innerHTML='(runs, X-training, HR, weight, & strength training)';this.createDetail(o,r(),'Search/Export Training','searchTraining');this.createDetail(o,r(),'Charts/Graphs','chartTraining','&nbsp;&mdash; '+'graphically link your training, weight, and heart rate data. And now chart your PRs alongside '+'with the standard datapoints!');this.createDetail(o,r(),'Support','gotoSupport');this.createDetail(o,r(),'Feedback','openFeedbackRequest');cell=o.insertRow(r()).insertCell(0).className='quickLinksSpacer';this.createHeader(o,r(),'Coming Soon');this.createNonLink(o,r(),'PR Finder','&nbsp;&mdash; sift through your history to find your Personal Records. '+'Great for pinpointing breakthrough training.');this.createNonLink(o,r(),'Import','&nbsp;old logs.');cell=o.insertRow(r()).insertCell(0).className='quickLinksSpacer';this.createHeader(o,r(),'Sponsors');this.createLink(o,r(),'Candice Stern Graphic Design','http://www.candicestern.com');this.createLink(o,r(),'Greenlit Communications','http://www.greenlitcommunications.com');this.createLink(o,r(),'Bodywise Wellness','http://www.bodywise-wellness.com');return o;}
QuickLinksDOM.createHeader=function(t,rows,caption)
{var o=t.insertRow(rows);o.className='quickLinksHeader';var cell=o.insertCell(0);cell.className='quickLinksHeader';cell.innerHTML=caption;return o;}
QuickLinksDOM.createDetail=function(t,rows,caption,linkId,comments)
{var o=t.insertRow(rows);var a,cell=o.insertCell(0);cell.className='quickLinks';cell.appendChild(a=o.myAnchor=document.createElement('a'));a.className='quickLinks';a.href='javascript:void(null)';a.innerHTML=caption;a.onclick=function(ev){Linker[linkId]();return false;};if(comments)
{cell.appendChild(a=document.createElement('span'));a.innerHTML=comments;}
return o;}
QuickLinksDOM.createNonLink=function(t,rows,caption,comments)
{var o=t.insertRow(rows);var elem,cell=o.insertCell(0);cell.className='quickLinks';cell.appendChild(a=document.createElement('b'));a.className='quickLinks';a.innerHTML=caption;if(comments)
{cell.appendChild(a=document.createElement('span'));a.innerHTML=comments;}
return o;}
QuickLinksDOM.createLink=function(t,rows,caption,href,comments)
{var o=t.insertRow(rows);var a,cell=o.insertCell(0);cell.className='quickLinks';cell.appendChild(a=document.createElement('a'));a.className='quickLinksSmall';a.href=href;a.target='new';a.innerHTML=caption;if(comments)
{cell.appendChild(a=document.createElement('span'));a.innerHTML=comments;}
return o;}
QuickLinksDOM.createNotices=function(value,t)
{if(!value)
return;var a,cell;this.createHeader(t,0,CAPTION_NOTICES);cell=t.insertRow(1).insertCell(0);cell.className='notices';if(0<value.numberOfMembershipRequests)
cell.appendChild(Elements.genAnchor('Requests to join team ('+value.numberOfMembershipRequests+')',function(ev){Linker.viewRequestsToJoinTeam();}));if(0<value.numberOfMembershipInvites)
cell.appendChild(Elements.genAnchor('Team invitations ('+value.numberOfMembershipInvites+')',function(ev){Linker.viewTeamInvitations();}));}
QuickLinksDOM.createLoginForm=function(value,callback)
{var cell,row,t,o=document.createElement('form');o.className='widgetPackage';o.onsubmit=function(ev){callback.login(this);return false;}
o.appendChild(t=document.createElement('table'));t.className='quickForm';row=t.insertRow(0);cell=row.insertCell(0);cell.className='quickForm';cell.appendChild(document.createTextNode('Email '));cell=row.insertCell(1);cell.className='quickForm';cell.appendChild(o.myFirstField=Inputter.genTextBox('userName',MAX_LEN_USER_NAME,25));row=t.insertRow(1);cell=row.insertCell(0);cell.className='quickForm';cell.appendChild(document.createTextNode('PWD '));cell=row.insertCell(1);cell.className='quickForm';cell.appendChild(Inputter.genPassword('password',MAX_LEN_PASSWORD,25));row=t.insertRow(2);cell=row.insertCell(0);cell.className='quickForm';cell.appendChild(Inputter.genSubmit('submitter',CAPTION_LOGIN));cell=row.insertCell(1);cell.className='quickForm';cell.appendChild(Elements.genAnchor(TITLE_FORGOT_PASSWORD,function(ev){callback.handleForgotPassword(o);return false;}));if(!window.noRememberMe)
{row=t.insertRow(3);row.insertCell(0).className='quickForm';cell=row.insertCell(1);cell.className='quickForm';cell.appendChild(Inputter.genCheckBox('rememberMe',1,false));cell.appendChild(document.createTextNode(' Remember Me'));}
return o;}

function RunFutureDecorator(caller)
{this.caller=caller;}
RunFutureDecorator.prototype.doByActual=function(id,body)
{var me=this;this.caller.getRunFuture(undefined,id,{handleRequestData:function(record){me.generate({body:body,record:record});}});}
RunFutureDecorator.prototype.generate=function(value)
{var r=value.record;if(!r)
return;var b=value.body;this.addToElement(b.myTimeOfDayName,r.timeOfDayName);this.addToElement(b.myRouteName,r.routeName,true);this.addToElement(b.myEffortLevelName,r.effortLevelName);this.addToElement(b.myWorkoutName,r.workoutName,true);this.addToElement(b.myShoeName,r.shoeName,true);this.addToElement(b.myCalories,r.calories);this.addToElement(b.myDuration,Formatter.toDuration(r));this.addToElement(b.myHeartRateAvg,r.heartRateAvg);this.addToElement(b.myHeartRateMax,r.heartRateMax);this.addToElement(b.myHeartRateTargetMin,r.heartRateTargetMin);this.addToElement(b.myHeartRateTargetMax,r.heartRateTargetMax);this.addToElement(b.myTemperatureName,r.temperatureName);this.addToElement(b.myHumidityName,r.humidityName);this.addToElement(b.myPrecipitationName,r.precipitationName);this.addToElement(b.myWindName,r.windName);this.addToElement(b.mySurfaceConditionName,r.surfaceConditionName);this.addToElement(b.myComments,r.comments,true);this.addDistanceToElement(b.myDistanceMiles,r.distanceMiles,r.paceMiles);this.addDistanceToElement(b.myDistanceKm,r.distanceKm,r.paceKm);}
RunFutureDecorator.prototype.addToElement=function(e,value,useNewLine)
{if(undefined==value)
return;if(useNewLine)
Elements.addBreak(e);Elements.addSpan(e,'detailFutureValue',(useNewLine?'':'&nbsp;&mdash;&nbsp;')+Formatter.toDisplayable(value));}
RunFutureDecorator.prototype.addDistanceToElement=function(e,distance,pace)
{if(undefined==distance)
return;this.addToElement(e,Formatter.toDistance(distance),true);if(undefined!=pace)
{Elements.addSpan(e,undefined,'&nbsp;&mdash;&nbsp;'+CAPTION_PACE+': ');Elements.addSpan(e,'detailFutureValue',Formatter.toPace(pace));}}

var SearchBlogsDOM=new DetailDOM();SearchBlogsDOM.generate=function(criteria,callback)
{var m=criteria.value;var v=criteria.filter;var cal=Calendar.getInstance();var e,t,o=this.createForm(criteria,callback);o.appendChild(t=this.createTable());this.createRowX(t,CAPTION_AUTHOR,false,SelectList.generate('author',m.authorOptions,CAPTION_NO_SEARCH),v.creatorId);e=this.createRowX(t,CAPTION_RELEASE_DATE,false,cal.create('fromDate',v.fromDate)).myValueCell;Elements.addText(e,' to ');e.appendChild(cal.create('toDate',v.toDate));if(m.isAdmin||m.isAuthor)
this.createRowX(t,CAPTION_STATUS,false,SelectList.generate('statusId',m.statusOptions,CAPTION_NO_SEARCH),v.statusId);this.createRowX(t,CAPTION_TITLE,false,o.myFirstField=Inputter.genTextBox('title',100,50),v.title);this.createRowX(t,'Blog Entry',false,Inputter.genTextBox('contents',100,50),v.contents);e=this.createAction(t);e.appendChild(Inputter.genSubmit('submitter',CAPTION_SUBMIT));Elements.addSpace(e);e.appendChild(Inputter.genButton('canceler',CAPTION_CANCEL,function(ev){callback.handleCancel(criteria,this.form);}));return o;}

var SearchCommunityTrainingDOM=new DetailDOM();SearchCommunityTrainingDOM.generate=function(criteria,callback)
{var m=criteria.value;var v=criteria.filter;var cal=Calendar.getInstance();var a,e,t,o=this.createForm(criteria,callback);o.appendChild(t=this.createTable());this.createRowX(t,CAPTION_LAST_NAME,false,o.myFirstField=Inputter.genTextBox('lastName',MAX_LEN_LAST_NAME,MAX_LEN_LAST_NAME),v.lastName);this.createRowX(t,CAPTION_TRAINING_TYPE,false,SelectList.generate('typeId',m.typeOptions,CAPTION_ALL),v.typeId);e=this.createRowX(t,CAPTION_TRAINING_DATE,false,cal.create('fromDate',v.fromDate)).myValueCell;Elements.addText(e,' to ');e.appendChild(cal.create('toDate',v.toDate));this.createRowX(t,CAPTION_CITY,false,Inputter.genTextBox('city',MAX_LEN_CITY,MAX_LEN_CITY),v.city);this.createRowX(t,CAPTION_STATE,false,SelectList.generate('state',m.stateOptions,CAPTION_NO_SEARCH),v.stateId);this.createRowX(t,CAPTION_COUNTRY,false,e=SelectList.generate('country',m.countryOptions,CAPTION_NO_SEARCH),v.countryId);e.onchange=function(ev){callback.handleChangeCountry(criteria,this);};e=this.createRowX(t,CAPTION_DISTANCE_MILES,false,Inputter.genTextBox('fromMiles',MAX_LEN_DISTANCE_MILES,MAX_LEN_DISTANCE_MILES),v.fromMiles).myValueCell;Elements.addText(e,' to ');e.appendChild(a=Inputter.genTextBox('toMiles',MAX_LEN_DISTANCE_MILES,MAX_LEN_DISTANCE_MILES));if(v.toMiles)
a.value=v.toMiles;e=this.createRowX(t,CAPTION_DISTANCE_KM,false,Inputter.genTextBox('fromKm',MAX_LEN_DISTANCE_KM,MAX_LEN_DISTANCE_KM),v.fromKm).myValueCell;Elements.addText(e,' to ');e.appendChild(a=Inputter.genTextBox('toKm',MAX_LEN_DISTANCE_KM,MAX_LEN_DISTANCE_KM));if(v.toKm)
a.value=v.toKm;this.createRowX(t,CAPTION_IS_RACE,false,Inputter.genCheckBox('isRace',1,v.isRace));e=this.createAction(t);e.appendChild(Inputter.genSubmit('submitter',CAPTION_SUBMIT));Elements.addSpace(e);e.appendChild(Inputter.genButton('canceler',CAPTION_CANCEL,function(ev){callback.handleCancel(criteria);}));return o;}

var SearchTeamsDOM=new DetailDOM();SearchTeamsDOM.generate=function(criteria,callback)
{var model=criteria.value;var v=criteria.filter;var e,t,o=this.createForm(criteria,callback);o.appendChild(t=this.createTable());this.createRowX(t,CAPTION_NAME,false,o.myFirstField=Inputter.genTextBox('teamName',MAX_LEN_DESC,MAX_LEN_DESC),v.name);this.createRowX(t,CAPTION_TEAM_TYPE,false,SelectList.generate('typeId',model.typeOptions,CAPTION_ALL),v.typeId);this.createRowX(t,CAPTION_CITY,false,Inputter.genTextBox('city',MAX_LEN_CITY,MAX_LEN_CITY),v.city);this.createRowX(t,CAPTION_STATE,false,SelectList.generate('state',model.stateOptions,CAPTION_NO_SEARCH),v.stateId);this.createRowX(t,CAPTION_COUNTRY,false,e=SelectList.generate('country',model.countryOptions,CAPTION_NO_SEARCH),v.countryId);e.onchange=function(ev){callback.handleChangeCountry(criteria,this);};e=this.createAction(t);e.appendChild(Inputter.genSubmit('submitter',CAPTION_SUBMIT));Elements.addSpace(e);e.appendChild(Inputter.genButton('canceler',CAPTION_CANCEL,function(ev){callback.handleCancel(criteria);}));return o;}

var SearchTrainingDOM=new DetailDOM();SearchTrainingDOM.generate=function(criteria,callback)
{var model=criteria.value;var v=criteria.filter;var cal=Calendar.getInstance();var elem,c,t,o=this.createForm(criteria,callback);o.appendChild(t=this.createTable());this.createRowX(t,CAPTION_TRAINING_TYPE,false,o.myFirstField=SelectList.generate('typeId',model.typeOptions,CAPTION_ALL),v.typeId);if(model.teammateOptions&&(0<model.teammateOptions.length))
{this.createRowX(t,CAPTION_TEAMMATE,false,elem=SelectList.generate('teammate',model.teammateOptions,CAPTION_ME),v.teammate);elem.onchange=function(ev){callback.handleChangeTeammate(criteria,this);};}
c=this.createRowX(t,CAPTION_TRAINING_DATE,false,cal.create('fromDate',v.fromDate)).myValueCell;Elements.addText(c,' to ');c.appendChild(cal.create('toDate',v.toDate));this.createRowX(t,CAPTION_ROUTE,false,SelectList.generate('route',model.routeOptions,CAPTION_NO_SEARCH),v.routeId);this.createRowX(t,CAPTION_EFFORT_LEVEL,false,SelectList.generate('effortLevel',model.effortLevelOptions,CAPTION_NO_SEARCH),v.effortLevelId);this.createRowX(t,CAPTION_WORKOUT,false,SelectList.generate('workout',model.workoutOptions,CAPTION_NO_SEARCH),v.workoutId);c=this.createRowX(t,CAPTION_DISTANCE_MILES,false,Inputter.genTextBox('fromMiles',MAX_LEN_DISTANCE_MILES,MAX_LEN_DISTANCE_MILES),v.fromMiles).myValueCell;Elements.addText(c,' to ');c.appendChild(elem=Inputter.genTextBox('toMiles',MAX_LEN_DISTANCE_MILES,MAX_LEN_DISTANCE_MILES));if(v.toMiles)
elem.value=v.toMiles;c=this.createRowX(t,CAPTION_DISTANCE_KM,false,Inputter.genTextBox('fromKm',MAX_LEN_DISTANCE_KM,MAX_LEN_DISTANCE_KM),v.fromKm).myValueCell;Elements.addText(c,' to ');c.appendChild(elem=Inputter.genTextBox('toKm',MAX_LEN_DISTANCE_KM,MAX_LEN_DISTANCE_KM));if(v.toKm)
elem.value=v.toKm;c=this.createRowX(t,CAPTION_HEART_RATE_AVG,false,Inputter.genTextBox('fromHeartRateAvg',MAX_LEN_HEART_RATE_AVG,MAX_LEN_HEART_RATE_AVG),v.fromHeartRateAvg).myValueCell;Elements.addText(c,' to ');c.appendChild(elem=Inputter.genTextBox('toHeartRateAvg',MAX_LEN_HEART_RATE_AVG,MAX_LEN_HEART_RATE_AVG));if(v.toHeartRateAvg)
elem.value=v.toHeartRateAvg;this.createRowX(t,CAPTION_IS_RACE,false,Inputter.genCheckBox('isRace',1,false));this.createRowX(t,CAPTION_EXPORT_AS,false,SelectList.generate('reportType',model.reportTypeOptions,CAPTION_NONE),v.exportReportTypeId);c=this.createAction(t);c.appendChild(Inputter.genSubmit('submitter',CAPTION_SUBMIT));c.appendChild(document.createTextNode(' '));c.appendChild(Inputter.genButton('canceler',CAPTION_CANCEL,function(ev){callback.handleCancel(criteria);}));return o;}

var SendTeamEmailDOM=new DetailDOM();SendTeamEmailDOM.generate=function(criteria,callback)
{var m=criteria.value;var v=m.value;var elem,cell,row,t,o=this.createForm(criteria,callback);o.innerHTML='Select one or more team member types. An e-mail will be sent<br />'+'to those members.';Elements.addBreak(o);Elements.addBreak(o);o.appendChild(t=this.createTable());this.createRow(t,CAPTION_TEAM_NAME,v.name);this.createRow(t,CAPTION_TEAM_OWNER,v.ownerName);this.createRowX(t,CAPTION_TO,true,MultiSelectList.generate('recipients',m.typeOptions,undefined,5));this.createRowX(t,CAPTION_SUBJECT,true,o.myFirstField=Inputter.genTextBox('subject',128,50));this.createAction(t).innerHTML='&nbsp;';var rows=t.rows.length;row=t.insertRow(rows++);this.createField(row,0,elem=document.createElement('b')).colSpan=2;elem.innerHTML=CAPTION_MESSAGE;row=t.insertRow(rows++);this.createField(row,0,elem=Inputter.genTextArea('body',60,6)).colSpan=2;elem.style.width='100%';cell=this.createAction(t);cell.appendChild(Inputter.genSubmit('submitter',CAPTION_SUBMIT));cell.appendChild(document.createTextNode(' '));cell.appendChild(Inputter.genButton('canceler',CAPTION_CANCEL,function(ev){callback.handleCancel(criteria,this.form);}));return o;}

var ShareTeamResourcesDOM=new DetailDOM();ShareTeamResourcesDOM.generate=function(criteria,callback)
{var model=criteria.value;var elem,cell,row,rows=0,t,o=this.createForm(criteria,callback);var a,b;o.innerHTML='If you are permitted, select from your list of training routes and '+'workouts those which you would like to share<br />with the entire team.';Elements.addBreak(o);Elements.addBreak(o);o.appendChild(t=this.createTable());this.createRow(t,CAPTION_TEAM_NAME,model.teamName).myValueCell.colSpan=3;rows=t.rows.length;row=t.insertRow(rows++);a=row.insertCell(0);a.colSpan=2;a.style.width='50%';a.style.verticalAlign='top';b=row.insertCell(1);b.colSpan=2;b.style.width='50%';b.style.verticalAlign='top';if(model.sharableRoutes)
{a.appendChild(elem=document.createElement('b'));elem.style.display='block';elem.innerHTML=CAPTION_ROUTES+' to share:';a.appendChild(a.mySharable=elem=MultiSelectList.generate('routes',model.sharableRoutes,model.mySharedRoutes,8));elem.style.maxWidth='400px';}
if(model.sharableWorkouts)
{b.appendChild(elem=document.createElement('b'));elem.style.display='block';elem.innerHTML=CAPTION_WORKOUTS+' to share:';b.appendChild(b.mySharable=elem=MultiSelectList.generate('workouts',model.sharableWorkouts,model.mySharedWorkouts,8));elem.style.maxWidth='400px';}
this.appendShared(a,CAPTION_ROUTES,model.sharedRoutes);this.appendShared(b,CAPTION_WORKOUTS,model.sharedWorkouts);cell=this.createAction(t);if(model.canShare)
{cell.appendChild(Inputter.genSubmit('submitter',CAPTION_SUBMIT));cell.appendChild(document.createTextNode(' '));}
cell.appendChild(Inputter.genButton('canceler',CAPTION_CANCEL,function(ev){callback.handleCancel(criteria,this.form);}));return o;}
ShareTeamResourcesDOM.appendShared=function(cell,caption,records)
{var item,em,elem;if(cell.mySharable)
cell.appendChild(document.createElement('br'));cell.appendChild(elem=document.createElement('b'));elem.style.display='block';elem.innerHTML=caption+' shared with team:';cell.appendChild(elem=cell.myShared=document.createElement('div'));elem.style.maxWidth='400px';if(!records||(0==records.length))
{elem.innerHTML='There are no '+caption+' shared with the team.';if(cell.mySharable)
cell.mySharable.style.height='300px';return;}
elem.className=MultiSelectList.CSS;for(var i=0;i<records.length;i++)
{var record=records[i];elem.appendChild(item=document.createElement('div'));item.innerHTML=record.name+' &mdash; ';item.appendChild(em=document.createElement('em'));em.innerHTML=record.owner;}
elem.style.height=(cell.mySharable?'150px':'300px');}

var SumTrainingDOM=new ListingDOM();SumTrainingDOM.generate=function(criteria,callback)
{var filter=criteria.filter;var model=criteria.value;var value=model.value;var crossTabs=value.crossTabs;var intervals=value.intervals;var colSpan=(!intervals||(0==intervals.length))?1:(crossTabs.length+1);var elem,cell,row,rows=0,sub,t,o=document.createElement('form');o.className='widgetPackage';o.appendChild(t=this.createTable());if(!filter.byYear)
{sub=t.createTHead();cell=sub.insertRow(0).insertCell(0);cell.colSpan=colSpan;cell.appendChild(Elements.genAnchor('&lt;&lt;'+CAPTION_YEAR,function(ev){callback.toYear(criteria);return false;}));}
if(filter.byWeek)
{Elements.addSpan(cell,undefined,'&nbsp;&nbsp;');cell.appendChild(Elements.genAnchor('&lt;'+CAPTION_MONTH,function(ev){callback.toMonth(criteria);return false;}));}
t.appendChild(sub=document.createElement('tbody'));row=sub.insertRow(rows++);cell=row.insertCell(0);cell.colSpan=colSpan;cell.className=this.CSS_FIELD+' nowrap';this.appendOptions(cell,'month',model.monthOptions,filter.month,function(ev){callback.handleChangeMonth(criteria,this);},CAPTION_ALL_MONTHS);this.appendOptions(cell,'year',model.yearOptions,model.currentYear,function(ev){callback.handleChangeYear(criteria,this);});this.appendOptions(cell,'trainingType',model.typeOptions,model.currentType,function(ev){callback.handleChangeType(criteria,this);});elem=this.appendOptions(cell,'distanceUnit',model.distanceUnitOptions,filter.distanceUnitId,function(ev){callback.handleChangeDistanceUnit(criteria,this);},CAPTION_DEFAULT_DISTANCE_UNIT);elem.options[elem.options.length]=new Option('Duration Only','onlyDuration');if(criteria.onlyDuration)
elem.value='onlyDuration';this.appendOptions(cell,'teammate',model.teammateOptions,filter.teammate,function(ev){callback.handleChangeTeammate(criteria,this);},CAPTION_ME);var totals=new Array(crossTabs.length);var crossTabIds=value.crossTabIds;if(1==colSpan)
{sub.insertRow(rows++).insertCell(0).appendChild(this.createNoDataFound());return o;}
row=this.createHeaderRow(sub,rows++);this.createHeaderCell(row,0,model.intervalCaption).style.width='80px';for(var i=0;i<crossTabs.length;i++)
{totals[i]={distance:0,duration:0};this.createHeaderCell(row,i+1).appendChild(this.createCrossTabHeader(criteria,callback,crossTabIds[i],crossTabs[i]));}
var intervalIds=value.intervalIds;for(var i=0;i<intervals.length;i++)
{row=sub.insertRow(rows++);row.className=this.getRowCss(i);if(filter.byWeek)
this.createDetailCell(row,0,intervals[i]);else
{cell=this.createDetailCell(row,0)
cell.appendChild(elem=document.createElement('a'));elem.href='javascript:void(null)';elem.innerHTML=intervals[i];elem.myInterval=intervalIds[i];elem.onclick=function(ev){callback.handleChangeInterval(criteria,this);return false;};if(filter.byYear)
{cell.appendChild(document.createTextNode(' '));cell.appendChild(elem=Inputter.genButtonX('showWeek','Show Week Details',function(ev){callback.toWeek(criteria,this);},'iconDetails'));elem.myInterval=intervalIds[i];}}
for(var j=0;j<crossTabs.length;j++)
{var item=value.data[i][j];cell=this.createDetailCell(row,j+1);if(item)
{if(!criteria.onlyDuration&&item.distance)
{totals[j].distance+=item.distance;cell.innerHTML=Formatter.toDistance(item.distance);}
else if(item.duration)
{totals[j].duration+=item.duration;cell.innerHTML=Formatter.fromTotalSeconds(item.duration);}}}}
row=sub.insertRow(rows++);row.className=this.getRowCss(intervals.length)+'Bold';this.createDetailCell(row,0,CAPTION_TOTALS);for(var i=0;i<crossTabs.length;i++)
{cell=this.createDetailCell(row,i+1)
if(0<totals[i].duration)
cell.innerHTML=Formatter.fromTotalSeconds(totals[i].duration);else if(0<totals[i].distance)
cell.innerHTML=Formatter.toDistance(totals[i].distance);}
return o;}
SumTrainingDOM.appendOptions=function(cell,name,options,value,onchange,header)
{if(!options||(0==options.length))
return;var elem=SelectList.generate(name,options,header);Elements.addSpace(cell);cell.appendChild(elem);if(value)
elem.value=value;if(onchange)
elem.onchange=onchange;return elem;}
SumTrainingDOM.createCrossTabHeader=function(criteria,callback,id,caption)
{return Elements.genAnchor(caption,function(ev){callback.handleChangeCrossTab(criteria,this,id);return false;});}

var TeamIconLegendDOM=new DetailDOM();TeamIconLegendDOM.generate=function(criteria,callback)
{var teamId=criteria;var cell,row,rows=0,o=document.createElement('table');o.className=this.CSS_TABLE;row=o.insertRow(rows++);cell=this.createValue(row);this.appendItem(cell,'icon_coach.gif','Coach');this.appendItem(cell,'icon_asst_coach.gif','Assistant Coach');this.appendItem(cell,'icon_captain.gif','Captain');this.appendItem(cell,'icon_team_member.gif','Team Member');cell=this.createValue(row);this.appendItem(cell,'icon_request.gif','Request To Join');this.appendItem(cell,'icon_invite.gif','Invite New Members');this.appendItem(cell,'icon_rsvp.gif','View Team Invitation');this.appendItem(cell,'icon_email.gif','Send Team E-mail');cell=this.createValue(row);this.appendItem(cell,'icon_details.gif','List Team Members');this.appendItem(cell,'icon_shared.gif','Share Resources With Team');this.appendItem(cell,'icon_report.gif','Team Members Summaries');return o;}
TeamIconLegendDOM.appendItem=function(elem,src,caption)
{var a=document.createElement('span');a.innerHTML=' &mdash; '+caption+' &nbsp;&nbsp; ';a.insertBefore(Elements.genImage(src),a.firstChild);elem.appendChild(a);}

var TeamMemberSummaryDOM=new ListingDOM();TeamMemberSummaryDOM.generate=function(criteria,callback)
{var filter=criteria.filter;var model=criteria.value;var value=model.value;var elem,cell,cells=0,row,rows=0,t,o=document.createElement('form');o.className='widgetPackage';o.appendChild(elem=document.createElement('h3'));elem.innerHTML=CAPTION_TEAM+': '+value.teamName;o.appendChild(t=this.createTable());row=this.createHeaderRow(t,rows++);cell=row.insertCell(0);cell.colSpan=model.headers.length+2;cell.className=this.CSS_FIELD+' nowrap';cell.appendChild(elem=SelectList.generate('interval',model.intervalOptions));if(filter.interval)
elem.value=filter.interval;elem.onchange=function(ev){callback.handleChangeInterval(criteria,this);return false;};cell.appendChild(document.createTextNode(' '));cell.appendChild(elem=Elements.genAnchor('&lt;&lt;',function(ev){callback.handleChangeYear(criteria,value.year-1);}));elem.className='year';cell.appendChild(document.createTextNode(' '+value.year+' '));cell.appendChild(elem=Elements.genAnchor('&gt;&gt;',function(ev){callback.handleChangeYear(criteria,value.year+1);}));elem.className='year';cell.appendChild(document.createTextNode(' '));cell.appendChild(elem=SelectList.generate('distanceUnit',model.distanceUnitOptions,CAPTION_DEFAULT_DISTANCE_UNIT));elem.onchange=function(ev){callback.handleChangeDistanceUnit(criteria,this);};if(filter.distanceUnitId)
elem.value=filter.distanceUnitId;var records=value.records;if(!records||(0==records.length))
{row=t.insertRow(rows++);cell=row.insertCell(0);cell.colSpan=model.headers.length+2;cell.appendChild(this.createNoDataFound());return o;}
if(value.isByWeek)
{row=this.createHeaderRow(t,rows++);this.createHeaderCell(row,0);cell=this.createHeaderCell(row,1);cell.colSpan=model.headers.length;this.createHeaderCell(row,2);var captions=model.months;var widths=model.monthWidths;var sub=this.createTable();sub.style.width='100%';cell.appendChild(sub);row=this.createHeaderRow(sub,0);for(var i=0;i<captions.length;i++)
this.createHeaderCell(row,i,captions[i]).style.width=widths[i]+'%';}
row=this.createHeaderRow(t,rows++);this.createHeaderCell(row,cells++,CAPTION_MEMBER);var captions=model.headers;for(var i=0;i<captions.length;i++)
this.createHeaderCell(row,cells++,captions[i]);this.createHeaderCell(row,cells++,CAPTION_TOTALS);for(var i=0;i<records.length;i++)
{var total=0;var record=records[i];cells=0;row=t.insertRow(rows++);row.className=this.getRowCss(i);this.createDetailCell(row,cells++,record.name);var distances=record.distances;for(j=0;j<distances.length;j++)
{var distance=distances[j];cell=this.createDetailCell(row,cells++);if(distance)
{cell.appendChild(document.createTextNode(Formatter.toDistance(distance)));total+=distance;}
else
cell.innerHTML='&nbsp;&nbsp;&nbsp;';}
this.createDetailCell(row,cells++,Formatter.toDistance(total));}
return o;}

var TeammatesListDOM=new DetailDOM();TeammatesListDOM.generate=function(criteria,callback)
{var records=criteria.records;var a,o=document.createElement('div');o.style.width='400px';records.splice(0,0,{desc:CAPTION_ME});for(var i=0;i<records.length;i++)
{var r=records[i];r.name=r.desc.substring(0,r.desc.indexOf(' ('));o.appendChild(a=Elements.genAnchor(r.desc,function(ev){callback.handleSelect(criteria,this.myRecord);return false;}));a.myRecord=r;}
return o;}

var TrainingChartDOM=new DetailDOM();TrainingChartDOM.generate=function(criteria,callback)
{var m=criteria.value;var v=criteria.filter;var cal=cal=Calendar.getInstance();var output=criteria.output=document.createElement('div');var elem,c,t,o=criteria.form=this.createForm(criteria,callback);output.appendChild(o);o.appendChild(t=this.createTable());if(m.teammateOptions&&(0<m.teammateOptions.length))
{this.createRowX(t,CAPTION_TEAMMATE,false,elem=SelectList.generate('teammate',m.teammateOptions,CAPTION_ME),v.teammate);elem.onchange=function(ev){callback.handleChangeTeammate(criteria,this);};}
c=this.createRowX(t,CAPTION_TRAINING_DATE,false,cal.create('fromDate',v.fromDate)).myValueCell;Elements.addText(c,' to ');c.appendChild(cal.create('toDate',v.toDate));this.createRowX(t,CAPTION_INTERVAL,false,SelectList.generate('interval',m.intervalOptions),v.interval);this.createRowX(t,CAPTION_FIRST_DATAPOINT,false,elem=SelectList.generate('datapoints',m.datapointOptions));elem.selectedIndex=0;this.createRowX(t,CAPTION_SECOND_DATAPOINT,false,SelectList.generate('datapoints',m.datapointOptions,CAPTION_NONE));this.createRowX(t,CAPTION_THIRD_DATAPOINT,false,SelectList.generate('datapoints',m.datapointOptions,CAPTION_NONE));this.createRowX(t,CAPTION_FOURTH_DATAPOINT,false,SelectList.generate('datapoints',m.datapointOptions,CAPTION_NONE));this.createRowX(t,CAPTION_FIFTH_DATAPOINT,false,SelectList.generate('datapoints',m.datapointOptions,CAPTION_NONE));this.createRowX(t,CAPTION_SIXTH_DATAPOINT,false,SelectList.generate('datapoints',m.datapointOptions,CAPTION_NONE));c=this.createAction(t);c.appendChild(Inputter.genSubmit('submitter',CAPTION_SUBMIT));if(callback.callback&&callback.callback.handleCancel)
{Elements.addSpace(c);c.appendChild(Inputter.genButton('canceler',CAPTION_CANCEL,function(ev){callback.handleCancel(criteria);}));}
return output;}
TrainingChartDOM.genComplete=function(criteria,callback)
{var v=criteria.filter;var elem,cell,row,o=document.createElement('table');row=o.insertRow(0);row.insertCell(0).appendChild(elem=document.createElement('a'));elem.href='javascript:void(null)';elem.innerHTML='&lt;&lt;Back';elem.onclick=function(ev){callback.handleBack(criteria);return false;};cell=row.insertCell(1);cell.style.textAlign='right';cell.innerHTML=CAPTION_SIZE+' ';cell.appendChild(elem=SelectList.generate('chartSize',criteria.value.sizeOptions));if(v.size)
elem.value=v.size;elem.onchange=function(ev){callback.handleChangeSize(criteria,this);};row=o.insertRow(1);cell=row.insertCell(0);cell.colSpan=2;cell.appendChild(elem=o.image=document.createElement('img'));elem.src=criteria.response.payload;return o;}

function TrainingFutureDetailsDecorator(caller)
{this.caller=caller;}
TrainingFutureDetailsDecorator.prototype=new ListingDOM();TrainingFutureDetailsDecorator.prototype.doByActual=function(id,body)
{var me=this;this.caller.getRunFutureDetails(undefined,id,{handleRequestData:function(value)
{me.decorate({body:body,value:value},me);}});}
TrainingFutureDetailsDecorator.prototype.decorate=function(criteria)
{var value=criteria.value;var records=value.records;var table=criteria.body.myTable;if((undefined==records)||(0==records.length)||!table)
return;var actualCount=table.myCount;var actualRows=table.myRows;var lastRow=table.myLastRow;for(var i=0;i<records.length;i++)
{var record=records[i];var rowIndex=(i<actualCount)?actualRows[i].rowIndex:(lastRow.rowIndex-1);var css=(i<actualCount)?actualRows[i].className:this.getRowCss(i);var cssCell=css+'Future';var row=table.insertRow(rowIndex+1);row.className=css;var cell=row.insertCell(0);cell.className=cssCell;cell=row.insertCell(1);cell.className=cssCell+' listingDistance';cell.innerHTML=Formatter.toDistance(record.distanceMiles)+MILE_ABBR;cell=row.insertCell(2);cell.className=cssCell+' listingDistance';cell.innerHTML=Formatter.toDistance(record.distanceKm)+KM_ABBR;cell=row.insertCell(3);cell.className=cssCell+' listingDuration';cell.innerHTML=Formatter.toDuration(record);cell=row.insertCell(4);cell.className=cssCell+' listingHR';cell.colSpan=table.myHrColSpan;if((undefined!=record.heartRateAvg)||(undefined!=record.heartRateMax))
cell.innerHTML=Formatter.toDisplayable(record.heartRateAvg)+' / '+Formatter.toDisplayable(record.heartRateMax);cell=row.insertCell(5);cell.className=cssCell;cell.innerHTML=Formatter.toDisplayable(record.comments);cell=row.insertCell(6);cell.className=cssCell;if(undefined!=record.paceMiles)
cell.innerHTML=Formatter.toPace(record.paceMiles);else if(undefined!=record.paceKm)
cell.innerHTML=Formatter.toPace(record.paceKm);}}

var TrainingIconLegendDOM=new DetailDOM();TrainingIconLegendDOM.generate=function(criteria,callback)
{var cell,row,rows=0,o=document.createElement('table');o.className=this.CSS_TABLE;row=o.insertRow(rows++);cell=this.createValue(row);this.appendItem(cell,'icon_plus_run.gif','Add Run');this.appendItem(cell,'icon_plus_xtrain.gif','Add X-training');this.appendItem(cell,'icon_dawn.gif','Morning Activity');this.appendItem(cell,'icon_sun.gif',' Afternoon Activity');this.appendItem(cell,'icon_moon.gif',' Evening Activity');cell=this.createValue(row);this.appendItem(cell,'icon_heart.gif','HR Log (resting/max.)');this.appendItem(cell,'icon_scale.gif','Weight Log (weight/fat %)');this.appendItem(cell,'icon_blood_pressure.gif','Blood Pressure (Sys/Dia)');this.appendItem(cell,'icon_sleep.gif','Sleep Log');cell=this.createValue(row);this.appendAnchor(cell,'icon_run.gif','Run','addRun');this.appendAnchor(cell,'icon_bike.gif','Bike','addXBike');this.appendAnchor(cell,'icon_swim.gif','Swim','addXSwim');this.appendAnchor(cell,'icon_spin.gif','Spin','addXSpin');this.appendAnchor(cell,'icon_foot.gif','Walk','addXWalk');this.appendAnchor(cell,'icon_stair_master.gif','Stair Master','addXStairMaster');this.appendAnchor(cell,'icon_soccer.gif','Soccer','addXSoccer');this.appendAnchor(cell,'icon_ice_skate.gif','Ice Skating','addXIceSkating');this.appendAnchor(cell,'icon_xc_ski.gif','XC Skiing','addXCrossCountrySkiing');this.appendAnchor(cell,'icon_yin_yang.gif','Martial Arts','addXMartialArts');cell=this.createValue(row);this.appendAnchor(cell,'icon_elliptical.gif','Elliptical','addXElliptical');this.appendAnchor(cell,'icon_water_run.gif','Water Run','addXWaterRun');this.appendAnchor(cell,'icon_row_machine.gif','Row Machine','addXRowMachine');this.appendAnchor(cell,'icon_inline_skate.gif','Inline Skating','addXInlineSkating');this.appendAnchor(cell,'icon_barbell.gif',CAPTION_STRENGTH_TRAINING,'addExercise');this.appendAnchor(cell,'icon_aerobics.gif','Aerobics','addXAerobics');this.appendAnchor(cell,'icon_yoga.gif','Yoga','addXYoga');this.appendAnchor(cell,'icon_pilates.gif','Pilates','addXPilates');this.appendAnchor(cell,'icon_skis.gif','Skiing','addXSkiing');this.appendAnchor(cell,'icon_snowshoe.gif','Snowshoeing','addXSnowshoeing');return o;}
TrainingIconLegendDOM.appendItem=function(elem,src,caption)
{var a=document.createElement('span');a.innerHTML=' &mdash; '+caption+' &nbsp;&nbsp; ';a.insertBefore(Elements.genImage(src),a.firstChild);elem.appendChild(a);}
TrainingIconLegendDOM.appendAnchor=function(elem,src,caption,action)
{var a=Elements.genAnchor(undefined,function(ev){Linker[action]();Popup.close();return false;});a.innerHTML=' &mdash; '+caption+' &nbsp;&nbsp; ';a.insertBefore(Elements.genImage(src),a.firstChild);elem.appendChild(a);}

var TrainingTotalsSmall={}
TrainingTotalsSmall.CSS_MAIN='quickForm';TrainingTotalsSmall.generate=function(criteria,callback)
{var v=criteria.value;var r=0,o=document.createElement('table');o.className=this.CSS_MAIN;this.createRow(o.insertRow(r++),v.year,v,'Year');this.createRow(o.insertRow(r++),v.monthName,v,'Month');this.createRow(o.insertRow(r++),CAPTION_WEEK,v,'Week');return o}
TrainingTotalsSmall.createRow=function(row,caption,v,i)
{var distance=v['total'+i];var abbr=v.distanceUnitAbbr;var duration=v['totalDuration'+i];var steps=v['totalSteps'+i];var _steps=(steps?(' / '+Formatter.toNumber(steps)+' '+CAPTION_STEPS):'');var e,c=row.insertCell(0);c.className=this.CSS_MAIN;c.innerHTML=caption;c=row.insertCell(1);c.className=this.CSS_MAIN;c.appendChild(e=document.createElement('b'));if(distance)
e.innerHTML=Formatter.toDistance(distance)+' '+abbr+_steps;else if(duration)
e.innerHTML=Formatter.fromTotalSeconds(duration)+_steps;else if(steps)
e.innerHTML=Formatter.toNumber(steps)+' '+CAPTION_STEPS;else
e.innerHTML=CAPTION_NA;return row;}

function CalendarSimple(caller,viewer,callback)
{this.caller=caller;this.viewer=viewer;this.callback=callback;}
CalendarSimple.prototype=new DetailSimple();CalendarSimple.getToday=Calendar.getToday;CalendarSimple.prototype=new DetailSimple();CalendarSimple.prototype.init=function(body){this.doToday(body);}
CalendarSimple.prototype.doToday=function(body){this.doWhen(Formatter.today(),body);}
CalendarSimple.prototype.doWhen=function(date,body){this.filter(this.fill({date:date}),body);}
CalendarSimple.prototype.fill=function(filter)
{var date=filter.date;filter.fromDate=new Date(date.getTime());filter.fromDate.setUTCDate(1);filter.toDate=new Date(date.getTime());filter.toDate.setUTCDate(this.viewer.getDaysInMonth(date.getUTCMonth(),date.getUTCFullYear()));return filter;}
CalendarSimple.prototype.makeCall=function(filter,dataHandler)
{this.caller.getCalendar(filter,dataHandler);}
CalendarSimple.prototype.handleChangeMonth=function(criteria,newValue)
{var filter=criteria.filter;filter.date.setMonth(newValue);this.fill(filter);this.run(criteria);}
CalendarSimple.prototype.handleChangeYear=function(criteria,offset)
{var filter=criteria.filter;filter.date.setFullYear(filter.date.getFullYear()+offset);this.fill(filter);this.run(criteria);}
CalendarSimple.prototype.handleChangeTeammate=function(criteria,elem)
{criteria.filter.teammate=elem.value;this.run(criteria);}
CalendarSimple.prototype.handleAddRun=function(criteria,elem)
{this.callback.addRun(elem.myDate,criteria.filter.teammate);}
CalendarSimple.prototype.handleAddXtraining=function(criteria,elem)
{this.callback.addXtraining(elem.myDate,criteria.filter.teammate);}
CalendarSimple.prototype.handleEditTraining=function(criteria,elem)
{var record=elem.myRecord;if(record.isRun)
{if(record.isFuture)
this.callback.editRunFuture(record.id);else
this.callback.editRun(record.id);}
else
this.callback.editXtraining(record.id);}
CalendarSimple.prototype.handleViewTraining=function(criteria,elem)
{var record=elem.myRecord;if(record.isRun)
{if(record.isFuture)
this.callback.viewRunFuture(record.id);else
this.callback.viewRun(record.id);}
else
this.callback.viewXtraining(record.id);}
CalendarSimple.prototype.handleAddExercise=function(criteria,elem)
{this.callback.addExercise(elem.myDate);}
CalendarSimple.prototype.handleEditExercise=function(criteria,elem)
{this.callback.editExercise(elem.myRecord.id);}
CalendarSimple.prototype.handleViewExercise=function(criteria,elem)
{this.callback.viewExercise(elem.myRecord.id);}
CalendarSimple.prototype.handleAddHeartRate=function(criteria,elem)
{this.callback.addHeartRateLog(elem.myDate);}
CalendarSimple.prototype.handleEditHeartRate=function(criteria,elem)
{this.callback.editHeartRateLog(elem.myRecord.id);}
CalendarSimple.prototype.handleAddWeight=function(criteria,elem)
{this.callback.addWeightLog(elem.myDate);}
CalendarSimple.prototype.handleEditWeight=function(criteria,elem)
{this.callback.editWeightLog(elem.myRecord.id);}
CalendarSimple.prototype.handleAddSleep=function(criteria,elem)
{this.callback.addSleepLog(elem.myDate);}
CalendarSimple.prototype.handleEditSleep=function(criteria,elem)
{this.callback.editSleepLog(elem.myRecord.id);}
CalendarSimple.prototype.handleAddMenstruation=function(criteria,elem)
{this.callback.addMenstruationLog(elem.myDate);}
CalendarSimple.prototype.handleEditMenstruation=function(criteria,elem)
{this.callback.editMenstruationLog(elem.myRecord.id);}

function DashboardSimple(caller,viewer,pageSize,callback)
{this.caller=caller;this.viewer=viewer;this.pageSize=pageSize;this.callback=callback;this.CAPTIONS=[CAPTION_TEAMMATES+' '+CAPTION_RUNNING,'Community '+CAPTION_RUNNING,CAPTION_TEAMMATES+' '+CAPTION_XTRAINING,'Community '+CAPTION_XTRAINING];}
DashboardSimple.prototype.NAMES=['TeammatesRunning','CommunityRunning','TeammatesXtraining','CommunityXtraining'];DashboardSimple.prototype.init=function(body){this.filter({},body);}
DashboardSimple.prototype.doLast=function(){this.run(this.lastCriteria);}
DashboardSimple.prototype.filter=function(filter,body){this.run({filter:filter},body);}
DashboardSimple.prototype.run=function(criteria,body)
{if(body)
criteria.body=body;else
body=criteria.body;var f=criteria.filter;if(!f.pageSize)
f.pageSize=this.pageSize;if(body.firstChild)
body.removeChild(body.firstChild);var o;body.appendChild(o=this.generate(criteria,this));var me=this;this.countTeammates({handleRequestData:function(value){var count=value.payload;if(0==count)
{o.captionTeammatesRunning.innerHTML='My '+CAPTION_RUNNING;o.captionTeammatesXtraining.innerHTML='My '+CAPTION_XTRAINING;me.caller.getRecentRuns(f,new DSDH(o.myTeammatesRunning,me));me.caller.getRecentXtraining(f,new DSDH(o.myTeammatesXtraining,me));}
else
{me.getRecentRunsByTeammates(f,new DSDH(o.myTeammatesRunning,me));me.getRecentXtrainingByTeammates(f,new DSDH(o.myTeammatesXtraining,me));}
me.getRecentRunsByCommunity(f,new DSDH(o.myCommunityRunning,me));me.getRecentXtrainingByCommunity(f,new DSDH(o.myCommunityXtraining,me));}});this.lastCriteria=criteria;}
DashboardSimple.prototype.countTeammates=function(dataHandler)
{this.caller.countTeammates(dataHandler);}
DashboardSimple.prototype.getRecentRunsByTeammates=function(filter,dataHandler)
{this.caller.getRecentRunsByTeammates(filter,dataHandler);}
DashboardSimple.prototype.getRecentXtrainingByTeammates=function(filter,dataHandler)
{this.caller.getRecentXtrainingByTeammates(filter,dataHandler);}
DashboardSimple.prototype.getRecentRunsByCommunity=function(filter,dataHandler)
{this.caller.getRecentRunsByCommunity(filter,dataHandler);}
DashboardSimple.prototype.getRecentXtrainingByCommunity=function(filter,dataHandler)
{this.caller.getRecentXtrainingByCommunity(filter,dataHandler);}
DashboardSimple.prototype.generate=function(criteria,callback)
{var e,b,o=document.createElement('div');o.className='widgetPackage';for(var i=0;i<this.NAMES.length;i++)
{var name=this.NAMES[i];o.appendChild(b=document.createElement('div'));b.className='dashboard';b.appendChild(e=o['caption'+name]=document.createElement('h3'));e.innerHTML=this.CAPTIONS[i];b.appendChild(e=o['my'+name]=document.createElement('div'));o.appendChild(document.createElement('br'));ProgressBar.start(e);}
return o;}
DashboardSimple.prototype.handleSelect=function(elem)
{var r=elem.myRecord;if(r.isRun)
Linker.viewRun(r.id);else
Linker.viewXtraining(r.id);}
function DSDH(body,callback)
{this.body=body;this.callback=callback;}
DSDH.prototype.handleRequestData=function(value)
{var me=this.callback,body=this.body;body.removeChild(body.firstChild);body.appendChild(me.viewer.generate(value,me));}

function DetailBlogSimple(caller,viewer,callback)
{this.caller=caller;this.viewer=viewer;this.callback=callback;}
DetailBlogSimple.prototype=new DetailSimple();DetailBlogSimple.prototype.doById=function(id,body){this.filter({id:id,isAuthenticated:globalInfo.isAuthenticated},body);}
DetailBlogSimple.prototype.makeCall=function(filter,dataHandler)
{this.caller.getBlog(filter.id,dataHandler);}
DetailBlogSimple.prototype.handleEmail=function(criteria){this.callback.handleEmail(criteria);}

function DetailExerciseSimple(caller,viewer,callback)
{this.caller=caller;this.viewer=viewer;this.callback=callback;}
DetailExerciseSimple.prototype=new DetailSimple();DetailExerciseSimple.prototype.doById=function(id,body){this.filter(id,body);}
DetailExerciseSimple.prototype.makeCall=function(filter,dataHandler)
{this.caller.getExercise(filter,dataHandler);}
DetailExerciseSimple.prototype.handleCancel=function(criteria){this.callback.handleCancel(criteria);}

function DetailRunSimple(caller,viewer,callback)
{this.caller=caller;this.viewer=viewer;this.callback=callback;}
DetailRunSimple.getInstance=function(caller,viewer,callback)
{var handler=new DetailRunSimple(caller,viewer,callback);handler.makeCall=function(filter,dataHandler){this.caller.getRun(filter.id,dataHandler);};return handler;}
DetailRunSimple.getFutureInstance=function(caller,viewer,callback)
{var handler=new DetailRunSimple(caller,viewer,callback);handler.doByActual=function(id,body){this.filter({actualId:id},body);};handler.makeCall=function(filter,dataHandler){this.caller.getRunFuture(filter.id,filter.actualId,dataHandler);};return handler;}
DetailRunSimple.prototype=new DetailSimple();DetailRunSimple.prototype.doById=function(id,body)
{this.filter({id:id},body);}
DetailRunSimple.prototype.handlePostLoad=function(criteria,output)
{var value=criteria.value;if(undefined!=value.shoeId)
{var me=this;this.caller.getShoe(value.shoeId,{handleRequestData:function(item){me.setShoe(item,output.myShoeUsage);}});}
if(!value.isFuture)
(new RunFutureDecorator(this.caller)).doByActual(value.id,output);}
DetailRunSimple.prototype.setShoe=function(value,body)
{body.innerHTML=Formatter.concatEquipUsage(value);body.className=value.isExpired?'paceExpired':'pace';}

function DetailTeamSimple(caller,viewer,callback)
{this.caller=caller;this.viewer=viewer;this.callback=callback;}
DetailTeamSimple.prototype=new DetailSimple();DetailTeamSimple.prototype.doById=function(id,body){this.filter(id,body);}
DetailTeamSimple.prototype.makeCall=function(filter,dataHandler)
{this.caller.getTeam(filter,dataHandler);}

function DetailXtrainingSimple(caller,viewer,callback)
{this.caller=caller;this.viewer=viewer;this.callback=callback;}
DetailXtrainingSimple.prototype=new DetailSimple();DetailXtrainingSimple.prototype.doById=function(id,body)
{this.filter({id:id},body);}
DetailXtrainingSimple.prototype.makeCall=function(filter,dataHandler)
{this.caller.getXtraining(filter.id,dataHandler);}
DetailXtrainingSimple.prototype.handlePostLoad=function(criteria,output)
{var me=this;var value=criteria.value;if(value.bikeId)
this.caller.getBike(value.bikeId,{handleRequestData:function(item){me.setEquip(item,output.myBikeUsage);}});if(value.skiId)
this.caller.getSki(value.skiId,{handleRequestData:function(item){me.setEquip(item,output.mySkiUsage);}});}
DetailXtrainingSimple.prototype.setEquip=function(value,body)
{body.innerHTML=Formatter.concatEquipUsage(value);body.className=value.isExpired?'paceExpired':'pace';}

function EditBlogCommentSimple(caller,viewer,callback)
{this.caller=caller;this.viewer=viewer;this.callback=callback;}
EditBlogCommentSimple.prototype=new DetailSimple();EditBlogCommentSimple.prototype.doAdd=function(body,blogId)
{this.filter({isAdd:true,blogId:blogId},body);}
EditBlogCommentSimple.prototype.doReply=function(id,body)
{this.filter({isAdd:true,replyId:id},body);}
EditBlogCommentSimple.prototype.doEdit=function(id,body)
{this.filter({isEdit:true,id:id},body);}
EditBlogCommentSimple.prototype.makeCall=function(filter,dataHandler)
{this.caller.getEditBlogComment(filter,dataHandler);}
EditBlogCommentSimple.prototype.extract=function(criteria,form)
{var record=criteria.value.value;if(form.myPreviewPage)
return record;record.title=form.title.value;if(form.fullName)
{record.fullName=form.fullName.value;record.emailAddress=form.emailAddress.value;}
record.url=form.url.value;record.contents=form.contents.value;return record;}
EditBlogCommentSimple.prototype.handleSubmit=function(criteria,form)
{var record=this.extract(criteria,form);var cb=this.createUpdateCallback(criteria,form,record);if(criteria.filter.isAdd)
this.caller.addBlogComment(record,cb);else
this.caller.setBlogComment(record,cb);}
EditBlogCommentSimple.prototype.handleCancel=function(criteria,form){this.callback.handleCancel(criteria);}
EditBlogCommentSimple.prototype.handlePreview=function(criteria,form)
{var record=this.extract(criteria,form);var body=criteria.body;body.removeChild(body.firstChild);body.appendChild(this.viewer.preview(criteria,this));}
EditBlogCommentSimple.prototype.handleBack=function(criteria,form)
{var body=criteria.body;body.removeChild(body.firstChild);body.appendChild(this.viewer.generate(criteria,this));}

function EditBlogReportSimple(caller,viewer,callback)
{this.caller=caller;this.viewer=viewer;this.callback=callback;}
EditBlogReportSimple.prototype=new DetailSimple();EditBlogReportSimple.prototype.doAdd=function(body,commentId)
{this.filter({isAdd:true,commentId:commentId},body);}
EditBlogReportSimple.prototype.doEdit=function(id,body)
{this.filter({isEdit:true,id:id},body);}
EditBlogReportSimple.prototype.makeCall=function(filter,dataHandler)
{this.caller.getEditBlogReport(filter,dataHandler);}
EditBlogReportSimple.prototype.handleSubmit=function(criteria,form)
{var record=criteria.value.value;record.contents=form.contents.value;var cb=this.createUpdateCallback(criteria,form,record);if(criteria.filter.isAdd)
this.caller.addBlogReport(record,cb);else
this.caller.setBlogReport(record,cb);}
EditBlogReportSimple.prototype.handleCancel=function(criteria,form){this.callback.handleCancel(criteria);}

function EditEquipmentSimple(caller,viewer,callback)
{this.caller=caller;this.viewer=viewer;this.callback=callback;}
EditEquipmentSimple.getBikeInstance=function(caller,viewer,callback)
{var handler=new EditEquipmentSimple(caller,viewer,callback);handler.makeCall=function(filter,dataHandler){this.caller.getEditBike(filter.id,dataHandler);};handler.addRecord=function(record,callback){this.caller.addBike(record,callback);};handler.setRecord=function(record,callback){this.caller.setBike(record,callback);};return handler;}
EditEquipmentSimple.getShoeInstance=function(caller,viewer,callback)
{var handler=new EditEquipmentSimple(caller,viewer,callback);handler.makeCall=function(filter,dataHandler){this.caller.getEditShoe(filter.id,dataHandler);};handler.addRecord=function(record,callback){this.caller.addShoe(record,callback);};handler.setRecord=function(record,callback){this.caller.setShoe(record,callback);};return handler;}
EditEquipmentSimple.getSkiInstance=function(caller,viewer,callback)
{var handler=new EditEquipmentSimple(caller,viewer,callback);handler.makeCall=function(filter,dataHandler){this.caller.getEditSki(filter.id,dataHandler);};handler.addRecord=function(record,callback){this.caller.addSki(record,callback);};handler.setRecord=function(record,callback){this.caller.setSki(record,callback);};return handler;}
EditEquipmentSimple.prototype=new DetailSimple();EditEquipmentSimple.prototype.doAdd=function(body){this.filter({isAdd:true},body);}
EditEquipmentSimple.prototype.doCopy=function(id,body)
{this.filter({id:id,isCopy:true},body);}
EditEquipmentSimple.prototype.doEdit=function(id,body)
{this.filter({id:id,isEdit:true},body);}
EditEquipmentSimple.prototype.handleCancel=function(criteria){this.callback.handleCancel(criteria);}
EditEquipmentSimple.prototype.handleSubmit=function(criteria,form)
{var record=criteria.value.value;record.purchaseDate=form.purchaseDate.myDate;record.brandId=form.brand.value;record.modelName=form.modelName.value;record.modelTypeId=form.modelType.value;record.previousMiles=form.previousMiles.value;record.previousKm=form.previousKm.value;record.expirationMiles=form.expirationMiles.value;record.expirationKm=form.expirationKm.value;record.warnWhenExpired=form.warnWhenExpired.checked;record.isActive=form.isActive.checked;var filter=criteria.filter;var callback=this.createUpdateCallback(criteria,form,record);if(filter.isAdd||filter.isCopy)
this.addRecord(record,callback);else
this.setRecord(record,callback);}

function EditExerciseSimple(caller,viewer,callback)
{this.caller=caller;this.viewer=viewer;this.callback=callback;}
EditExerciseSimple.prototype=new DetailSimple();EditExerciseSimple.prototype.confirmDelete=ListingSimple.prototype.confirmDelete;EditExerciseSimple.prototype.doAdd=function(body,when){this.filter({isAdd:true,logDate:when},body);}
EditExerciseSimple.prototype.doCopy=function(id,body){this.filter({isCopy:true,id:id},body);}
EditExerciseSimple.prototype.doEdit=function(id,body){this.filter({isEdit:true,id:id},body);}
EditExerciseSimple.prototype.makeCall=function(filter,dataHandler)
{this.caller.getEditExercise(filter,dataHandler);}
EditExerciseSimple.prototype.handleChangeMuscleGroup=function(elem,exerciseTypeId)
{this.caller.getExerciseTypes(elem.value,new RepopulateSelectList(elem.form.exerciseType,CAPTION_EXERCISE_TYPE,exerciseTypeId));}
EditExerciseSimple.prototype.toRecord=function(form,criteria)
{var record=criteria.value.value;record.exerciseDate=form.exerciseDate.myDate;record.timeOfDayId=form.timeOfDay.value;record.focus=MultiSelectList.retrieve(form.focus);record.heartRateAvg=form.heartRateAvg.value;record.heartRateMax=form.heartRateMax.value;record.comments=form.comments.value;var sets=form.sets.options;if(0==sets.length)
record.sets=undefined;else
{var fix=function(a){return(a?a:'');};record.sets=[];for(var i=0;i<sets.length;i++)
{var set=sets[i].mySet;record.sets[i]=set.exerciseTypeId+DELIMITER+set.repetitions+DELIMITER+
fix(set.weight)+DELIMITER+fix(set.weightUnitId)+DELIMITER+
fix(set.heartRateAvg)+DELIMITER+fix(set.heartRateMax)+DELIMITER+
fix(set.comments)+DELIMITER+set.isMaxOut;}}
return record;}
EditExerciseSimple.prototype.handleSubmit=function(criteria,form)
{var record=this.toRecord(form,criteria);var filter=criteria.filter;var callback=this.createUpdateCallback(criteria,form,record);if(filter.isAdd||filter.isCopy)
this.caller.addExercise(record,callback);else
this.caller.setExercise(record,callback);}
EditExerciseSimple.prototype.handleCopy=function(criteria,form)
{var record=this.toRecord(form,criteria);this.caller.addExercise(record,this.createUpdateCallback(criteria,form,record));}
EditExerciseSimple.prototype.handleDelete=function(criteria,record)
{if(!this.confirmDelete())
return;var me=this;this.caller.deleteExercise(record.id,{handleRequestData:function(value){me.callback.handleComplete(criteria);}});}
EditExerciseSimple.prototype.handleCancel=function(criteria){this.callback.handleCancel(criteria);}

function EditFeedbackSimple(caller,viewer,callback)
{this.caller=caller;this.viewer=viewer;this.callback=callback;}
EditFeedbackSimple.prototype=new DetailSimple();EditFeedbackSimple.prototype.open=function(body){this.doAdd(body);}
EditFeedbackSimple.prototype.doAdd=function(body)
{this.filter({isAdd:true},body);}
EditFeedbackSimple.prototype.doError=function(error,body)
{this.filter({isError:true,error:error},body);}
EditFeedbackSimple.prototype.makeCall=function(filter,dataHandler)
{this.caller.getEditFeedback(filter,dataHandler);}
EditFeedbackSimple.prototype.handleCancel=function(criteria,form){this.callback.handleCancel(criteria);}
EditFeedbackSimple.prototype.handleSubmit=function(criteria,form)
{var record=criteria.value.value;record.typeId=form.typeId.value;record.comments=form.comments.value;var error=criteria.filter.error;if(error)
{record.url=error.url;record.payload=error.payload;}
this.caller.addFeedback(record,this.createUpdateCallback(criteria,form,record));}

function EditHeartRateLogSimple(caller,viewer,callback)
{this.caller=caller;this.viewer=viewer;this.callback=callback;}
EditHeartRateLogSimple.prototype=new DetailSimple();EditHeartRateLogSimple.prototype.confirmDelete=ListingSimple.prototype.confirmDelete;EditHeartRateLogSimple.prototype.doAdd=function(body,logDate){this.filter({isAdd:true,logDate:logDate},body);}
EditHeartRateLogSimple.prototype.doCopy=function(id,body){this.filter({isCopy:true,id:id},body);}
EditHeartRateLogSimple.prototype.doEdit=function(id,body){this.filter({isEdit:true,id:id},body);}
EditHeartRateLogSimple.prototype.makeCall=function(filter,dataHandler)
{this.caller.getEditHeartRateLog(filter,dataHandler);}
EditHeartRateLogSimple.prototype.handleSubmit=function(criteria,form)
{var record=criteria.value.value;record.logDate=form.logDate.myDate;record.heartRateMin=form.heartRateMin.value;record.heartRateMax=form.heartRateMax.value;record.bpSystolic=form.bpSystolic.value;record.bpDiastolic=form.bpDiastolic.value;var filter=criteria.filter;var callback=this.createUpdateCallback(criteria,form,record);if(filter.isAdd||filter.isCopy)
this.caller.addHeartRateLog(record,callback);else
this.caller.setHeartRateLog(record,callback);}
EditHeartRateLogSimple.prototype.handleDelete=function(criteria,record)
{if(!this.confirmDelete())
return;var me=this;this.caller.deleteHeartRateLog(record.id,{handleRequestData:function(value){me.callback.handleComplete(criteria);}});}
EditHeartRateLogSimple.prototype.handleCancel=function(criteria)
{this.callback.handleCancel(criteria);}

function EditMenstruationLogSimple(caller,viewer,callback)
{this.caller=caller;this.viewer=viewer;this.callback=callback;}
EditMenstruationLogSimple.prototype=new DetailSimple();EditMenstruationLogSimple.prototype.confirmDelete=ListingSimple.prototype.confirmDelete;EditMenstruationLogSimple.prototype.doAdd=function(body,logDate){this.filter({isAdd:true,logDate:logDate},body);}
EditMenstruationLogSimple.prototype.doCopy=function(id,body){this.filter({isCopy:true,id:id},body);}
EditMenstruationLogSimple.prototype.doEdit=function(id,body){this.filter({isEdit:true,id:id},body);}
EditMenstruationLogSimple.prototype.makeCall=function(filter,dataHandler)
{this.caller.getEditMenstruationLog(filter,dataHandler);}
EditMenstruationLogSimple.prototype.handleSubmit=function(criteria,form)
{var record=criteria.value.value;record.logDate=form.logDate.myDate;record.comments=form.comments.value;var filter=criteria.filter;var callback=this.createUpdateCallback(criteria,form,record);if(filter.isAdd||filter.isCopy)
this.caller.addMenstruationLog(record,callback);else
this.caller.setMenstruationLog(record,callback);}
EditMenstruationLogSimple.prototype.handleDelete=function(criteria,record)
{if(!this.confirmDelete())
return;var me=this;this.caller.deleteMenstruationLog(record.id,{handleRequestData:function(value){me.callback.handleComplete(criteria);}});}
EditMenstruationLogSimple.prototype.handleCancel=function(criteria)
{this.callback.handleCancel(criteria);}

function EditRouteSimple(caller,viewer,callback)
{this.caller=caller;this.viewer=viewer;this.callback=callback;}
EditRouteSimple.prototype=new DetailSimple();EditRouteSimple.prototype.doAdd=function(body){this.filter({isAdd:true},body);}
EditRouteSimple.prototype.doCopy=function(id,body)
{this.filter({id:id,isCopy:true},body);}
EditRouteSimple.prototype.doEdit=function(id,body)
{this.filter({id:id,isEdit:true},body);}
EditRouteSimple.prototype.makeCall=function(filter,dataHandler)
{this.caller.getEditRoute(filter.id,dataHandler);}
EditRouteSimple.prototype.handleCancel=function(criteria){this.callback.handleCancel(criteria);}
EditRouteSimple.prototype.handleSubmit=function(criteria,form)
{var record=criteria.value.value;record.desc=form.desc.value;record.distanceMiles=form.distanceMiles.value;record.distanceKm=form.distanceKm.value;record.typeId=form.typeId.value;record.isRace=form.isRace.checked;record.comments=form.comments.value;record.sharedTeamIds=MultiSelectList.retrieve(form.teams);var filter=criteria.filter;var callback=this.createUpdateCallback(criteria,form,record);if(filter.isAdd||filter.isCopy)
this.caller.addRoute(record,callback);else
this.caller.setRoute(record,callback);}

function EditSleepLogSimple(caller,viewer,callback)
{this.caller=caller;this.viewer=viewer;this.callback=callback;}
EditSleepLogSimple.prototype=new DetailSimple();EditSleepLogSimple.prototype.confirmDelete=ListingSimple.prototype.confirmDelete;EditSleepLogSimple.prototype.doAdd=function(body,logDate){this.filter({isAdd:true,logDate:logDate},body);}
EditSleepLogSimple.prototype.doCopy=function(id,body){this.filter({isCopy:true,id:id},body);}
EditSleepLogSimple.prototype.doEdit=function(id,body){this.filter({isEdit:true,id:id},body);}
EditSleepLogSimple.prototype.makeCall=function(filter,dataHandler)
{this.caller.getEditSleepLog(filter,dataHandler);}
EditSleepLogSimple.prototype.handleSubmit=function(criteria,form)
{var record=criteria.value.value;record.logDate=form.logDate.myDate;record.sleepQualityId=form.sleepQuality.value;record.durationHours=form.durationHours.value;record.durationMinutes=form.durationMinutes.value;var filter=criteria.filter;var callback=this.createUpdateCallback(criteria,form,record);if(filter.isAdd||filter.isCopy)
this.caller.addSleepLog(record,callback);else
this.caller.setSleepLog(record,callback);}
EditSleepLogSimple.prototype.handleDelete=function(criteria,record)
{if(!this.confirmDelete())
return;var me=this;this.caller.deleteSleepLog(record.id,{handleRequestData:function(value){me.callback.handleComplete(criteria);}});}
EditSleepLogSimple.prototype.handleCancel=function(criteria)
{this.callback.handleCancel(criteria);}

function EditTeamMemberSimple(caller,viewer,callback)
{this.caller=caller;this.viewer=viewer;this.callback=callback;}
EditTeamMemberSimple.prototype=new DetailSimple();EditTeamMemberSimple.prototype.doEdit=function(id,body){this.filter({id:id},body);}
EditTeamMemberSimple.prototype.makeCall=function(filter,dataHandler)
{this.caller.getEditTeamMember(filter,dataHandler);}
EditTeamMemberSimple.prototype.handleSubmit=function(criteria,form)
{var record=criteria.value.value;record.canViewProfile=form.canViewProfile.checked;record.canEditProfile=form.canEditProfile.checked;record.canViewLog=form.canViewLog.checked;record.canEditLog=form.canEditLog.checked;record.canViewCalendar=form.canViewCalendar.checked;record.canEditCalendar=form.canEditCalendar.checked;record.canViewSummary=form.canViewSummary.checked;if(!record.isOwner&&!record.isPending)
{record.isActive=form.isActive.checked;record.statusId=record.isActive?STATUS_ACTIVE:STATUS_INACTIVE;}
this.caller.setTeamMember(record,this.createUpdateCallback(criteria,form,record));}
EditTeamMemberSimple.prototype.handleCancel=function(criteria){this.callback.handleCancel(criteria);}

function EditTeamSimple(caller,viewer,callback)
{this.caller=caller;this.viewer=viewer;this.callback=callback;}
EditTeamSimple.prototype=new DetailSimple();EditTeamSimple.prototype.init=function(body){this.doAdd(body);}
EditTeamSimple.prototype.doAdd=function(body){this.filter({isAdd:true},body);}
EditTeamSimple.prototype.doEdit=function(id,body){this.filter({isEdit:true,id:id},body);}
EditTeamSimple.prototype.makeCall=function(filter,dataHandler)
{this.caller.getEditTeam(filter.id,dataHandler);}
EditTeamSimple.prototype.handleChangeCountry=function(criteria,elem)
{this.caller.getStates(elem.value,new RepopulateSelectList(elem.form.state));}
EditTeamSimple.prototype.handleSubmit=function(criteria,form)
{var record=criteria.value.value;record.name=form.desc.value;record.typeId=form.typeId.value;record.city=form.city.value;record.stateId=form.state.value;record.countryId=form.country.value;record.webSiteUrl=form.webSiteUrl.value;record.isActive=form.isActive.checked;record.isSearchable=form.isSearchable.checked;record.comments=form.comments.value;var a=function(form,name){var b=form.elements[name];for(var i=0;i<b.length;i++)b[i].myItem[name]=b[i].value;};a(form,'canViewProfile');a(form,'canEditProfile');a(form,'canViewLog');a(form,'canEditLog');a(form,'canViewCalendar');a(form,'canEditCalendar');a(form,'canViewSummary');a=function(form,name){var b=form.elements[name];for(var i=0;i<b.length;i++)b[i].myItem[name]=b[i].checked;};a(form,'canCreateTeamRoutes');a(form,'canCreateTeamWorkouts');a(form,'canSendTeamEmails');a(form,'canInviteNewMembers');var access=record.access,accessTypes=record.accessTypes;for(var i=0;i<access.length;i++)
{var item=access[i],type=accessTypes[i];record.access[i]=type.memberTypeId+DELIMITER+item.canViewProfile+DELIMITER+item.canEditProfile+DELIMITER+
item.canViewLog+DELIMITER+item.canEditLog+DELIMITER+item.canViewCalendar+DELIMITER+
item.canEditCalendar+DELIMITER+item.canViewSummary+DELIMITER+item.canCreateTeamRoutes+DELIMITER+
item.canCreateTeamWorkouts+DELIMITER+item.canSendTeamEmails+DELIMITER+item.canInviteNewMembers+
(type.id?(DELIMITER+type.id):'');}
var filter=criteria.filter;var callback=this.createUpdateCallback(criteria,form,record);if(filter.isAdd)
this.caller.addTeam(record,callback);else
this.caller.setTeam(record,callback);for(var i=0;i<record.access.length;i++)
record.access[i]=form.canViewProfile[i].myItem;}
EditTeamSimple.prototype.handleCancel=function(criteria)
{this.callback.handleCancel(criteria);}

function EditTrainingSimple(caller,viewer,callback)
{this.caller=caller;this.viewer=viewer;this.callback=callback;}
EditTrainingSimple.prototype=new DetailSimple();EditTrainingSimple.getRunInstance=function(caller,viewer,callback)
{var handler=new EditTrainingSimple(caller,viewer,callback)
handler.makeCall=function(filter,dataHandler){this.caller.getEditRun(filter,dataHandler);};handler.addRecord=function(record,callback){this.caller.addRun(record,callback);};handler.setRecord=function(record,callback){this.caller.setRun(record,callback);};handler.deleteRecord=function(record,callback)
{if(record.isFuture)
this.caller.deleteRunFuture(record.id,callback);else
this.caller.deleteRun(record.id,callback);};handler.handlePostLoad=function(criteria,output)
{var value=criteria.value.value;if(value.shoeId)
this.selectShoe(value.shoeId,output);if(criteria.filter.isEdit)
(new RunFutureDecorator(this.caller)).doByActual(value.id,output);};return handler;}
EditTrainingSimple.getXtrainingInstance=function(caller,viewer,callback)
{var handler=new EditTrainingSimple(caller,viewer,callback)
handler.makeCall=function(filter,dataHandler){this.caller.getEditXtraining(filter,dataHandler);};handler.addRecord=function(record,callback){this.caller.addXtraining(record,callback);};handler.setRecord=function(record,callback){this.caller.setXtraining(record,callback);};handler.deleteRecord=function(record,callback){this.caller.deleteXtraining(record.id,callback);};handler.handlePostLoad=function(criteria,output)
{var value=criteria.value.value;if(value.bikeId)
this.selectBike(value.bikeId,output);if(value.skiId)
this.selectSki(value.skiId,output);this.selectType(value.type,output);}
return handler;}
EditTrainingSimple.prototype.init=function(body){this.doAdd(body);};EditTrainingSimple.prototype.doAdd=function(body,when,userId,typeId){this.filter({isAdd:true,trainingDate:when,teammate:userId,typeId:typeId},body);}
EditTrainingSimple.prototype.doCopy=function(id,body){this.filter({id:id,isCopy:true},body);}
EditTrainingSimple.prototype.doEdit=function(id,body){this.filter({id:id,isEdit:true},body);}
EditTrainingSimple.prototype.doEditFuture=function(id,body){this.filter({futureId:id,isEdit:true},body);}
EditTrainingSimple.prototype.handleAddRoute=function(criteria,elem)
{elem=elem.mySelect;var form=elem.form,me=this,record=criteria.value.value;Linker.addRoute(function(value){elem.options[elem.options.length]=new Option(value.desc,value.id);elem.value=value.id;me.selectRoute(record,form,value);});}
EditTrainingSimple.prototype.handleAddWorkout=function(criteria,elem)
{elem=elem.mySelect;Linker.addWorkout(function(value){elem.options[elem.options.length]=new Option(value.desc,value.id);elem.value=value.id;});}
EditTrainingSimple.prototype.handleAddShoe=function(criteria,elem)
{elem=elem.mySelect;var form=elem.form,me=this,record=criteria.value.value;Linker.addShoe(function(item){me.caller.getShoe(item.id,{handleRequestData:function(value){elem.options[elem.options.length]=new Option(value.desc,value.id);elem.value=value.id;form.myShoeUsage.innerHTML=Formatter.concatEquipUsage(value);}});});}
EditTrainingSimple.prototype.handleAddBike=function(criteria,elem)
{elem=elem.mySelect;var form=elem.form,me=this,record=criteria.value.value;Linker.addBike(function(item){me.caller.getBike(item.id,{handleRequestData:function(value){elem.options[elem.options.length]=new Option(value.desc,value.id);elem.value=value.id;form.myBikeUsage.innerHTML=Formatter.concatEquipUsage(value);}});});}
EditTrainingSimple.prototype.handleAddSki=function(criteria,elem)
{elem=elem.mySelect;var form=elem.form,me=this,record=criteria.value.value;Linker.addSki(function(item){me.caller.getSki(item.id,{handleRequestData:function(value){elem.options[elem.options.length]=new Option(value.desc,value.id);elem.value=value.id;form.mySkiUsage.innerHTML=Formatter.concatEquipUsage(value);}});});}
EditTrainingSimple.prototype.handleChangeType=function(criteria,elem)
{var me=this;this.caller.getXtrainingType(elem.value,{handleRequestData:function(value){me.selectType(value,elem.form);}});}
EditTrainingSimple.prototype.handleChangeRoute=function(criteria,elem)
{if(0==elem.selectedIndex)
return;var form=elem.form,me=this,record=criteria.value.value;this.caller.getRoute(elem.value,{handleRequestData:function(value){me.selectRoute(record,form,value);}});}
EditTrainingSimple.prototype.selectType=function(record,form)
{ListingSimple.showRow(form.rowRoute,record.showDistanceInfo);ListingSimple.showRow(form.rowBike,record.showBikeInfo);ListingSimple.showRow(form.rowSki,record.showSkiInfo);ListingSimple.showRow(form.rowSwimStroke,record.showSwimStrokeInfo);ListingSimple.showRow(form.rowYogaStyle,record.showYogaInfo);ListingSimple.showRow(form.rowWattage,record.isMachine);ListingSimple.showRow(form.rowRpm,record.showRotationInfo);ListingSimple.showRow(form.rowCalories,record.isMachine);ListingSimple.showRow(form.rowDistanceMiles,record.showDistanceInfo);ListingSimple.showRow(form.rowDistanceKm,record.showDistanceInfo);ListingSimple.showRow(form.rowTemperature,record.showAirWeatherInfo);ListingSimple.showRow(form.rowWaterTemperature,!record.showAirWeatherInfo);ListingSimple.showRow(form.rowHumidity,record.showAirWeatherInfo);ListingSimple.showRow(form.rowPrecipitation,!record.isIndoor);ListingSimple.showRow(form.rowWind,!record.isIndoor);ListingSimple.showRow(form.rowSurfaceCondition,!record.isIndoor&&!record.showSnowInfo);ListingSimple.showRow(form.rowSnowCondition,record.showSnowInfo);ListingSimple.showRow(form.rowSteps,record.showSteps);ListingSimple.showRow(form.rowMartialArtType,record.showMartialArtInfo);ListingSimple.showRow(form.rowTechnique,record.showMartialArtInfo);ListingSimple.showRow(form.rowInstructor,record.showMartialArtInfo);}
EditTrainingSimple.prototype.selectRoute=function(record,form,value)
{form.distanceMiles.value=Formatter.toDisplayable(record.distanceMiles=value.distanceMiles);form.distanceKm.value=Formatter.toDisplayable(record.distanceKm=value.distanceKm);this.changePaceInfo(record,form);}
EditTrainingSimple.prototype.selectShoe=function(id,form)
{this.caller.getShoe(id,{handleRequestData:function(value)
{form.myShoeUsage.innerHTML=Formatter.concatEquipUsage(value);form.myShoeUsage.className=value.isExpired?'paceExpired':'pace';}});}
EditTrainingSimple.prototype.selectBike=function(id,form)
{this.caller.getBike(id,{handleRequestData:function(value)
{form.myBikeUsage.innerHTML=Formatter.concatEquipUsage(value);form.myBikeUsage.className=value.isExpired?'paceExpired':'pace';}});}
EditTrainingSimple.prototype.selectSki=function(id,form)
{this.caller.getSki(id,{handleRequestData:function(value)
{form.mySkiUsage.innerHTML=Formatter.concatEquipUsage(value);form.mySkiUsage.className=value.isExpired?'paceExpired':'pace';}});}
EditTrainingSimple.prototype.handleChangeEffortLevel=function(criteria,elem)
{if(0==elem.selectedIndex)
return;var form=elem.form,me=this;caller.getEffortLevel(elem.value,{handleRequestData:function(value){form.heartRateTargetMin.value=Formatter.toDisplayable(value.heartRateMin);form.heartRateTargetMax.value=Formatter.toDisplayable(value.heartRateMax);}});}
EditTrainingSimple.prototype.handleChangeShoe=function(criteria,elem)
{var form=elem.form;if(0==elem.selectedIndex)
{form.myShoeUsage.innerHTML='';return;}
this.selectShoe(elem.value,form);}
EditTrainingSimple.prototype.handleChangeBike=function(criteria,elem)
{var form=elem.form;if(0==elem.selectedIndex)
{form.myBikeUsage.innerHTML='';return;}
this.selectBike(elem.value,form);}
EditTrainingSimple.prototype.handleChangeSki=function(criteria,elem)
{var form=elem.form;if(0==elem.selectedIndex)
form.mySkiUsage.innerHTML='';else
this.selectSki(elem.value,form);}
EditTrainingSimple.prototype.handleChangeInfo=function(criteria,elem)
{var record=criteria.value.value;var value,form=elem.form;if(0==elem.value.length)
value=undefined;else if(undefined==(value=Formatter.parseFloat(elem.value)))
{window.alert('Must be numeric.');setTimeout(function(){elem.focus();},100);return;}
record[elem.name]=value;this.changePaceInfo(record,form);}
EditTrainingSimple.prototype.changePaceInfo=function(record,form)
{if(record.distanceMiles)
{form.myDistanceMiles.style.display='inline';form.milesToKm.innerHTML=Formatter.toDistance(Formatter.toKm(record.distanceMiles));form.myPaceMiles.innerHTML=Formatter.toPaceMiles(record);}
else
form.myDistanceMiles.style.display='none';if(record.distanceKm)
{form.myDistanceKm.style.display='inline';form.kmToMiles.innerHTML=Formatter.toDistance(Formatter.toMiles(record.distanceKm));form.myPaceKm.innerHTML=Formatter.toPaceKm(record);}
else
form.myDistanceKm.style.display='none';}
EditTrainingSimple.prototype.handleSubmit=function(criteria,form)
{var record=criteria.value.value;record.teammate=criteria.value.teammate;record.trainingDate=form.trainingDate.myDate;record.timeOfDayId=form.timeOfDay.value;record.routeId=form.route.value;record.effortLevelId=form.effortLevel.value;record.workoutId=form.workout.value;if(record.isRun)
record.shoeId=form.shoe.value;else
{record.typeId=form.typeId.value;record.bikeId=form.bikeId.value;record.skiId=form.skiId.value;record.swimStrokeId=form.swimStroke.value;record.yogaStyleId=form.yogaStyleId.value;record.wattageAvg=form.wattageAvg.value;record.wattageMax=form.wattageMax.value;record.rpmAvg=form.rpmAvg.value;record.rpmMax=form.rpmMax.value;record.waterTemperatureId=form.waterTemperatureId.value;record.snowConditionId=form.snowConditionId.value;record.steps=form.steps.value;record.martialArtTypeId=form.martialArtTypeId.value;record.technique=form.technique.value;record.instructor=form.instructor.value;}
record.distanceMiles=form.distanceMiles.value;record.distanceKm=form.distanceKm.value;record.durationHours=form.durationHours.value;record.durationMinutes=form.durationMinutes.value;record.durationSeconds=form.durationSeconds.value;record.calories=form.calories.value;record.heartRateAvg=form.heartRateAvg.value;record.heartRateMax=form.heartRateMax.value;record.heartRateTargetMin=form.heartRateTargetMin.value;record.heartRateTargetMax=form.heartRateTargetMax.value;record.temperatureId=form.temperatureId.value;record.temp=form.temp.value;record.tempUnitId=form.tempUnitId.value;record.humidityId=form.humidityId.value;record.humidity=form.humidity.value;record.precipitationId=form.precipitationId.value;record.windId=form.windId.value;record.wind=form.wind.value;record.windUnitId=form.windUnitId.value;record.surfaceConditionId=form.surfaceConditionId.value;record.comments=form.comments.value;var filter=criteria.filter;var callback=this.createUpdateCallback(criteria,form,record);if(!record.trainingDate)
{window.alert('Please provide a '+CAPTION_TRAINING_DATE+'.');form.trainingDate.focus();return;}
if(filter.isEdit&&record.isFuture)
filter.isCopy=(record.trainingDate.getTime()<(new Date()).getTime());record.isCopy=filter.isCopy;record.isContinue=form.saveAndAddSplits;if(filter.isAdd||filter.isCopy)
this.addRecord(record,callback);else
this.setRecord(record,callback);}
EditTrainingSimple.prototype.handleCancel=function(criteria,form){this.callback.handleCancel(criteria);}
EditTrainingSimple.prototype.handleDelete=function(criteria,record)
{var me=this;this.deleteRecord(record,{handleRequestData:function(value){me.callback.handleComplete(criteria);}});}

function EditUserSimple(caller,viewer,callback)
{this.caller=caller;this.viewer=viewer;this.callback=callback;this.trDisplayValue=ListingSimple.TR_DISPLAY_VALUE;}
EditUserSimple.prototype=new DetailSimple();EditUserSimple.prototype.register=function(body){this.filter({isRegister:true},body);}
EditUserSimple.prototype.doAdd=function(body){this.filter({isAdd:true},body);}
EditUserSimple.prototype.doCopy=function(body){this.filter({isCopy:true},body);}
EditUserSimple.prototype.doEdit=function(id,body){this.filter({isEdit:true,id:id},body);}
EditUserSimple.prototype.doMe=function(body){this.filter({isMe:true},body);}
EditUserSimple.prototype.makeCall=function(filter,dataHandler)
{if(filter.isMe)
this.caller.getEditMyProfile(dataHandler);else
this.caller.getEditUser(filter.id,dataHandler);}
EditUserSimple.prototype.handleCountryChange=function(criteria,elem)
{this.caller.getStates(elem.value,new RepopulateSelectList(elem.form.state));}
EditUserSimple.prototype.handleCancel=function(criteria,form)
{this.callback.handleCancel(criteria);}
EditUserSimple.prototype.openWeatherLocations=function(criteria,form)
{var user={};user.city=form.city.value;user.stateId=form.state.value;user.countryId=form.country.value;if(''==user.city)
{window.alert('Please supply a city.');form.city.focus();return;}
if(''==user.countryId)
{window.alert('Please select a country.');form.country.focus();return;}
var me=this;this.caller.getWeatherLocations(user,{handleRequestData:function(value){items=value.payload;form.myWeatherLocation.style.display='none';if(!items||(0==items.length))
window.alert('Sorry, we couldn\'t find a weather location for your city/country combination.');else if(1==items.length)
form.postalCode.value=items[0].id;else
{var e=form.weatherLocation;form.myWeatherLocation.style.display=me.trDisplayValue;SelectList.repopulate(e,{records:items},'Please Pick One');e.focus();}}});}
EditUserSimple.prototype.handleGenderChange=function(criteria,elem)
{if(this.showGenderInfo(elem))
elem.form.trackCycles.focus();}
EditUserSimple.prototype.showGenderInfo=function(elem)
{var b=(GENDER_FEMALE==elem.value);elem.form.myTrackCycles.style.display=(b?this.trDisplayValue:'none');return b;}
EditUserSimple.prototype.handleSubmit=function(criteria,form)
{var record=criteria.value.value;var password=form.password;if((0<password.value.length)&&(password.value!=form.confirmPassword.value))
{window.alert('Your password does not match the confirmation. Please try again.');password.focus();return false;}
record.emailAddress=form.emailAddress.value;record.password=password.value;record.firstName=form.firstName.value;record.middleInitial=form.middleInitial.value;record.lastName=form.lastName.value;record.city=form.city.value;record.stateId=form.state.value;record.countryId=form.country.value;record.postalCode=form.postalCode.value;record.genderId=form.gender.value;record.trackCycles=((GENDER_FEMALE==record.genderId)?form.trackCycles.checked:false);record.dateOfBirth=form.dateOfBirth.myDate;record.defaultTimeOfDayId=form.defaultTimeOfDay.value;record.defaultUnitTypeId=form.defaultUnitType.value;record.firstDayOfWeekId=form.firstDayOfWeek.value;record.shareJournal=form.shareJournal.checked;record.hasInstantWeather=form.hasInstantWeather.checked;record.biography=form.biography.value;var filter=criteria.filter;var callback=this.createUpdateCallback(criteria,form,record);if(filter.isRegister)
this.caller.registerUser(record,callback);else if(filter.isAdd||filter.isCopy)
this.caller.addUser(record,callback);else
this.caller.setUser(record,callback);}

function EditWeightLogSimple(caller,viewer,callback)
{this.caller=caller;this.viewer=viewer;this.callback=callback;}
EditWeightLogSimple.prototype=new DetailSimple();EditWeightLogSimple.prototype.confirmDelete=ListingSimple.prototype.confirmDelete;EditWeightLogSimple.prototype.doAdd=function(body,logDate){this.filter({isAdd:true,logDate:logDate},body);}
EditWeightLogSimple.prototype.doCopy=function(id,body){this.filter({isCopy:true,id:id},body);}
EditWeightLogSimple.prototype.doEdit=function(id,body){this.filter({isEdit:true,id:id},body);}
EditWeightLogSimple.prototype.makeCall=function(filter,dataHandler)
{this.caller.getEditWeightLog(filter,dataHandler);}
EditWeightLogSimple.prototype.handleSubmit=function(criteria,form)
{var record=criteria.value.value;record.logDate=form.logDate.myDate;record.weight=form.weight.value;record.weightUnitId=form.weightUnit.value;record.bodyFatPercent=form.bodyFatPercent.value;var filter=criteria.filter;var callback=this.createUpdateCallback(criteria,form,record);if(filter.isAdd||filter.isCopy)
this.caller.addWeightLog(record,callback);else
this.caller.setWeightLog(record,callback);}
EditWeightLogSimple.prototype.handleDelete=function(criteria,record)
{if(!this.confirmDelete())
return;var me=this;this.caller.deleteWeightLog(record.id,{handleRequestData:function(value){me.callback.handleComplete(criteria);}});}
EditWeightLogSimple.prototype.handleCancel=function(criteria)
{this.callback.handleCancel(criteria);}

function EditWorkoutSimple(caller,viewer,callback)
{this.caller=caller;this.viewer=viewer;this.callback=callback;}
EditWorkoutSimple.prototype=new DetailSimple();EditWorkoutSimple.prototype.doAdd=function(body){this.filter({isAdd:true},body);}
EditWorkoutSimple.prototype.doCopy=function(id,body)
{this.filter({id:id,isCopy:true},body);}
EditWorkoutSimple.prototype.doEdit=function(id,body)
{this.filter({id:id,isEdit:true},body);}
EditWorkoutSimple.prototype.makeCall=function(filter,dataHandler)
{this.caller.getEditWorkout(filter.id,dataHandler);}
EditWorkoutSimple.prototype.handleCancel=function(criteria){this.callback.handleCancel(criteria);}
EditWorkoutSimple.prototype.handleSubmit=function(criteria,form)
{var record=criteria.value.value;record.desc=form.desc.value;record.isFartlek=form.isFartlek.checked;record.isTrack=form.isTrack.checked;record.comments=form.comments.value;record.sharedTeamIds=MultiSelectList.retrieve(form.teams);var filter=criteria.filter;var callback=this.createUpdateCallback(criteria,form,record);record.isCopy=filter.isCopy;record.isContinue=form.saveAndAddRepeats;if(filter.isAdd||filter.isCopy)
this.caller.addWorkout(record,callback);else
this.caller.setWorkout(record,callback);}

function EmailBlogSimple(caller,viewer,callback)
{this.caller=caller;this.viewer=viewer;this.callback=callback;}
EmailBlogSimple.prototype=new DetailSimple();EmailBlogSimple.prototype.doById=function(id,body){this.filter(id,body);}
EmailBlogSimple.prototype.makeCall=function(filter,dataHandler)
{this.caller.getBlog(filter,dataHandler);}
EmailBlogSimple.prototype.handleSubmit=function(criteria,form)
{var value={id:criteria.value.id};var options=form.recipients.options;if(0==options.length)
{window.alert('Please provide one or more e-mail addresses before submitting.');form.email.focus();return;}
var a=value.emailAddresses=[];for(var i=0;i<options.length;i++)
a[i]=options[i].value;var me=this;this.caller.emailBlog(value,{handleRequestData:function(value){me.callback.handleComplete(criteria);},handleRequestError:function(error){window.alert(error.message?error.message:error);form.email.focus();}});}
EmailBlogSimple.prototype.handleCancel=function(criteria,form)
{this.callback.handleCancel(criteria);}

function InviteNewTeamMembersSimple(caller,viewer,callback)
{this.caller=caller;this.viewer=viewer;this.callback=callback;}
InviteNewTeamMembersSimple.prototype=new DetailSimple();InviteNewTeamMembersSimple.prototype.doParent=function(parentId,body){this.filter({teamId:parentId},body);}
InviteNewTeamMembersSimple.prototype.makeCall=function(filter,dataHandler)
{this.caller.getTeam(filter.teamId,dataHandler);}
InviteNewTeamMembersSimple.prototype.handleSubmit=function(criteria,form)
{var value={teamId:criteria.value.id};var options=form.newMembers.options;if(0==options.length)
{window.alert('Please provide new members before submitting.');form.email.focus();return;}
var a=value.newMembers=[];for(var i=0;i<options.length;i++)
a[i]=options[i].value;var me=this;this.caller.inviteNewMembers(value,{handleRequestData:function(value){me.callback.handleComplete(criteria);},handleRequestError:function(error){form.showActionButtons();window.alert(error.message?error.message:error);form.email.focus();}});}
InviteNewTeamMembersSimple.prototype.handleCancel=function(criteria,form)
{this.callback.handleCancel(criteria);}

function LeaderBoardSimple(caller,viewer,callback)
{this.caller=caller;this.viewer=viewer;this.callback=callback;}
LeaderBoardSimple.prototype=new ListingSimple();LeaderBoardSimple.prototype.init=function(body){this.filter({},body);}
LeaderBoardSimple.prototype.makeCall=function(filter,dataHandler)
{if(filter.byYear)
this.caller.leaderBoardByYear(filter,dataHandler);else if(filter.byMonth)
this.caller.leaderBoardByMonth(filter,dataHandler);else if(filter.byWeek)
this.caller.leaderBoardByWeek(filter,dataHandler);else
this.caller.leaderBoard(filter,dataHandler);}
LeaderBoardSimple.prototype.handleChangePeriod=function(criteria,elem)
{var filter=criteria.filter;if(filter.byWeek)
filter.week=elem.value;else
filter.month=elem.value;this.run(criteria);}
LeaderBoardSimple.prototype.handleChangeYear=function(criteria,newYear)
{criteria.filter.year=newYear;this.run(criteria);}
LeaderBoardSimple.prototype.handleChangeDistanceUnit=function(criteria,elem)
{criteria.filter.distanceUnitId=elem.value;this.run(criteria);}
LeaderBoardSimple.prototype.handleChangeType=function(criteria,elem)
{criteria.filter.trainingTypeId=elem.value;this.run(criteria);}
LeaderBoardSimple.prototype.toAll=function(criteria,elem)
{var filter=criteria.filter;filter.byAll=true;filter.byYear=filter.byMonth=filter.byWeek=false;this.run(criteria);}
LeaderBoardSimple.prototype.toYear=function(criteria,elem)
{var filter=criteria.filter;filter.byYear=true;filter.byAll=filter.byMonth=filter.byWeek=false;this.run(criteria);}
LeaderBoardSimple.prototype.toMonth=function(criteria,elem)
{var filter=criteria.filter;filter.byMonth=true;filter.byYear=filter.byAll=filter.byWeek=false;this.run(criteria);}
LeaderBoardSimple.prototype.toWeek=function(criteria,elem)
{var filter=criteria.filter;filter.byWeek=true;filter.byYear=filter.byMonth=filter.byAll=false;this.run(criteria);}

function ListBlogCommentsSimple(caller,viewer,pageSize,callback)
{this.caller=caller;this.viewer=viewer;this.pageSize=pageSize;this.callback=callback;}
ListBlogCommentsSimple.prototype=new ListingSimple();ListBlogCommentsSimple.prototype.doParent=function(parentId,body){this.filter({parentId:parentId},body);}
ListBlogCommentsSimple.prototype.makeCall=function(filter,dataHandler)
{this.caller.searchBlogComments(filter,dataHandler);}
ListBlogCommentsSimple.prototype.handleReply=function(criteria,record)
{this.callback.handleReply(criteria,record);}
ListBlogCommentsSimple.prototype.handleReportAbuse=function(criteria,record)
{this.callback.handleReportAbuse(criteria,record);}
ListBlogCommentsSimple.prototype.handleEdit=function(criteria,record)
{this.callback.handleEdit(criteria,record);}
ListBlogCommentsSimple.prototype.handleDelete=function(criteria,record)
{if(!this.confirmDelete(criteria.value))
return;var me=this;this.caller.deleteBlogComment(record.id,{handleRequestData:function(value){me.run(criteria);}});}
ListBlogCommentsSimple.prototype.handleSort=function(criteria,item)
{var filter=criteria.filter;filter.sortOn=item.sortOn;filter.sortDir=item.sortDir;this.run(criteria);}

function ListBlogsSimple(caller,viewer,pageSize,callback)
{this.caller=caller;this.viewer=viewer;this.pageSize=pageSize;this.callback=callback;}
ListBlogsSimple.prototype=new ListingSimple();ListBlogsSimple.prototype.init=function(body){this.filter({mine:true},body);}
ListBlogsSimple.prototype.makeCall=function(filter,dataHandler)
{this.caller.searchBlogs(filter,dataHandler);}
ListBlogsSimple.prototype.handleMore=function(criteria){this.callback.handleMore(criteria);}
ListBlogsSimple.prototype.handleSelect=function(criteria,record)
{this.callback.handleSelect(criteria,record);}
ListBlogsSimple.prototype.handleEdit=function(criteria,record)
{this.callback.handleEdit(criteria,record);}
ListBlogsSimple.prototype.handleDelete=function(criteria,record)
{if(!this.confirmDelete(criteria.value))
return;var me=this;this.caller.deleteBlog(record.id,{handleRequestData:function(value){me.run(criteria);}});}
ListBlogsSimple.prototype.handleSort=function(criteria,item)
{var filter=criteria.filter;filter.sortOn=item.sortOn;filter.sortDir=item.sortDir;this.run(criteria);}

function ListEffortLevelsSimple(caller,viewer,pageSize,callback)
{this.caller=caller;this.viewer=viewer;this.pageSize=pageSize;this.callback=callback;}
ListEffortLevelsSimple.prototype=new ListingSimple();ListEffortLevelsSimple.prototype.init=function(body){this.filter({},body);}
ListEffortLevelsSimple.prototype.makeCall=function(filter,dataHandler)
{this.caller.searchEffortLevels(dataHandler);}
ListEffortLevelsSimple.prototype.handleChange=function(criteria,elem,record)
{var me=this;record[elem.name]=elem.value;this.caller.setEffortLevel(record,{handleRequestData:function(value){me.flicker(elem);},handleRequestError:function(error){window.alert(error.message?error.message:error);elem.focus();}});}

function ListEquipmentSimple(caller,viewer,pageSize,callback)
{this.caller=caller;this.viewer=viewer;this.pageSize=pageSize;this.callback=callback;}
ListEquipmentSimple.getBikeInstance=function(caller,viewer,pageSize,callback)
{var handler=new ListEquipmentSimple(caller,viewer,pageSize,callback);handler.makeCall=function(filter,dataHandler){this.caller.searchBikes(dataHandler);};handler.deleteRecord=function(id,callback){this.caller.deleteBike(id,callback);};handler.setRecord=function(record,callback){this.caller.setBike(record,callback);};return handler;}
ListEquipmentSimple.getShoeInstance=function(caller,viewer,pageSize,callback)
{var handler=new ListEquipmentSimple(caller,viewer,pageSize,callback);handler.makeCall=function(filter,dataHandler){this.caller.searchShoes(dataHandler);};handler.deleteRecord=function(id,callback){this.caller.deleteShoe(id,callback);};handler.setRecord=function(record,callback){this.caller.setShoe(record,callback);};return handler;}
ListEquipmentSimple.getSkiInstance=function(caller,viewer,pageSize,callback)
{var handler=new ListEquipmentSimple(caller,viewer,pageSize,callback);handler.makeCall=function(filter,dataHandler){this.caller.searchSkis(dataHandler);};handler.deleteRecord=function(id,callback){this.caller.deleteSki(id,callback);};handler.setRecord=function(record,callback){this.caller.setSki(record,callback);};return handler;}
ListEquipmentSimple.prototype=new ListingSimple();ListEquipmentSimple.prototype.init=function(body){this.run({},body);}
ListEquipmentSimple.prototype.handleSelect=function(criteria,record){this.callback.handleSelect(criteria,record);}
ListEquipmentSimple.prototype.copyRecord=function(criteria,record){this.callback.copyRecord(criteria,record);}
ListEquipmentSimple.prototype.handleDelete=function(criteria,record)
{if(!this.confirmDelete(criteria.value))
return;var me=this;this.deleteRecord(record.id,{handleRequestData:function(value){me.run(criteria);}});}
ListEquipmentSimple.prototype.handleChange=function(criteria,elem)
{var me=this,record=elem.myRecord;this.setRecord(record,{handleRequestData:function(value){me.flicker(elem);},handleRequestError:function(error){window.alert(error.message?error.message:error);elem.focus();}});}

function ListRoutesSimple(caller,viewer,pageSize,callback)
{this.caller=caller;this.viewer=viewer;this.pageSize=pageSize;this.callback=callback;}
ListRoutesSimple.prototype=new ListingSimple();ListRoutesSimple.prototype.init=function(body){this.run({},body);}
ListRoutesSimple.prototype.makeCall=function(filter,dataHandler){this.caller.searchRoutes(dataHandler);}
ListRoutesSimple.prototype.handleSelect=function(criteria,record){this.callback.handleSelect(criteria,record);}
ListRoutesSimple.prototype.copyRecord=function(criteria,record){this.callback.copyRecord(criteria,record);}
ListRoutesSimple.prototype.deleteRecord=function(criteria,record)
{if(!this.confirmDelete(criteria.value))
return;var me=this;this.caller.deleteRoute(record.id,{handleRequestData:function(value){me.run(criteria);}});}

function ListTeamMembersSimple(caller,viewer,callback)
{this.caller=caller;this.viewer=viewer;this.callback=callback;}
ListTeamMembersSimple.prototype=new ListingSimple();ListTeamMembersSimple.prototype.doParent=function(parentId,body){this.filter({teamId:parentId},body);}
ListTeamMembersSimple.prototype.makeCall=function(filter,dataHandler)
{this.caller.searchTeamMembers(filter,dataHandler);}
ListTeamMembersSimple.prototype.handleChangeStatus=function(criteria,elem)
{criteria.filter.statusId=elem.value;this.run(criteria);}
ListTeamMembersSimple.prototype.handleDelete=function(criteria,elem)
{if(!this.confirmDelete())
return;var me=this;this.caller.deleteTeamMember(elem.myRecord.id,{handleRequestData:function(value){me.run(criteria);}});}
ListTeamMembersSimple.prototype.handleChangeType=function(criteria,elem)
{var me=this;this.caller.changeTeamMemberType(elem.myRecord.id,elem.value,{handleRequestData:function(value){me.flicker(elem);}});}

function ListTeamsSimple(caller,viewer,callback)
{this.caller=caller;this.viewer=viewer;this.callback=callback;}
ListTeamsSimple.prototype=new ListingSimple();ListTeamsSimple.prototype.init=function(body){this.run({myTeams:true},body);}
ListTeamsSimple.prototype.makeCall=function(filter,dataHandler)
{if(filter)
this.caller.searchTeams(filter,dataHandler);else
this.caller.listMyTeams(dataHandler);}
ListTeamsSimple.prototype.handleSelect=function(criteria,elem)
{var record=elem.myRecord;if(record.isOwner)
this.callback.editTeam(record.id);else
this.callback.viewTeam(record.id);}
ListTeamsSimple.prototype.handleMember=function(criteria,elem)
{this.callback.editTeamMember(elem.myRecord.memberId);}
ListTeamsSimple.prototype.handleRequest=function(criteria,elem)
{this.callback.requestToJoinTeam(elem.myRecord);}
ListTeamsSimple.prototype.handleInvite=function(criteria,elem)
{this.callback.inviteNewMembers(elem.myRecord.id);}
ListTeamsSimple.prototype.handleRsvp=function(criteria,elem)
{this.callback.viewTeamInvitation(elem.myRecord.id);}
ListTeamsSimple.prototype.handleEmail=function(criteria,elem)
{this.callback.sendTeamEmail(elem.myRecord.id);}
ListTeamsSimple.prototype.handleListMembers=function(criteria,elem)
{var record=elem.myRecord;if(record.isOwner)
this.callback.manageTeamMembers(record.id);else
this.callback.listTeamMembers(record.id);}
ListTeamsSimple.prototype.handleShareResources=function(criteria,elem)
{this.callback.shareTeamResources(elem.myRecord.id);}
ListTeamsSimple.prototype.handleMemberSummary=function(criteria,elem)
{this.callback.sumTeamTraining(elem.myRecord.id);}
ListTeamsSimple.prototype.handleCancelMembership=function(criteria,elem)
{var record=elem.myRecord;if(!window.confirm('Do you wish to cancel your membership to the '+record.name+'?'))
return;var me=this;this.caller.deleteTeamMember(record.memberId,{handleRequestData:function(status){me.run(criteria);},handleRequestError:function(status){window.alert(status.message?status.message:status);}});}

function ListTrainingDetailsSimple(caller,viewer,pageSize,callback)
{this.caller=caller;this.viewer=viewer;this.pageSize=pageSize;this.callback=callback;}
ListTrainingDetailsSimple.getRunInstance=function(caller,viewer,pageSize,callback)
{var handler=new ListTrainingDetailsSimple(caller,viewer,pageSize,callback);handler.decorator=new TrainingFutureDetailsDecorator(caller);handler.makeCall=function(filter,dataHandler){this.caller.getRunDetails(filter.parentId,dataHandler);};handler.setRecord=function(record,callback){this.caller.setRunDetail(record,callback);};handler.addRecord=function(record,callback){this.caller.addRunDetail(record,callback);};handler.deleteRecord=function(record,callback){this.caller.deleteRunDetail(record,callback);};handler.handlePostLoad=function(criteria,output){this.decorator.doByActual(criteria.filter.parentId,output);};return handler;}
ListTrainingDetailsSimple.getRunFutureInstance=function(caller,viewer,pageSize,callback)
{var handler=new ListTrainingDetailsSimple(caller,viewer,pageSize,callback);handler.makeCall=function(filter,dataHandler){this.caller.getRunFutureDetails(filter.parentId,undefined,dataHandler);};handler.setRecord=function(record,callback){this.caller.setRunFutureDetail(record,callback);};handler.addRecord=function(record,callback){this.caller.addRunFutureDetail(record,callback);};handler.deleteRecord=function(record,callback){this.caller.deleteRunFutureDetail(record,callback);};return handler;}
ListTrainingDetailsSimple.getWorkoutInstance=function(caller,viewer,pageSize,callback)
{var handler=new ListTrainingDetailsSimple(caller,viewer,pageSize,callback);handler.makeCall=function(filter,dataHandler){this.caller.getWorkoutDetails(filter.parentId,dataHandler);};handler.setRecord=function(record,callback){this.caller.setWorkoutDetail(record,callback);};handler.addRecord=function(record,callback){this.caller.addWorkoutDetail(record,callback);};handler.deleteRecord=function(record,callback){this.caller.deleteWorkoutDetail(record,callback);};return handler;}
ListTrainingDetailsSimple.getXtrainingInstance=function(caller,viewer,pageSize,callback)
{var handler=new ListTrainingDetailsSimple(caller,viewer,pageSize,callback);handler.makeCall=function(filter,dataHandler){this.caller.getXtrainingDetails(filter.parentId,dataHandler);};handler.setRecord=function(record,callback){this.caller.setXtrainingDetail(record,callback);};handler.addRecord=function(record,callback){this.caller.addXtrainingDetail(record,callback);};handler.deleteRecord=function(record,callback){this.caller.deleteXtrainingDetail(record,callback);};return handler;}
ListTrainingDetailsSimple.prototype=new ListingSimple();ListTrainingDetailsSimple.prototype.doParent=function(parentId,body)
{this.filter({parentId:parentId},body);}
ListTrainingDetailsSimple.prototype.handleUpdate=function(elem)
{var record=elem.myRecord;if(''==elem.value)
record[elem.name]=undefined;else
record[elem.name]=elem.value;var me=this;this.setRecord(record,{handleRequestData:function(value){me.flicker(elem);me.viewer.recalc(elem);},handleRequestError:function(error){window.alert(error.message?error.message:error);elem.focus();}});}
ListTrainingDetailsSimple.prototype.handleDelete=function(criteria,record)
{var me=this;this.deleteRecord(record,{handleRequestData:function(value){me.run(criteria);}});}
ListTrainingDetailsSimple.prototype.handleAdd=function(criteria,form)
{var filter=criteria.filter;var record={parentId:filter.parentId};record.distanceMiles=form.distanceMilesX.value;record.distanceKm=form.distanceKmX.value;record.durationHours=form.durationHoursX.value;record.durationMinutes=form.durationMinutesX.value;record.durationSeconds=form.durationSecondsX.value;record.heartRateAvg=form.heartRateAvgX.value;record.heartRateMax=form.heartRateMaxX.value;record.comments=form.commentsX.value;var me=this;this.addRecord(record,{handleRequestData:function(value){me.run(criteria);},handleRequestError:function(error){if(error.message)
{window.alert(error.message);if(error.field&&form[error.field+'X'])
form[error.field+'X'].focus();}
else
window.alert(error);}});}

function ListTrainingSimple(caller,viewer,pageSize,callback)
{this.caller=caller;this.viewer=viewer;this.pageSize=pageSize;this.callback=callback;}
ListTrainingSimple.prototype=new ListingSimple();ListTrainingSimple.prototype.init=function(body){this.doRecent(undefined,body);}
ListTrainingSimple.prototype.doRecent=function(userId,body)
{var fromDate=Formatter.today();fromDate.setMonth(fromDate.getMonth()-1);var filter={fromDate:fromDate};filter.currentUser=(undefined==userId);if(!filter.currentUser)
filter.userId=userId;filter.doingRecent=true;this.filter(filter,body);}
ListTrainingSimple.prototype.makeCall=function(filter,dataHandler)
{this.caller.searchTraining(filter,dataHandler);}
ListTrainingSimple.prototype.handleSelect=function(criteria,record){this.callback.handleSelect(criteria,record);}
ListTrainingSimple.prototype.handleCopy=function(criteria,record){this.callback.copyRecord(criteria,record);}
ListTrainingSimple.prototype.showDetails=function(criteria,record){this.callback.showDetails(criteria,record);}
ListTrainingSimple.prototype.handleDelete=function(criteria,record)
{if(!this.confirmDelete(criteria.value))
return;var me=this;var callback={handleRequestData:function(value){me.run(criteria);}};if(record.isRun)
this.caller.deleteRun(record.id,callback);else
this.caller.deleteXtraining(record.id,callback);}
ListTrainingSimple.prototype.toggle=function(criteria,elem)
{if(!elem.isExpanded&&!elem.isFilled)
{var form,me=this,cell=elem.myCell,record=elem.myRecord;this.callback.fillTrainingInfo(record,cell);cell.appendChild(document.createElement('br'));cell.appendChild(form=document.createElement('form'));form.appendChild(Inputter.genButton('closer','Close',function(ev){me.toggle(criteria,elem);}));elem.isFilled=true;}
this.setRowVisibility(elem.myRow,!elem.isExpanded);this.viewer.toggle(elem,elem.isExpanded);elem.isExpanded=!elem.isExpanded;}

function ListWorkoutsSimple(caller,viewer,pageSize,callback)
{this.caller=caller;this.viewer=viewer;this.pageSize=pageSize;this.callback=callback;}
ListWorkoutsSimple.prototype=new ListingSimple();ListWorkoutsSimple.prototype.init=function(body){this.run({},body);}
ListWorkoutsSimple.prototype.makeCall=function(filter,dataHandler){this.caller.searchWorkouts(dataHandler);}
ListWorkoutsSimple.prototype.handleSelect=function(criteria,record){this.callback.handleSelect(criteria,record);}
ListWorkoutsSimple.prototype.copyRecord=function(criteria,record){this.callback.copyRecord(criteria,record);}
ListWorkoutsSimple.prototype.showDetails=function(criteria,record){this.callback.showDetails(criteria,record);}
ListWorkoutsSimple.prototype.deleteRecord=function(criteria,record)
{if(!this.confirmDelete(criteria.value))
return;var me=this;this.caller.deleteWorkout(record.id,{handleRequestData:function(value){me.run(criteria);}});}

function MembershipInvitesSimple(caller,viewer,callback)
{this.caller=caller;this.viewer=viewer;this.callback=callback;}
MembershipInvitesSimple.prototype=new ListingSimple();MembershipInvitesSimple.prototype.init=function(body){this.filter({},body);}
MembershipInvitesSimple.prototype.doParent=function(parentId,body){this.filter({teamId:parentId},body);}
MembershipInvitesSimple.prototype.makeCall=function(filter,dataHandler)
{this.caller.getMembershipInvites(filter.teamId,dataHandler);}
MembershipInvitesSimple.prototype.restart=function(criteria,elem)
{var records=criteria.value.records;if(1==records.length)
{this.callback.handleCancel(criteria);return;}
records.splice(elem.myIndex,1);var body=criteria.body;body.removeChild(body.firstChild);body.appendChild(this.viewer.generate(criteria,this));}
MembershipInvitesSimple.prototype.handleAccept=function(criteria,elem)
{var me=this;this.caller.acceptTeamInvitation(elem.myRecord.id,{handleRequestData:function(value){me.restart(criteria,elem);}});}
MembershipInvitesSimple.prototype.handleDecline=function(criteria,elem)
{var me=this;this.caller.declineTeamInvitation(elem.myRecord.id,{handleRequestData:function(value){me.restart(criteria,elem);}});}
MembershipInvitesSimple.prototype.handleCancel=function(criteria,elem)
{this.callback.handleCancel(criteria);}

function MembershipRequestsSimple(caller,viewer,callback)
{this.caller=caller;this.viewer=viewer;this.callback=callback;}
MembershipRequestsSimple.prototype=new ListingSimple();MembershipRequestsSimple.prototype.init=function(body){this.run({},body);}
MembershipRequestsSimple.prototype.makeCall=function(filter,dataHandler)
{this.caller.getMembershipRequests(dataHandler);}
MembershipRequestsSimple.prototype.restart=function(criteria,elem)
{var records=criteria.value.records;if(1==records.length)
{this.callback.handleCancel(criteria);return;}
records.splice(elem.myIndex,1);var body=criteria.body;body.removeChild(body.firstChild);body.appendChild(this.viewer.generate(criteria,this));}
MembershipRequestsSimple.prototype.handleApprove=function(criteria,elem)
{var me=this;this.caller.approveRequestToJoinTeam(elem.myRecord.id,{handleRequestData:function(value){me.restart(criteria,elem);}});}
MembershipRequestsSimple.prototype.handleReject=function(criteria,elem)
{var me=this;this.caller.rejectRequestToJoinTeam(elem.myRecord.id,{handleRequestData:function(value){me.restart(criteria,elem);}});}
MembershipRequestsSimple.prototype.handleCancel=function(criteria,elem)
{this.callback.handleCancel(criteria);}

function SearchBlogsSimple(caller,viewer,callback)
{this.caller=caller;this.viewer=viewer;this.callback=callback;}
SearchBlogsSimple.prototype=new DetailSimple();SearchBlogsSimple.prototype.init=function(body){this.filter({},body);}
SearchBlogsSimple.prototype.makeCall=function(filter,dataHandler)
{this.caller.getSearchBlogs(filter,dataHandler);}
SearchBlogsSimple.prototype.handleCancel=function(criteria,form){this.callback.handleCancel(criteria);}
SearchBlogsSimple.prototype.handleSubmit=function(criteria,form)
{var filter={};filter.creatorId=form.author.value;filter.fromDate=form.fromDate.getDate();filter.toDate=form.toDate.getDate();filter.title=form.title.value;filter.contents=form.contents.value;if(form.statusId)
filter.statusId=form.statusId.value;this.callback.handleComplete(criteria,filter);}

function SearchCommunityTrainingSimple(caller,viewer,callback)
{this.caller=caller;this.viewer=viewer;this.callback=callback;}
SearchCommunityTrainingSimple.prototype=new DetailSimple();SearchCommunityTrainingSimple.prototype.init=function(body){this.filter({},body);}
SearchCommunityTrainingSimple.prototype.makeCall=function(filter,dataHandler)
{this.caller.getSearchCommunityTraining(filter,dataHandler);}
SearchCommunityTrainingSimple.prototype.handleChangeCountry=function(criteria,elem)
{if(0==elem.value.length)
return;this.caller.getStates(elem.value,new RepopulateSelectList(elem.form.state,CAPTION_NO_SEARCH));}
SearchCommunityTrainingSimple.prototype.handleCancel=function(criteria){this.callback.handleCancel(criteria);}
SearchCommunityTrainingSimple.prototype.handleSubmit=function(criteria,form)
{var filter={};filter.lastName=form.lastName.value;filter.typeId=form.typeId.value;filter.fromDate=form.fromDate.myDate;filter.toDate=form.toDate.myDate;filter.city=form.city.value;filter.stateId=form.state.value;filter.countryId=form.country.value;filter.fromMiles=form.fromMiles.value;filter.toMiles=form.toMiles.value;filter.fromKm=form.fromKm.value;filter.toKm=form.toKm.value;if(form.isRace.checked)
filter.isRace=true;else
filter.isRace=undefined;if(0==form.fromDate.value.length)
filter.fromDate=undefined;if(0==form.toDate.value.length)
filter.toDate=undefined;this.callback.handleComplete(criteria,filter);}

function SearchTeamsSimple(caller,viewer,callback)
{this.caller=caller;this.viewer=viewer;this.callback=callback;}
SearchTeamsSimple.prototype=new DetailSimple();SearchTeamsSimple.prototype.init=function(body){this.filter({},body);}
SearchTeamsSimple.prototype.makeCall=function(filter,dataHandler)
{this.caller.getSearchTeams(filter,dataHandler);}
SearchTeamsSimple.prototype.handleChangeCountry=function(criteria,elem)
{if(0==elem.value.length)
return;this.caller.getStates(elem.value,new RepopulateSelectList(elem.form.state,CAPTION_NO_SEARCH));}
SearchTeamsSimple.prototype.handleCancel=function(criteria){this.callback.handleCancel(criteria);}
SearchTeamsSimple.prototype.handleSubmit=function(criteria,form)
{var filter={};filter.name=form.teamName.value;filter.typeId=form.typeId.value;filter.city=form.city.value;filter.stateId=form.state.value;filter.countryId=form.country.value;this.callback.handleComplete(criteria,filter);}

function SearchTrainingSimple(caller,viewer,callback)
{this.caller=caller;this.viewer=viewer;this.callback=callback;}
SearchTrainingSimple.prototype=new DetailSimple();SearchTrainingSimple.prototype.init=function(body){this.filter({},body);}
SearchTrainingSimple.prototype.makeCall=function(filter,dataHandler)
{this.caller.getSearchTraining(filter,dataHandler);}
SearchTrainingSimple.prototype.handleChangeTeammate=function(criteria,elem)
{var form=elem.form;var userId=elem.value;this.caller.getRoutes(userId,new RepopulateSelectList(form.route,CAPTION_NO_SEARCH));this.caller.getEffortLevels(userId,new RepopulateSelectList(form.effortLevel,CAPTION_NO_SEARCH));this.caller.getWorkouts(userId,new RepopulateSelectList(form.workout,CAPTION_NO_SEARCH));}
SearchTrainingSimple.prototype.handleCancel=function(criteria){this.callback.handleCancel(criteria);}
SearchTrainingSimple.prototype.handleSubmit=function(criteria,form)
{var filter={};filter.typeId=form.typeId.value;if(form.teammate)
filter.teammate=form.teammate.value;filter.fromDate=form.fromDate.myDate;filter.toDate=form.toDate.myDate;filter.routeId=form.route.value;filter.effortLevelId=form.effortLevel.value;filter.workoutId=form.workout.value;filter.fromMiles=form.fromMiles.value;filter.toMiles=form.toMiles.value;filter.fromKm=form.fromKm.value;filter.toKm=form.toKm.value;filter.fromHeartRateAvg=form.fromHeartRateAvg.value;filter.toHeartRateAvg=form.toHeartRateAvg.value;if(form.isRace.checked)
filter.isRace=true;else
filter.isRace=undefined;filter.exportReportTypeId=(0<form.reportType.selectedIndex)?form.reportType.value:undefined;filter.currentUser=true;if(0==form.fromDate.value.length)
filter.fromDate=undefined;if(0==form.toDate.value.length)
filter.toDate=undefined;this.callback.handleComplete(criteria,filter);}

function SendTeamEmailSimple(caller,viewer,callback)
{this.caller=caller;this.viewer=viewer;this.callback=callback;}
SendTeamEmailSimple.prototype=new DetailSimple();SendTeamEmailSimple.prototype.doParent=function(parentId,body){this.filter({teamId:parentId},body);}
SendTeamEmailSimple.prototype.makeCall=function(filter,dataHandler)
{this.caller.getSendTeamEmail(filter.teamId,dataHandler);}
SendTeamEmailSimple.prototype.handleSubmit=function(criteria,form)
{var value={};value.teamId=criteria.value.value.id;value.types=MultiSelectList.retrieve(form.recipients);value.subject=form.subject.value;value.body=form.body.value;var me=this;this.caller.sendTeamEmail(value,this.createUpdateCallback(criteria,form,value));}
SendTeamEmailSimple.prototype.handleCancel=function(criteria,form){this.callback.handleCancel(criteria);}

function ShareTeamResourcesSimple(caller,viewer,callback)
{this.caller=caller;this.viewer=viewer;this.callback=callback;}
ShareTeamResourcesSimple.prototype=new DetailSimple();ShareTeamResourcesSimple.prototype.doParent=function(parentId,body){this.filter(parentId,body);}
ShareTeamResourcesSimple.prototype.makeCall=function(filter,dataHandler)
{this.caller.getTeamSharing(filter,dataHandler);}
ShareTeamResourcesSimple.prototype.handleSubmit=function(criteria,form)
{var value={};value.teamId=criteria.value.teamId;if(form.routes)
value.routeIds=MultiSelectList.retrieve(form.routes);if(form.workouts)
value.workoutIds=MultiSelectList.retrieve(form.workouts);this.caller.shareTeamResources(value,this.createUpdateCallback(criteria,form,value));}
ShareTeamResourcesSimple.prototype.handleCancel=function(criteria,form){this.callback.handleCancel(criteria);}

function SumTrainingSimple(caller,viewer,callback)
{this.caller=caller;this.viewer=viewer;this.callback=callback;}
SumTrainingSimple.prototype=new ListingSimple();SumTrainingSimple.prototype.init=function(body){this.byYear(body);}
SumTrainingSimple.prototype.byYear=function(body){this.filter({byYear:true},body);}
SumTrainingSimple.prototype.byMonth=function(body){this.filter({byMonth:true,year:(new Date()).getFullYear()},body);}
SumTrainingSimple.prototype.byWeek=function(body){this.filter({byWeek:true,year:(new Date()).getFullYear()},body);}
SumTrainingSimple.prototype.makeCall=function(filter,dataHandler)
{if(filter.byWeek)
this.caller.sumTrainingByWeek(filter,dataHandler);else if(filter.byMonth)
this.caller.sumTrainingByMonth(filter,dataHandler);else
this.caller.sumTrainingByYear(filter,dataHandler);}
SumTrainingSimple.prototype.toYear=function(criteria)
{var filter=criteria.filter;filter.byYear=true;filter.byMonth=filter.byWeek=false;this.run(criteria);}
SumTrainingSimple.prototype.toMonth=function(criteria)
{var filter=criteria.filter;filter.byMonth=true;filter.byYear=filter.byWeek=false;this.run(criteria);}
SumTrainingSimple.prototype.toWeek=function(criteria,elem)
{var filter=criteria.filter;filter.byWeek=true;filter.byYear=filter.byMonth=false;filter.year=elem.myInterval;this.run(criteria);}
SumTrainingSimple.prototype.handleChangeMonth=function(criteria,elem)
{criteria.filter.month=elem.value;this.run(criteria);}
SumTrainingSimple.prototype.handleChangeYear=function(criteria,elem)
{criteria.filter.year=elem.value;this.run(criteria);}
SumTrainingSimple.prototype.handleChangeType=function(criteria,elem)
{criteria.filter.trainingTypeId=elem.value;this.run(criteria);}
SumTrainingSimple.prototype.handleChangeDistanceUnit=function(criteria,elem)
{var v=elem.value;if(criteria.onlyDuration=('onlyDuration'==v))
this.doValue(criteria);else
{criteria.filter.distanceUnitId=v;this.run(criteria);}}
SumTrainingSimple.prototype.handleChangeTeammate=function(criteria,elem)
{criteria.filter.teammate=elem.value;this.run(criteria);}
SumTrainingSimple.prototype.handleChangeCrossTab=function(criteria,elem,id)
{var filter=criteria.filter;if(filter.byYear||filter.year)
{filter.year=undefined;filter.trainingTypeId=id;if(filter.byYear)
{filter.byYear=false;filter.byMonth=true;}}
else
{filter.trainingTypeId=undefined;filter.year=id;}
this.run(criteria);}
SumTrainingSimple.prototype.handleChangeInterval=function(criteria,elem)
{var filter=criteria.filter;if(filter.byYear)
{filter.byMonth=true;filter.byYear=false;filter.year=elem.myInterval;}
else
{filter.byWeek=true;filter.byMonth=false;filter.month=elem.myInterval;}
this.run(criteria);}

function TeamMemberSummarySimple(caller,viewer,callback)
{this.caller=caller;this.viewer=viewer;this.callback=callback;}
TeamMemberSummarySimple.prototype=new ListingSimple();TeamMemberSummarySimple.prototype.doParent=function(id,body){this.filter({teamId:id},body);}
TeamMemberSummarySimple.prototype.makeCall=function(filter,dataHandler)
{this.caller.sumTeamTraining(filter,dataHandler);}
TeamMemberSummarySimple.prototype.handleChangeInterval=function(criteria,elem)
{criteria.filter.interval=elem.value;this.run(criteria);}
TeamMemberSummarySimple.prototype.handleChangeYear=function(criteria,newYear)
{criteria.filter.year=newYear;this.run(criteria);}
TeamMemberSummarySimple.prototype.handleChangeDistanceUnit=function(criteria,elem)
{criteria.filter.distanceUnitId=elem.value;this.run(criteria);}

function TrainingChartSimple(caller,viewer,callback)
{this.caller=caller;this.viewer=viewer;this.callback=callback;}
TrainingChartSimple.prototype=new DetailSimple();TrainingChartSimple.prototype.init=function(body){this.filter({interval:CAPTION_MONTH},body);}
TrainingChartSimple.prototype.makeCall=function(filter,dataHandler)
{this.caller.getChartCriteria(filter,dataHandler);}
TrainingChartSimple.prototype.handleChangeTeammate=function(criteria,elem)
{var me=this;this.caller.getChartDatapoints(elem.value,{handleRequestData:function(value){me.loadDatapoints(value,elem.form);}});}
TrainingChartSimple.prototype.loadDatapoints=function(value,form)
{var elems=form.datapoints;for(var i=0;i<elems.length;i++)
{var firstEntry=(0<i)?CAPTION_NONE:undefined;SelectList.repopulate(elems[i],value,firstEntry);}
elems[0].selectedIndex=0;}
TrainingChartSimple.prototype.handleSubmit=function(criteria,form)
{var filter=criteria.filter;if(form.teammate)
filter.teammate=form.teammate.value;filter.fromDate=form.fromDate.getDate();filter.toDate=form.toDate.getDate();filter.interval=form.interval.value;filter.selections=[];var elems=form.datapoints;for(var i=0;i<elems.length;i++)
if(0<elems[i].value.length)
filter.selections[filter.selections.length]=elems[i].value;var me=this;this.caller.runChart(filter,{handleRequestData:function(value)
{criteria.form=form;form.style.display='none';criteria.response=value;if(criteria.chart)
{criteria.chart.image.src=value.payload;criteria.chart.style.display='block';}
else
criteria.output.appendChild(criteria.chart=me.viewer.genComplete(criteria,me));},handleRequestError:function(error)
{window.alert(error.message?error.message:error);elems[0].focus();}});}
TrainingChartSimple.prototype.handleCancel=function(criteria){this.callback.handleCancel(criteria);}
TrainingChartSimple.prototype.handleChangeSize=function(criteria,elem)
{var filter=criteria.filter;filter.size=elem.value;var me=this;this.caller.runChart(filter,{handleRequestData:function(value)
{criteria.chart.image.src=value.payload;}});}
TrainingChartSimple.prototype.handleBack=function(criteria)
{criteria.form.showActionButtons();criteria.chart.style.display='none';criteria.form.style.display='block';}

function TrainingTotalsSimple(caller,viewer)
{this.caller=caller;this.viewer=viewer;}
TrainingTotalsSimple.prototype=new DetailSimple();TrainingTotalsSimple.prototype.doNow=function(body,userId,typeId)
{this.filter(new TrainingTotalsFilter(userId,typeId,new Date()),body);}
TrainingTotalsSimple.prototype.makeCall=function(filter,dataHandler)
{this.caller.getTrainingTotals(filter,dataHandler);}
