$(function(){

	/*
	 * toolTip
	 * 
	 * ici on rajoute toutes les classe qui veulent le toolTip
	 */
	//$(".notification_icon").tipTip({maxWidth: "auto", edgeOffset: 10});
	//Ne marche pas bien pour la carte de france qui je dois changer !
	//$("#carteDeFrance").children().tipTip({maxWidth: "auto", edgeOffset: 10});
	
	 


		// select all desired input fields and attach tooltips to them
		$(".tp").tooltip({

			// place tooltip on the right edge
			//position: "center right",
			position: "center right",

			// a little tweaking of the position : vertical , horizontal
			offset: [0, 10],

			// use the built-in fadeIn/fadeOut effect
			effect: "fade",

			// custom opacity setting
			opacity: 0.7,

			// use this single tooltip element
			tip: '.tooltip'

		});

		// select all desired input fields and attach tooltips to them
		$(".tp_bottom_left").tooltip({

			// place tooltip on the right edge
			//position: "center right",
			position: "bottom left",

			// a little tweaking of the position : vertical , horizontal
			offset: [0, 10],

			// use the built-in fadeIn/fadeOut effect
			effect: "fade",

			// custom opacity setting
			opacity: 0.7,

			// use this single tooltip element
			tip: '.tooltip'

		});
		
		
//A utiliser plus tard apres correction de bug
/*		$("#carteDeFrance").children().tooltip({

			position: "center right",

			offset: [0, 10],

			effect: "fade",

			opacity: 0.7,

			tip: '.tooltip'

		});
*/		
		
	
	
	
	/*
	 * 			C O R N E R
	 * http://jquery.malsup.com/corner/
	 * 		ex: corner(30px); 
	 */
	$('#recherche').corner();
});





/* * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* 					  VALIDATION DE FORM    			 */
/* http://www.smartwebby.com/dhtml/email_validation.asp  */
/*				  Avec quelques modifications			 */

/*
 * Pour la validation du mot de passe voir ici
 * http://yensdesign.com/2009/01/how-validate-forms-both-sides-using-php-jquery/ 
 */

/**
 * Function ValidateForm is used to make sure that the email field is not blank and that it is a valid email address on form submission.
 */
function validateContactForm(){
	//var emailID=document.frmSample.txtEmail
	var emailID=document.getElementById("sendMailForm").email;
	var msgID=document.getElementById("sendMailForm").message;
		
	//d'abord l'email
	//if(!validateEmail(emailID) )
	if(validateEmail(emailID) == false)
	{
		$('#img4email').show();
		return false;
	}
	
	//Vérification du message
	if((msgID.value==null)||(msgID.value.length < 10)){
		$('#img4msg').show();
		alert("Veuillez saisir votre message");
		msgID.focus();
		
		return false;
	}
	return true
 }



function validateAuthenticationForm(){
	var emailID=document.getElementById("authenticationForm").emailAuth;
	var pwdID=document.getElementById("authenticationForm").password;
		
	//d'abord l'email
	//if(!validateEmail(emailID) )
	if(validateEmail(emailID) == false)
	{
		$('#img4AuthEmail').show();
		return false;
	}
	
	//Vérification du password
	if ((pwdID.value==null)||(pwdID.value=="")){
		$('#img4password').show();
		alert("Veuillez saisir votre mot de passe");
		pwdID.focus();
		
		return false;
	}
	return true
}



function validateEmail(emailID){

	if ((emailID.value==null)||(emailID.value=="")){
		alert("Veuillez saisir votre email");
		emailID.focus();
		
		return false;
	}

	if (isValideEmail(emailID.value)==false){
		emailID.value="";
		alert("Veuillez saisir une adresse email valide");
		emailID.focus()
		return false;
	}
	//Sinon email bon alors return true
	return true;
}



/**
 * Function isValideEmail is used to verify if the given value is a possible valid email address. 
 * This function thus simply makes sure the email address has one (@), atleast one (.). 
 * It also makes sure that there are no spaces, extra '@'s or a (.) just before or after the @. 
 * It also makes sure that there is atleast one (.) after the @.
 * @param str
 * @return
 */
function isValideEmail(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   //alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    return false
		 }

 		 return true;					
	}


/*   VALIDATION DE FORM    */
/* * * * * * * * * * * * * */
