<!--
var expireDate = new Date();
var year = expireDate.getYear(); 
year = (year < 1900) ? year + 1900 : year;
expireDate.setYear(year + 3);

function cookieChck() {
	var allcookies = document.cookie;
  	var detectCookie = allcookies.indexOf("2k_maf2_check=");
	if (detectCookie != -1) {
		
		var start = detectCookie + 14; //start of cookie value
		var end = allcookies.indexOf(";",start); //end of cookie value
	
		if (end==-1) end = allcookies.length;
		var userAge = allcookies.substring(start,end); //extract the birthdate
		userAge = unescape(userAge); //decode value
		var age = new Date(userAge);
	
	//		alert(age);
	
		//check if over 17
		
		if (over17(age)){
			var lang_cookie = allcookies.indexOf("2k_lang_pref=");
			var start = lang_cookie + 13; //start of cookie value
			var end = allcookies.indexOf(";",start); //end of cookie value
	
			if (end==-1) end = allcookies.length;
			var lang_pref = allcookies.substring(start,end); //extract the birthdate
			location.replace("enter.html?lang=" + lang_pref );
			
		}
		else	
		{
			location.replace("sorry.html");
		}
	}
	else {checkDate();}
}



//creates a cookie with the values passed in
function my_setCookie(nam, val, expire, domain, path) {
	var cookie_str = "";
	cookie_str += nam + "=" + escape(val);
	//cookie_str += "; domain=" + domain;//deleted because the cookie wasn't 
	//cookie_str += "; path=" + path;    //getting detected and they're not needed
	cookie_str += "; expires=" + expire.toGMTString();
	document.cookie = cookie_str;
};



function setCookie() {    
	//if the date is valid, create a cookie
	var user_age = new Date();
	user_age.setMonth(document.ValidForm.birthmonth[document.ValidForm.birthmonth.selectedIndex].value-1);
	user_age.setDate(document.ValidForm.birthday[document.ValidForm.birthday.selectedIndex].value);
	user_age.setFullYear(document.ValidForm.birthyear[document.ValidForm.birthyear.selectedIndex].value);
	my_setCookie("2k_maf2_check", user_age.toUTCString() , expireDate, ".2kgames.com", "/");
} 

function setLanguangeCookie() {
	lang = document.ValidForm.lang[document.ValidForm.lang.selectedIndex].value;
	my_setCookie("2k_lang_pref", lang , expireDate, ".2kgames.com", "/");
}


function over17(age){
	var ageDate = new Date();
	var ageYear = ageDate.getFullYear()-17;
	ageDate.setFullYear(ageYear);
	
	if (age <= ageDate) {return true;}
	else {return false;}
}


function checkDate()
{
var age = new Date();
age.setMonth(document.ValidForm.birthmonth[document.ValidForm.birthmonth.selectedIndex].value-1);
age.setDate(document.ValidForm.birthday[document.ValidForm.birthday.selectedIndex].value);
age.setYear(document.ValidForm.birthyear[document.ValidForm.birthyear.selectedIndex].value);
	if ((document.ValidForm.birthday[document.ValidForm.birthday.selectedIndex].value != 0) && (document.ValidForm.birthmonth[document.ValidForm.birthmonth.selectedIndex].value !=0) && (document.ValidForm.birthyear[document.ValidForm.birthyear.selectedIndex].value != 0))
	{
		setCookie();
		setLanguangeCookie();
		if (over17(age)){
			location.replace("enter.html?lang=" + document.ValidForm.lang[document.ValidForm.lang.selectedIndex].value);
		}
		else	
		{
			location.replace("sorry.html");
		}
	}
}

window.onload=cookieChck;
//-->
