
//popup image pour le CMS
function PopupImage (url)
{
    zoomslide.open(url);
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf('?'))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}


/**
 * Vérifie les champs du formulaire.
 *
 * Fonction appelée à la soumission du formulaire.
 *
 * @return bool TRUE si OK, FALSE en cas d'erreur
 */
function champsok()
{
    if (document.getElementById('demande').value.length == 0) {
        alert("Votre demande, merci.");
        document.getElementById('demande').focus();
        return false;
    }
    if (document.getElementById('email').value.length == 0) {
        alert("Votre e-mail, merci.");
        document.getElementById('email').focus();
        return false;
    }
    if (document.getElementById('email').value.toLowerCase().match(
        /^[a-zA-Z0-9][a-zA-Z0-9._-]*@([a-zA-Z][a-zA-Z0-9_\-]*\.)*[a-z0-9]+[a-z0-9\-]+\.[a-z]{2,6}$/
        ) == null) {
        alert("Veuillez vérifier votre e-mail, merci.");
        document.getElementById('email').focus();
        return false;
    }
    return true;
}

function champsokEmploi()
{
    if (document.getElementById('nomReseau').value.length == 0) {
        alert("Le nom du réseau, merci.");
        document.getElementById('nomReseau').focus();
        return false;
    }
	if (document.getElementById('nomPoste').value.length == 0) {
        alert("L'intitulé du poste, merci.");
        document.getElementById('nomPoste').focus();
        return false;
    }
	if (document.getElementById('missions').value.length == 0) {
        alert("Les principales missions du poste, merci.");
        document.getElementById('missions').focus();
        return false;
    }
	if (document.getElementById('contrat').value.length == 0) {
        alert("Le type de contrat, merci.");
        document.getElementById('contrat').focus();
        return false;
    }
	if (document.getElementById('ville').value.length == 0) {
        alert("La ville, merci.");
        document.getElementById('ville').focus();
        return false;
    }
	if (document.getElementById('aContacter').value.length == 0) {
        alert("La personne à contacter, merci.");
        document.getElementById('aContacter').focus();
        return false;
    }
	if (document.getElementById('telephone').value.length == 0) {
        alert("Son numéro de téléphone, merci.");
        document.getElementById('telephone').focus();
        return false;
    }
	if (document.getElementById('sonEmail').value.length == 0) {
        alert("Son E-mail, merci.");
        document.getElementById('sonEmail').focus();
        return false;
    }
	if (document.getElementById('sonEmail').value.toLowerCase().match(
        /^[a-zA-Z0-9][a-zA-Z0-9._-]*@([a-zA-Z][a-zA-Z0-9_\-]*\.)*[a-z0-9]+[a-z0-9\-]+\.[a-z]{2,6}$/
        ) == null) {
        alert("Veuillez vérifier l'adresse mail, merci.");
        document.getElementById('sonEmail').focus();
        return false;
    }
    return true;
}

/* matthias - pour l'antispam */
// les variables sont les champs obligatoires
var emailSpam = demandeSpam = false;
function activate(inputId)
{
	if(inputId == "demande") demandeSpam = true;
	else if(inputId == "email") emailSpam = true;
	
	// si tout est à true, on active la validation
	if(demandeSpam === true && emailSpam === true) {
		document.getElementById("spm2").value = "1";
	}
}

var nomReseauSpam = nomPosteSpam = missionsSpam = contratSpam = villeSpam = aContacterSpam = telephoneSpam = sonEmailSpam = false;
function activateEmploi(inputId)
{
	if(inputId == "nomReseau") nomReseauSpam = true;
	else if(inputId == "nomPoste") nomPosteSpam = true;
	else if(inputId == "missions") missionsSpam = true;
	else if(inputId == "contrat") contratSpam = true;
	else if(inputId == "ville") villeSpam = true;
	else if(inputId == "aContacter") aContacterSpam = true;
	else if(inputId == "telephone") telephoneSpam = true;
	else if(inputId == "sonEmail") sonEmailSpam = true;
	
	// si tout est à true, on active la validation
	if(nomReseauSpam === true && nomPosteSpam === true && missionsSpam === true && contratSpam === true && villeSpam === true && aContacterSpam === true && telephoneSpam === true && sonEmailSpam === true) {
		document.getElementById("spm2").value = "1";
	}
}

/* matthias - pour gen_rubriques_liste() */
function expand_menu(ul) { $("#menu_"+ul).slideToggle("slow"); }

/* matthias - inscription à newsletter */
function inscriptionNewsletter(domaine, cle, email)
{

    if (email.match(/^[a-zA-Z0-9][a-zA-Z0-9._-]*@([a-zA-Z][a-zA-Z0-9_\-]*\.)*[a-z0-9]+[a-z0-9\-]+\.[a-z]{2,6}$/) == null)
    {
        alert("Veuillez vérifier votre e-mail, merci.");
        document.getElementById('nlemail').focus();
        return false;
    }
    else
    {
        $.get("http://"+domaine+".niouzletter.com/inscription.php?cle="+encodeURIComponent(cle)+"&email="+encodeURIComponent(email),
        function(data){
            alert("Votre adresse mail est enregistrée, merci.");
            $("#cadreNL").slideToggle("fast");
        });
    }
}

/* Jérémy - RefNat */
function home(){
	// <a href="javascript:void(0);" onclick="home();">Accueil</a>
	document.location.href = "/";
}
