// OUVERTURE LIEN EN TARGET='_blank'

function popup(page) {
    window.open(page);
}

// fonction pour surligner les champs invalides
function surligne(champ, erreur) {
	if(erreur) champ.style.backgroundColor = "#fdf";
	else champ.style.backgroundColor = "";
}

// VERIFICATION DES FORMULAIRES DES POPUP
function verifMail(champ) {
	var regex = /^[a-zA-Z0-9._-]+@[a-z0-9._-]{2,}\.[a-z]{2,4}$/;
	
	if(champ.value == ""){
		return false;
	}
	if(!regex.test(champ.value)) {
	 
	 var text = $('#mail_inscription').text();
		$('input[type=text]').css('color', '#dd053d').val("Votre adresse mail n'est pas valide");
		return false;
	} else {
		return true;
    }
}


/**/


/**/


function verifForm(f,type) {
	
	if( type == 'submit' ) {
		emailOk = verifMail(f.mail_inscription);
		if(emailOk) {			
			show_popup_inscription_home(f.mail_inscription);
		}
		return false;
	}
	else return emailOk = verifMail(f.mail_inscription);
	/*if(emailOk) {		
		
		return false;		
	} else {
		document.getElementById('shad').style.display='block';
		document.getElementById('error_mail').style.display='block';
		return false;
	}*/
}
/*function verifForm2(f) {
	var emailOk = verifMail(f.mail_inscription_2);	 
	
	if(emailOk) {		
		show_popup_inscription_home(f.mail_inscription_2);
		document.getElementById('shad').style.display='none';
		document.getElementById('mail_error').style.display='none';
		return false;		
	} else {
		document.getElementById('mail_error').style.display='block';
		return false;
	}
}
*/
// POPUP(s)
function show_popup_inscription_home( mail ){
	
		var boxInput = document.getElementById('formBoxInput');
		var boxInputYellow = document.getElementById('boxConfirmation');
	
	document.getElementById('btn_ok_home').src = 'img/loader.gif';
	
	var response = ajax_file( 'ajax_send_mail_prive.php?mail=' + mail.value );

	document.getElementById('btn_ok_home').src = 'img/btn_ok_home.jpg';
	
	if( response != 'false' ) {

		if( response == 'same' ) {
			$("#formBoxInput").fadeOut(200);
			$("#boxInput a").fadeOut(200);
			$("#boxInputError").fadeIn(300);
			
			//document.getElementById('user_mail_alternate').innerHTML=document.getElementById('mail_inscription').value;
			
		}
		else {
			
			$("#formBoxInput").fadeOut(200);
			$("#boxInput a").fadeOut(200);
			$("#boxConfirmation").fadeIn(300);			
			
				
		}
		
	}
}






