		$(function() {
			$.urlParam = function(name){
				var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href);
				return results[1] || 0;
			}
			var category = jQuery.url.param("category");		
			var location = jQuery.url.param("location");
			var dateParam = jQuery.url.param("date");
			
			if (location == "portland") {
				$("#location_portland").attr("id", "location_portland-active");
			} else if (location == "coast") {
				$("#location_coast").attr("id", "location_coast-active");
			} else if (location == "eastern") {
				$("#location_eastern").attr("id", "location_eastern-active");
			} else if (location == "southern") {
				$("#location_southern").attr("id", "location_southern-active");
			} else if (location == "hood-gorge") {
				$("#location_hood-gorge").attr("id", "location_hood-gorge-active");
			} else if (location == "central") {
				$("#location_central").attr("id", "location_central-active");			
			}
			
			
			if (category == "new-releases") {
				$("#category_new-releases").attr("id", "category_new-releases-active");
			} else if (category == "meet-brewer") {
				$("#category_meet-brewer").attr("id", "category_meet-brewer-active");
			} else if (category == "tastings") {
				$("#category_tastings").attr("id", "category_tastings-active");
			} else if (category == "festivals") {
				$("#category_festival").attr("id", "category_festival-active");
			} else if (category == "pairing") {
				$("#category_pairing").attr("id", "category_pairing-active");
			} else if (category == "tapping") {
				$("#category_tapping").attr("id", "category_tapping-active");			
			} else if (category == "other") {
				$("#category_other").attr("id", "category_other-active");			
			}
			
			
			var date = new Date();
			var currentMonth = date.getMonth();
			var currentDate = date.getDate();
			var currentYear = date.getFullYear();



			$( "#datepicker" ).datepicker({
				dateFormat: 'yy-mm-dd',
				defaultDate: dateParam,
				minDate: new Date(currentYear, currentMonth, currentDate),
				onSelect: function(){
					var day = $("#datepicker").datepicker('getDate').getDate();                 
					var month = $("#datepicker").datepicker('getDate').getMonth() + 1;             
					var year = $("#datepicker").datepicker('getDate').getFullYear();
					var fullDate = year + "-" + month + "-" + day;
					var str_output = fullDate;
					$('#date-selected').html(str_output);
					window.location = '/events/?date=' + str_output;
				}
			});
			
			var date = $.urlParam('date'); 

			$('#datepicker').click(function() {
				$.urlParam('date') = date;
			});

		});
