	$(document).ready(function() 
	{			
		if( is_closed() ) {
			$('.lib_hour_start').addClass('lib_hour_closed').text('closed');
			$('.lib_hour_end').hide();
		}else{
			$('.lib_hour_start').text(default_hours[current_day][0]);
			$('.lib_hour_end').text(default_hours[current_day][1]);
		}	
	
		$('.lib_hour_day').text(day_name[current_day] + '.');
		$('.lib_hour_more').parent().attr('href', 'http://library.vicu.utoronto.ca/about_us/#hours');

		//not related so we should move this to elsewhere
		$('#footer .copyright').html('Copyright © 2012 Victoria University Library. All Rights Reserved.');
		$('#footer_logo').append('<a href="http://www.vicu.utoronto.ca" style="display: block; width: 100%; height: 100%;"></a>');
		$('#header_links li:eq(0) a').attr('href', 'http://library.vicu.utoronto.ca/emmanuel/');
		$('#header_links li:eq(1) a').attr('href', 'http://library.vicu.utoronto.ca/friends.htm');
		$('#header_links li:eq(2) a').attr('href', 'http://library.vicu.utoronto.ca/sitemap.html');
		$('#header_links li:eq(3) a').attr('href', 'http://library.vicu.utoronto.ca/ask_us/');
	});

	/***** PRINT FRIENDLY CSS *****/
	if(document.createStyleSheet) {
		document.createStyleSheet('http://library.vicu.utoronto.ca/css/print.css');
	}else{
		$('head').append('<link href="http://library.vicu.utoronto.ca/css/print.css" rel="stylesheet" media="print" />');
	}

	/* google analytics tracking code STARTS here (again, we should move this elsewhere) */
	  var _gaq = _gaq || [];
	  _gaq.push(['_setAccount', 'UA-16155048-1']);
	  _gaq.push(['_trackPageview']);
	
	  (function() {
		var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
		ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
		var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
	  })();
	/* google analytics tracking code ENDS here (again, we should move this elsewhere) */		

	
	var day_name = new Array('SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT');
	var date = new Date();
	var current_day = date.getDay();
	var current_date = date.getDate() + '/' + (date.getMonth() + 1) + '/' + date.getFullYear() ;
	
	
	var default_hours = [
		['', ''],  //Sunday
		['8:30', '8:45'], 
		['8:30', '8:45'], 
		['8:30', '8:45'], 
		['8:30', '8:45'], 
		['8:30', '4:45'], 
		['', '']
	];
	
	var regular_hours  = [
		['1:00', '11:45'],  //Sunday
		['8:30', '11:45'], 
		['8:30', '11:45'], 
		['8:30', '11:45'], 
		['8:30', '11:45'], 
		['8:30', '6:45'], 
		['12:00', '5:45']
	];			
	
	var extended_hours  = [
		['10:00', '11:45'],  //Sunday
		['8:30', '11:45'], 
		['8:30', '4:45'], 
		['8:30', '11:45'], 
		['8:30', '11:45'], 
		['8:30', '11:45'], 
		['10:00', '11:45']
	];
	
	var pre_term_hours = [
		['', ''],  //Sunday
		['9:00', '4:45'], 
		['9:00', '4:45'], 
		['9:00', '4:45'], 
		['9:00', '4:45'], 
		['9:00', '4:45'],
		['', '']
	];	
	
	default_hours = pre_term_hours;
	
	current_time = new Date();
	
	reg_hours_date = new Date();
	reg_hours_date.setMonth(0); //0 = Jan, 1 = Feb...
	reg_hours_date.setDate(9);
	reg_hours_date.setYear(2012);
	reg_hours_date.setHours(0, 0, 0, 0);
	
	if(current_time.getTime() >= reg_hours_date.getTime()) {
		default_hours = regular_hours;
	}
	
	
	//date format: dd/mm/yyyy
	var holidays = [			
		['21/12/2011', '1/1/2012'],
		['20/2/2012'],
		['6/4/2012']
	]
	
	function getFullYearDate(date) {
		var date_array = date.toString().split('/');
		return new Date(date_array[2], (date_array[1] - 1), date_array[0]);
	}
			
	function is_holiday(current_date, holidays) {	
		var start_date = '';
		var end_end = '';
		var current_date_converted = getFullYearDate(current_date);
		var list_size = holidays.length;

		for(var i = 0; i < list_size ;i++) {
			if( holidays[i].length == 2 ) {				
				start_date = getFullYearDate(holidays[i][0]);
				end_date = getFullYearDate(holidays[i][1]);
				if( current_date_converted >= start_date && current_date_converted <= end_date ) {
					return true;
				}
			}else{
				if( current_date == holidays[i][0] ) {
					return true;
				}
			}
		}
		return false;
	}
	
	function is_closed() {
		return default_hours[current_day][0] == '' || is_holiday(current_date, holidays);
	}
	


