
function StartTime_onChange() {
	var dateFieldValue= Xrm.Page.getAttribute('vhacrm_starttime_datetime').getValue();
	if (dateFieldValue){
		var year = dateFieldValue.getFullYear();
		var month = dateFieldValue.getMonth() + 1;
		var day = dateFieldValue.getDate();
		var dateText = month.toString() + '/' + day.toString() + '/' + year.toString();
		Xrm.Page.getAttribute("vhacrm_workdatetext_text").setValue(dateText); 
		Xrm.Page.getAttribute("vhacrm_endtime_datetime").setValue(dateFieldValue);	
	}
	else{
		Xrm.Page.getAttribute("vhacrm_workdatetext_text").setValue(null);
		Xrm.Page.getAttribute("vhacrm_endtime_datetime").setValue(null);	
	}
}

function OvertimeStartTime_onChange() {
	var dateFieldValue= Xrm.Page.getAttribute('vhacrm_overtimestarttime_datetime').getValue();
	if (dateFieldValue){
		var year = dateFieldValue.getFullYear();
		var month = dateFieldValue.getMonth() + 1;
		var day = dateFieldValue.getDate();
		var dateText = month.toString() + '/' + day.toString() + '/' + year.toString();
		Xrm.Page.getAttribute("vhacrm_workdatetext_text").setValue(dateText); 
		Xrm.Page.getAttribute("vhacrm_overtimeendtime_datetime").setValue(dateFieldValue);	
	}
	else{
		Xrm.Page.getAttribute("vhacrm_workdatetext_text").setValue(null);
		Xrm.Page.getAttribute("vhacrm_overtimeendtime_datetime").setValue(null);	
	}
}
function overtime_onChange(){
// clear associated fields when Overtime changes
	if (Xrm.Page.getAttribute("vhacrm_overtime_bool").getValue() != true) {
	    Xrm.Page.getAttribute("vhacrm_overtimestarttime_datetime").setValue(null);
        Xrm.Page.getAttribute("vhacrm_overtimeendtime_datetime").setValue(null);
    }
}
