var images = [
	'images/study-in-the-library.png',
	'images/m-phone.png',
	'images/books.png',
	'images/campus-guy.png',
	'images/library1c.png',
	'images/alex-reading.png',
    	'images/m-phone.png'
       
              
];

/* Leave as '' to make the system use normal hours (below) */
var exception_hours = [
	'',					/* Sunday */
	'',					/* Monday */
	'',					/* Tuesday */
	'',					/* Wednesday */
	'',					/* Thursday */
	'',					/* Friday */
	'',					/* Saturday */
]

var normal_hours = [
	'Closed',	/* Sunday */
	'8am - 8pm',	 /* Monday */
	'8am - 8pm',	/* Tuesday */
	'8am - 8pm',	/* Wednesday */
	'8am - 8pm',	/* Thursday */
	'8am - 5pm',	/* Friday */
	'10am - 4pm',	/* Saturday */
];

$(document).ready(function() {

	// Removes the default value from a text box as soon as the user
	// clicks inside it. Puts the default value back if the user does
	// not enter anything
	$('.default-value').each(function() {
	    var default_value = this.value;
	    $(this).focus(function()
	    {
	        if(this.value == default_value)
	        {
	            this.value = '';
	        }
	    });
	    $(this).blur(function()
	    {
	        if(this.value == '')
	        {
	            this.value = default_value;
	        }
	    });
	});
	
	// Make the 'Go' button on the search form work in IE
	$('#search input.button').val(" ");
	
	// The random image rotator based on the images array at the top
	// of this file. Add as many images as you want to that array
	var selected = images[Math.floor(Math.random() * images.length)];
	$('#left-picture img').attr('src', selected);
	
	/*// Provide Google Scholar search option
	$('#search select').append('<option value="google-scholar">Search Google Scholar</option>');
	$('#search form').submit(function() {
		if ($('#search select').val() == 'google-scholar')
		{
			$('#searchValue').attr('name', 'q');
			$('#search form').attr('action', 'http://scholar.google.com/scholar');
			$('#search input[type=hidden]').remove();
		}
	});*/
	
	// Today's Hours calendar
	/* I can't believe this is the best way to do this in JavaScript */
	var months = [
		'Jan',
		'Feb',
		'Mar',
		'Apr',
		'May',
		'Jun',
		'Jul',
		'Aug',
		'Sep',
		'Oct',
		'Nov',
		'Dec',
	];
	var now = new Date();
	$('.calendar .calendar-month').html(months[now.getMonth()]);
	$('.calendar .calendar-day').html(now.getDate());
	if (exception_hours[now.getDay()] == '')
	{
		$('#open-hours').html(normal_hours[now.getDay()]);
	}
	else
	{
		$('#open-hours').html(exception_hours[now.getDay()]);
	}
	
});
