/* schedule.js 
 * 
 * James Cradock <jim@yellahoose.com> 
 */

// Self-explanatory. 
function editSchedule(form_obj, schedule_id) { 
	form_obj.Action.value = 'Edit'; 
	form_obj.Schedule_ID.value = schedule_id; 
	form_obj.submit(); 
} 
// Self-explanatory. 
function addSchedule(form_obj) { 
	if (! form_obj.Date.value.match(/^\d{2}\/\d{2}\/\d{4}$/)) { 
		alert('Enter a date for the shoot in mm/dd/yyyy format.'); 
	} else { 
		form_obj.Action.value = 'Add'; 
		form_obj.submit(); 
	} 
} 
// Self-explanatory. 
function updateSchedule(form_obj) { 
	if (! form_obj.Date.value.match(/^\d{2}\/\d{2}\/\d{4}$/)) { 
		alert('Enter a date for the shoot in mm/dd/yyyy format.'); 
	} else { 
		form_obj.Action.value = 'Update'; 
		form_obj.submit(); 
	}
} 
// Self-explanatory. 
function changeSchedule(form_obj, schedule_id) { 
	form_obj.Schedule_ID.value = schedule_id; 
	form_obj.submit(); 
} 
// Self-explanatory. 
function removeSchedule(form_obj, schedule_id) { 
	// if (form_obj.Number_of_Reservations.value > 0) { 
	// 	alert('You cannot delete this schedule, because there are reservations associated with it.'); 
	// } else { 
	var res = confirm('Are you certain you want to remove this scheduled date. This will remove reservations also. This CANNOT be undone.'); 
	if (res) {  
		form_obj.Action.value = 'Remove'; 
		form_obj.Schedule_ID.value = schedule_id; 
		form_obj.submit(); 
	} 
} 
