	/**
	* 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;
		
		$("#mask").click(function(){
			hidePopin();
		});
	}

	/**
	* Access site home page
	*/
	function gotoSite(isEntrance,siteId)
	{
		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;
		}
				
		// no log for "other" options
		if ( $("#birthDate").attr("class")=="active" ) 
		{
			//check fields
			if($("#year").val()=='yyyy' || $("#year").val()=='')	{ alert('Please fill the year');return false;}
			if($("#month").val()=='mm' || $("#month").val()=='') 	{ alert('Please fill the month');return false;}
			if($("#day").val()=='dd' || $("#day").val()=='') 		{ alert('Please fill the day');return false;}
			
			//check date
			
			if (urlSite=="http://www.cointreau.us"){
				
				
				if( compareDates( $("#day").val() , $("#month").val() , $("#year").val() ) == true )
			{
			if(urlSite!='http://www.cointreaupolitan.fr') logProfil(COE_I_ID);
				
				if(isEntrance) location = urlSite;
				else hidePopin();
				
				// show home animation for some specific site
				
			if( isSpecialHomePopin(siteId) ) showShakerPopin();
			
				return false;
			} 
			else {
				alert('Sorry, you are not authorized to enter this site.');
				return false;	
			}
			
			
			}else{
			
			
			
			if( compareDates2( $("#day").val() , $("#month").val() , $("#year").val() ) == true )
			{
			if(urlSite!='http://www.cointreaupolitan.fr') logProfil(COE_I_ID);
				
				if(isEntrance) location = urlSite;
				else hidePopin();
				
				/*if (urlSite=="http://www.cointreau.nl"){
					if( isSpecialHomePopinnl(siteId) ) showShakerPopin();
				}else{
					if( isSpecialHomePopin(siteId) ) showShakerPopin();
					
				}*/
				
				if (urlSite=="http://www.cointreau.nl"){
					if( isSpecialHomePopinnl(siteId) ) showShakerPopin();
				}
				if (urlSite=="http://www.cointreau.com/home-26.html"){
				
									
					if( isSpecialHomePopinn2(siteId) ) showShakerPopin();
				}
				
				
				
				// show home animation for some specific site
				
			
				return false;
			} 
			else {
				alert('Sorry, you are not authorized to enter this site.');
				return false;	
			}
		}
		
		
		
		}
		else 
		{
			if(urlSite!='http://www.cointreaupolitan.fr') logProfil(COE_I_ID);
			
			if(isEntrance) location = urlSite;
			else 		   
			{
				hidePopin();
				
				// show home animation for some specific site
				if( isSpecialHomePopin(siteId) ) showShakerPopin();
				
			}
			
			return false;
		}
	}
	
	/**
	 * Test if the site need to load a special popin on the homepage
	 * 
	 * @param integer siteId 
	 * @return boolean
	 */
	function isSpecialHomePopin(siteId)
	{
		return  $("#homePage").is("body")  && 
				
				(
						siteId == 800001 //|| // US
						//siteId == 800436 //|| NL
						//DISABLE siteId == 800334 || // FR
						//DISABLE siteId == 800108 || // BE_FR
						//DISABLE siteId == 800215 || // BE_NL
						//DISABLE siteId == 800537    // ES
				); 
			  
	}
	function isSpecialHomePopinnl(siteId)
	{
		return  $("#homePage").is("body")  && 
				
				(
						siteId == 800436 //|| // NL
						//siteId == 800436 //|| NL
						//DISABLE siteId == 800334 || // FR
						//DISABLE siteId == 800108 || // BE_FR
						//DISABLE siteId == 800215 || // BE_NL
						//DISABLE siteId == 800537    // ES
				); 
			  
	}
		function isSpecialHomePopinn2(siteId)
	{
		return  $("#homePage").is("body")  && 
				
				(
						siteId == 2 //|| // NL
						//siteId == 800436 //|| NL
						//DISABLE siteId == 800334 || // FR
						//DISABLE siteId == 800108 || // BE_FR
						//DISABLE siteId == 800215 || // BE_NL
						//DISABLE siteId == 800537    // ES
				); 
			  
	}
	
	/**
	* 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;

		}
	}
	function compareDates2(nDay, nMonth, nYear) {
		// age souhaité
		var age 	= "18";
		
		
		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) > 18) ? true : false;

		}
	}
	
	/**
	* Test if the submitted date is old enough
	*/
	function compareDates_old(day,month,year) {
		// age souhaité
		var age = "21";
		
		var d = new Date();
		todayYear = d.getFullYear();
		todayMonth = d.getMonth();
		todayDay = d.getDate();
		
		if(year=="" || year<="1900" || month=="" || month>="13" || day=="" || day>="32") {
			return false;
		} else { 
			month = month-1;
			if(todayYear - year >= age) {
				if(month < todayMonth) { return true; }
				if(month == todayMonth) {
					if(day <= todayDay) { return true; } else {	return false; }
				} 
				if(month > todayMonth) { return true; }
			} else { return false; }
		}
	}
	

	/**
	* Ini special form for US site
	* Test if the submitted date is old enough
	*/
	function initIdentification() 
	{
		$("#birthDate").hide();
		
		//if the current site is the US we display the special form
		if( true ||
			(
				$("select option:selected").attr("id") == "profilCurrentSite" &&
				$("select option:selected").attr("class") == "needBirthDate"
			)
		)
		{
			//
			$("#birthDate").show();
			$("#birthDate").addClass("active");
		}
		
		$("#birthDate").parent().css("position","relative");
	}
	