function openlegal(url)
{
	var pop = window.open(url, "LEGAL", "width=500,height=400,scrollbars=1,resizable=1,menubar=0");
	pop.focus();
}

function openPress()
{
	var pop = window.open("http://press.levelvodka.com", "LEGAL", "width=800,height=600,scrollbars=1,resizable=1,menubar=1");
	pop.focus();
}

var screenW = 1200, screenH = 800;

if (parseInt(navigator.appVersion)>3)
{
	screenW = screen.width;
	screenH = screen.height-27;
}
else if (navigator.appName == "Netscape" && parseInt(navigator.appVersion)==3 && navigator.javaEnabled())
{
	var jToolkit = java.awt.Toolkit.getDefaultToolkit();
	var jScreenSize = jToolkit.getScreenSize();
	screenW = jScreenSize.width;
	screenH = jScreenSize.height-27;
}

function fieldFocus(obj)
{
	obj.select();
}

function fieldKeyUp(event, obj)
{
	if ((event.keyCode < 48 || event.keyCode > 57) && (event.keyCode < 96 || event.keyCode > 105))
	{
		return;
	}
	if (obj.id == 'yy' && obj.value.length == 4)
	{
		document.getElementById('mm').select();
		return;
	}
	if (obj.id == 'mm' && obj.value.length == 2)
	{
		document.getElementById('dd').select();
		return;
	}
}

var age_no_limit = 'hr,th,vn';
var age_16_limit = 'aw,be,vg,fr,fx,it,jm,pt,es';
var age_19_limit = 'ca,kp,kr';
var age_20_limit = 'fi,is,jp,nz,no,se';
var age_21_limit = 'ee,hn,id,my,us';

function checkAge(server_year, server_month, server_day, country)
{
	var year = document.getElementById('yy').value;
	var month = document.getElementById('mm').value;
	var day = document.getElementById('dd').value;

	if (isNaN(year) || isNaN(month) || isNaN(day))
	{
		alert('Please enter your birthdate (must contain numbers only).\n\nSee our Terms and Conditions for further information.');
		return false;
	}

	year = parseInt(year, 10);
	month = parseInt(month, 10);
	day = parseInt(day, 10);

	if (year <= 7 || day > 31 || day <= 0 || month > 12 || month <= 0 || year <= 1900)
	{
		alert('Please enter your birthdate (must be a valid date).\n\nSee our Terms and Conditions for further information.');
		return false;
	}

	country = country.toLowerCase();

	var year_compare = 21;

	if (age_no_limit.indexOf(country) >= 0)
		year_compare = -1;
	else if (age_16_limit.indexOf(country) >= 0)
		year_compare = 16;
	else if (age_19_limit.indexOf(country) >= 0)
		year_compare = 19;
	else if (age_20_limit.indexOf(country) >= 0)
		year_compare = 20;
	else if (age_21_limit.indexOf(country) >= 0)
		year_compare = 21;

	server_year -= year_compare;

	var birth = year * 10000 + month * 100 + day;

	var legal = server_year * 10000 + server_month * 100 + server_day;

	if (birth <= legal)
	{
		openSite();
		return false;
	}

	alert('You have to be over '+year_compare+' to access this site.\n\nSee our Terms and Conditions for further information.');

	return false;
}