var is_Safari=navigator.userAgent.indexOf('Safari');
var isMiles=1;
var isKm=2;
var isMeters=3;
var isYards=4;
function DisplayDateCategory()
{
var rdo=document.getElementsByName("optStartDate");
var lblStartDate;
var lblRaceDate;
lblStartDate=document.getElementById("divlblStartDate");
lblRaceDate=document.getElementById("divlblRaceDate");
lblStartDate.style.display="none";
lblRaceDate.style.display="none";
if(document.all)
{
if(rdo[1].checked)
{
lblStartDate.style.display="block";
}
if(rdo[2].checked)
{
lblRaceDate.style.display="block";
}
}
else
{
if(rdo[0].checked)
{
lblStartDate.style.display="block";
}
if(rdo[1].checked)
{
lblRaceDate.style.display="block";
}
}
}
function ResetAll()
{
document.getElementById('txtTrainingName').value="";
document.getElementById('txtTrainingDuration').value="";
document.getElementById('txtPrice').value="";
document.getElementById('txtTrainingDescription').value="";
return(false);
}
function ShowOtherActivity()
{
if(document.getElementById('ddlActivityType')!=null)
{
if(document.getElementById('ddlActivityType').value=="Other")
{
document.getElementById('divlblOtherActivity').style.display="block";
document.getElementById('divtxtOtherActivity').style.display="block";
}
else
{
document.getElementById('divlblOtherActivity').style.display="none";
document.getElementById('divtxtOtherActivity').style.display="none";
}
}
}
function ShowFixedDuration()
{
if(document.getElementById('chkDuration')!=null)
{
if(document.getElementById('chkDuration').checked==true)
{
document.getElementById('divlblStartDate').style.display="block";
document.getElementById('divtxtStartDate').style.display="block";
document.getElementById('divlblEndDate').style.display="block";
document.getElementById('divtxtEndDate').style.display="block";
document.getElementById('divlblPlanDuration').style.display="none";
document.getElementById('divtxtPlanDuration').style.display="none";
}
else
if(document.getElementById('chkDuration').checked==false)
{
document.getElementById('divlblStartDate').style.display="none";
document.getElementById('divtxtStartDate').style.display="none";
document.getElementById('divlblEndDate').style.display="none";
document.getElementById('divtxtEndDate').style.display="none";
document.getElementById('divlblPlanDuration').style.display="block";
document.getElementById('divtxtPlanDuration').style.display="block";
}
}
}
function ShowTermDesc(e,termDesc)
{
objX=(document.all)?document.documentElement.scrollLeft:window.pageXOffset;
objY=(document.all)?document.documentElement.scrollTop:window.pageYOffset;
objX=e.clientX+objX+10;
objY=e.clientY+objY-10;
objpopup=document.getElementById("divTermDesc");
if(objpopup!=null)
{
if(document.getElementById("lblTermDesc")!=null)
{
document.getElementById("lblTermDesc").innerHTML=termDesc;
}
if(document.getElementById("lblTermDescPopupTitle")!=null)
{
document.getElementById("lblTermDescPopupTitle").innerHTML="Term Description";
}
objpopup.style.left=objX+"px";
objpopup.style.top=objY+"px";
objpopup.style.display="block";
}
}
function HideTermDesc(e)
{
var objpopup;
objpopup=document.getElementById("divTermDesc");
if(objpopup!=null)
{
objpopup.style.display="none";
}
}
function MoveTermDescPopup(e)
{
var objpopup;
objX=(document.all)?document.documentElement.scrollLeft:window.pageXOffset;
objY=(document.all)?document.documentElement.scrollTop:window.pageYOffset;
objX=e.clientX+objX+10;
objY=e.clientY+objY-10;
objpopup=document.getElementById("divTermDesc");
objpopup.style.left=objX+"px";
objpopup.style.top=objY+"px";
if(objpopup!=null)
{
objpopup.style.display="block";
}
}
function DeleteActivityRecordConfirmation(RecordId,btnId)
{
document.getElementById("confirmBox_hidButtonId").value=btnId;
document.getElementById("hidRecordId").value=RecordId;
ShowConfirmBox('Are you sure you want to delete the selected activity record?');
return false;
}
function ValidateAddExcercise()
{
errors=" ";
mandatoryFieldsErrorFlag=false;
var status=ValidateAddExcerciseRoutines();
if(status==false)
{
var registrationErrorsDiv=document.getElementById("WarningMsgs3_RegistrationErrors");
registrationErrorsDiv.style.display="block";
document.getElementById("WarningMsgs3_divWarningInfo").style.display="block";
registrationErrorsDiv.innerHTML="";
registrationErrorsDiv.innerHTML=errors;
return false;
}
else
{
var registrationErrorsDiv=document.getElementById("WarningMsgs3_RegistrationErrors");
document.getElementById("WarningMsgs3_divWarningInfo").style.display="none";
registrationErrorsDiv.style.display="none";
return true;
}
}
function ValidateAddExcerciseRoutines()
{
var userControl="";
var status=true;
var tempWorkoutType=document.getElementById("ddlWorkoutType").value;
if(tempWorkoutType=="7")
{
var activity=document.getElementById("ddlExcerciseType").value;
if(activity=="Other")
{var varTemp=document.getElementById("txtOtherExcercise");
var alertName=" Other Excercise ";
var isMandatory='True';
if(bValidate(varTemp,"AlphaWithSpaceAnd",isMandatory,alertName)!=true)
{
varTemp.focus();
status=false;
return false;
}
}
var varTemp=document.getElementById(userControl+"txtExcerciseHr");
var alertName=" Hours ";
var isMandatory='false';
if(bValidate(varTemp,"Numeric",isMandatory,alertName)!=true)
{
varTemp.focus();
status=false;
return false;
}
if(varTemp.value>24)
{
errors+=alertName+" should be between 0 to 24."+'<br/>';
varTemp.focus();
status=false;
return false;
}
var varTemp=document.getElementById(userControl+"txtExcerciseMin");
var alertName=" Minutes ";
var isMandatory='false';
if(bValidate(varTemp,"Numeric",isMandatory,alertName)!=true)
{
varTemp.focus();
status=false;
return false;
}
if(varTemp.value>59)
{
errors+=alertName+" should be between 0 to 59."+'<br/>';
varTemp.focus();
status=false;
return false;
}
var varTemp=document.getElementById(userControl+"txtExcerciseSec");
var alertName=" Seconds ";
var isMandatory='false';
if(bValidate(varTemp,"Numeric",isMandatory,alertName)!=true)
{
varTemp.focus();
status=false;
return false;
}
if(varTemp.value>59)
{
errors+=alertName+" should be between 0 to 59."+'<br/>';
varTemp.focus();
status=false;
return false;
}
if((varTemp.value==24)&&((varTemp1.value>0)||(varTemp2.value>0)))
{
errors+=alertName+" cannot be more than 24 hours, Please enter again."+'<br/>';
varTemp.focus();
status=false;
return false;
}
var varTemp=document.getElementById("txtExerciseNoOfSets");
var alertName=" No. of sets ";
var isMandatory='false';
if(bValidate(varTemp,"Numeric",isMandatory,alertName)!=true)
{
varTemp.focus();
status=false;
return false;
}
if(varTemp.value>10)
{
errors+=alertName+" cannot be more than 10."+'<br/>';
varTemp.focus();
status=false;
return false;
}
if(varTemp.value<=10)
{
var strRepetitions=document.getElementById("hidGridRepetitions").value;
if(strRepetitions!="")
{
var arrRepetitions=strRepetitions.split(" ");
var iCount;
for(iCount=0;iCount<arrRepetitions.length;iCount++)
{
var strFloatExp="^(([0-9])+([\.]([0-9])*)?)$";
var status;
objRegExp=new RegExp(strFloatExp);
var varTemp=document.getElementById(arrRepetitions[iCount]);
var alertName=" Repetitions ";
if(varTemp!=null)
{
if(varTemp.value=="")
{
errors+='<li>'+alertName+" should not be empty."+'<br/></li>';
status=false;
break;
}
if(varTemp.value=="0")
{
errors+='<li>'+alertName+" should not be 0."+'<br/></li>';
status=false;
break;
}
if(objRegExp.test(varTemp.value)==false)
{
errors+='<li>'+alertName+" should be numeric."+'<br/></li>';
status=false;
break;
}
if(varTemp.value>100)
{
errors+='<li>'+alertName+" cannot be more than 100."+'<br/></li>';
status=false;
break;
}
}
}
}
var strWeight=document.getElementById("hidGridWeight").value;
if(strWeight!="")
{
var arrWeight=strWeight.split(" ");
var iCount;
for(iCount=0;iCount<arrWeight.length;iCount++)
{
var strFloatExp="^(([0-9])+([\.]([0-9])*)?)$";
var status;
objRegExp=new RegExp(strFloatExp);
var varTemp=document.getElementById(arrWeight[iCount]);
var alertName=" Weight ";
if(varTemp!=null)
{
if(varTemp.value=="")
{
errors+='<li>'+alertName+" should not be empty."+'<br/></li>';
status=false;
break;
}
if(objRegExp.test(varTemp.value)==false)
{
errors+='<li>'+alertName+" should be numeric."+'<br/></li>';
status=false;
break;
}
if(varTemp.value>1000)
{
errors+='<li>'+alertName+" cannot be more than 1000."+'<br/></li>';
status=false;
break;
}
}
}
}
}
}
return status;
}
function NoOfSetsChange()
{
errors=" ";
var varTemp=document.getElementById("txtExerciseNoOfSets");
var alertName=" No. of sets ";
if(varTemp.value>10)
{
errors+=alertName+" cannot be more than 10 "+'<br/>';
status=false;
var registrationErrorsDiv=document.getElementById("WarningMsgs3_RegistrationErrors");
document.getElementById("WarningMsgs3_divWarningInfo").style.display="block";
registrationErrorsDiv.style.display="block";
registrationErrorsDiv.innerHTML="";
registrationErrorsDiv.innerHTML=errors;
return false;
}
else
{
var registrationErrorsDiv=document.getElementById("WarningMsgs3_RegistrationErrors");
registrationErrorsDiv.style.display="none";
document.getElementById("WarningMsgs3_divWarningInfo").style.display="none";
return true;
}
}
function GridNoOfSetsChange()
{
var txtNoOfSets=document.getElementById("hidGridNoOfSets").value;
errors=" ";
var varTemp=document.getElementById(txtNoOfSets);
var alertName=" No. of sets ";
if(varTemp.value>10)
{
errors+=alertName+" cannot be more than 10 "+'<br/>';
status=false;
var registrationErrorsDiv=document.getElementById("WarningMsgs3_RegistrationErrors");
document.getElementById("WarningMsgs3_divWarningInfo").style.display="block";
registrationErrorsDiv.style.display="block";
registrationErrorsDiv.innerHTML="";
registrationErrorsDiv.innerHTML=errors;
return false;
}
else
{
var registrationErrorsDiv=document.getElementById("WarningMsgs3_RegistrationErrors");
registrationErrorsDiv.style.display="none";
document.getElementById("WarningMsgs3_divWarningInfo").style.display="none";
return true;
}
}
function RepetitionDataChange(strCtrlId)
{
var strFloatExp="^(([0-9])+([\.]([0-9])*)?)$";
var status;
objRegExp=new RegExp(strFloatExp);
errors="<ul>";
var varTemp=document.getElementById(strCtrlId);
var alertName=" Repetitions ";
if(varTemp.value!="")
{if(objRegExp.test(varTemp.value)==false)
{
errors+='<li>'+alertName+" should be numeric."+'<br/></li>';
status=false;
}
}
if(varTemp.value>100)
{
errors+='<li>'+alertName+" cannot be more than 100."+'<br/></li>';
status=false;
}
if(status==false)
{
var registrationErrorsDiv=document.getElementById("WarningMsgs3_RegistrationErrors");
document.getElementById("WarningMsgs3_divWarningInfo").style.display="block";
registrationErrorsDiv.style.display="block";
errors+='</ul>';
registrationErrorsDiv.innerHTML="";
registrationErrorsDiv.innerHTML=errors;
return false;
}
else
{
var registrationErrorsDiv=document.getElementById("WarningMsgs3_RegistrationErrors");
registrationErrorsDiv.style.display="none";
document.getElementById("WarningMsgs3_divWarningInfo").style.display="none";
return true;
}
}
function GridRepetitionDataChange(strCtrlId)
{
var status;
var strFloatExp="^(([0-9])+([\.]([0-9])*)?)$";
objRegExp=new RegExp(strFloatExp);
errors="<ul>";
var varTemp=document.getElementById(strCtrlId);
var alertName=" Repetitions ";
if(varTemp.value!="")
{
if(objRegExp.test(varTemp.value)==false)
{
errors+='<li>'+alertName+" should be numeric."+'<br/></li>';
status=false;
}
}
if(varTemp.value>100)
{
errors+='<li>'+alertName+" cannot be more than 100."+'<br/></li>';
status=false;
}
if(status==false)
{
var registrationErrorsDiv=document.getElementById("WarningMsgs3_RegistrationErrors");
document.getElementById("WarningMsgs3_divWarningInfo").style.display="block";
registrationErrorsDiv.style.display="block";
errors+='</ul>';
registrationErrorsDiv.innerHTML="";
registrationErrorsDiv.innerHTML=errors;
return false;
}
else
{
var registrationErrorsDiv=document.getElementById("WarningMsgs3_RegistrationErrors");
registrationErrorsDiv.style.display="none";
document.getElementById("WarningMsgs3_divWarningInfo").style.display="none";
return true;
}
}
function WeightDataChange(strCtrlId)
{
var status;
var strFloatExp="^(([0-9])+([\.]([0-9])*)?)$";
objRegExp=new RegExp(strFloatExp);
errors="<ul>";
var varTemp=document.getElementById(strCtrlId);
var alertName=" Weight ";
if(varTemp.value!="")
{
if(objRegExp.test(varTemp.value)==false)
{
errors+='<li>'+alertName+" should be numeric."+'<br/></li>';
status=false;
}
}
if(varTemp.value>1000)
{
errors+='<li>'+alertName+" cannot be more than 1000."+'<br/></li>';
status=false;
}
if(status==false)
{
var registrationErrorsDiv=document.getElementById("WarningMsgs3_RegistrationErrors");
document.getElementById("WarningMsgs3_divWarningInfo").style.display="block";
registrationErrorsDiv.style.display="block";
errors+='</ul>';
registrationErrorsDiv.innerHTML="";
registrationErrorsDiv.innerHTML=errors;
return false;
}
else
{
var registrationErrorsDiv=document.getElementById("WarningMsgs3_RegistrationErrors");
registrationErrorsDiv.style.display="none";
document.getElementById("WarningMsgs3_divWarningInfo").style.display="none";
return true;
}
}
function GridWeightDataChange(strCtrlId)
{
var status;
var strFloatExp="^(([0-9])+([\.]([0-9])*)?)$";
objRegExp=new RegExp(strFloatExp);
errors="<ul>";
var varTemp=document.getElementById(strCtrlId);
var alertName=" Weight ";
if(varTemp.value!="")
{
if(objRegExp.test(varTemp.value)==false)
{
errors+='<li>'+alertName+" should be numeric."+'<br/></li>';
status=false;
}
}
if(varTemp.value>1000)
{
errors+='<li>'+alertName+" cannot be more than 1000."+'<br/></li>';
status=false;
}
if(status==false)
{
var registrationErrorsDiv=document.getElementById("WarningMsgs3_RegistrationErrors");
document.getElementById("WarningMsgs3_divWarningInfo").style.display="block";
registrationErrorsDiv.style.display="block";
errors+='</ul>';
registrationErrorsDiv.innerHTML="";
registrationErrorsDiv.innerHTML=errors;
return false;
}
else
{
var registrationErrorsDiv=document.getElementById("WarningMsgs3_RegistrationErrors");
registrationErrorsDiv.style.display="none";
document.getElementById("WarningMsgs3_divWarningInfo").style.display="none";
return true;
}
}
function ValidateTrainingDates()
{
var _strMessage;
varTemp=document.getElementById("txtStartDate");
if(varTemp.value==""||varTemp.value==null)
{
_strMessage="Start Date should not be empty.";
document.getElementById('WarningMsgs_RegistrationErrors').style.display="block";
document.getElementById('WarningMsgs_RegistrationErrors').innerHTML=_strMessage;
document.getElementById("WarningMsgs_divWarningInfo").style.display="block";
return(false);
}
varTemp=document.getElementById("txtEndDate");
if(varTemp.value==""||varTemp.value==null)
{
_strMessage="End Date should not be empty";
document.getElementById('WarningMsgs_RegistrationErrors').style.display="block";
document.getElementById('WarningMsgs_RegistrationErrors').innerHTML=_strMessage;
document.getElementById("WarningMsgs_divWarningInfo").style.display="block";
return(false);
}
var startdate=new Date(document.getElementById("txtStartDate").value);
var enddate=new Date(document.getElementById("txtEndDate").value);
var DateDiff=enddate-startdate;
day=startdate.getDate();
month=startdate.getMonth()+1;
year=startdate.getFullYear();
startdate=month+"/"+day+"/"+year;
day=enddate.getDate();
month=enddate.getMonth()+1;
year=enddate.getFullYear();
enddate=month+"/"+day+"/"+year;
if(startdate==enddate)
{
}
else
if(DateDiff<0)
{
_strMessage="Start Date should not be greater than End Date";
document.getElementById('WarningMsgs_RegistrationErrors').style.display="block";
document.getElementById('WarningMsgs_RegistrationErrors').innerHTML=_strMessage;
document.getElementById("WarningMsgs_divWarningInfo").style.display="block";
return(false);
}
return(true);
}
function ValidateFields()
{
var _strMessage;
if(!ValidateTrainingName())
{
return(false);
}
if(document.getElementById('ddlActivityType').value=="Other")
{
if(document.getElementById('txtOtherActivity').value=="")
{
_strMessage="Other Activity Type should not be empty.";
document.getElementById('WarningMsgs_RegistrationErrors').style.display="block";
document.getElementById('WarningMsgs_RegistrationErrors').innerHTML=_strMessage;
document.getElementById("WarningMsgs_divWarningInfo").style.display="block";
return(false);
}
}
if(document.getElementById('chkDuration').checked==true)
{
if(!ValidateTrainingDates())
{
return(false);
}
}
else
{
if(!ValidateTrainingDuration())
{
return(false);
}
}
if(!ValidatePrice())
{
return(false);
}
if(document.getElementById("chkIsPasswordProtected").checked==1)
{
if(!ValidatePassword())
{
return(false);
}
}
if(!ValidateDescription())
{
return(false);
}
varTemp=document.getElementById("PhotoUpload");
alertName=" Logo Image ";
if(varTemp!=null&&varTemp!="")
{
varTemp=varTemp.value;
if(varTemp!=null&&varTemp!="")
{
var extension=varTemp.substring(varTemp.length-3);
var ValidImage=CheckImageFileType(varTemp);
if(!ValidImage)
{
document.getElementById('WarningMsgs_RegistrationErrors').style.display="block";
document.getElementById('WarningMsgs_RegistrationErrors').innerHTML='<ul><li>'+" Please Re-Enter "+alertName+'<br/></li></ul>';
document.getElementById("PhotoUpload").setfocus;
document.getElementById("WarningMsgs_divWarningInfo").style.display="block";
return(false);
}
}
}
}
function ValidateTrainingName()
{
var Name="Training Plan Name";
var Value=document.getElementById('txtTrainingName').value;
if(!(ValidateMandatory(Name,Value)&&ValidateLength(Name,Value,255)))
{
document.getElementById('txtTrainingName').setfocus;
return(false);
}
var sExp;
sExp="^[0-9a-z(),\.\/ & ';\:-]+$";
objRegExp=new RegExp(sExp,'gi');
if(objRegExp.test(Value.trim())==false)
{
document.getElementById('WarningMsgs_RegistrationErrors').style.display="block";
document.getElementById('WarningMsgs_RegistrationErrors').innerHTML="Training Plan Name should contain only letters, numbers, space, comma, colon, dot, semicolon, single quote, forward slash, hyphen and ampersand.";
document.getElementById("WarningMsgs_divWarningInfo").style.display="block";
document.getElementById('txtTrainingName').setfocus;
return false;
}
return(true);
}
function ValidateTrainingDuration()
{
var Name="Training Duration";
var Value=document.getElementById('txtTrainingDuration').value;
if(Value==0)
{
document.getElementById('WarningMsgs_RegistrationErrors').style.display="block";
document.getElementById('WarningMsgs_RegistrationErrors').innerHTML=Name+" cannot be blank.";
document.getElementById("WarningMsgs_divWarningInfo").style.display="block";
return(false);
}
if(!(ValidateMandatory(Name,Value)&&ValidateLength(Name,Value,4)&&ValidateNumericFormat(Name,Value)))
{
document.getElementById('txtTrainingDuration').setfocus;
return(false);
}
return(true);
}
function ValidatePrice()
{
var Name="Price";
var Value;
if(document.getElementById('txtPrice').value=="")
{
Value=0;
}
else
{
Value=document.getElementById('txtPrice').value;
}
if(!(ValidateLength(Name,Value,255)&&ValidateRealFormat(Name,Value)))
{
document.getElementById('txtPrice').setfocus;
return(false);
}
return(true);
}
function ValidateDescription()
{
var Name="Description";
var Value=document.getElementById('txtTrainingDescription').value;
if(!(ValidateMandatory(Name,Value)))
{
document.getElementById('txtTrainingDescription').setfocus;
return(false);
}
return(true);
}
function ValidatePlanPassword()
{
var Name="Password";
var Value=document.getElementById('txtPassword').value;
if(!(ValidateMandatory(Name,Value)))
{
document.getElementById('txtPassword').setfocus;
return(false);
}
return(true);
}
function ValidatePassword()
{
var Name="Password";
var Value=document.getElementById('txtPassword').value;
Value=trim(Value);
if(!(ValidateMandatory(Name,Value)&&ValidateLengthLimit(Name,Value,6)&&ValidatePasswordType(Name,Value)))
{
document.getElementById('txtPassword').setfocus;
return(false);
}
return(true);
}
function ValidateLength(vFldName,vFieldVal,vFieldSize)
{
if(vFieldVal.length>vFieldSize)
{
document.getElementById('WarningMsgs_RegistrationErrors').style.display="block";
document.getElementById('WarningMsgs_RegistrationErrors').innerHTML=vFldName+" cannot contain more than "+vFieldSize;
document.getElementById("WarningMsgs_divWarningInfo").style.display="block";
return(false);
}
else
{
return(true);
}
}
function ValidateLengthLimit(vFldName,vFieldVal,vFieldSize)
{
if(vFieldVal.length<vFieldSize)
{
document.getElementById('WarningMsgs_RegistrationErrors').style.display="block";
document.getElementById('WarningMsgs_RegistrationErrors').innerHTML=vFldName+" cannot be less than "+vFieldSize+" characters";
document.getElementById("WarningMsgs_divWarningInfo").style.display="block";
return(false);
}
else
{
return(true);
}
}
function ValidatePasswordType(vFldName,vFieldVal)
{
var objRegExp="^[^\ ]*$";
if(vFieldVal==0)
{
return(true);
}
else if(vFieldVal.match(objRegExp)==null)
{
document.getElementById('WarningMsgs_RegistrationErrors').style.display="block";
document.getElementById('WarningMsgs_RegistrationErrors').innerHTML=vFldName+" is in invalid format.";
document.getElementById("WarningMsgs_divWarningInfo").style.display="block";
return(false);
}
else
{
return(true);
}
}
function ValidateMandatory(vFldName,vFieldVal)
{
if(vFieldVal=='')
{
document.getElementById('WarningMsgs_RegistrationErrors').style.display="block";
document.getElementById('WarningMsgs_RegistrationErrors').innerHTML=vFldName+" cannot be empty.";
document.getElementById("WarningMsgs_divWarningInfo").style.display="block";
return(false);
}
else
{
return(true);
}
}
function ValidateRealFormat(vFldName,vFieldVal)
{
var objRegExp="^(([0-9])+([\.]([0-9][0-9]))?)$";
if(vFieldVal==0)
{
return(true);
}
else if(vFieldVal.match(objRegExp)==null)
{
document.getElementById('WarningMsgs_RegistrationErrors').style.display="block";
document.getElementById('WarningMsgs_RegistrationErrors').innerHTML=vFldName+" is in invalid format.";
document.getElementById("WarningMsgs_divWarningInfo").style.display="block";
return(false);
}
else
{
return(true);
}
}
function ValidateNumericFormat(vFldName,vFieldVal)
{
var sNumericExp="^[\\s]*[0-9]+[\\s]*$";
if(vFieldVal==0)
{
return(true);
}
else if(vFieldVal.match(sNumericExp)==null)
{
document.getElementById('WarningMsgs_RegistrationErrors').style.display="block";
document.getElementById('WarningMsgs_RegistrationErrors').innerHTML="Please enter valid "+vFldName+".";
document.getElementById("WarningMsgs_divWarningInfo").style.display="block";
return(false);
}
else
{
return(true);
}
}
function ValidateDatevalue(vFldName,vFieldVal)
{
var TodayDate=new Date();
var StartDate=new Date(vFieldVal);
if((StartDate.getDate()==TodayDate.getDate())&&(StartDate.getMonth()==TodayDate.getMonth())&&(StartDate.getFullYear()==TodayDate.getFullYear()))
{
return(true);
}
else
{
if(StartDate<TodayDate==true)
{
document.getElementById('WarningMsgs_RegistrationErrors').style.display="block";
document.getElementById('WarningMsgs_RegistrationErrors').innerHTML="Start/Race date cannot be prior to the current date.";
document.getElementById("WarningMsgs_divWarningInfo").style.display="block";
return(false);
}
else
{
return(true);
}
}
}
function ValidateGetPlan()
{
var objCtrl=document.getElementById('hidStartDate').value;
if(document.getElementById('hidFixedDuration')!=null)
{
if(document.getElementById('hidFixedDuration').value=="0")
{
if(!ValidateTrainingStartDate())
{
return(false);
}
}
}
if(objCtrl.indexOf("1/1/1900")>=0)
{if(!ValidateTrainingStartDate())
{
return(false);
}
}
if(!ValidateTrainingMessage())
{
return(false);
}
if(document.getElementById('hidIsPasswordProtected').value=="1")
{
if(!ValidatePlanPassword())
{
return(false);
}
}
if(document.getElementById("chkAcceptTerms")!=null)
{
if(document.getElementById("chkAcceptTerms").checked==false)
{
document.getElementById('WarningMsgs_RegistrationErrors').style.display="block";
document.getElementById('WarningMsgs_RegistrationErrors').innerHTML="Please accept the Terms Of Use to subscribe to this plan.";
document.getElementById("WarningMsgs_divWarningInfo").style.display="block";
document.getElementById("chkAcceptTerms").focus();
return false;
}
}
}
function ValidateCoachSubscribe()
{
var Name="Message";
var Value=document.getElementById('txtCoachSubscribeMessage').value;
if(!(ValidateMandatoryCoachSubscribe(Name,Value)))
{
document.getElementById('txtCoachSubscribeMessage').setfocus;
return(false);
}
return(true);
}
function ValidateMandatoryCoachSubscribe(vFldName,vFieldVal)
{
if(vFieldVal=='')
{
document.getElementById("WarningMsg1_divWarningInfo").style.display="block";
document.getElementById('WarningMsg1_RegistrationErrors').style.display="block";
document.getElementById('WarningMsg1_RegistrationErrors').innerHTML=vFldName+" cannot be empty.";
return(false);
}
else
{
return(true);
}
}
function ValidateTrainingStartDate()
{
var Name="Start / Race Date";
var Value=document.getElementById('txtTrainingStartDate').value;
if(!(ValidateMandatory(Name,Value)&&ValidateDatevalue(Name,Value)))
{
document.getElementById('txtTrainingStartDate').setfocus;
return(false);
}
return(true);
}
function ValidateTrainingMessage()
{
var Name="Message";
var Value=trim(document.getElementById('txtMessage').value);
document.getElementById('txtMessage').innerHTML=trim(document.getElementById('txtMessage').value);
if(!(ValidateMandatory(Name,Value)))
{
document.getElementById('txtMessage').focus();
return(false);
}
return(true);
}
function ValidateMessage()
{
var Name="Message";
var Value=document.getElementById('txtSubscribeMessage').value;
if(!(ValidateMessageMandatory(Name,Value)))
{
document.getElementById('txtMessage').setfocus;
return(false);
}
return(true);
}
function ValidateMessageMandatory(vFldName,vFieldVal)
{
if(vFieldVal=='')
{
if(document.getElementById('WarningMsgs_RegistrationErrors')!=null)
{
document.getElementById('WarningMsgs_RegistrationErrors').style.display="block";
document.getElementById('WarningMsgs_RegistrationErrors').innerHTML=vFldName+" cannot be empty.";
document.getElementById('WarningMsgs_divWarningInfo').style.display="block";
}
if(document.getElementById('WarningMsgs2_RegistrationErrors')!=null)
{
document.getElementById('WarningMsgs2_RegistrationErrors').style.display="block";
document.getElementById('WarningMsgs2_RegistrationErrors').innerHTML=vFldName+" cannot be empty.";
document.getElementById('WarningMsgs2_divWarningInfo').style.display="block";
}
return(false);
}
else
{
return(true);
}
}
function ValidateThresholdMessage()
{
var Name="Comment";
var Value=document.getElementById('txtComment').value;
if(!(ValidateMandatory(Name,Value)))
{
document.getElementById('txtComment').setfocus;
return(false);
}
return(true);
}
function DurationInSec(HourObj,MinuteObj,SecondObj)
{
var temp=null;
var hr1=HourObj.value;
var min1=MinuteObj.value;
var sec1=SecondObj.value;
var duration=0;
if((hr1=="NaN")||(hr1==""))
{
hr1=0;
}
if((min1=="NaN")||(min1==""))
{
min1=0;
}
if((sec1=="NaN")||(sec1==""))
{
sec1=0;
}
hr1=parseFloat(hr1);
duration=(hr1*3600)+(min1*60)+(sec1*1);
return(duration);
}
function convertPaceOnUnitType(pace,unitType,workout)
{
if(workout=="1"||workout=="11"||workout=="12")
{
if(unitType==isKm)
{
pace=parseFloat(pace*(3600/1000));
}
else
if(unitType==isMiles)
{
pace=parseFloat(pace*(3600/1609.344));
}
}
else
{
if(unitType==isKm)
{
pace=pace*1000;
}
else if(unitType==isMiles)
{
pace=pace*1609.344;
}
else if(unitType==isMeters)
{
pace=pace*1;
}
else if(unitType==isYards)
{
pace=pace*0.9144;
}
}
if((workout=="3")&&((unitType==isMeters)||(unitType==isYards)))
{
pace=pace*100;
}
return(parseFloat(pace));
}
function calculatePace(DistanceObj,UnitObj,WorkoutObj,duration,PaceObj)
{
var temp=null;
var dist=DistanceObj.value;
dist=parseFloat(dist);
var unitType=UnitObj.value;
var unitName=GetUnitName(unitType);
if(unitType==isKm)
{
dist=dist*1000;
}
else
if(unitType==isMiles)
{
dist=dist*1609.344;
}
else
if(unitType==isMeters)
{
dist=dist*1;
}
else
if(unitType==isYards)
{
dist=dist*0.9144;
}
var pace=0;
dist=parseFloat(dist);
pace=parseFloat(pace);
var sport=WorkoutObj.value;
var totalPace=0;
if(sport=="1"||sport=="11"||sport=="12")
{
if(dist!=0&&duration!=0)
{
pace=parseFloat(dist/duration);
pace=convertPaceOnUnitType(pace,unitType,sport);
if(pace.toString()=="NaN")
{
pace=0;
}
totalPace=parseFloat(Math.round(pace*100)/100);
}
else
{
pace=0;
totalPace=0;
}
if(PaceObj!=null)
{
PaceObj.value=totalPace+" "+unitName+"/hour";
}
}
else
{if(dist!=0&&duration!=0)
{
pace=parseFloat(duration/dist);
pace=convertPaceOnUnitType(pace,unitType,sport);
if(pace.toString()=="NaN")
{
pace=0;
}
var totalPace=parseFloat(Math.round(pace));
var hr=0;
var min=0;
var sec=0;
var strPace="";
hr=parseInt(totalPace/3600);
totalPace=totalPace%3600;
min=parseInt(totalPace/60);
totalPace=totalPace%60;
sec=parseInt(totalPace);
strPace=hr+":"+min+":"+sec;
}
else
{
pace=0;
strPace="0:0:0";
}
if(PaceObj!=null)
{
if((sport=="3")&&((unitType==isMeters)||(unitType==isYards)))
{
unitName="100 "+unitName;
}
PaceObj.value=strPace+" / "+unitName;
}
}
return true;
}
function GetUnitName(unitType)
{
var unitName="";
switch(parseInt(unitType))
{
case 1:unitName="miles";break;
case 2:unitName="km";break;
case 3:unitName="meters";break;
case 4:unitName="yards";break;
}
return(unitName);
}
function CalculatePaceValue()
{
if(document.getElementById('ddlWorkoutType').value!="7")
{
var HourObj=document.getElementById("txtHrDuration");
var MinuteObj=document.getElementById("txtMinDuration");
var SecondObj=document.getElementById("txtSecDuration");
var duration=DurationInSec(HourObj,MinuteObj,SecondObj);
var DistanceObj=document.getElementById("txtDistance");
var UnitObj=document.getElementById("ddlDistanceUnits");
var WorkoutObj=document.getElementById("ddlWorkoutType");
var PaceObj=document.getElementById("txtPace");
calculatePace(DistanceObj,UnitObj,WorkoutObj,duration,PaceObj);
}
return(true);
}
function GetTrainingPlan(PlanId,PlanName,CoachId,CoachName,Price,IsPasswordProtected,StartDate,PlanDuration)
{
if(document.getElementById('hidUserId').value==0)
{
ShowMessageBox("Please Login to the system to Get Plan.");
return(false);
}
else if(document.getElementById('hidUserId').value==CoachId)
{
ShowMessageBox("Coach cannot subscribe his own plan.");
return(false);
}
else
{
document.getElementById('hidStartDate').value=StartDate;
document.getElementById('hidPlanId').value=PlanId;
document.getElementById('hidPlanName').value=PlanName;
document.getElementById('hidCoachId').value=CoachId;
document.getElementById('hidCoachName').value=CoachName;
document.getElementById('hidPlanDuration').value=PlanDuration;
var btnObj=document.getElementById("btnCheckSubscription");
if((document.all)||(is_Safari>0))
{
btnObj.click();
}
else
{
var e=document.createEvent("MouseEvents");
e.initEvent("click",true,true);
btnObj.dispatchEvent(e);
}
document.getElementById('WarningMsgs_RegistrationErrors').style.display="none";
document.getElementById("WarningMsgs_divWarningInfo").style.display="none";
document.getElementById('hidIsPasswordProtected').value=IsPasswordProtected;
if(IsPasswordProtected=="1")
{
document.getElementById('divProtectPassword').style.display="block";
}
else
{
document.getElementById('divProtectPassword').style.display="none";
}
if(Price=="Free")
{
document.getElementById('hidPrice').value="1";
}
else
{
document.getElementById('hidPrice').value="0";
}
var valMessage=document.getElementById("lblPlanName");
valMessage.innerHTML=PlanName;
document.getElementById('divlblStartDate').style.display="none";
document.getElementById('divlblRaceDate').style.display="none";
document.getElementById('divtxtStartDate').style.display="none";
document.getElementById('divlblDate').style.display="none";
document.getElementById('divlblDateOption').style.display="none";
if(StartDate.indexOf("1/1/1900")>=0)
{
document.getElementById('divlblStartDate').style.display="block";
document.getElementById('divtxtStartDate').style.display="block";
document.getElementById('divlblDate').style.display="block";
document.getElementById('divlblDateOption').style.display="block";
var rdo=document.getElementsByName("optStartDate");
if(document.all)
{
rdo[1].checked=true;
}
else
{
rdo[0].checked=true;
}
}
else
{
}
document.getElementById('txtTrainingStartDate').value="";
document.getElementById('txtMessage').value="";
document.getElementById('txtPassword').value="";
document.getElementById('chkAcceptTerms').checked=false;
}
}
function GetPlan()
{
if(document.getElementById('hidUserId').value==0)
{
ShowMessageBox("Please Login to the system to Get Plan.");
return(false);
}
else if(document.getElementById('hidUserId').value==document.getElementById('hidCoachId').value)
{
ShowMessageBox("Coach cannot subscribe his own plan.");
return(false);
}
else
{
var btnObj=document.getElementById("btnCheckSubscription");
if((document.all)||(is_Safari>0))
{
btnObj.click();
}
else
{
var e=document.createEvent("MouseEvents");
e.initEvent("click",true,true);
btnObj.dispatchEvent(e);
}
var IsPasswordProtected=document.getElementById('hidIsPasswordProtected').value;
if(IsPasswordProtected=="1")
{
document.getElementById('divProtectPassword').style.display="block";
}
else
{
document.getElementById('divProtectPassword').style.display="none";
}
document.getElementById('WarningMsgs_RegistrationErrors').style.display="none";
document.getElementById("WarningMsgs_divWarningInfo").style.display="none";
document.getElementById('divlblStartDate').style.display="none";
document.getElementById('divlblRaceDate').style.display="none";
document.getElementById('divtxtStartDate').style.display="none";
document.getElementById('divlblDate').style.display="none";
document.getElementById('divlblDateOption').style.display="none";
if(document.getElementById('hidFixedDuration').value=="1")
{
}
else
{
document.getElementById('divlblStartDate').style.display="block";
document.getElementById('divtxtStartDate').style.display="block";
document.getElementById('divlblDate').style.display="block";
document.getElementById('divlblDateOption').style.display="block";
var rdo=document.getElementsByName("optStartDate");
if(document.all)
{
rdo[1].checked=true;
}
else
{
rdo[0].checked=true;
}
}
document.getElementById('txtTrainingStartDate').value="";
document.getElementById('txtMessage').value="";
document.getElementById('txtPassword').value="";
var PlanName=document.getElementById('hidPlanName').value;
var valMessage=document.getElementById("lblTrPlanName");
valMessage.innerHTML=PlanName;
document.getElementById('chkAcceptTerms').checked=false;
}
}
function GetCoachSubscribe()
{
if(document.getElementById('hidUserId').value==0)
{
ShowMessageBox("Please Login to the system to Get Coach Subscription.");
return(false);
}
else
{
if(document.getElementById('hidUserId').value==document.getElementById('hidCoachId').value)
{
ShowMessageBox("Coach cannot Subscribe himself.");
return(false);
}
else
{
document.getElementById('WarningMsgs_RegistrationErrors').style.display="none";
document.getElementById("WarningMsgs_divWarningInfo").style.display="none";
if(document.getElementById('WarningMsg1_RegistrationErrors')!=null)
{
document.getElementById('WarningMsg1_RegistrationErrors').style.display="none";
document.getElementById("WarningMsg1_divWarningInfo").style.display="none";
}
var CoachName=document.getElementById('hidCoachName').value;
var valMessage=document.getElementById("lblNameofCoach");
valMessage.innerHTML=CoachName;
document.getElementById('txtCoachSubscribeMessage').value="";
ShowModalPopup('divCoachSubscribe','Coach Subscription');
}
}
}
function ValidateImport()
{
var value=document.getElementById('WorkoutFileUpload').value;
if(value=="")
{
document.getElementById('WarningImportMsgs_RegistrationErrors').style.display="block";
document.getElementById('WarningImportMsgs_divWarningInfo').style.display="block";
document.getElementById('WarningImportMsgs_RegistrationErrors').innerHTML="Please select the file.";
return(false);
}
return(true);
}
function AddWorkType(PlanId,DayId)
{
var btnObj=document.getElementById("btnHidAddWorkout");
if((document.all)||(is_Safari>0))
{
btnObj.click();
}
else
{
var e=document.createEvent("MouseEvents");
e.initEvent("click",true,true);
btnObj.dispatchEvent(e);
}
SetVisibleControlForWorkoutType();
var arrobj;
document.getElementById('hidDayValue').value=DayId;
document.getElementById('hidPlanId').value=PlanId;
document.getElementById('hidWorkTypeValue').value=0;
ResetPlanPreview();
if(document.getElementById("divBrickUI")!=null)
{
document.getElementById("divBrickUI").style.display="none";
}
if(document.getElementById("divExcerciseUI")!=null)
{
arrobj=document.getElementById("divExcerciseUI");
arrobj.style.display="none";
}
if(document.getElementById("divWorkoutUI")!=null)
{
document.getElementById("divWorkoutUI").style.display="block";
}
ShowModalPopup('divWorkoutPreview','Workout Preview');
document.getElementById("ddlWorkoutType").style.display="inline";
document.getElementById("ddlDistanceUnits").style.display="inline";
document.getElementById("ddlWorkoutType").value="1";
if(document.getElementById("ddlExcerciseType")!=null)
{
arrobj=document.getElementById("ddlExcerciseType");
arrobj.style.display="inline";
}
if(document.getElementById("ddlActivityName")!=null)
{
document.getElementById("ddlActivityName").style.display="inline";
}
if(document.getElementById("ddlActivityUnit")!=null)
{
document.getElementById("ddlActivityUnit").style.display="inline";
}
return false;
}
function GetWeeklyDetails(WeekId)
{
document.getElementById('hidWeekId').value=WeekId;
ShowModalPopup('divweeklyPreview','Weekly workout details');
}
function AcceptPlanConfirmation(RecordId,btnId)
{
document.getElementById("confirmBox_hidButtonId").value=btnId;
document.getElementById("hidRecordId").value=RecordId;
ShowConfirmBox('Do you want to accept the plan subscription?');
return false;
}
function AcceptPlanSuccess()
{
document.getElementById('WarningMsgs_RegistrationErrors').style.display="none";
document.getElementById("WarningMsgs_divWarningInfo").style.display="none";
var valPlanName=document.getElementById("lblTrPlanName");
valPlanName.innerHTML=document.getElementById('hidPlanName').value;
document.getElementById('txtMessage').value="";
ShowModalPopup('divSubscribe','Training Plan Subscription');
}
function AcceptPlanFail()
{
document.getElementById('hidPlanId').value="";
document.getElementById('hidPlanName').value="";
document.getElementById('hidStartDate').value="";
document.getElementById('hidUserId').value="";
document.getElementById('hidPlanSubscribeId').value="";
}
function AcceptPlan(PlanSubscribeId,PlanId,PlanName,StartDate,UserId,Priceval)
{
var result=false;
if(Priceval=="0")
{
result=true;
}
else
{
document.getElementById('hidPlanId').value=PlanId;
document.getElementById('hidPlanName').value=PlanName;
document.getElementById('hidStartDate').value=StartDate;
document.getElementById('hidUserId').value=UserId;
document.getElementById('hidPlanSubscribeId').value=PlanSubscribeId;
AcceptPlanConfirmation('JSOperation','AcceptPlanSuccess');
}
if(result==true)
{
document.getElementById('WarningMsgs_RegistrationErrors').style.display="none";
document.getElementById("WarningMsgs_divWarningInfo").style.display="none";
document.getElementById('hidPlanId').value=PlanId;
document.getElementById('hidPlanName').value=PlanName;
document.getElementById('hidStartDate').value=StartDate;
document.getElementById('hidUserId').value=UserId;
var valPlanName=document.getElementById("lblTrPlanName");
valPlanName.innerHTML=PlanName;
document.getElementById('txtMessage').value="";
document.getElementById('hidPlanSubscribeId').value=PlanSubscribeId;
ShowModalPopup('divSubscribe','Training Plan Subscription');
}
}
function DenyPlanConfirmation(RecordId,btnId)
{
document.getElementById("confirmBox_hidButtonId").value=btnId;
document.getElementById('hidPlanSubscribeId').value=RecordId;
ShowConfirmBox('Do you want to deny the plan subscription?');
return false;
}
function DenyPlan(PlanSubscribeId)
{
DenyPlanConfirmation(PlanSubscribeId,'btnhiddenDenyplan');
return false;
}
function UnsubscribePlanConfirmation(RecordId,btnId)
{
document.getElementById("confirmBox_hidButtonId").value=btnId;
document.getElementById('hidPlanSubscribeId').value=RecordId;
ShowConfirmBox('Do you want to unsubscribe the plan?');
return false;
}
function UnsubscribePlan(PlanSubscribeId)
{
UnsubscribePlanConfirmation(PlanSubscribeId,'btnhiddenDeleteplan');
return false;
}
function UnsubscribeFreePlanConfirmation(RecordId,btnId)
{
document.getElementById("confirmBox_hidButtonId").value=btnId;
document.getElementById('hidPlanSubscribeId').value=RecordId;
ShowConfirmBox('Do you want to unsubscribe the plan?');
return false;
}
function UnsubscribeFreePlan(PlanSubscribeId)
{
UnsubscribeFreePlanConfirmation(PlanSubscribeId,'btnhiddenDeleteFreeplan');
return false;
}
function AcceptCoachConfirmation(RecordId,btnId)
{
document.getElementById("confirmBox_hidButtonId").value=btnId;
document.getElementById("hidRecordId").value=RecordId;
ShowConfirmBox('Do you want to accept the subscription?');
return false;
}
function AcceptCoachSuccess()
{
ShowModalPopup('divUserSubscribe','User Subscription');
}
function AcceptCoachFail()
{
document.getElementById('hidCoachSubscribeId').value="";
document.getElementById('hidUserSubscribeId').value="";
document.getElementById('hidUserName').value="";
}
function AcceptCoach(CoachSubscribeId,UserId,UserName)
{
document.getElementById('hidCoachSubscribeId').value=CoachSubscribeId;
document.getElementById('hidUserSubscribeId').value=UserId;
document.getElementById('hidUserName').value=UserName;
AcceptCoachConfirmation('JSOperation','AcceptCoachSuccess');
}
function DenyCoachConfirmation(RecordId,btnId)
{
document.getElementById("confirmBox_hidButtonId").value=btnId;
document.getElementById("hidCoachSubscribeId").value=RecordId;
ShowConfirmBox('Do you want to deny the Coach Subscription?');
return false;
}
function DenyCoach(CoachSubscribeId)
{
DenyCoachConfirmation(CoachSubscribeId,'btnHiddenDenyCoach');
return false;
}
function GetThreshold(SubscribeId,CoachName,TotalPlanSold,TotalUserSubscribe,CoachId)
{
document.getElementById('WarningMsgs_RegistrationErrors').style.display="none";
document.getElementById("WarningMsgs_divWarningInfo").style.display="none";
document.getElementById('hidCoachId').value=CoachId;
document.getElementById('hidCoachName').value=CoachName;
document.getElementById('hidSubscribeId').value=SubscribeId;
document.getElementById('hidTotalPlansold').value=TotalPlanSold;
document.getElementById('hidTotalUserSubscribe').value=TotalUserSubscribe;
document.getElementById('txtUserSubscribeLimit').value="";
document.getElementById('txtPlanAmountLimit').value="";
document.getElementById('txtComment').value="";
var valCoachName=document.getElementById("lblCoachName");
valCoachName.innerHTML=CoachName;
var btnObj=document.getElementById("btnHiddenEditThresholdLimit");
if(btnObj!=null&&btnObj!="")
{
if((document.all)||(is_Safari>0))
{
btnObj.click();
}
else
{
var e=document.createEvent("MouseEvents");
e.initEvent("click",true,true);
btnObj.dispatchEvent(e);
}
}
ShowModalPopup('divSubscriptionLimit','Coach Subscription Threshold');
}
function ResetPlanPreview()
{
document.getElementById('txtDistance').value="";
document.getElementById('txtHrDuration').value="";
document.getElementById('txtMinDuration').value="";
document.getElementById('txtSecDuration').value="";
document.getElementById('txtPace').value="";
document.getElementById('txtWorkoutInstructions').value="";
document.getElementById('txtNotes').value="";
if(document.getElementById("txtActivityDistance")!=null)
{
document.getElementById("txtActivityDistance").value="";
}
if(document.getElementById("txtActivityHr")!=null)
{
document.getElementById("txtActivityHr").value="";
}
if(document.getElementById("txtActivityMin")!=null)
{
document.getElementById("txtActivityMin").value="";
}
if(document.getElementById("txtActivitySec")!=null)
{
document.getElementById("txtActivitySec").value="";
}
if(document.getElementById("txtActivityPace")!=null)
{
document.getElementById("txtActivityPace").value="";
}
if(document.getElementById("lblTotalActivityDistance")!=null)
{
document.getElementById("lblTotalActivityDistance").innerHTML="";
}
if(document.getElementById("lblTotalActivityDuration")!=null)
{
document.getElementById("lblTotalActivityDuration").innerHTML="";
}
if(document.getElementById("lblAvgActivityPace")!=null)
{
document.getElementById("lblAvgActivityPace").innerHTML="";
}
if(document.getElementById("ddlActivityName")!=null)
{
document.getElementById("ddlActivityName").value="1";
}
if(document.getElementById("ddlActivityUnit")!=null)
{
document.getElementById("ddlActivityUnit").value="1";
}
if(document.getElementById("lblCycleActivityDistance")!=null)
{
document.getElementById("lblCycleActivityDistance").innerHTML="";
}
if(document.getElementById("lblCycleActivityDuration")!=null)
{
document.getElementById("lblCycleActivityDuration").innerHTML="";
}
if(document.getElementById("lblCycleActivityPace")!=null)
{
document.getElementById("lblCycleActivityPace").innerHTML="";
}
}
function EditWorkType(WorkTypeId,DayId)
{
if(document.getElementById('hidWorkTypeValue')!=null)
{
document.getElementById('hidWorkTypeValue').value=WorkTypeId;
document.getElementById('hidDayValue').value=DayId;
ResetPlanPreview();
var btnObj=document.getElementById("btnHiddenEditWorkType");
if(btnObj!=null&&btnObj!="")
{
if((document.all)||(is_Safari>0))
{
btnObj.click();
}
else
{
var e=document.createEvent("MouseEvents");
e.initEvent("click",true,true);
btnObj.dispatchEvent(e);
}
}
ShowModalPopup('divWorkoutPreview','Workout Preview');
document.getElementById("ddlWorkoutType").style.display="inline";
document.getElementById("ddlDistanceUnits").style.display="inline";
SetVisibleControlForWorkoutType();
}
return(true);
}
function DeleteWorkTypeConfirmation(RecordId,btnId)
{
document.getElementById("confirmBox_hidButtonId").value=btnId;
document.getElementById("hidWorkTypeValue").value=RecordId;
ShowConfirmBox('Do you want to delete the workout?');
return false;
}
function DeleteWorkType(WorkTypeId,DayId)
{
document.getElementById('hidDayValue').value=DayId;
DeleteWorkTypeConfirmation(WorkTypeId,'btnHiddenDeleteWorkType');
}
function DispWorkTypeDetails(WorkTypeId,DayId)
{
document.getElementById('hidWorkTypeValue').value=WorkTypeId;
document.getElementById('hidDayValue').value=DayId;
document.getElementById('lblWorloutType').innerHTML="";
document.getElementById('lblInstructions').innerHTML="";
document.getElementById('lblNotes').innerHTML="";
document.getElementById('divExcerciseUI').style.display="none";
document.getElementById('divBrickUI').style.display="none";
document.getElementById('divWorkoutUI').style.display="none";
var btnObj=document.getElementById("btnHiddenEditWorkType");
if(btnObj!=null&&btnObj!="")
{
if((document.all)||(is_Safari>0))
{
btnObj.click();
}
else
{
var e=document.createEvent("MouseEvents");
e.initEvent("click",true,true);
btnObj.dispatchEvent(e);
}
}
ShowModalPopup('divWorkoutPreview','Workout Details');
return(true);
}
function ImportWorkout()
{
document.getElementById('dwindowimportworkouttype').style.display="block";
}
function CancelImport()
{
document.getElementById('dwindowimportworkouttype').style.display="none";
return(false);
}
function CloseImport()
{
document.getElementById('dwindowimportworkouttype').style.display="none";
return(true);
}
function ValidateWorkTypePreview()
{
document.getElementById('WarningMsgs3_RegistrationErrors').style.display="none";
document.getElementById("WarningMsgs3_divWarningInfo").style.display="none";
var tempWorkoutType=document.getElementById("ddlWorkoutType").value;
if(tempWorkoutType=="Other")
{
if(document.getElementById("txtOtherWorkoutType")!=null)
{
if(document.getElementById("txtOtherWorkoutType").value=="")
{
document.getElementById('WarningMsgs3_RegistrationErrors').style.display="block";
document.getElementById("WarningMsgs3_divWarningInfo").style.display="block";
document.getElementById('WarningMsgs3_RegistrationErrors').innerHTML="Please enter all the mandatory fields.";
document.getElementById("txtOtherWorkoutType").setfocus;
return(false);
}
}
}
if((tempWorkoutType!="7")&&(tempWorkoutType!="8"))
{
if(!ValidateDistance())
{
return(false);
}
}
if((tempWorkoutType!="8")&&(tempWorkoutType!="7"))
{
if(!ValidateHrDuration())
{
return(false);
}
if(!ValidateMinDuration())
{
return(false);
}
if(!ValidateSecDuration())
{
return(false);
}
}
var WorkTypeValue=document.getElementById('hidWorkTypeValue').value;
var objdivDay=document.getElementById('divDay');
}
function ValidateDistance()
{
var Name="Distance";
var Value=document.getElementById('txtDistance').value;
if(!(ValidateWorkoutLength(Name,Value,4)&&ValidateWorkoutRealFormat(Name,Value)))
{
document.getElementById('txtDistance').setfocus;
return(false);
}
return(true);
}
function ValidateHrDuration()
{
var Name="Hour Duration";
var Value;
if(document.getElementById('txtHrDuration').value=="")
{
Value=0;
}
else
{
Value=document.getElementById('txtHrDuration').value;
}
if(!(ValidateWorkoutLength(Name,Value,4)&&ValidateWorkoutNumericFormat(Name,Value)))
{
document.getElementById('txtHrDuration').setfocus;
return(false);
}
return(true);
}
function ValidateMinDuration()
{
var Name="Minute Duration";
var Value;
if(document.getElementById('txtMinDuration').value=="")
{
Value=0;
}
else
{
Value=document.getElementById('txtMinDuration').value;
}
if(!(ValidateWorkoutLength(Name,Value,4)&&ValidateWorkoutNumericFormat(Name,Value)))
{
document.getElementById('txtMinDuration').setfocus;
return(false);
}
return(true);
}
function ValidateSecDuration()
{
var Name="Sec Duration";
var Value;
if(document.getElementById('txtSecDuration').value=="")
{
Value=0;
}
else
{
Value=document.getElementById('txtSecDuration').value;
}
if(!(ValidateWorkoutLength(Name,Value,4)&&ValidateWorkoutNumericFormat(Name,Value)))
{
document.getElementById('txtSecDuration').setfocus;
return(false);
}
return(true);
}
function ValidateDuration()
{
var HrValue=document.getElementById('txtHrDuration').value;
var MinVale=document.getElementById('txtMinDuration').value;
var SecValue=document.getElementById('txtSecDuration').value;
if((HrValue==""||HrValue=="0")&&(MinVale==""||MinVale=="0")&&(SecValue==""||SecValue=="0"))
{
document.getElementById('WarningMsgs3_RegistrationErrors').style.display="block";
document.getElementById('WarningMsgs3_RegistrationErrors').innerHTML="Duration cannot be empty.";
document.getElementById("WarningMsgs3_divWarningInfo").style.display="block";
return(false);
}
return(true);
}
function ValidatePace()
{
var Name="Pace";
var Value=document.getElementById('txtPace').value;
if(!(ValidateWorkoutLength(Name,Value,8)))
{
document.getElementById('txtPace').setfocus;
return(false);
}
return(true);
}
function ValidateWorkoutMandatory(vFldName,vFieldVal)
{
if(vFieldVal=='')
{
document.getElementById('WarningMsgs3_RegistrationErrors').style.display="block";
document.getElementById('WarningMsgs3_RegistrationErrors').innerHTML=vFldName+" cannot be empty.";
document.getElementById("WarningMsgs3_divWarningInfo").style.display="block";
return(false);
}
else
{
return(true);
}
}
function ValidateWorkoutLength(vFldName,vFieldVal,vFieldSize)
{
if(vFieldVal.length>vFieldSize)
{
document.getElementById('WarningMsgs3_RegistrationErrors').style.display="block";
document.getElementById('WarningMsgs3_RegistrationErrors').innerHTML=vFldName+" cannot contain more than "+vFieldSize;
document.getElementById("WarningMsgs3_divWarningInfo").style.display="block";
return(false);
}
else
{
return(true);
}
}
function ValidateWorkoutNumericFormat(vFldName,vFieldVal)
{
var sNumericExp="^[\\s]*[0-9]+[\\s]*$";
if(vFieldVal==0)
{
return(true);
}
else if(vFieldVal.match(sNumericExp)==null)
{
document.getElementById('WarningMsgs3_RegistrationErrors').style.display="block";
document.getElementById('WarningMsgs3_RegistrationErrors').innerHTML=vFldName+" is in invalid format.";
document.getElementById("WarningMsgs3_divWarningInfo").style.display="block";
return(false);
}
else
{
return(true);
}
}
function ValidateWorkoutRealFormat(vFldName,vFieldVal)
{
var objRegExp=/(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/;
if(vFieldVal==0)
{
return(true);
}
else if(vFieldVal.match(objRegExp)==null)
{
document.getElementById('WarningMsgs3_RegistrationErrors').style.display="block";
document.getElementById('WarningMsgs3_RegistrationErrors').innerHTML=vFldName+" is in invalid format.";
document.getElementById("WarningMsgs3_divWarningInfo").style.display="block";
return(false);
}
else
{
return(true);
}
}
function ValidateInstructions()
{
var Name="Workout Instructions";
var Value=document.getElementById('txtWorkoutInstructions').value;
if(!(ValidateMandatory(Name,Value)))
{
document.getElementById('txtWorkoutInstructions').setfocus;
return(false);
}
return(true);
}
function ValidateNotes()
{
var Name="Notes";
var Value=document.getElementById('txtNotes').value;
if(!(ValidateMandatory(Name,Value)))
{
document.getElementById('txtNotes').setfocus;
return(false);
}
return(true);
}
function ExcerciseTypeChange()
{
var excercise=document.getElementById("ddlExcerciseType").value;
if(excercise=="Other")
{
if(document.getElementById("divlblOtherExcercise")!=null)
{
document.getElementById("divlblOtherExcercise").style.display="block";
}
if(document.getElementById("divtxtOtherExcercise")!=null)
{
document.getElementById("divtxtOtherExcercise").style.display="block";
}
}
else
{
if(document.getElementById("divlblOtherExcercise")!=null)
{
document.getElementById("divlblOtherExcercise").style.display="none";
}
if(document.getElementById("divtxtOtherExcercise")!=null)
{
document.getElementById("divtxtOtherExcercise").style.display="none";
}
}
}
function GridExcerciseTypeChange()
{
var txtExcerciseType=document.getElementById("hidGridExcerciseType").value;
SetVisibleControlForExcercise();
}
function SetVisibleControlForExcercise()
{
var txtExcerciseType=document.getElementById("hidGridExcerciseType").value;
var lblOtherExcercise=document.getElementById("hidGridlblOtherExcercise").value;
var txtOtherExcercise=document.getElementById("hidGridtxtOtherExcercise").value;
if(document.getElementById(txtExcerciseType).value=="Other")
{
document.getElementById(lblOtherExcercise).style.display="block";
document.getElementById(txtOtherExcercise).style.display="block";
}
else
{
document.getElementById(lblOtherExcercise).style.display="none";
document.getElementById(txtOtherExcercise).style.display="none";
}
}
function loadUPEventHandler()
{
var prm=Sys.WebForms.PageRequestManager.getInstance();
prm.add_endRequest(UPEndRequestHandler);
}
function UPEndRequestHandler(sender,args)
{
var err=args.get_error();
if(err)
{
if(err.name=="Sys.WebForms.PageRequestManagerServerErrorException")
{
args.set_errorHandled(true);
}
if(err.name=="Sys.WebForms.PageRequestManagerParserErrorException")
{
e.set_errorHandled(true);
}
}
var UserMessage=null;
var EditMessage=null;
UserMessage=document.getElementById("hidUserMessage");
if(UserMessage!=null&&UserMessage!="")
{
var UserMessageVal=UserMessage.value;
}
switch(UserMessageVal)
{
case"WorkoutDDLChanged":
UserMessage.value="";
CalculatePaceValue();
SetVisibleControlForWorkoutType();
break;
case"PlanBackSuccess":
UserMessage.value="";
CheckPassword();
ShowFixedDuration();
ShowOtherActivity();
break;
case"ddlSportsChanged":
UserMessage.value="";
ShowFixedDuration();
ShowOtherActivity();
break;
case"AddTermSuccessful":
UserMessage.value="";
closepopup('pnlAddTerm');
var msg="Congratulations! Term saved successfully";
ShowMessageBox(msg);
break;
case"DeleteExcerciseSuccess":
UserMessage.value="";
if(document.getElementById("divlblOtherExcercise")!=null)
{
document.getElementById("divlblOtherExcercise").style.display="none";
}
if(document.getElementById("divtxtOtherExcercise")!=null)
{
document.getElementById("divtxtOtherExcercise").style.display="none";
}
break;
case"ExcerciseEditSaved":
UserMessage.value="";
if(document.getElementById("divlblOtherExcercise")!=null)
{
document.getElementById("divlblOtherExcercise").style.display="none";
}
if(document.getElementById("divtxtOtherExcercise")!=null)
{
document.getElementById("divtxtOtherExcercise").style.display="none";
}
break;
case"AddExcerciseSuccess":
UserMessage.value="";
if(document.getElementById("divlblOtherExcercise")!=null)
{
document.getElementById("divlblOtherExcercise").style.display="none";
}
if(document.getElementById("divtxtOtherExcercise")!=null)
{
document.getElementById("divtxtOtherExcercise").style.display="none";
}
break;
case"ExcerciseEdited":
UserMessage.value="";
SetVisibleControlForExcercise();
break;
case"ShowAddWorkout":
UserMessage.value="";
if(document.getElementById("divlblOtherExcercise")!=null)
{
document.getElementById("divlblOtherExcercise").style.display="none";
}
if(document.getElementById("divtxtOtherExcercise")!=null)
{
document.getElementById("divtxtOtherExcercise").style.display="none";
}
break;
case"ActivityEdited":
UserMessage.value="";
SetVisibleControlForActivity();
UserMessage.value="";
break;
case"WorkoutAddedSuccessfully":
closepopup();
var msg="Congratulations! Workout saved successfully.";
ShowMessageBox(msg);
UserMessage.value="";
break;
case"ErrorAddWorkout":
alert("Error occurred while adding the Workout. Please try again.");
UserMessage.value="";
break;
case"EditWorkoutSuccessfully":
ShowModalPopup('divWorkoutPreview','Workout Preview');
if(document.getElementById("divlblOtherExcercise")!=null)
{
document.getElementById("divlblOtherExcercise").style.display="none";
}
if(document.getElementById("divtxtOtherExcercise")!=null)
{
document.getElementById("divtxtOtherExcercise").style.display="none";
}
SetVisibleControlForWorkoutType();
document.getElementById("ddlWorkoutType").style.display="inline";
document.getElementById("ddlDistanceUnits").style.display="inline";
if(document.getElementById("ddlActivityName")!=null)
{
document.getElementById("ddlActivityName").style.display="inline";
}
document.getElementById("ddlExcerciseType").style.display="inline";
document.getElementById("ddlActivityUnit").style.display="inline";
CalculatePaceValue();
UserMessage.value="";
break;
case"ErrorEditWorkout":
alert("Error occurred while editing the Workout. Please try again.");
UserMessage.value="";
break;
case"PlanSubscribeAddedSuccessfully":
closepopup('divSubscribe');
var msg="Plan subscription is successful.";
ShowMessageBox(msg);
break;
case"PlanSubscribeAddedSuccessfullyTwitted":
closepopup('divSubscribe');
var msg="Congratulations! Plan subscribed successfully and shared with twitter.";
ShowMessageBox(msg);
break;
case"PlanUnsubscribeDone":
var msg="Plan is successfully unsubscribed.";
ShowMessageBox(msg);
UserMessage.value="";
break;
case"ErrorPlanSubscribe":
alert("Error occurred while adding the Workout. Please try again.");
UserMessage.value="";
break;
case"DispWorkoutSuccessfully":
document.getElementById("divWorkoutUI").style.display="none";
document.getElementById("divBrickUI").style.display="none";
document.getElementById("divExcerciseUI").style.display="none";
if(document.getElementById("lblWorloutType").innerHTML=="Brick")
{
document.getElementById("divBrickUI").style.display="block";
}
else
if(document.getElementById("lblWorloutType").innerHTML=="Weight Training")
{
document.getElementById("divExcerciseUI").style.display="block";
}
else
{
document.getElementById("divWorkoutUI").style.display="block";
}
ShowModalPopup('divWorkoutPreview','Workout Details');
UserMessage.value="";
break;
case"ErrorDispWorkout":
alert("Error occurred while editing the New Workout. Please try again.");
UserMessage.value="";
break;
case"CoachSubscribeAddedSuccessfully":
closepopup('divCoachSubscribe');
var msg="Coach subscription is successful.";
ShowMessageBox(msg);
UserMessage.value="";
break;
case"ErrorCoachSubscribe":
alert("Error occurred while subscribing the coach. Please try again.");
UserMessage.value="";
break;
case"PlanAcceptSuccessfully":
closepopup();
var msg="Congratulations! Plan has been successfully accepted.";
ShowMessageBox(msg);
UserMessage.value="";
break;
case"ErrorPlanAccept":
alert("Error occurred while Plan Subscription. Please try again.");
UserMessage.value="";
break;
case"UserSubscribeSuccessfully":
closepopup();
var msg="User subscription is successful.";
ShowMessageBox(msg);
UserMessage.value="";
break;
case"ErrorUserSubscribe":
alert("Error occurred while Plan Subscription. Please try again.");
UserMessage.value="";
break;
case"CoachAlreadySubscribe":
closepopup();
var msg="You have already subscribe for this coach.";
ShowMessageBox(msg);
UserMessage.value="";
break;
case"PlanAlreadySubscribe":
closepopup();
var msg="You have already subscribe for this Plan.";
ShowMessageBox(msg);
UserMessage.value="";
break;
case"CoachSubscribehisPlan":
closepopup();
var msg="You have tried to subscribe your own plan.";
ShowMessageBox(msg);
UserMessage.value="";
break;
case"EditThresholdDetailsSuccessfully":
ShowModalPopup('divSubscriptionLimit','Coach Subscription Threshold');
UserMessage.value="";
break;
case"EditThresholdError":
closepopup();
alert("Error occurred while editing Threshold details. Please try again.");
UserMessage.value="";
break;
case"ThresholdUpdatedSuccessfully":
closepopup();
var msg="Threshold subscription details are updated successfully.";
ShowMessageBox(msg);
UserMessage.value="";
break;
case"ErrorThresholdUpdate":
closepopup();
alert("Error occurred while updating the Threshold Limit. Please try again.");
UserMessage.value="";
break;
case"LessThresholdLimit":
closepopup();
var msg="Threshold limit is less than actual value.";
ShowMessageBox(msg);
UserMessage.value="";
break;
case"ExceedThresholdLimit":
closepopup();
ShowMessageBox("Exceed Than Threshold Limit.");
UserMessage.value="";
break;
case"ValidatePassword":
closepopup('divCheckPassword');
ShowModalPopup('divSubscribe','Get Training Plan');
UserMessage.value="";
break;
case"IncorrectPassword":
DisplayMessage();
UserMessage.value="";
break;
case"CheckPassword":
DisplayPasswordMessage();
UserMessage.value="";
break;
case"DisplayPassword":
CheckPassword();
UserMessage.value="";
break;
case"CheckUserSubscription":
UserMessage.value="";
if(document.getElementById("hidSubscriptionMsg").value=="TRUE")
{
ShowMessageBox("User has already subscribe for this plan.");
return;
}
else
{
ShowModalPopup('divSubscribe','Get Training Plan');
}
break;
case"PlanSaveSuccess":
UserMessage.value="";
var msg="Congratulations! Your plan has been successfully created.";
ShowMessageBox(msg);
break;
default:
return;
}
}
function SetVisibleControlForWorkoutType()
{
var sport=document.getElementById("ddlWorkoutType").value;
var e=document.getElementById("ddlDistanceUnits");
var unitType=e.options[e.selectedIndex].text;
if(sport=="7")
{
var arrobj;
if(document.getElementById("divlblDistance")!=null)
{
arrobj=document.getElementById("divlblDistance");
arrobj.style.display="none";
}
if(document.getElementById("divtxtDistance")!=null)
{
arrobj=document.getElementById("divtxtDistance");
arrobj.style.display="none";
}
if(document.getElementById("divlblPace")!=null)
{
arrobj=document.getElementById("divlblPace");
arrobj.style.display="none";
}
if(document.getElementById("divtxtPace")!=null)
{
arrobj=document.getElementById("divtxtPace");
arrobj.style.display="none";
}
if(document.getElementById("divlblOtherWorkoutType")!=null)
{
arrobj=document.getElementById("divlblOtherWorkoutType");
arrobj.style.display="none";
}
if(document.getElementById("divtxtOtherWorkoutType")!=null)
{
arrobj=document.getElementById("divtxtOtherWorkoutType");
arrobj.style.display="none";
}
if(document.getElementById("divBrickUI")!=null)
{
document.getElementById("divBrickUI").style.display="none";
}
if(document.getElementById("divExcerciseUI")!=null)
{
arrobj=document.getElementById("divExcerciseUI");
arrobj.style.display="block";
}
if(document.getElementById("divWorkoutUI")!=null)
{
document.getElementById("divWorkoutUI").style.display="none";
}
}
else
if(sport=="8")
{
if(document.getElementById("divBrickUI")!=null)
{
document.getElementById("divBrickUI").style.display="block";
}
if(document.getElementById("divExcerciseUI")!=null)
{
arrobj=document.getElementById("divExcerciseUI");
arrobj.style.display="none";
}
if(document.getElementById("divWorkoutUI")!=null)
{
document.getElementById("divWorkoutUI").style.display="none";
}
if(document.getElementById("divlblOtherWorkoutType")!=null)
{
arrobj=document.getElementById("divlblOtherWorkoutType");
arrobj.style.display="none";
}
if(document.getElementById("divtxtOtherWorkoutType")!=null)
{
arrobj=document.getElementById("divtxtOtherWorkoutType");
arrobj.style.display="none";
}
}
else
if(sport=="Other")
{
var arrobj;
if(document.getElementById("divlblDistance")!=null)
{
arrobj=document.getElementById("divlblDistance");
arrobj.style.display="block";
}
if(document.getElementById("divtxtDistance")!=null)
{
arrobj=document.getElementById("divtxtDistance");
arrobj.style.display="block";
}
if(document.getElementById("divlblPace")!=null)
{
arrobj=document.getElementById("divlblPace");
arrobj.style.display="block";
}
if(document.getElementById("divtxtPace")!=null)
{
arrobj=document.getElementById("divtxtPace");
arrobj.style.display="block";
}
if(document.getElementById("divlblOtherWorkoutType")!=null)
{
arrobj=document.getElementById("divlblOtherWorkoutType");
arrobj.style.display="block";
}
if(document.getElementById("divtxtOtherWorkoutType")!=null)
{
arrobj=document.getElementById("divtxtOtherWorkoutType");
if(document.getElementById("hidUserMessage").value!="EditWorkoutSuccessfully")
{
document.getElementById("txtOtherWorkoutType").value="";
}
arrobj.style.display="block";
}
if(document.getElementById("divBrickUI")!=null)
{
document.getElementById("divBrickUI").style.display="none";
}
if(document.getElementById("divWorkoutUI")!=null)
{
document.getElementById("divWorkoutUI").style.display="block";
}
if(document.getElementById("divExcerciseUI")!=null)
{
arrobj=document.getElementById("divExcerciseUI");
arrobj.style.display="none";
}
}
else
{
var arrobj;
if(document.getElementById("divlblDistance")!=null)
{
arrobj=document.getElementById("divlblDistance");
arrobj.style.display="block";
}
if(document.getElementById("divtxtDistance")!=null)
{
arrobj=document.getElementById("divtxtDistance");
arrobj.style.display="block";
}
if(document.getElementById("divlblPace")!=null)
{
arrobj=document.getElementById("divlblPace");
arrobj.style.display="block";
}
if(document.getElementById("divtxtPace")!=null)
{
arrobj=document.getElementById("divtxtPace");
arrobj.style.display="block";
}
if(document.getElementById("divlblOtherWorkoutType")!=null)
{
arrobj=document.getElementById("divlblOtherWorkoutType");
arrobj.style.display="none";
}
if(document.getElementById("divtxtOtherWorkoutType")!=null)
{
arrobj=document.getElementById("divtxtOtherWorkoutType");
arrobj.style.display="none";
}
if(document.getElementById("divBrickUI")!=null)
{
document.getElementById("divBrickUI").style.display="none";
}
if(document.getElementById("divWorkoutUI")!=null)
{
document.getElementById("divWorkoutUI").style.display="block";
}
if(document.getElementById("divExcerciseUI")!=null)
{
arrobj=document.getElementById("divExcerciseUI");
arrobj.style.display="none";
}
}
}
function CheckPassword()
{
var Status=document.getElementById("chkIsPasswordProtected");
if(Status!=null)
{
if(Status.checked==true)
{
document.getElementById('divProtectPassword').style.display="block";
}
else
{
document.getElementById('divProtectPassword').style.display="none";
}
}
}
function DisplayMessage()
{
var valMessage=document.getElementById("lblPlanName");
valMessage.innerHTML=document.getElementById('hidPlanName').value;
document.getElementById('divProtectPassword').style.display="block";
document.getElementById('WarningMsgs_RegistrationErrors').style.display="block";
document.getElementById('WarningMsgs_RegistrationErrors').innerHTML="Password is incorrect.";
document.getElementById("WarningMsgs_divWarningInfo").style.display="block";
}
function DisplayPasswordMessage()
{
var valMessage=document.getElementById("lblTrPlanName");
valMessage.innerHTML=document.getElementById('hidPlanName').value;
document.getElementById('divProtectPassword').style.display="block";
document.getElementById('WarningMsgs_RegistrationErrors').style.display="block";
document.getElementById('WarningMsgs_RegistrationErrors').innerHTML="Password is incorrect.";
document.getElementById("WarningMsgs_divWarningInfo").style.display="block";
}
function calculateActivityData()
{
var activity=document.getElementById("ddlActivityName").value;
if(activity=="4")
{
document.getElementById("divActivityDistance").style.display="none";
document.getElementById("divActivityPace").style.display="none";
}
else
{
document.getElementById("divActivityDistance").style.display="block";
document.getElementById("divActivityPace").style.display="block";
}
if(activity!="4")
{
var HourObj=document.getElementById("txtActivityHr");
var MinuteObj=document.getElementById("txtActivityMin");
var SecondObj=document.getElementById("txtActivitySec");
var duration=DurationInSec(HourObj,MinuteObj,SecondObj);
var DistanceObj=document.getElementById("txtActivityDistance");
var UnitObj=document.getElementById("ddlActivityUnit");
var WorkoutObj=document.getElementById("ddlActivityName");
var PaceObj=document.getElementById("txtActivityPace");
calculatePace(DistanceObj,UnitObj,WorkoutObj,duration,PaceObj);
}
}
function ValidateAddActivity()
{
errors="<ul>";
mandatoryFieldsErrorFlag=false;
var status=ValidateAddActivityRoutines();
if(status==false)
{
var registrationErrorsDiv=document.getElementById("WarningMsgs3_RegistrationErrors");
document.getElementById("WarningMsgs3_divWarningInfo").style.display="block";
registrationErrorsDiv.style.display="block";
errors+='</ul>';
registrationErrorsDiv.innerHTML="";
registrationErrorsDiv.innerHTML=errors;
return false;
}
else
{
var registrationErrorsDiv=document.getElementById("WarningMsgs3_RegistrationErrors");
document.getElementById("WarningMsgs3_divWarningInfo").style.display="none";
registrationErrorsDiv.style.display="none";
return true;
}
}
function ValidateAddActivityRoutines()
{
var userControl="";
var status=true;
var tempWorkoutType=document.getElementById("ddlWorkoutType").value;
if(tempWorkoutType=="8")
{
var activity=document.getElementById("ddlActivityName").value;
if(activity!="4")
{
var varTemp=document.getElementById('txtActivityDistance');
var alertName=" Distance ";
var isMandatory='false';
if(bValidate(varTemp,"Float",isMandatory,alertName)!=true)
{
status=false;
}
}
var varTemp=document.getElementById(userControl+"txtActivityHr");
var alertName=" Hours ";
var isMandatory='false';
if(bValidate(varTemp,"Numeric",isMandatory,alertName)!=true)
{
status=false;
}
if(varTemp.value>24)
{
errors+='<li>'+alertName+" should be between 0 to 24."+'<br/></li>';
status=false;
}
var varTemp=document.getElementById(userControl+"txtActivityMin");
var alertName=" Minutes ";
var isMandatory='false';
if(bValidate(varTemp,"Numeric",isMandatory,alertName)!=true)
{
status=false;
}
if(varTemp.value>59)
{
errors+='<li>'+alertName+" should be between 0 to 59."+'<br/></li>';
status=false;
}
var varTemp=document.getElementById(userControl+"txtActivitySec");
var alertName=" Seconds ";
var isMandatory='false';
if(bValidate(varTemp,"Numeric",isMandatory,alertName)!=true)
{
status=false;
}
if(varTemp.value>59)
{
errors+='<li>'+alertName+" should be between 0 to 59."+'<br/></li>';
status=false;
}
if((varTemp.value==24)&&((varTemp1.value>0)||(varTemp2.value>0)))
{
errors+='<li>'+alertName+" cannot be more than 24 hours, Please enter again."+'<br/></li>';
status=false;
}
}
return status;
}
function calculateGridActivityData()
{
var txtActivityType=document.getElementById("hidGridActivityType").value;
SetVisibleControlForActivity();
if(document.getElementById(txtActivityType)!=null)
{
if(document.getElementById(txtActivityType).value!="4")
{
var txtHour=document.getElementById("hidGridHourId").value;
var txtMinute=document.getElementById("hidGridMinuteId").value;
var txtSecond=document.getElementById("hidGridSecondId").value;
var HourObj=document.getElementById(txtHour);
var MinuteObj=document.getElementById(txtMinute);
var SecondObj=document.getElementById(txtSecond);
var duration=DurationInSec(HourObj,MinuteObj,SecondObj);
var txtDistance=document.getElementById("hidGridDistanceId").value;
var txtUnit=document.getElementById("hidGridUnitId").value;
var txtWorkout=document.getElementById("hidGridActivityType").value;
var txtPace=document.getElementById("hidGridPaceId").value;
var DistanceObj=document.getElementById(txtDistance);
var UnitObj=document.getElementById(txtUnit);
var WorkoutObj=document.getElementById(txtWorkout);
var PaceObj=document.getElementById(txtPace);
calculatePace(DistanceObj,UnitObj,WorkoutObj,duration,PaceObj);
}
}
}
function SetVisibleControlForActivity()
{
var txtActivityType=document.getElementById("hidGridActivityType");
var txtDistanceId=document.getElementById("hidGridDistanceId").value;
var txtUnitId=document.getElementById("hidGridUnitId").value;
var txtHourId=document.getElementById("hidGridHourId").value;
var txtMinuteId=document.getElementById("hidGridMinuteId").value;
var txtSecondId=document.getElementById("hidGridSecondId").value;
var txtPaceId=document.getElementById("hidGridPaceId").value;
if(document.getElementById("txtActivityType")!=null)
{
if(document.getElementById("txtActivityType").value=="4")
{
document.getElementById("txtDistanceId").style.display="none";
document.getElementById("txtUnitId").style.display="none";
document.getElementById("txtPaceId").style.display="none";
}
else
{
document.getElementById("txtDistanceId").style.display="block";
document.getElementById("txtUnitId").style.display="block";
document.getElementById("txtPaceId").style.display="block";
}
}
}
function ValidateGridActivityRecord()
{
errors="<ul>";
mandatoryFieldsErrorFlag=false;
var status=ValidateGridActivityRoutines();
if(status==false)
{
var registrationErrorsDiv=document.getElementById("WarningMsgs3_RegistrationErrors");
document.getElementById("WarningMsgs3_divWarningInfo").style.display="block";
registrationErrorsDiv.style.display="block";
errors+='</ul>';
registrationErrorsDiv.innerHTML="";
registrationErrorsDiv.innerHTML=errors;
return false;
}
else
{
var registrationErrorsDiv=document.getElementById("WarningMsgs3_RegistrationErrors");
document.getElementById("WarningMsgs3_divWarningInfo").style.display="none";
registrationErrorsDiv.style.display="none";
return true;
}
}
function ValidateGridExcerciseRecord()
{
errors="<ul>";
mandatoryFieldsErrorFlag=false;
var status=ValidateGridExcerciseRoutines();
if(status==false)
{
var registrationErrorsDiv=document.getElementById("WarningMsgs3_RegistrationErrors");
document.getElementById("WarningMsgs3_divWarningInfo").style.display="block";
registrationErrorsDiv.style.display="block";
errors+='</ul>';
registrationErrorsDiv.innerHTML="";
registrationErrorsDiv.innerHTML=errors;
return false;
}
else
{
var registrationErrorsDiv=document.getElementById("WarningMsgs3_RegistrationErrors");
document.getElementById("WarningMsgs3_divWarningInfo").style.display="none";
registrationErrorsDiv.style.display="none";
return true;
}
}
function ValidateGridActivityRoutines()
{
var txtActivityType=document.getElementById("hidGridActivityType").value;
var txtDistanceId=document.getElementById("hidGridDistanceId").value;
var txtUnitId=document.getElementById("hidGridUnitId").value;
var txtHourId=document.getElementById("hidGridHourId").value;
var txtMinuteId=document.getElementById("hidGridMinuteId").value;
var txtSecondId=document.getElementById("hidGridSecondId").value;
var txtPaceId=document.getElementById("hidGridPaceId").value;
var userControl="";
var status=true;
if(document.getElementById(txtActivityType).value!="4")
{
var varTemp=document.getElementById(txtDistanceId);
var alertName=" Distance ";
var isMandatory='false';
if(bValidate(varTemp,"Float",isMandatory,alertName)!=true)
{
status=false;
}
}
var varTemp=document.getElementById(userControl+txtHourId);
var alertName=" Hours ";
var isMandatory='false';
if(bValidate(varTemp,"Numeric",isMandatory,alertName)!=true)
{
status=false;
}
if(varTemp.value>24)
{
errors+='<li>'+alertName+" should be between 0 to 24."+'<br/></li>';
status=false;
}
var varTemp=document.getElementById(userControl+txtMinuteId);
var alertName=" Minutes ";
var isMandatory='false';
if(bValidate(varTemp,"Numeric",isMandatory,alertName)!=true)
{
status=false;
}
if(varTemp.value>59)
{
errors+='<li>'+alertName+" should be between 0 to 59."+'<br/></li>';
status=false;
}
var varTemp=document.getElementById(userControl+txtSecondId);
var alertName=" Seconds ";
var isMandatory='false';
if(bValidate(varTemp,"Numeric",isMandatory,alertName)!=true)
{
status=false;
}
if(varTemp.value>59)
{
errors+='<li>'+alertName+" should be between 0 to 59."+'<br/></li>';
status=false;
}
if((varTemp.value==24)&&((varTemp1.value>0)||(varTemp2.value>0)))
{
errors+='<li>'+alertName+" cannot be more than 24 hours, Please enter again."+'<br/></li>';
status=false;
}
return status;
}
function ValidateGridExcerciseRoutines()
{
var txtActivityType=document.getElementById("hidGridExcerciseType").value;
var txtHourId=document.getElementById("hidGridExceriseHourId").value;
var txtMinuteId=document.getElementById("hidGridExcerciseMinuteId").value;
var txtSecondId=document.getElementById("hidGridExcerciseSecondId").value;
var txtOtherExcercise=document.getElementById("hidGridtxtOtherExcercise").value;
var txtNoOfSets=document.getElementById("hidGridNoOfSets").value;
var userControl="";
var status=true;
var activity=document.getElementById(txtActivityType).value;
if(activity=="Other")
{var varTemp=document.getElementById(txtOtherExcercise);
var alertName=" Other Excercise ";
var isMandatory='True';
if(bValidate(varTemp,"AlphaWithSpaceAnd",isMandatory,alertName)!=true)
{
status=false;
}
}
var varTemp=document.getElementById(userControl+txtHourId);
var alertName=" Hours ";
var isMandatory='false';
if(bValidate(varTemp,"Numeric",isMandatory,alertName)!=true)
{
status=false;
}
if(varTemp.value>24)
{
errors+='<li>'+alertName+" should be between 0 to 24."+'<br/></li>';
status=false;
}
var varTemp=document.getElementById(userControl+txtMinuteId);
var alertName=" Minutes ";
var isMandatory='false';
if(bValidate(varTemp,"Numeric",isMandatory,alertName)!=true)
{
status=false;
}
if(varTemp.value>59)
{
errors+='<li>'+alertName+" should be between 0 to 59."+'<br/></li>';
status=false;
}
var varTemp=document.getElementById(userControl+txtSecondId);
var alertName=" Seconds ";
var isMandatory='false';
if(bValidate(varTemp,"Numeric",isMandatory,alertName)!=true)
{
status=false;
}
if(varTemp.value>59)
{
errors+='<li>'+alertName+" should be between 0 to 59."+'<br/></li>';
status=false;
}
if((varTemp.value==24)&&((varTemp1.value>0)||(varTemp2.value>0)))
{
errors+='<li>'+alertName+" cannot be more than 24 hours, Please enter again."+'<br/></li>';
status=false;
}
var varTemp=document.getElementById(txtNoOfSets);
var alertName=" No. of sets ";
var isMandatory='false';
if(bValidate(varTemp,"Numeric",isMandatory,alertName)!=true)
{
status=false;
}
if(varTemp.value>10)
{
errors+='<li>'+alertName+" cannot be more than 10."+'<br/></li>';
status=false;
}
if(varTemp.value<=10)
{
var strRepetitions=document.getElementById("hidGridRepetitions").value;
if(strRepetitions!="")
{
var arrRepetitions=strRepetitions.split(" ");
var iCount;
for(iCount=0;iCount<arrRepetitions.length;iCount++)
{
var strFloatExp="^(([0-9])+([\.]([0-9])*)?)$";
var status;
objRegExp=new RegExp(strFloatExp);
var varTemp=document.getElementById(arrRepetitions[iCount]);
var alertName=" Repetitions ";
if(varTemp!=null)
{
if(varTemp.value=="")
{
errors+='<li>'+alertName+" should not be empty."+'<br/></li>';
status=false;
break;
}
if(varTemp.value=="0")
{
errors+='<li>'+alertName+" should not be 0."+'<br/></li>';
status=false;
break;
}
if(objRegExp.test(varTemp.value)==false)
{
errors+='<li>'+alertName+" should be numeric."+'<br/></li>';
status=false;
break;
}
if(varTemp.value>100)
{
errors+='<li>'+alertName+" cannot be more than 100."+'<br/></li>';
status=false;
break;
}
}
}
}
var strWeight=document.getElementById("hidGridWeight").value;
if(strWeight!="")
{
var arrWeight=strWeight.split(" ");
var iCount;
for(iCount=0;iCount<arrWeight.length;iCount++)
{
var strFloatExp="^(([0-9])+([\.]([0-9])*)?)$";
var status;
objRegExp=new RegExp(strFloatExp);
var varTemp=document.getElementById(arrWeight[iCount]);
var alertName=" Weight ";
if(varTemp!=null)
{
if(varTemp.value=="")
{
errors+='<li>'+alertName+" should not be empty."+'<br/></li>';
status=false;
break;
}
if(objRegExp.test(varTemp.value)==false)
{
errors+='<li>'+alertName+" should be numeric."+'<br/></li>';
status=false;
break;
}
if(varTemp.value>1000)
{
errors+='<li>'+alertName+" cannot be more than 1000."+'<br/></li>';
status=false;
break;
}
}
}
}
}
return status;
}
function ValidateTerms()
{
var objCtrl;
objCtrl=document.getElementById("txtTermName");
if(objCtrl.value.trim()=="")
{
document.getElementById("WarningMsgs2_RegistrationErrors").style.display='block';
document.getElementById("WarningMsgs2_RegistrationErrors").innerHTML="Please enter all mandatory data";
document.getElementById("WarningMsgs2_divWarningInfo").style.display='block';
return false;
}
var sExp;
sExp="^[0-9a-z(),\.\/ & ';\:-]+$";
objRegExp=new RegExp(sExp,'gi');
if(objRegExp.test(objCtrl.value.trim())==false)
{
document.getElementById("WarningMsgs2_RegistrationErrors").style.display='block';
document.getElementById("WarningMsgs2_RegistrationErrors").innerHTML="Term should contain only letters, numbers, space, comma, colon, dot, semicolon, single quote, forward slash, hyphen and ampersand.";
document.getElementById("WarningMsgs2_divWarningInfo").style.display='block';
return false;
}
objCtrl=document.getElementById("txtTermDescription");
if(objCtrl.value.trim()=="")
{
document.getElementById("WarningMsgs2_RegistrationErrors").style.display='block';
document.getElementById("WarningMsgs2_RegistrationErrors").innerHTML="Please enter all mandatory data";
document.getElementById("WarningMsgs2_divWarningInfo").style.display='block';
return false;
}
return true;
}
function ShowAddTermPopup()
{var objCtrl;
objCtrl=document.getElementById("hidTermId");
if(objCtrl!=null)
{
objCtrl.value="";
}
objCtrl=document.getElementById("txtTermName");
if(objCtrl!=null)
{
objCtrl.value="";
}
objCtrl=document.getElementById("txtTermDescription");
if(objCtrl!=null)
{
objCtrl.value="";
}
var registrationErrorsDiv=document.getElementById("WarningMsgs2_RegistrationErrors");
registrationErrorsDiv.style.display="none";
document.getElementById("WarningMsgs2_divWarningInfo").style.display="none";
ShowModalPopup('pnlAddTerm','Training Plans - Add New Term');
return false;
}
function DeletePlanConfirmation(RecordId,btnId)
{
document.getElementById("confirmBox_hidButtonId").value=btnId;
document.getElementById("hidRecordId").value=RecordId;
ShowConfirmBox('Would you like to delete the Plan?');
return false;
}
function DeleteTrainingPlanConfirmation(RecordId,btnId)
{
document.getElementById("confirmBox_hidButtonId").value=btnId;
document.getElementById("hidRecordId").value=RecordId;
ShowConfirmBox('Would you like to delete the Plan?');
return false;
}
function ShowPlanCreatedMessageBox(facebookMessage,SendTweet,SendFacebook,logoutStatus,OperType)
{
var msg="";
if(SendTweet=="False")
{
if(OperType==0)
{
msg="Congratulations! Your plan has been successfully created.";
}
else
{
msg="Congratulations! Your plan has been successfully updated.";
}
}
else
{
if(OperType==0)
{
msg="Congratulations! Your plan has been successfully created and shared with Twitter.";
}
else
{
msg="Congratulations! Your plan has been successfully updated and shared with Twitter.";
}
}
if(SendFacebook=="True")
{
ShowMessagewithData(msg,facebookMessage,logoutStatus);
}
else
{document.getElementById("msgData").value="";
ShowMessageBox(msg);
}
return true;
}
function ShowFBPublishData()
{
if(document.getElementById("hidSendFacebook").value=="True")
{var Path=self.location.href;
var PageName=Path.substring(Path.lastIndexOf("/")+1,Path.length);
if(PageName.indexOf("CreatePlan.aspx")>=0)
{
var FBMessage=document.getElementById("hidFBMessage").value
}
else
{
var FBMessage=document.getElementById("hidFacebookPlanName").value;
}
FBPublishData(FBMessage);
}
}
function ShowFBPublish()
{
setTimeout("ShowFBPublishData()",5000);
}
