/**
 *	Hide the book button with given id. Why GJ chose not to do this
 *	the same way as showBookButton is a mystery to me.
**/
function hideBookButton(id){
	for (var i=0; i<document.bookSaloon.treatmentTime.length; i++){
		treatmentTimeId = document.bookSaloon.treatmentTime[i].id;
		if($(treatmentTimeId).checked){
			$('book_' + treatmentTimeId).style.display = 'block';
		}else{
			$('book_' + treatmentTimeId).style.display = 'none';
		}
	}
}


/**
 *	Show the book button behind a given time.
**/
function showBookButton(id){
	$('book_' + id).style.display = 'block';
}


/**
 *	Set the checkbox with given ID to checked.
**/
function selectTime(id){
	$(id).checked = true;
	
	if ($('timeNoPreference').checked == true)
		return;	


	var timeEmployee = id.split('_');
	var time = timeEmployee[1];

	if ($('timeMorning').checked == true && time > 720) {
		$('timeNoPreference').checked = true;		
		$('timeMorning').checked 			= false;
	}
	if ($('timeEvening').checked == true && time < 720) {
		$('timeNoPreference').checked = true;		
		$('timeEvening').checked			=	false
	}
}


function hideTimes () {
	if ($('timeSelect'))
		$('timeSelect').style.display = 'none';
	$('makeAppointmentSpan').style.display = 'none';
	if ($('addAppointmentSpan'))
		$('addAppointmentSpan').style.display = 'none';
}


/**
 *	Determine the type of book button to show: either the
 *	bookbutton for a single appointment, or the bookbutton
 *	to select a whole series of appointments. 
 *
 *	Since the last option is only available to saloon employees
 *	we hide the series book buttons from customers.
**/
function selectBookButton () {
	if (!$('enterSeries'))
		return selectSingleBookButton();
	if ($('enterSeries').checked)
		selectSeriesBookButton();
	else
		selectSingleBookButton();
}


function selectSeriesBookButton () {
	$('addAppointmentSpan').style.display = 'inline';
	var singleButtons = document.getElementsByName('makeAppointment');
	var multiButtons	= document.getElementsByName('addAppointment');
	for (var i = 0; i < singleButtons.length; i++) {
		multiButtons[i].style.display = 'inline';
		if (!singleButtons[i].id)
			singleButtons[i].style.display = 'none';
	}
}


function selectSingleBookButton () {
	if (!$('addAppointmentSpan'))
		return;
		
	$('addAppointmentSpan').style.display = 'none';
	var singleButtons = document.getElementsByName('makeAppointment');
	var multiButtons	= document.getElementsByName('addAppointment');
	for (var i = 0; i < singleButtons.length; i++) {
		singleButtons[i].style.display = 'inline';
		if (!multiButtons[i].id)
			multiButtons[i].style.display = 'none';
	}
}