function get_cookie (cookie_name) {
	var results = document.cookie.match ('(^|;) ?' + cookie_name + '=([^;]*)(;|$)');
	if (results) return (unescape(results[2]));
	else return null;
}

$(document).ready(function(){
	$("#age_check_bg").height($(document).height());
	if (get_cookie('varified') != "yes") {
		$("#age_check_bg").show();
		window.document.body.style.bgColor = "#000000";
	}
	$("#check_age").click(function(){
		var min_age = 21;
		var year = $("#year").val();
		var month = $("#month").val();
		var day = $("#day").val();
		if (year == "YYYY" || month == "MM" || day == "DD") alert("Please fill out the age form.");
		else {
			var theirDate = new Date(year, month-1, day);
			var today = new Date;
			var reqDate = new Date(today.getFullYear()-min_age, today.getMonth(), today.getDay());
			if ((reqDate - theirDate) > 0) {
				$("#age_check_bg").slideUp();
				document.cookie = "varified=yes";
			} else {
				alert("We are sorry, but you do not meet the age requirment for this page.");
				window.location = "http://www.acceptresponsibility.org/";
			}
		}
		
	});
});