function checkEmail(emailAddr) {
	// Cette fonction vérifie la bon format d'une adresse e-mail.
	// Comme :
	// user@domain.com ou user.perso@domain.com
	
	var i;
	
	// Recherche de @
	i = emailAddr.indexOf("@");
	if (i == -1) {
		return false;
	}
	
	// Séparation du nom de l'utilisateur et du nom de domaine.
	var username = emailAddr.substring(0, i);
	var domain = emailAddr.substring(i + 1, emailAddr.length)

	// Recherche des espaces au début du nom de l'utilisateur.
	i = 0;
	while ((username.substring(i, i + 1) == " ") && (i < username.length)) {
		i++;
	}
	// Les enlève s'il en trouve.
	if (i > 0) {
		username = username.substring(i, username.length);
	}

	// Recherche d'espaces à la fin du nom de domaine.
	i = domain.length - 1;
	while ((domain.substring(i, i + 1) == " ") && (i >= 0)) {
		i--;
	}
	// Les enlève s'il en trouve.
	if (i < (domain.length - 1)) {
		domain = domain.substring(0, i + 1);
	}

	// Vérifie que le nom de l'utilisateur et du domaine ne soit pas vide.
	if ((username == "") || (domain == "")) {
		return false;
	}
	
	// Vérifie s'il n'y a pas de caractères interdits dans le nom de l'utilisateur.
	var ch;
	for (i = 0; i < username.length; i++) {
		ch = (username.substring(i, i + 1)).toLowerCase();
		if (!(((ch >= "a") && (ch <= "z")) || 
			((ch >= "0") && (ch <= "9")) ||
			(ch == "_") || (ch == "-") || (ch == "."))) {
				return false;
		}
	}
	
	// Vérifie s'il n'y a pas de caractères interdits dans le nom de domaine
	for (i = 0; i < domain.length; i++) {
		ch = (domain.substring(i, i + 1)).toLowerCase();
		if (!(((ch >= "a") && (ch <= "z")) || 
			((ch >= "0") && (ch <= "9")) ||
			(ch == "_") || (ch == "-") || (ch == "."))) {
				return false;
		}
	}

// Ajouter ci-dessous de nouveaux noms de domaine.
// Voir tous les noms de domaine sur http://www.toulouse-renaissance.net/c_outils/c-nom-domaine.htm
//
var aSuffix = new Array("com","net","int","aero","biz","museum","name","info","coop","pro","eu","edu","org","gov","mil","bj","dz","de","ad","be","ca","bf","bi","cm","cf","cg","cd","ci","dj","fr","ga","gp","gf","lu","mg","ml","ma","mq","mr","mc","nc","pf","re","pm","sn","ch","td","tf","tn","eu");
	var bFoundSuffix = false;
	i = 0;
	while (i < aSuffix.length) {
		if (("." + aSuffix[i]) == domain.substring(domain.length - aSuffix[i].length - 1, domain.length)) {
			return true;
		}
		i++;
	}
	// Si le nom de domaine est inconnu  : return false
	return false;
	
}


$(function() {
	
	
	$('#nav').droppy({speed: 100});
	$("a[rel]").overlay({ 
		expose: {color: '#fff', 
        //loadSpeed: 200, 
        opacity: 0.8 },
		effect: 'apple', 
		onBeforeLoad: function() { 
			// grab wrapper element inside content
			var wrap = this.getContent().find(".contentWrap");
			// load the page specified in the trigger
			wrap.load(this.getTrigger().attr("href"));
		} 
	});

});


function valider(sF){
	bVal = true;
	
	if (sF.prenom.value=='' && bVal){
		alert('Veuillez saisir votre prenom');
		bVal=false;
		sF.prenom.focus();
	}
	
	if (sF.nom.value=='' && bVal){
		alert('Veuillez saisir votre nom');
		bVal=false;
		sF.nom.focus();
	}
	
	if (sF.email.value=='' && bVal){
		alert('Veuillez saisir votre email');
		bVal=false;
		sF.email.focus();
	}
		
	return bVal;
}



function Click(inp){
	
	 var $mainContent = $("#contenu");
    
    var url = '',
        hash = window.location.hash;
    
        $el = $(inp);
                
		// Scroll the page up (mostly so they can see the spinner graphic begin)
		//$(window).scrollTop(0);
					
		url = $el.attr("href") + " #contenu";
		
		$('#contenu').fadeIn('slow', function() {

			$mainContent.load(url, function() {
			
				window.location.hash = $el.attr("href");
				
				Cufon.replace('.typo', {hover: true});
				Cufon.replace('#nav a', {hover: true});
				
				if(document.getElementById("triggers")) {
					$("#triggers a").overlay({
						target: '#gallery',
						expose: '#ffffff' 
						}).gallery({
							speed: 800
					});	
				} // if(document.getElementById("triggers"))
				
			});
		
		});
        		 
        // Make sure the links don't reload the page
      	return false;

}
