function birthdayWarning() {
	if ($('#birthdaymonth').val() && $('#birthdayday').val()) {
		var oneDay = 1000*60*60*24
		var now = new Date();
		var birthday = new Date(now.getFullYear(), $('#birthdaymonth').val()-1, $('#birthdayday').val());
		daysToBirthday = Math.ceil((birthday - now)/oneDay);
		if (daysToBirthday >= 0 && daysToBirthday <= 7) {
			if ($('#birthday-warning').length == 0) {
				var div = document.createElement('div');
				div.id = 'birthday-warning';
				div.className = 'inline-warning';
				div.appendChild(document.createTextNode('Your birthday is less than 1 week from now. You will receive your birthday offer next year.'))
				$('#birthday-picker').append(div);
			}
			$('#birthday-warning').slideDown(250)
		} else {
			$('#birthday-warning').slideUp(250)
		}
	}
}

function showMap() {
	$('#zip').blur();
	if (!jmmap.map) {
		jmmap.setup('map'); // (div)
	}
	jmmap.showStoresInZip($('#zip').val(),true); // zip code, pickClosest
}

$(document).ready(function () {
	// detect gmaps compatible browser
	if (GBrowserIsCompatible()) {
		//if zip auto-filled, show map
		if ($('#zip').val().length == 5) {
			showMap();
		}
		// check zip keups to show maps
		$('#zip').keyup(function() {
			if (this.value.length == 5) {
				showMap();
			}
		});
		if ($('#storeno').val()) {
			if (!jmmap.map) {
				jmmap.setup('map'); // (div)
			}
			jmmap.showSingleStore($('#storeno').val())
		}
		window.onunload = GUnload;
	}
	$('#birthdaymonth').change(birthdayWarning);
	$('#birthdayday').change(birthdayWarning);
});
