﻿function getLanguage( lang ){
	switch ( lang ) {
		case "dk":

			var sLink = '"composite-157.htm"';
			var sLang = '"dk"';
			document.getElementById("masQue18").innerHTML = "Du skal være over 18 år for at besøge denne hjemmeside.";

			document.getElementById("porfavor").innerHTML = "Venligst oplys land og fødselsdata:";

			document.getElementById("error").innerHTML = "Venligst oplys land og fødselsdata:";

			document.getElementById("chooseYear").innerHTML = "År";

			document.getElementById("a").innerHTML = "År";
 
			document.getElementById("m").innerHTML = "Måned";
   
			//document.getElementById("chooseMonth").innerHTML = "Måned";
     
			document.getElementById("d").innerHTML = "Dag";
			
			document.getElementById("footer").innerHTML = "<img height='63' width='698' alt='berries' src='/images/footer.gif'>";
     
			//document.getElementById("chooseDay").innerHTML = "Dag";
      
			document.getElementById("dk").className = "langSel";

			document.getElementById("se").className = "";

			document.getElementById("no").className = "";

			document.getElementById("uk").className = "";
 
			document.getElementById("visit").innerHTML = "<a href='javascript:checkForm("+ sLang +")' title='Besøg hjemmesiden her'>Besøg hjemmesiden her</a>";

			document.getElementById("read").innerHTML = "<a href='javascript:popUp("+ sLink +");' title='Læs Pernod Ricards ansvarserklæring her'>Læs Pernod Ricards ansvarserklæring her</a>";        
     

			break;
		case "se":
			var sLink = '"composite-159.htm"';
			var sLang = '"se"';
			document.getElementById("masQue18").innerHTML = "Du skal være over 18 år for at besøge denne hjemmeside.";
			document.getElementById("porfavor").innerHTML = "Venligst oplys land og fødselsdata:";
			document.getElementById("error").innerHTML = "Venligst oplys land og fødselsdata:";
			document.getElementById("chooseYear").innerHTML = "År";
			document.getElementById("a").innerHTML = "År";
			document.getElementById("m").innerHTML = "Måned";
			//document.getElementById("chooseMonth").innerHTML = "Måned";
			document.getElementById("d").innerHTML = "Dag";
			//document.getElementById("chooseDay").innerHTML = "Dag";
			document.getElementById("dk").className = "";
			document.getElementById("se").className = "langSel";
			document.getElementById("no").className = "";
			document.getElementById("uk").className = "";
			document.getElementById("visit").innerHTML = "<a href='javascript:checkForm("+ sLang +")' title='Besøg hjemmesiden her'>Besøg hjemmesiden her</a>";
			document.getElementById("read").innerHTML = "<a href='javascript:popUp("+ sLink +");' title='Læs Pernod Ricards ansvarserklæring her'>Læs Pernod Ricards ansvarserklæring her</a>";
			break;
		case "no":
			var sLink = '"composite-158.htm"';
			var sLang = '"no"';
			document.getElementById("masQue18").innerHTML = "Du skal være over 18 år for at besøge denne hjemmeside.";
			document.getElementById("porfavor").innerHTML = "Venligst oplys land og fødselsdata:";
			document.getElementById("error").innerHTML = "Venligst oplys land og fødselsdata:";
			document.getElementById("chooseYear").innerHTML = "År";
			document.getElementById("a").innerHTML = "År";
			document.getElementById("m").innerHTML = "Måned";
			//document.getElementById("chooseMonth").innerHTML = "Måned";
			document.getElementById("d").innerHTML = "Dag";
			//document.getElementById("chooseDay").innerHTML = "Dag";
			document.getElementById("dk").className = "";
			document.getElementById("se").className = "";
			document.getElementById("no").className = "langSel";
			document.getElementById("uk").className = "";
			document.getElementById("visit").innerHTML = "<a href='javascript:checkForm("+ sLang +")' title='Besøg hjemmesiden her'>Besøg hjemmesiden her</a>";
			document.getElementById("read").innerHTML = "<a href='javascript:popUp("+ sLink +");' title='Læs Pernod Ricards ansvarserklæring her'>Læs Pernod Ricards ansvarserklæring her</a>";
			break;
		case "uk":
			var sLink = '"composite-160.htm"';
			var sLang = '"uk"';
			document.getElementById("masQue18").innerHTML = "To visit this homepage you must be above 18.";
			document.getElementById("porfavor").innerHTML = "Please fill in your birth year and country:";
			document.getElementById("error").innerHTML = "Please fill in your birth year and country:";
			document.getElementById("chooseYear").innerHTML = "Year";
			document.getElementById("a").innerHTML = "Year";
			document.getElementById("m").innerHTML = "Month";
			//document.getElementById("chooseMonth").innerHTML = "Month";
			document.getElementById("d").innerHTML = "Day";
			//document.getElementById("chooseDay").innerHTML = "Day";
			document.getElementById("dk").className = "";
			document.getElementById("se").className = "";
			document.getElementById("no").className = "";
			document.getElementById("uk").className = "langSel";
			document.getElementById("footer").innerHTML = "<img height='63' width='698' alt='berries' src='/images/footeruk.gif'>";
			document.getElementById("visit").innerHTML = "<a href='javascript:checkForm("+ sLang +");' title='Visit site'>Visit site </a>";
			document.getElementById("read").innerHTML = "<a href='javascript:popUp("+ sLink +");' title='Read the Pernod Ricard Responsibility statement here'>Read the Pernod Ricard Responsibility statement here</a>";
			break;
		default:
			
	}
}

function popUp( sUrl ){
	window.open(sUrl,"my_new_window", "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, copyhistory=yes, width=550, height=560, top=200, left=300")
}


function renderYears(){
	var i 
	for ( i = 1930; i < 2009; i++ ){
		document.write('<option value="' + i + '">' + i + '</option>')
	}
}

function renderMonths(){
	var i 
	for ( i = 1; i < 13; i++ ){
		document.write('<option value="' + i + '">' + i + '</option>')
	}
}

function renderDates(){
	var i 
	for ( i = 1; i < 32; i++ ){
		document.write('<option value="' + i + '">' + i + '</option>')
	}
}

function renderCountries()
{
	var countries = 
	{
		"Afghanistan":0,
		"Albania":18,
		"Algeria":18,
		"Andorra":18,
		"Angola":18,
		"Antigua and Barbuda":18,
		"Argentina":18,
		"Armenia":18,
		"Australia":18,
		"Austria":18,
		"Azerbaijan":18,
		"Bahamas":18,
		"Bahrain":21,
		"Bangladesh":0,
		"Barbados":18,
		"Belarus":21,
		"Belgium":18,
		"Belize":18,
		"Benin":18,
		"Bhutan":18,
		"Bolivia":18,
		"Bosnia and Herzegovina":18,
		"Botswana":18,
		"Brazil":18,
		"Brunei Darussalam":0,
		"Bulgaria":18,
		"Burkina Faso":18,
		"Cambodia":18,
		"Cameroon":18,
		"Canada":19,
		"Cape Verde":18,
		"Central African Republic":18,
		"Chad":18,
		"Chile":18,
		"China":18,
		"Colombia":18,
		"Congo":18,
		"Costa Rica":18,
		"Côte d´Ivoire":18,
		"Croatia":18,
		"Cuba":18,
		"Cyprus":18,
		"Czech Republic":18,
		"Danmark":18,
		"Djibouti":18,
		"Dominica":18,
		"Dominican Republic":18,
		"Ecuador":18,
		"Egypte	":21,
		"El Salvador":18,
		"Equatorial Guinea":18,
		"Estonia":18,
		"Fiji":18,
		"Finland":20,
		"France":18,
		"French Polynesia":18,
		"Gabon":18,
		"Gambia":18,
		"Georgia":18,
		"Germany":18,
		"Ghana":18,
		"Greece":18,
		"Grenada":18,
		"Guatemala":18,
		"Guinea":18,
		"Guinea-Bissau":18,
		"Guyana":18,
		"Haiti":18,
		"Honduras":18,
		"Hong Kong":18,
		"Hungary":18,
		"Island":20,
		"India":25,
		"Indonesia":21,
		"Iran":0,
		"Irak":0,
		"Ireland":18,
		"Israel":18,
		"Italy":18,
		"Jamaica":18,
		"Japan":20,
		"Jordan":0,
		"Kazakhstan":18,
		"Kenya":18,
		"Kuwait":21,
		"Kyrgyzstan":18,
		"Laos":18,
		"Latvia":18,
		"Lebanon":18,
		"Lesotho":18,
		"Liberia":18,
		"Libya":0,
		"Liechtenstein":18,
		"Lithuania":18,
		"Luxembourg":18,
		"Macedonia":18,
		"Madagascar":18,
		"Malawi":18,
		"Malaysia":18,
		"Maldives":18,
		"Mali":18,
		"Malta":18,
		"Mauritania":18,
		"Mauritius":18,
		"Mexico":18,
		"Micronesia":18,
		"Moldova":18,
		"Monaco":18,
		"Mongolia":21,
		"Morocco":18,
		"Mozambique":18,
		"Namibia":18,
		"Nepal":18,
		"Netherlands":18,
		"New Zealand":18,
		"Nicaragua":19,
		"Niger":18,
		"Nigeria":21,
		"North Korea":18,
		"Norway":20,
		"Oman":21,
		"Ouganda":18,
		"Ouzbekistan":0,
		"Pakistan":0,
		"Panama":18,
		"Papua New Guinea":18,
		"Paraguay":20,
		"Peru":18,
		"Philippines":18,
		"Poland":18,
		"Portugal":18,
		"Qatar":18,
		"Romania":18,
		"Russia":18,
		"Rwanda":18,
		"Saint Kitts and Nevis":18,
		"Saint Lucia":18,
		"Saint Vincent and the Grenadines":18,
		"Samoa":21,
		"San Marino":18,
		"Sao Tome and Principe":18,
		"Saudi Arabia":0,
		"Senegal":18,
		"Serbia and Montenegro":18,
		"Seychelles":18,
		"Sierra Leone":18,
		"Singapore":18,
		"Slovakia":18,
		"Slovenia":18,
		"Somalia":18,
		"South Africa":18,
		"South Korea":19,
		"Spain":18,
		"Sri Lanka":18,
		"Sudan":0,
		"Suriname":0,
		"Swaziland":18,
		"Sweden":20,
		"Switzerland":18,
		"Syria":18,
		"Tanzania":18,
		"Taiwan":18,
		"Thailand":20,
		"Togo":18,
		"Tonga":18,
		"Trinidad and Tobago":18,
		"Tunisia":0,
		"Turkey":18,
		"Turkmenistan":18,
		"Tuvalu":18,
		"Uganda":18,
		"Ukraine":18,
		"United Arab Emirates":21,
		"United Kingdom":18,
		"USA":21,
		"Uruguay":18,
		"Uzbekistan":0,
		"Vanuatu":18,
		"Venezuela":18,
		"Vietnam":18,
		"Yemen":0,
		"Zambia":18,
		"Zimbabwe":18
	}
	
	for(key in countries)
	{ 
		if(key == "Danmark")
		{
			document.write('<option selected="selected" value="' + countries[key] + '">' + key + '</option>');	
		}
		else
		{
	  		document.write('<option value="' + countries[key] + '">' + key + '</option>');
		}
 	}
}


function checkForm( oLang ) {

	var a =''
	var oForm = document.forms[0]

	if(oForm.ano.value == "-1" || oForm.mes.value == "-1" || oForm.dia.value == "-1") a = ("fillIn");
	//if(oForm.ano.value == "-1") a = ("fillIn");

	if ( a != '' ) 
	{
		document.getElementById("error").style.display = "block";
		document.getElementById("error").style.visibility = "visible";
	}
	else{
		checkAge( oLang );
	}
}

function checkAge( oLang ){
	/* the minumum age you want to allow in */
	var minAge = document.forms["age_form"]["country"].value*1; //18;

	// if not allowed access, redirect right away
	if(minAge === 0)
	{
		var loc = '';
		switch ( oLang ) 
		{
			case "dk":
				loc = "composite-115.htm"
			break;
			case "se":
				loc = "composite-159.htm"
			break;
			case "no":
				loc = "composite-158.htm"
			break;
			case "uk":
				loc = "composite-160.htm"
			break;
			default:
				loc = "composite-115.htm"
			break;
		}
		location.href = loc;
		return;
	}
	var bday 	= parseInt(document.forms["age_form"]["dia"].value);
	var bmo 	= parseInt(document.forms["age_form"]["mes"].value);
	bmo = bmo - 1;
	var byr 	= parseInt(document.forms["age_form"]["ano"].value);
	var byr;
	var age;
	var now 	= new Date();
	tday		= now.getDate();
	tmo			= (now.getMonth());
	tyr			= (now.getFullYear());

	
	if((tmo > bmo)||(tmo==bmo & tday>=bday))
	{
		age=byr
	}
	else
	{
		age=byr+1
	}
	var myAge = tyr-age;
	
	if(myAge >= minAge)
	{
		switch ( oLang ) 
		{
			case "dk":
				document.location.href = "gammeldansk"
			break;
			case "uk":
				//document.location.href = "composite-1215.htm"
				document.location.href = "composite-58.htm"
			break;
		}
	}
	/*FOR UNG*/
	else
	{
		switch ( oLang ) 
		{
			case "dk":
				document.location.href = "composite-115.htm"
			break;
			case "se":
				document.location.href = "composite-159.htm"
			break;
			case "no":
				document.location.href = "composite-158.htm"
			break;
			case "uk":
				document.location.href = "composite-160.htm"
			break;
		}
	}
	
}
