var couleurAr = "#F7FFFF";
var couleurEr = "orange"
var nomInputEmail = '.mail_pro';
var nomform = ".send";
//mettre class="non" pour les inputs non obligatoires
var message = new Array("L'adresse mail n'est pas valide, merci de corriger. The email address is not valid, correct thank you", "Le champ E-mail est vide, merci de compléter. The E-mail field is empty, thank you to complete.","Il manque certains renseignements, merci de compléter. It lacks some information, thank you to complete");
var err = false;


$(document).ready(function(){
	$(".chk_jounaliste").click(function(){
		if($(this).attr('checked') == true){
			$(".redaction").show();
		}
		else {
			$(".redaction").hide();
		}
	});
	
	$(".send").click(function(){
		
		var sortie = $("div."+$(this).attr('lang')+" input[type=text]").serialize();
		var journaliste = $("div."+$(this).attr('lang')+" input[type=checkbox]").serialize();
		
		var err = false;
		$("."+$(this).attr('lang')+" "+"input.ob").each(function(){//champs obligatoires
			if($(this).val() == ''){
				$(this).css({backgroundColor: couleurEr});
				err = true;
				}
			});	
		if(err == true){
			alert(message[2]);
			return false;
		}
		else { 
			$.post("act/inscr_dbweb.php",{chaine:sortie, journal: journaliste},function(data){
				$("#retour").html(data);
				$("input[type=text]").val('');
				$(".message").show();
			});
		}
	
	});
	
	
	
	/*verif formulaire*/
	$(nomform).click(function(){
	
	});
	
	$("input[type='text']").focus(function(){
		$(this).css({backgroundColor: couleurAr});
		});
	


	$(nomInputEmail).blur(function(){// verif adresse email
		if (this.value != "")   { 
      		indexAroba = this.value.indexOf('@'); 
      		indexPoint = this.value.indexOf('.'); 
     			 if ((indexAroba < 0) || (indexPoint < 0)) { 
						this.style.backgroundColor = couleurEr; 
						alert (message[0]); 
      				} 
   			} 

		else   { //si champ vide
      		this.style.backgroundColor = couleurEr;
      		alert(message[1]); 
   		}
	});
	
	
	

	
});