var glenGroupReferrers = ['www.glenmorangie.de'];

function initAgeVerification(){
	//init prettyPhoto
	$("a[rel^='prettyPhoto']").prettyPhoto( { theme:'dark_square', modal:true, callback:function(){} } );
	
	
	// Set pretty photo height
	// Width based on browser
	var iframeWidth;
	if(userAgent.match('Internet Explorer')){
		iframeWidth = 595;
	} else {
		iframeWidth = 474;
	}
	
	// Height based on locale
	var iframeHeight = (locale == 'german') ? iframeHeight = 560 : iframeHeight = 467;
	
	
	if(popUpRequired()==false){
		// set cookie
		$.cookie('old_enough',1, { expires: 365, domain: document.domain});		
	} else {
		// check for cookie
		// no cookie throw the age verification overlay
		if($.cookie('old_enough')==null){
			$.prettyPhoto.open('/age-verification?iframe=true&width=510&height='+iframeHeight+'');
			// hide close button
			$('.pp_close').css('display','none');
		}
	}
};

function popUpRequired(){
	var launchPopup = true;
	// check if user is mobile
	if(globalConfig.is_mobile_user==true){
		launchPopup = false;
	}
	// check referrer for gelnmorangie group websites
	if(checkRef()==false){
		launchPopup = false;
	}
	// return value	
	return launchPopup;
}

function checkRef(){
	var refParts = document.referrer.toLowerCase().split('/');
	return ($.inArray( refParts[2],glenGroupReferrers)!=-1) ? false : true;
}
