var month = new Array(11);
month[0] = "January";
month[1] = "February";
month[2] = "March";
month[3] = "April";
month[4] = "May";
month[5] = "June";
month[6] = "July";
month[7] = "August";
month[8] = "September";
month[9] = "October";
month[10] = "November";
month[11] = "December";

var now = new Date();

var today = month[now.getMonth()] + " " + now.getDate() + ", " + parseInt(now.getYear() + 1900);

var currentPage = window.location.href.substring(window.location.href.lastIndexOf('/') + 1);
if (!currentPage) currentPage = "index.html";

$(document).ready(function() {
	$("#header .left").click(function() {
		window.location.href = "http://www.losgatosrotary.org";
	});
	$("#date").html(today);
	$("#menu a").each(function(index) {
		$(this).html("<span>" + $(this).html() + "</span>");
		if ($(this).attr("href") == currentPage) {
			$(this).addClass("active");
			if ($(this).parents("ul").length == 2) {
				$(this).parents("ul").show();
				$(this).parents("ul").siblings("a").addClass("active");
				$("#menu").height(70);
			}
			if ($(this).next().length != 0) {
				$(this).next().show();
				$("#menu").height(70);
			}
		}
		if ($(this).attr("href") == "") {
			$(this).click(function(event) {
				event.preventDefault();
				$("#menu a").removeClass("active");
				$("#menu a").next().hide();
				$(this).addClass("active");
				if ($(this).next().length != 0) {
					$(this).next().show();
					$("#menu").height(70);
				} else {
					$("#menu").height(26);
				}
			});
		}
	});
	if ($("#main").height() < 300) $("#main").height(300);
	$("#font #smaller").click(function(event) {
		event.preventDefault();
		var currentFontSize = $('#main').css('font-size');
		var currentFontSizeNum = parseFloat(currentFontSize, 10);
		var newFontSize = currentFontSizeNum * 0.8;
		$('#main').css('font-size', newFontSize);
	});
	$("#font #larger").click(function(event) {
		event.preventDefault();
		var currentFontSize = $('#main').css('font-size');
		var currentFontSizeNum = parseFloat(currentFontSize, 10);
		var newFontSize = currentFontSizeNum * 1.2;
		$('#main').css('font-size', newFontSize);
	});
	$("#footer .menu").html($("#menu").html());
	$("#footer .menu ul ul").hide();
	$(".slideshow").cycle({ fx: "fade" });
	$("#upcomingevents").height($("#theme").height());
});
