/** age verification functions and variables */
var cookieName = 'col_solare.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();
	// start flash
	getSWF("homepage").startFlash();

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

function displayVerification() {
	$.openDOMWindow({ 
			borderSize: 0,
			overlayColor: '#000',
			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/' 
		});
}

function getSWF(swfID) {
	if (navigator.appName.indexOf("Microsoft") != -1) {
		return window[swfID];
	} else {
		return document[swfID];
	}
}

function onFlashLoaded() {
	// if there is a cookie
	if(checkCookie(cookieName)) {
		// start flash
		getSWF("homepage").startFlash();
	}
}

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

});
