/**
 *
 * @access public
 * @return void
 **/
function UpdateHours(which)
{
	var select = $(which+'_hour');
	var selected_option = select.options[select.selectedIndex].value;

	var option;
	select.options.length = 0;

	if (($F(which+'_location') == 2) || ($F(which+'_location') == 3))
	{
		for (hour=1; hour<=5; hour++)
		{
		   	option = document.createElement('option');
			option.setAttribute('value',hour+':00');
			var text = document.createTextNode(hour+':00 a.m.');
			option.appendChild(text);
			select.appendChild(option);
		   	option = document.createElement('option');
			option.setAttribute('value',hour+':30');
			var text = document.createTextNode(hour+':30 a.m.');
			option.appendChild(text);
			select.appendChild(option);
		}
	}

	if (($F(which+'_location') == 2) || ($F(which+'_location') == 3) || ($F(which+'_location') == 4))
	{
		for (hour=6; hour<=7; hour++)
		{
		   	option = document.createElement('option');
			option.setAttribute('value',hour+':00');
			var text = document.createTextNode(hour+':00 a.m.');
			option.appendChild(text);
			select.appendChild(option);
		   	option = document.createElement('option');
			option.setAttribute('value',hour+':30');
			var text = document.createTextNode(hour+':30 a.m.');
			option.appendChild(text);
			select.appendChild(option);
		}
	}

	for (hour=8; hour<=11; hour++)
	{
	   	option = document.createElement('option');
		option.setAttribute('value',hour+':00');
		var text = document.createTextNode(hour+':00 a.m.');
		option.appendChild(text);
		select.appendChild(option);
	   	option = document.createElement('option');
		option.setAttribute('value',hour+':30');
		var text = document.createTextNode(hour+':30 a.m.');
		option.appendChild(text);
		select.appendChild(option);
	}

   	option = document.createElement('option');
	option.setAttribute('value','12:00');
	var text = document.createTextNode('NOON');
	option.appendChild(text);
	select.appendChild(option);
   	option = document.createElement('option');
	option.setAttribute('value','12:30');
	var text = document.createTextNode('12:30 p.m.');
	option.appendChild(text);
	select.appendChild(option);

	for (hour=1; hour<=3; hour++)
	{
	   	option = document.createElement('option');
		option.setAttribute('value',(hour+12)+':00');
		var text = document.createTextNode(hour+':00 p.m.');
		option.appendChild(text);
		select.appendChild(option);
	   	option = document.createElement('option');
		option.setAttribute('value',(hour+12)+':30');
		var text = document.createTextNode(hour+':30 p.m.');
		option.appendChild(text);
		select.appendChild(option);
	}

	var pickup_date = new Date();
	var regex_date = /(\d{1,2})-(\d{1,2})-(\d{4})/;
	var date_array;

	if (date_array = regex_date.exec($F(which+'_date')))
	{
		pickup_date.setFullYear(date_array[3],date_array[2]-1,date_array[1]);
	}
	if ((pickup_date.getDay() != 0) || ($F(which+'_location') == 4) || ($F(which+'_location') == 3) || ($F(which+'_location') == 4))
	{
		for (hour=4; hour<=5; hour++)
		{
		   	option = document.createElement('option');
			option.setAttribute('value',(hour+12)+':00');
			var text = document.createTextNode(hour+':00 p.m.');
			option.appendChild(text);
			select.appendChild(option);
		   	option = document.createElement('option');
			option.setAttribute('value',(hour+12)+':30');
			var text = document.createTextNode(hour+':30 p.m.');
			option.appendChild(text);
			select.appendChild(option);
		}
	}

	if (($F(which+'_location') == 2) || ($F(which+'_location') == 3) || ($F(which+'_location') == 4))
	{
		for (hour=6; hour<=9; hour++)
		{
		   	option = document.createElement('option');
			option.setAttribute('value',(hour+12)+':00');
			var text = document.createTextNode(hour+':00 p.m.');
			option.appendChild(text);
			select.appendChild(option);
		   	option = document.createElement('option');
			option.setAttribute('value',(hour+12)+':30');
			var text = document.createTextNode(hour+':30 p.m.');
			option.appendChild(text);
			select.appendChild(option);
		}
	}

	if (($F(which+'_location') == 2) || ($F(which+'_location') == 3))
	{
		for (hour=10; hour<=11; hour++)
		{
		   	option = document.createElement('option');
			option.setAttribute('value',(hour+12)+':00');
			var text = document.createTextNode(hour+':00 p.m.');
			option.appendChild(text);
			select.appendChild(option);
		   	option = document.createElement('option');
			option.setAttribute('value',(hour+12)+':30');
			var text = document.createTextNode(hour+':30 p.m.');
			option.appendChild(text);
			select.appendChild(option);
		}
	   	option = document.createElement('option');
		option.setAttribute('value','00:00');
		var text = document.createTextNode('MIDNIGHT');
		option.appendChild(text);
		select.appendChild(option);
	   	option = document.createElement('option');
		option.setAttribute('value','00:30');
		var text = document.createTextNode('12:30 a.m.');
		option.appendChild(text);
		select.appendChild(option);
	}

	options = select.options;
	for (var i=0; i < options.length; i++)
	{
		if (options[i].value == selected_option)
		{
			options[i].setAttribute('selected', true);
			break;
		}
	}
}
