

	var histoire = {
	
		init : function() {

			if (pageId == 'HomePage')
				jQuery('a#BtnMentionsLegales').click(function() { histoire.mentions(); return false; });
		
			if (pageId == 'Contact')
				jQuery('form#FormContact').submit(function() { return histoire.contactSend(); });

		},
	
	
		mentions : function() {
		
			jQuery('body').prepend('<div id="Alert" class="mentonsLegalesBox"></div>');
			jQuery('#Alert').load('lib/mentions-legales.inc.html', function() {
				jQuery('a#BtnAlertClose').click(function() { histoire.alertClose(); return false; });
			});
		
		},
		
		alertClose : function() {
			jQuery('#Alert').fadeOut(500, function() {
				jQuery('#Alert').remove();
			});
		},
		
		
		contactSend : function() {
			var error = '';
			
			if (jQuery('input#prenom').val() == '')
				error += "Champs prenom vide.\n";
			
			if (jQuery('input#nom').val() == '')
				error += "Champs nom vide.\n";
			
			if (jQuery('input#mail').val() != '') {

				var emailReg = /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/;
				emailReg.ignoreCase =  true;

				if( !emailReg.test($('input#mail').val()) )
					error += "email invalide\n";
			}
			else
				error += "Champs mail vide ou adresse invalide.\n";
			
			if ( (jQuery('input#sujet').val() == '') || (jQuery('input#sujet').val().length < 5) )
				error += "Champs sujet vide ou trop court (minimum 5 caractères).\n";

			
			if ( (jQuery('textarea#message').val() == '') || (jQuery('textarea#message').val().length < 15) )
				error += 'Champs message vide ou trop court (minimum 15 caractères).' + "\n";



			// - Si il y a des erreurs
			if (error.length > 0) {
				alert(error);
				return false;
			}
			else
				return true;


		}
	
	}
	
	
	jQuery(document).ready(function() {
		histoire.init();
	});
