//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('nom').value.length == 0) {
        notifierErreur('nom', "Le nom est incorrect", "recap");
        document.getElementById('nom').focus();
        return false;
    }
    if (document.getElementById('prenom').value.length == 0) {
        notifierErreur('prenom', "Le prénom est incorrect", "recap");

        document.getElementById('prenom').focus();
        return false;
    }
    if (document.getElementById('adresse').value.length == 0) {
        notifierErreur('adresse', "L'adresse est incorrecte", "recap");
        document.getElementById('adresse').focus();
        return false;
    }
    if (document.getElementById('cp').value.length == 0) {
        notifierErreur('cp', "Le code postal est incorrect", "recap");
        document.getElementById('cp').focus();
        return false;
    }
    if (document.getElementById('ville').value.length == 0) {
        notifierErreur('ville', "La ville est incorrecte", "recap");
        document.getElementById('ville').focus();
        return false;
    }

    if (document.getElementById('email').value.length == 0) {
        notifierErreur('email', "L'email est incorrect", "recap");
        document.getElementById('email').focus();
        return false;
    }
    if (document.getElementById('email').value.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) {
        notifierErreur('email', "L'email est incorrect", "recap");
        document.getElementById('email').focus();
        return false;
    }


    return true;
}


function champsokPresse()
{
    if (document.getElementById('nom').value.length == 0) {
        notifierErreur('nom', "Le nom est incorrect", "recap");
        document.getElementById('nom').focus();
        return false;
    }
    if (document.getElementById('prenom').value.length == 0) {
        notifierErreur('prenom', "Le prénom est incorrect", "recap");

        document.getElementById('prenom').focus();
        return false;
    }
    if (document.getElementById('adresse').value.length == 0) {
        notifierErreur('adresse', "L'adresse est incorrecte", "recap");
        document.getElementById('adresse').focus();
        return false;
    }
    if (document.getElementById('cp').value.length == 0) {
        notifierErreur('cp', "Le code postal est incorrect", "recap");
        document.getElementById('cp').focus();
        return false;
    }
    if (document.getElementById('ville').value.length == 0) {
        notifierErreur('ville', "La ville est incorrecte", "recap");
        document.getElementById('ville').focus();
        return false;
    }
    if (document.getElementById('pays').value.length == 0) {
        notifierErreur('pays', "Le pays est incorrect", "recap");
        document.getElementById('pays').focus();
        return false;
    }
    if (document.getElementById('email').value.length == 0) {
        notifierErreur('email', "L'email est incorrect", "recap");
        document.getElementById('email').focus();
        return false;
    }
    if (document.getElementById('email').value.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) {
        notifierErreur('email', "L'email est incorrect", "recap");
        document.getElementById('email').focus();
        return false;
    }


    return true;
}






/* 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.");
        });
    }
}





function ouvreContenu(numero){

	if(monTimer[numero])
		clearTimeout(monTimer[numero]);
	if($("#contenu"+numero).css('display')=='none')
    	$("#contenu"+numero).slideDown();



}

var monTimer = new Array();
function fermeContenu(numero){
	  monTimer[numero]=setTimeout(function (){ $("#contenu"+numero).slideUp() },200);

}

ancienNumActif=1;
function affcommentaire(num){

    $("#titre"+ancienNumActif).removeClass("actif");
	$("#titre"+num).removeClass("actif").addClass("actif");

	if(ancienNumActif!=num) {
	$("#commentaire"+ancienNumActif).slideUp(function(){
	$("#commentaire"+num).slideDown(function(){


	});});
	ancienNumActif=num;


	}
	else {$("#commentaire"+num).slideToggle();}
}
function cachecommentaire(){
/*$("#commentaire"+ancienNumActif).slideUp();*/
}


function affChoixPays (pointDOrigine) {

$('#choix'+pointDOrigine).html('<a href="javascript:void(0)" onclick="choixpays(\''+pointDOrigine+'\', \'fr\')"><img src="images/drap/drap_fr.gif" width="14" height="12" border="0" vspace="2" />France</a><br />            <a href="javascript:void(0)" onclick="choixpays(\''+pointDOrigine+'\', \'be\')"><img src="images/drap/drap_be.gif" width="14" height="12" border="0" vspace="2" />Belgique</a><br />      <a href="javascript:void(0)" onclick="choixpays(\''+pointDOrigine+'\', \'lu\')"><img src="images/drap/drap_lu.gif" width="14" height="12" border="0" vspace="2" />Luxembourg</a><br /><a href="javascript:void(0)" onclick="choixpays(\''+pointDOrigine+'\', \'ch\')"><img src="images/drap/drap_ch.gif" width="14" height="12" border="0" vspace="2" />Suisse</a>');
$('#choix'+pointDOrigine).show();
}

function choixpays(qui,pays) {
	$('#'+qui+'Libelle').html('<img src="/images/fleche-pays.png" border="0"/><img src="images/drap/drap_'+pays+'.gif" width="14" height="12" border="0" />');
	$('#'+qui).val(pays);
	$('#choix'+qui).hide();
	if (qui == 'paysDepart') {
		$('#nomVille').val('');
		$('#cpVille').val('');

	}

}

