/*
Inclusion du script de formulaire mel
*/
function VerificationFormulaire(){
	adresse = document.formulaire_mel.formulaire_mel_adresse.value;
	var place = formulaire_mel_adresse.indexOf("@",1);
	var point = formulaire_mel_adresse.indexOf(".",place+1);
	from = document.formulaire_mel.formulaire_mel_from.value;
	var place2 = formulaire_mel_from.indexOf("@",1);
	var point2 = formulaire_mel_from.indexOf(".",place+1);
	if (((place > -1)&&(formulaire_mel_adresse.length >2)&&(point > 1)) && (document.formulaire_mel.formulaire_mel_nom.value!="") && ((place2 > -1)&&(formulaire_mel_from.length >2)&&(point2 > 1)))
		{
		document.formulaire_mel.submit();
		}
	else
		{	
			var erreurMsg='';
			if (!((place > -1)&&(formulaire_mel_adresse.length >2)&&(point > 1)))
				erreurMsg = 'formulaire_mel_adresse_erreurMsg';
			if (document.formulaire_mel.formulaire_mel_nom.value=="")
				erreurMsg = erreurMsg + 'formulaire_mel_nom_erreurMsg';
			if (!((place2 > -1)&&(formulaire_mel_from.length >2)&&(point2 > 1)))
				erreurMsg = erreurMsg + 'formulaire_mel_from_erreurMsg';
			alert(erreurMsg);
		}
}

// Inclusion du script d inscription mel

function VerificationMel(inscription_mel_variable)
{
    // check that there is actually something there
    if (inscription_mel_variable == "")
    {
        return "";
    }

    // check for bad characters
    var bad_chars = " \/:,<'&";
    for (i = 0; i < bad_chars.length; i++)
    {
        if (inscription_mel_variable.indexOf(bad_chars.charAt(i)) != -1)
        {
            return "";
        }
    }

    // check that there is at least one '@' and that it's
    // not the first character of the email address
    var at_index = inscription_mel_variable.indexOf("@", 1);
    if (at_index == -1)
    {
        return "";
    }

    // now check that there are no more '@' characters after
    // the one we've found
    if (inscription_mel_variable.indexOf("@", at_index + 1) != -1)
    {
        return "";
    }

    // check that there is at least one '.' after the '@'
    var dot_index = inscription_mel_variable.indexOf(".", at_index + 1);
    if (dot_index == -1)
    {
        return "";
    }

    // now look for any consecutive '.' chars and replace
    // them with single ones... also replace '>' or ';'
    // with '.'
    // we'll do this all in one pass... makes the code
    // simpler even though it's unlikely that we'll end
    // up with consecutive ';' or '>' characters

    if ((inscription_mel_variable.indexOf("..", at_index + 1) != -1) ||
        (inscription_mel_variable.indexOf(";", at_index + 1) != -1) ||
        (inscription_mel_variable.indexOf(">", at_index + 1) != -1))
    {
        var replace_chars = ".;>";
        var new_email = inscription_mel_variable.substring(0, at_index + 1);
        for (i = at_index + 1; i < inscription_mel_variable.length; i++)
        {
            if (replace_chars.indexOf(inscription_mel_variable.charAt(i)) != -1)
            {
                new_email += ".";
                while ((replace_chars.indexOf(inscription_mel_variable.charAt(i + 1)) != -1) &&
                       (i < inscription_mel_variable.length))
                {
                    i++;
                }
            }
            else
            {
                new_email += inscription_mel_variable.charAt(i);
            }
        }
        inscription_mel_variable = new_email;
    }

    // now check that there is something before the dot which 
    // follows the '@' and at least 2 characters following the
    // last dot
    // first find the index of the first dot again, since it 
    // might have changed in the removal of duplicate dots, etc

    dot_index = inscription_mel_variable.indexOf(".", at_index + 1);
    if (dot_index == at_index + 1)
    {
        return "";
    }
    dot_index = inscription_mel_variable.lastIndexOf(".");
    if (dot_index > inscription_mel_variable.length - 3)
    {
        return "";
    }

    return inscription_mel_variable;
}

/*POPUP WINDOW IN CENTER */

var win= null;
function NewWindow(mypage,myname,w,h,scroll){
var winl = (screen.width-w)/2;
var wint = 15;
var settings ='height='+h+',';
settings +='width='+w+',';
settings +='top='+wint+',';
settings +='left='+winl+',';
settings +='scrollbars='+scroll+',';
settings +='resizable=yes';
win=window.open(mypage,myname,settings);
if(parseInt(navigator.appVersion) >= 4){win.window.focus();}
}

function MM_openBrWindow(theURL,winName,features) {
window.open(theURL,winName,features);
}




