// JavaScript Document

// special date exceptions - special date rules can be added in advance here in the format 'dd-mm-yyyy' : 'display time string'
// NOTE: do NOT leave a trailing comma after the last array element as this breaks in IE, remove past dates when this file is updated
var qsDateExceptions = {

	'28-11-2011' : '9am to 9pm',
	'29-11-2011' : '9am to 9pm',
	'30-11-2011' : '9am to 9pm',
	'01-12-2011' : '9am - 9pm',
	'02-12-2011' : '9am - 9pm',
	'03-12-2011' : '9am - 7pm',
	'05-12-2011' : '9am - 9pm',
	'06-12-2011' : '9am - 9pm',
	'07-12-2011' : '9am - 9pm',
	'08-12-2011' : '9am - 9pm',
	'09-12-2011' : '9am - 9pm',
	'10-12-2011' : '9am - 7pm',	
	'12-12-2011' : '9am - 9pm',
	'13-12-2011' : '9am - 9pm',
	'14-12-2011' : '9am - 9pm',
	'15-12-2011' : '9am - 9pm',
	'16-12-2011' : '9am - 9pm',
	'17-12-2011' : '9am - 7pm',
	'19-12-2011' : '9am - 9pm',
	'20-12-2011' : '9am - 9pm',
	'21-12-2011' : '9am - 9pm',
	'22-12-2011' : '9am - 9pm',
	'23-12-2011' : '9am - 9pm',
	'24-12-2011' : '9am to 5pm',
	'25-12-2011' : 'Closed',
	'26-12-2011' : '10am to 5.30pm',
	'27-12-2011' : '9am to 7pm',
	'28-12-2011' : '9am to 7pm',
	'29-12-2011' : '9am to 8pm',
	'30-12-2011' : '9am to 7pm',
	'31-12-2011' : '9am to 5pm',
	'01-01-2012' : 'Closed',
	'02-01-2012' : '10am to 5.30pm'
}

function printOpeningTimes() {
	outputTimes(new Date());
}


function printTomorrowTimes() {
	var currentTime = new Date();
	var dateInc = parseInt(currentTime.getTime(), 10) + 86400000;
	var tomorrowDate = new Date(dateInc);
	outputTimes(tomorrowDate);
}

function outputTimes(selectedDate) {
	var dayOfWeek = selectedDate.getDay()
	var times = '';

	// standard times
	if ((dayOfWeek == 1) || (dayOfWeek == 2)  || (dayOfWeek == 3) || (dayOfWeek == 5)) { // mon, tue, wed, fri
		times = "9am to 5.30pm";
	} else if ((dayOfWeek == 4)) { // thu
		times = "9am to 8pm";
	} else if ((dayOfWeek == 6)) { // sat
		times = "9am to 6pm";
	} else if ((dayOfWeek == 0)) { // sun
		times = "10.30am to 4.30pm";
	}

	// check if the day passed in is subject to a special rule exception and apply the update times as necessary
	for(var i in qsDateExceptions) {
		var dateArr = i.split('-');
		if( parseInt(dateArr[0], 10) == parseInt(selectedDate.getDate(), 10) &&  (parseInt(dateArr[1], 10)-1) == parseInt(selectedDate.getMonth(), 10) && parseInt(dateArr[2], 10) == parseInt(selectedDate.getFullYear(), 10)) {
			times = qsDateExceptions[i];
		}
	}
	document.write(times);
}


/* deprecated code - new dates/opening times just need to be added to the qsDateExceptions array */

 function printEasterTimes()
{
	var currentTime = new Date();
	var dayOfWeek = currentTime.getDay();
	
	
	if ((dayOfWeek == 5))
	{
		 document.write("9am to 5.30pm (Good Friday)");			
	}
	else if ((dayOfWeek == 6))
	{
		 document.write("9am to 6pm (Easter Saturday)");
	}
	else if ((dayOfWeek == 0))
	{
		 document.write("CLOSED (Easter Sunday)");
	}
	else if ((dayOfWeek == 1))
	{
		 document.write("10.30am to 4.30pm (Easter Monday)");			
	}	
	else if ((dayOfWeek == 2))
	{
		 document.write("9am to 5.30pm");			
	}
	else if ((dayOfWeek == 4))
	{
		 document.write("9am to 8pm");			
	}	
	else if ((dayOfWeek == 3))
	{
		document.write("9am to 5.30pm");		
	}
}



function printBankHolidayTimes()
{
	var currentTime = new Date();
	var dayOfWeek = currentTime.getDay();
	
	
	if ((dayOfWeek == 0) || (dayOfWeek == 1))
		{
			 document.write("10.30am to 4.30pm");
		}
	else if ((dayOfWeek == 2)  || (dayOfWeek == 3) || (dayOfWeek == 5))
		{
			 document.write("9am to 5.30pm");
		}
	else if ((dayOfWeek == 4))
		{
			 document.write("9am to 8pm");
		}
	else if ((dayOfWeek == 6))
		{
			 document.write("9am to 6pm");
		}
}

