	/**
	* Log Access profil
	*/
	function logProfil(coe_i_id)
	{
		var html = $.ajax({
		 url: "/index.php?coe_i_id="+coe_i_id+"&ctrl=identification&act=identification",
		 async: false
		}).responseText;
		
		ISPROFILLOG = true;
		
	}
	
	function tabInputs() {
		if (jQuery('.popin-country')[0]) {
			var filled = function(id) {
				jQuery(id).keyup(function(){
					if (jQuery(this).attr('value').length == 2
					&& !jQuery(id).attr('filled')
					&& !isNaN(parseInt(jQuery(this).attr('value')))) {
						jQuery(id).parent().next().children()[1].select();
						jQuery(id).attr('filled','true')
					}
				});
			};
			filled('#sn-datebirth-month');
			filled('#sn-datebirth-day');
			
		}
	}

	/**
	* Access site home page
	*/
	function gotoSite(isEntrance)
	{
		var oSelectCountry 	= document.getElementById('country');
		var urlSite 		= oSelectCountry.options[oSelectCountry.selectedIndex].value;
		var isCurrentSite 	= oSelectCountry.options[oSelectCountry.selectedIndex].id == 'profilCurrentSite';
		
		if(urlSite=='')
		{
			alert(LABEL_ENTRANCE_FORM_ERROR_COUNTRY)
			return false;
		}
		
		if(!isCurrentSite)
		{
			location = urlSite;
		}
		
		//check fields
		var helpUser = function(id) {
			if (jQuery(id).val().length == 1) {
				jQuery(id).val(0+jQuery(id).val());
			}
		};
		helpUser('#sn-datebirth-day');
		helpUser('#sn-datebirth-month');
		
		if($("#sn-datebirth-year").val()=='YYYY' || $("#sn-datebirth-year").val()=='') { 
			alert('Please fill the year');
			return false;
		}
		if($("#sn-datebirth-month").val()=='MM' || $("#sn-datebirth-month").val()=='') { 
			alert('Please fill the month');
			return false;
		}
		if($("#sn-datebirth-day").val()=='DD' || $("#sn-datebirth-day").val()=='') { 
			alert('Please fill the day');
			return false;
		}
		
		//check date
		if( compareDates( $("#sn-datebirth-day").val() , $("#sn-datebirth-month").val() , $("#sn-datebirth-year").val() ) == true ) {
			logProfil(COE_I_ID);
			recallJavascript();
			closePopin();
		} 
		else {
			var answer = confirm('Sorry, you are not authorized to enter this site.\nDo you like to quit Metaxa\'s website ?');
			if (answer)
				window.location = 'http://www.google.com';
		}
	}

	/**
	* Test if we change to another site from the current one 
	* As the current site is selected, by changing the select option mean that we access another site
	* then we have to redirect the user to the correct home page
	*/
	function changeSite()
	{
		var oSelectCountry 	= document.getElementById('country');
		var urlSite 		= oSelectCountry.options[oSelectCountry.selectedIndex].value;
		location 			= urlSite;
	}
	
	/**
	* Test if the submitted date is old enough
	*/
	function compareDates(nDay, nMonth, nYear) {
		// age souhaité
		var age 	= "21";
		
		
		var d 		= new Date();
		todayYear 	= d.getFullYear();
		todayMonth 	= d.getMonth();
		todayDay 	= d.getDate();
		
		if(nYear=="" || nYear<="1900" || nMonth=="" || nMonth>="13" || nDay=="" || nDay>="32") {
			return false;
		} else { 

			var nCurrentDate = d.getTime();
			var nBirthday = new Date(nYear, nMonth, nDay);
			var nTimeElapsed = nCurrentDate - nBirthday; // time in milliseconds
			var nMillisecondsPerYear = 365 * 24 * 60 * 60 * 1000;
	
			return ((nTimeElapsed / nMillisecondsPerYear) > 21) ? true : false;

		}
	}