function afficherBloc(idElement){
    if(document.form.defAlerte.checked){
        document.getElementById(idElement).style.display = 'block';
    }else{
        document.getElementById(idElement).style.display = 'none';
    }
    
}
function afficherBlocLang(idElement){
    //alert(idElement);
    if(document.getElementById(idElement).style.display != 'block'){
        //alert('none');
        document.getElementById(idElement).style.display = 'block';
    }else{
        //alert('block');
        document.getElementById(idElement).style.display = 'none';
    }

}
function afficherSelect(id, lang){
        var val = id;
		var lang = lang;
        $(document).ready(
	function(){
               $.ajax({
                    type: "POST",
                    url:  "ajouter-selection.php",
                    data: 'idProd='+val,

                    beforeSend: function(){
                    },
                    success: function(msg){
                        $(".isSelection").html('('+msg+')');
                        $("#maSelection"+val).html("<form action=\"\" method=\"post\" enctype=\"multipart/form-data\"><label onclick=\"javascript:supSelectIndex("+val+")\" class=\"select_prod\">&nbsp;&nbsp;SUPPRIMER</label><a href=\"fiche-produit.php?idP="+val+"&lang="+lang+"\" class=\"a_visiter\" style=\"padding:8px 0 0 0;\">VISITER</a></form>");
                        $("#ajouter"+val).html('Ajout&eacute;');
                        //alert('Le produit a ete bien ajoute.');
                    }

                }).responseText;
        });
    }

function ajouterSelect(id){
        var val = id;
        $(document).ready(
	function(){
               $.ajax({
                    type: "POST",
                    url:  "ajouter-selection.php",
                    data: 'idProd='+val,

                    beforeSend: function(){
                    },
                    success: function(msg){
                        $(".isSelection").html('('+msg+')');
                        alert('Le produit a ete bien ajoute.');
                    }

                }).responseText;
        });
    }

 function supSelect(id){
        var val = id;
        $(document).ready(
	function(){
               $.ajax({
                    type: "POST",
                    url:  "sup-selection.php",
                    data: 'idProd='+val,

                    beforeSend: function(){
                    },
                    success: function(msg){
                        $(".isSelection").html('('+msg+')');
                        $("#ZoneSelect"+val).css({
                            'display' :'none'
                        });
                    }

                }).responseText;
        });
    }


 function supSelectIndex(id, lang){
        var val = id;
		var lang = lang;
        $(document).ready(
	function(){
               $.ajax({
                    type: "POST",
                    url:  "sup-selection.php",
                    data: 'idProd='+val,

                    beforeSend: function(){
                    },
                    success: function(msg){
                        $(".isSelection").html('('+msg+')');
                        $("#ajouter"+val).html('');
                        $("#maSelection"+val).html("<form action=\"\" method=\"post\" enctype=\"multipart/form-data\"><input type=\"hidden\" name=\"id\" value=\""+val+"\" /><label id=\"addSelect"+val+"\" class=\"select_prod\"><input type=\"checkbox\" onclick=\"javascript:afficherSelect('"+val+"');\" style=\"margin-top:-1px;.margin-top:-4px;\" name=\"select"+val+"\" id=\"addSelect"+val+"\" />S&Eacute;L&Eacute;CTION</label><a href=\"fiche-produit.php?idP="+val+"&lang="+lang+"\" class=\"a_visiter\" style=\"padding:8px 0 0 0;\">VISITER</a></form>");
                    }

                }).responseText;
        });
    }

    function checkemail(idElement){
var invalidcheck=0;
var str=document.getElementById(idElement).value
var filter=/^(\w+(?:\.\w+)*)@((?:\w+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
if (filter.test(str)){
var tempstring=str.split("@")
tempstring=tempstring[1].split(".")
if (invalidcheck!=1)
{
	document.getElementById(idElement).style.backgroundColor ='#FFFFFF';
	document.getElementById(idElement).style.borderColor = '#cccccc';
	testresults=true
}
else{
testresults=false
}
}
else{
document.getElementById(idElement).style.backgroundColor ='#fdf8f8';
document.getElementById(idElement).style.borderColor = '#ff9999';
testresults=false
}
return (testresults)
}


function checkCivilite(){
	if (document.form1.c[0].checked || document.form1.c[1].checked || document.form1.c[2].checked)
	{
		//document.getElementById('c1').style.color = '#000000'
		//document.getElementById('c2').style.color = '#000000'
		//document.getElementById('c3').style.color = '#000000'
		return true
	}
	else
	{
		//document.getElementById('c1').style.color = '#FF0000'
		//document.getElementById('c2').style.color = '#FF0000'
		//document.getElementById('c3').style.color = '#FF0000'
		return false
	}
}

function checkTxtEmpty(idElement){
	if (document.getElementById(idElement).value != "")
	{
		document.getElementById(idElement).style.backgroundColor = '#FFFFFF';
		document.getElementById(idElement).style.borderColor = '#cccccc';
		return true
	}
	else
	{
		document.getElementById(idElement).style.backgroundColor = '#fdf8f8';
		document.getElementById(idElement).style.borderColor = '#ff9999';
		return false
	}
}

function checkCodePostal(idElement){
	nbr = document.getElementById(idElement).value
	if (nbr.length >= 1 && !isNaN(nbr))
	{
		document.getElementById(idElement).style.backgroundColor = '#FFFFFF';
		document.getElementById(idElement).style.borderColor = '#cccccc';
		return true
	}
	else
	{
		document.getElementById(idElement).style.backgroundColor = '#fdf8f8';
		document.getElementById(idElement).style.borderColor = '#ff9999';
		return false
	}
}

function checkTel(idElement){
	nbr = document.getElementById(idElement).value
	if (nbr.length >= 1 && !isNaN(nbr))
	{
		document.getElementById(idElement).style.backgroundColor = '#FFFFFF';
		document.getElementById(idElement).style.borderColor = '#cccccc';
		return true
	}
	else
	{
		document.getElementById(idElement).style.backgroundColor = '#fdf8f8';
		document.getElementById(idElement).style.borderColor = '#ff9999';
		return false
	}
}

function checkall(){
 var nom = checkTxtEmpty('nom')
 var email = checkemail('email')
 var tel = checkTel('tel')
 var adresse = checkTxtEmpty('input_adresse')
 var demande = checkTxtEmpty('demande')

if (!(nom && email && tel && adresse && demande))
{
	//document.getElementById('erreursaisie').style.visibility = 'visible';
	alert('Merci de bien remplir le formulaire.');
	return false ;
}
else
	document.insertion.submit();
	return true;
}