/** age verification functions and variables */
var cookieName = 'red_diamond_winery.age_verification';

function checkCookie() {
	return $.cookie(cookieName);
}

function passValidation(checked) {
	if (checked != false) {
		// They checked the box; the cookie is set for 30 days
		$.cookie(cookieName,true, { expires: 30,path: '/' });
	} else {
	$.cookie(cookieName,true,{path: '/'});
	}
	
	// get rid of the modal and they're on their way:
	$.closeDOMWindow();

	// or, force a reload of the page to enable Flash (if necessary)
//	location.reload(true);
	
}

function displayVerification() {
	$.openDOMWindow({ 
			borderSize: 0,
			overlayColor: '#261C16',
			overlayOpacity:'75',
			draggable: 0,
			modal: 1,
			width: 450,
			height: 387,
			loader:1,
			modal:1, 
			loaderImagePath:'/img/verify/spinner.gif', 
			loaderHeight:16, 
			loaderWidth:17, 
			windowSource:'iframe',
			windowPadding:0,
			windowSourceURL: '/verify/' 
		});
}

$(document).ready(function(){
	
	// if there is no cookie put up the age verification modal
	if(!checkCookie(cookieName)) {
		displayVerification();
	}

});
