Cufon.replace('h1', {fontFamily: 'Segoe Script', textShadow: '#183614 2px 2px'});
Cufon.replace('h2', {fontFamily: 'Segoe Script', textShadow: '#183614 2px 2px'});
Cufon.replace('h3', {fontFamily: 'Segoe Script', textShadow: '#183614 2px 2px'});
Cufon.replace('h4', {fontFamily: 'Segoe Script'});
Cufon.replace('.marydale', {fontFamily: 'Marydale', lineHeight: '1.2'});

$(document).ready(function()
{
	//CHECK COOKIE AND SHOW AGE GATE IF NEEDED
	var cookieName = "MenageATrois";

	if($.cookie(cookieName) != "AgeVerified")
	{
		var ageGate = '<div id="ageGate-container">' + 
					'<div id="ageGate">' +
					'<img class="logo" src="images/menage-logo.png" width="208" height="52" alt="Menage a Trois" />' +
					'<h1 id="welcomeLabel">Welcome</h1>' +
					'<p class="marydale">If you&#39;re 21, we invite you to enter our website. Please verify that you are of age or older by entering your birthdate below.</p>' +
					'<form id="age-gate-form" action="">' +
						'<fieldset><label for="age-month">MONTH</label><br /><input id="monthInput" type="text" name="age-month" class="age-gate-input" maxlength="2" /></fieldset>' +
						'<fieldset><label for="age-date">DAY</label><br /><input id="dateInput" type="text" name="age-date" class="age-gate-input" maxlength="2" /></fieldset>' +
						'<fieldset><label for="age-year">YEAR</label><br /><input id="yearInput" type="text" name="age-year" class="age-gate-input" maxlength="2" /></fieldset>' +
						'<input id="ageSubmit" type="image" src="images/age-gate-submit.png" name="submit" />' +
					'</form>' +
					'</div>' +
				  '</div>';

		$.modal(ageGate, {overlayClose: false, escClose: false, opacity: 70, focus: true});

		Cufon.replace('#welcomeLabel', {fontFamily: 'Segoe Script', textShadow: '#dfb932 2px 2px'});
		Cufon.replace('#ageGate p', {fontFamily: 'Marydale'});
		Cufon.now();

		//CHECK AGE ON FORM SUBMISSION
		$("#age-gate-form").submit(function(e)
		{
			e.preventDefault();

			var date = $("#dateInput").val();
			var month = $("#monthInput").val();
			var year = '19' + $("#yearInput").val();
			var age = 21;

			var mydate = new Date();
			mydate.setFullYear(year, month-1, date);

			var currdate = new Date();
			currdate.setFullYear(currdate.getFullYear() - age);

			if((currdate - mydate) < 0)
			{
				alert("Sorry, only persons over the age of " + age + " may enter this site");
				return false;
			}

			$.cookie(cookieName, 'AgeVerified');
			$.modal.close();
		});
	}

	$.localScroll.defaults.axis = "x";;
	$.localScroll({hash:true});

	if(location.hash == "")
	{
		location.hash = "menage";
	}

	$.localScroll.hash();

	$.swapImage(".swapImage", true, true, "mouseenter", "mouseleave");

	if(GBrowserIsCompatible())
	{
		var point = new GLatLng(38.421241, -122.390116);

		var map = new GMap2(document.getElementById("map"));
		map.setCenter(point, 13);
		map.setUIToDefault();

		map.addOverlay(new GMarker(point));
	}

	$('.smallBottle').hover(function()
	{

		$(this).parent().parent().find('h4.bottleNavLabel').text($(this).attr('alt'));
		Cufon.replace('h4', {fontFamily: 'Segoe Script'});

		$(this).parent().parent().find('h4.bottleNavLabel').css("visibility", "visible");
	},
	function()
	{
		$(this).parent().parent().find('h4.bottleNavLabel').css("visibility", "hidden");
	});

	$('.smallBottle').mouseenter(function()
	{

		$(this).parent().parent().find('h4.bottleNavLabel').text($(this).attr('alt'));
		Cufon.replace('h4', {fontFamily: 'Segoe Script'});

		$(this).parent().parent().find('h4.bottleNavLabel').css("visibility", "visible");
	});

	$('.smallBottle').mouseleave(function()
	{
		$(this).parent().parent().find('h4.bottleNavLabel').css("visibility", "hidden");
	});
	
	$('.top-rounded').corner(
	{
		tl: {radius: 6},
		tr: {radius: 6},
		bl: {radius: 0},
		br: {radius: 0},
		antiAlias: true,
		autoPad: true
	});
	
	$('.rounded').corner(
	{
		tl: {radius: 6},
		tr: {radius: 6},
		bl: {radius: 6},
		br: {radius: 6},
		antiAlias: true,
		autoPad: true
	});

	var sloc = new locator({div:'shopForm', style:'inline', css:'none'});
	sloc.show();
});

function showPrivacyPolicy()
{
	$("#privacy-policy-container").modal( 
	{
		opacity: 75,
		escClose: true, 
		overlayClose: true,
		onClose: function()
		{
			hidePrivacyPolicy();
		},
		onShow: function()
		{
			Cufon.replace('.segoe', {fontFamily: 'Segoe Script'});
		}
	});
	
	return false;
}

function hidePrivacyPolicy()
{
	$.modal.close();
}

function showTerms()
{
	$("#terms-container").modal( 
	{
		opacity: 75,
		escClose: true, 
		overlayClose: true,
		onClose: function()
		{
			hidePrivacyPolicy();
		},
		onShow: function()
		{
			Cufon.replace('.segoe', {fontFamily: 'Segoe Script'});
		}
	});
	
	return false;
}

function hideTerms()
{
	$.modal.close();
}
