// date functions
var monthtext=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sept','Oct','Nov','Dec'];

function populatedropdown(dayfield, monthfield, yearfield){
var today=new Date()
var dayfield=document.getElementById(dayfield)
var monthfield=document.getElementById(monthfield)
var yearfield=document.getElementById(yearfield)
for (var i=0; i<31; i++)
dayfield.options[i]=new Option(i, i+1)
dayfield.options[today.getDate()]=new Option(today.getDate(), today.getDate(), true, true) //select today's day
for (var m=0; m<12; m++)
monthfield.options[m]=new Option(monthtext[m], monthtext[m])
monthfield.options[today.getMonth()]=new Option(monthtext[today.getMonth()], monthtext[today.getMonth()], true, true) //select today's month
var thisyear=today.getFullYear()
for (var y=0; y<20; y++){
yearfield.options[y]=new Option(thisyear, thisyear)
thisyear-=1
}
yearfield.options[0]=new Option(today.getFullYear(), today.getFullYear(), true, true) //select today's year
}


$(document).ready(function() {
	$("#showdates table tr").hover(
	function() {
		$("td",this).addClass("hover");
	},
	function() {
		$("td",this).removeClass("hover");
	});
	
	// open all external links in a new window
	$("a[href^='http://']").attr("target","_blank");
	
	// Highlight current page in nav
	$("#headnav li").removeClass("current");
	$("#headnav li a").each(function() {
		urlArray = window.location.href.split("/");
		if($(this).attr("href") == "/"+urlArray[urlArray.length-2]) {
			$(this).parents("li").addClass("current");
		} else if(urlArray[urlArray.length-1] == "index.php") {
			$("#headnav li:first").addClass("current");
		} else {
			$("#actionlinks li a").each(function() {
				urlArray = window.location.href.split("/");
				if($(this).attr("href") == "/"+urlArray[urlArray.length-2]) {
					$("#actionlinks li").removeClass("current");
					$(this).parents("li").addClass("current");
				}
			});		
		}
	});
	
	// Fix the footer links
	$("#footerlinks li:first").addClass("first");
	
	// sticky footer
	function fixFooter() {
		if($(window).height() > $("#container").height()) {
			$("#container").height($(window).height() - 30);
			$("#container").css({"padding-bottom":"30px"});
			$("#footer").css({
				"position":"absolute",
				"top": ($("#container").height() - ($("#footer").outerHeight()+20))
			});
		}
	}

	$(window).resize(function() {
		fixFooter();
	});
	
	window.setTimeout(function() {
		fixFooter();
	}, 50);

//	populatedropdown("dob_day", "dob_month", "dob_year");
});
