$(document).ready(function() {
		
	// init puce
	var temp = $(".liste_notice").size();
	$("#puce_notice_0").removeClass().addClass('pastille_1_on');
	$("#puce_notice_"+(temp-1)).removeClass().addClass('pastille_3_off');
	
	$("#module_notice").scrollable( {
		size:1, 
		clickable: true,
		onSeek: function(event, i) {
			var position = this.getIndex();
			var total_position = this.getSize();
			
			/* Reinitialisation des puces */
			$("#puce_notice_0").removeClass().addClass('pastille_1_off');
			for(var i=1; i< (total_position-1); i++){
				$("#puce_notice_"+i).removeClass().addClass('pastille_2_off');
			}
			$("#puce_notice_"+(total_position-1)).removeClass().addClass('pastille_3_off');
			
			/* Positionement du rollover */
			if(position == 0){
				$("#puce_notice_0").removeClass().addClass('pastille_1_on');
			}
			else if(position == (total_position-1)){
				$("#puce_notice_"+(total_position-1)).removeClass().addClass('pastille_3_on');
			}
			else{
				$("#puce_notice_"+position).removeClass().addClass('pastille_2_on');
			}
		}	
	
	} ).navigator({ navi: "#flowtabs", naviItem: 'a' }).autoscroll({ autoplay: true, interval: 8000 } );
	
	
	
	// init puce
	var temp = $(".liste_actu").size();
	$("#puce_actu_0").removeClass().addClass('pastille_1_on');
	$("#puce_actu_"+(temp-1)).removeClass().addClass('pastille_3_off');
	
	$("#module_actualite").scrollable( {
		size:1, 
		clickable: true,
		onSeek: function(event, i) {
			var position = this.getIndex();
			var total_position = this.getSize();			 
			 
			// Reinitialisation des puces 
			$("#puce_actu_0").removeClass().addClass('pastille_1_off');
			for(var i=1; i< (total_position-1); i++){				
				$("#puce_actu_"+i).removeClass().addClass('pastille_2_off');
			}
			$("#puce_actu_"+(total_position-1)).removeClass().addClass('pastille_3_off');
			
			// Positionement du rollover 
			if(position == 0){
				$("#puce_actu_0").removeClass().addClass('pastille_1_on');
			}
			else if(position == (total_position-1)){
				$("#puce_actu_"+(total_position-1)).removeClass().addClass('pastille_3_on');
			}
			else{
				$("#puce_actu_"+position).removeClass().addClass('pastille_2_on');
			}
		}	
	} ).navigator({ navi: "#flowtabs_2", naviItem: 'a' }).autoscroll({ autoplay: true, interval: 10000 } );
	 
});

 



 
function verif_contact(){
	
	var success = 1;
	$("#info_error").html("");
		
	var societe = $("#societe").val(); 
	var adresse = $("#adresse").val();
	var ville = $("#ville").val();
	var cp = $("#cp").val();;
	var pays = $("#pays").val();;
	var prenom = $("#prenom").val(); 
	var nom = $("#nom").val(); 
	var fonction = $("#fonction").val();
	
	var tel = $("#tel").val();
	var fax = $("#fax").val();
	var email = $("#email").val();
	var commentaire = $("#commentaire").val();
	
	if( nom == "" ){
		dialog_error("nom");
		success=0;
	}else{
		$("#nom").removeClass().addClass("input_1");
	}
	
	if( adresse == "" ){
		dialog_error("adresse");
		success=0;
	}else{
		$("#adresse").removeClass().addClass("input_1");
	}
	
	if( prenom == "" ){
		dialog_error("prenom");
		success=0;
	}else{
		$("#prenom").removeClass().addClass("input_1");
	}

	if( societe == "" ){
		dialog_error("societe");
		success=0;
	}else{
		$("#societe").removeClass().addClass("input_1");
	}	
	
	if( commentaire == "" ){
		dialog_error("commentaire");
		success=0;
	}else{
		$("#commentaire").removeClass().addClass("input_1");
	}	
	
	if( !verif_email(email) ){
		dialog_error("email");
		success=0;
	}else{
		$("#email").removeClass().addClass("input_1");
	}
	
	if(success == 1){
		$("#bouton_envoi").html('<img src="theme/load.gif" alt=""/>&nbsp;Envoi en cours ...');
	
		$.post("formulaire/valider_contact.php", { societe:societe, adresse:adresse, ville:ville, pays:pays, cp:cp, fax:fax,
			nom:nom, prenom:prenom, fonction:fonction,  tel:tel, email:email, commentaire:commentaire }, function(data){	
			$("#all_contact").html("<br/><br/>Votre message a &eacute;t&eacute; envoy&eacute;.<br/>Merci."); 
		});
	} 
}

/**
* Erreur sur le formulaire
*/
function dialog_error(champs){
	$("#info_error").html("Les champs en rouge sont incorrects."); 
	$("#"+champs).removeClass().addClass("input_1_error");
}

/**
* Verification de l'email
*/
function verif_email(email){
	var regle = RegExp("^([a-zA-Z0-9_-])+([.]?[a-zA-Z0-9_-]{1,})*@([a-zA-Z0-9-_]{2,}[.])+[a-zA-Z]{2,3}$");
	
	var resultat = regle.exec(email);
	if(resultat != null){
		return 1;
	}else{
		return 0;
	}
}

