var index = {
	
	enter: function() {
	
		//check the date has been selected
		if( $F('dob_day').blank() || $F('dob_month').blank() || $F('dob_year').blank() ) {
			
			alert('Please enter your date of birth');
			return;
			
		}
		
		if( !this.old_enough() ) {
			
			alert('You must be 18 or over to enter this site');
			return;
			
		}
		
		//check the country
		if( $F('country').blank() ) {
			
			alert('Please select your country of residence');
			return;
			
			
		}
		
		//go to the relevant site
		location.href = $F('country') == 'uk' ? './uk/home' : './it/home';
		
		
	
	},
	
	old_enough: function() {
		
		//get today
		var today = new Date();
		
		//the date 18 years ago
		var min_age = new Date( today.getFullYear() - 18, today.getMonth(), today.getDate() );
		
		//and the date specififed in the form
		var date_given = new Date( $F('dob_year'), $F('dob_month') - 1, $F('dob_day') );
		
		//are the years more than 18? if yes then ok
		if( date_given.getFullYear() - min_age.getFullYear() < 0 ) return true;
		else if( date_given.getFullYear() - min_age.getFullYear() > 0 ) return false;
		else { //same year so look at month

			if( date_given.getMonth() - min_age.getMonth() < 0 ) return true;
			else if( date_given.getMonth() - min_age.getMonth() > 0 ) return false;
			else { //same month so look at date

				return date_given.getDate() <= min_age.getDate();
				
			}
			
		}
		
	}

}

