function checkEmail(mail) {
	if ((mail.indexOf("@")>=0)&&(mail.indexOf(".")>=0)) {
		return true;
	} else {
		return false;
	}
}

function verif_email (form_name) {
	var error = 0;
	var normal_color = "#FFFFFF";
	var error_color = "#d6e64a";
	var myForm = document.forms[form_name];
	var msg = "Veuillez corriger les erreurs ci-dessous :\n\n";
	
	if (myForm.elements["email"].value == "") {
		error = 1;
		msg += "Remplir le champ EMAIL.\n";
	}  else if (!checkEmail(myForm.elements["email"].value)) {
		error = 1;
		msg = "Vous devez entrer un email de type nom@fournisseur.com\n";
	}
		
	if (error == 0) {
		return true;
	} else {
		alert(msg);
		return false;
	}
}

function submit_error(form_name) {
	var myFrom = document.forms[form_name];
	var email_f = myFrom.elements["email"].value;
	longueur = email_f.length;
	index = email_f.indexOf("@");
	index2 = email_f.indexOf(";");
	
	if ((index < 1) || (index==(longueur-1))) {
		alert("Vous devez entrer un email de type nom@fournisseur.com");
		document.formulaire.mail.focus();
		return false;
	}
	if (index2 > 0){
		alert("Vous ne devez pas avoir de ; dans votre email");
		document.formulaire.mail.focus();
		return false;
	}
	
	domaine = email_f.substring(index+1,longueur);
	longueur = domaine.length;
	index = domaine.indexOf(".");
	if ((index < 1) || (index==(longueur-1))){
		alert("Vous devez entrer un email de type nom@fournisseur.com");
		document.formulaire.mail.focus();
		return false;
	}
}


function ConfirmEmailLegit()
{
    var MailValue = document.getElementById('mail').value; 
    if (!MailValue) 
    {
        alert('Vous devez inscrire une adresse courriel!'); 
        return FALSE;
    }
    var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; // not valid
    var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/; // valid
    if (!reg1.test(MailValue) && reg2.test(MailValue)) { // if syntax is valid
        AddEmail();
        document.getElementById('CB30Link').submit();
        return true;
    }
    alert ('Vous devez inscrire une adresse couriel valide!');
    return FALSE;
}

//BLINK - IE does not understand the blink css
var text_timer;
var text_timer_2;
var text_timer_3;
var text_visible = 1;
var text_visible_2 = 1;
var text_visible_3 = 1;
var text_tmp;
var text_tmp_2;
var text_tmp_3;

function blink()
{
   if (text_visible)
	 {
	    text_tmp = document.getElementById('mail').value;
			document.getElementById('mail').value = '';
			text_visible = false;
	 }
   else
	 {
	    document.getElementById('mail').value = text_tmp;
			text_visible = true;
	 }
}
function start_blink()
{
   if (document.getElementById('mail').value=='@')
	 {
	    text_timer = setInterval('blink()', 500);
	 }
}
function stop_blink()
{
   if (text_timer)
    {
	    clearInterval(text_timer);
	 }
 }
function email_focus()
{
    stop_blink();
    if (document.getElementById('mail').value == '@') document.getElementById('mail').value = '';
}
function email_blur()
{
   e = document.getElementById('mail');
	 if (document.getElementById('mail').value == '@' || document.getElementById('mail').value == '')
	 {
	    document.getElementById('mail').value = '@';
	    start_blink();
	 }
}

function blink2()
{
   if (text_visible_2)
	 {
	    text_tmp_2 = document.getElementById('mail2').value;
			document.getElementById('mail2').value = '';
			text_visible_2 = false;
	 }
   else
	 {
	    document.getElementById('mail2').value = text_tmp_2;
			text_visible_2 = true;
	 }
}
function start_blink2()
{
   if (document.getElementById('mail2').value=='@')
	 {
	    text_timer_2 = setInterval('blink2()', 500);
	 }
}
function stop_blink2()
{
   if (text_timer_2)
    {
	    clearInterval(text_timer_2);
	 }
 }
function email_focus2()
{
    stop_blink2();
    if (document.getElementById('mail2').value == '@') document.getElementById('mail2').value = '';
}
function email_blur2()
{
   e2 = document.getElementById('mail2');
	 if (document.getElementById('mail2').value == '@' || document.getElementById('mail2').value == '')
	 {
	    document.getElementById('mail2').value = '@';
	    start_blink2();
	 }
}

function blink3()
{
   if (text_visible_3)
	 {
	    text_tmp_3 = document.getElementById('mail3').value;
			document.getElementById('mail3').value = '';
			text_visible_3 = false;
	 }
   else
	 {
	    document.getElementById('mail3').value = text_tmp_3;
			text_visible_3 = true;
	 }
}
function start_blink3()
{
   if (document.getElementById('mail3').value=='@')
	 {
	    text_timer_3 = setInterval('blink3()', 500);
	 }
}
function stop_blink3()
{
   if (text_timer_3)
    {
	    clearInterval(text_timer_3);
	 }
 }
function email_focus3()
{
    stop_blink3();
    if (document.getElementById('mail3').value == '@') document.getElementById('mail3').value = '';
}
function email_blur3()
{
   e3 = document.getElementById('mail3');
	 if (document.getElementById('mail3').value == '@' || document.getElementById('mail3').value == '')
	 {
	    document.getElementById('mail3').value = '@';
	    start_blink3();
	 }
}

if (window.addEventListener) window.addEventListener("load", start_blink, false);
else if (window.attachEvent) window.attachEvent("onload", start_blink);
else if (document.getElementById) window.onload=start_blink;

if (window.addEventListener) window.addEventListener("load", start_blink2, false);
else if (window.attachEvent) window.attachEvent("onload", start_blink2);
else if (document.getElementById) window.onload=start_blink2;

if (window.addEventListener) window.addEventListener("load", start_blink3, false);
else if (window.attachEvent) window.attachEvent("onload", start_blink3);
else if (document.getElementById) window.onload=start_blink3;
