//
function formulaire(){
    var error = $("p.error");
    var load = $("img.load");
    $(error).hide();
    
    $("form#commentBlog").submit(function(e){
	e.preventDefault();
	if( ($("#email").val() == "") || ($("#comment").val() == "")  ){
	    $(error).text("");
	    $(error).append("Tous les champs sont obligatoires").fadeIn(200);
	}else if( $("#code").val() != 5) {
	    $(error).text("");
	    $(error).append("Le code anti-spam est incorrect.").fadeIn(200);
	}else{
	    var datas = $(this).serialize();
	    $(load).show();
	    $(error).text("");
	    $.ajax({
		type: 'POST',      // envoi des données en POST
		url: $(this).attr('action'),     // envoi au fichier défini dans l'attribut action
		data: datas,     // sélection des champs à envoyer
		success: function(msg) {     // callback en cas de succès
		    $(error).text("");
		    $(load).hide();
		    if(msg == 1){
			$(error).append("Commentaire enregistré.");
			$(error).fadeIn(200);
			$("#commentBlog").hide();
		    }else{
			$(error).append("Erreur lors de l'enregistrement. Recommencer.");
		    }
		}
	    });
	}
    });
}


function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MasquerDiv(nom_div){
	var div = nom_div;
	document.getElementById('div_'+div).style.display = 'none';
}

function setproperty(div, value, initvalue){
	if(document.getElementById(div).style.fontSize == value+"px"){
		document.getElementById(div).style.fontSize = initvalue+"px";
	}else{
		document.getElementById(div).style.fontSize = value+"px";
	}
}

function confirmerSuppressionDossier(modId,dr,sd){
	if(confirm("Etes-vous sûr de vouloir supprimer ce dossier ?\nTous les fichiers présents dans ce dossier seront supprimés")){
	window.location="index.php?m="+modId+"&dr="+dr+"&sd="+sd+"&supprimerDossier";
	}
}

function confirmerSuppressionFichier(modId,dr,sd,fichier,div,typeAffichage){
	if(confirm("Etes-vous sûr de vouloir supprimer ce fichier ?")){
	window.location="index.php?m="+modId+"&dr="+dr+"&sd="+sd+"&fichier="+fichier+"&supprimerFichier&div="+div+"&af="+typeAffichage+"";
	}
}

function confirmerSuppression(modId,enrId,titre,rub){
	if(confirm("Etes-vous sûr de vouloir supprimer cet enregistrement ?")){
	window.location="index.php?"+modId+"&"+enrId+"&t="+titre+"&supprimer=true&div="+rub+"";
	}
}

function confirmerSuppression2(url,enrId,titre,rub){
	if(confirm("Etes-vous sûr de vouloir supprimer cet enregistrement ?")){
	window.location="index.php?"+url+"&"+enrId+"&t="+titre+"&supprimer=true&div="+rub+"";
	}
}

// coloriser champ lors d'un focus
function color_input(id){
	document.getElementById(id).style.backgroundColor = '#EBEBEB';
}
function no_color_input(id){
	document.getElementById(id).style.backgroundColor = '#FFFFFF';
}

// Afficher et masquer un div
// Afficher et masquer un div
function AfficherDiv(nom_div,puce){
	var div = nom_div;
	var modifierPuce = puce;
	 if(document.getElementById('div_'+div).style.display == 'block'){
	 	document.getElementById('div_'+div).style.display = 'none';
		if(modifierPuce){
			document.getElementById('puce_'+div).src = 'imagesDefault/puce_plus.gif';
		}
	}else{
		document.getElementById('div_'+div).style.display = 'block';
		document.getElementById('puce_'+div).src = 'imagesDefault/puce_moins.gif';
	}
	 
}
function MasquerDiv(nom_div){
	var div = nom_div;
	document.getElementById('div_'+div).style.display = 'none';
}

function AfficherDivInfosPratiques(nom_div1, nom_div2, nom_div3){
	document.getElementById('div_'+nom_div1).style.display = 'block';
	document.getElementById('bt_'+nom_div1).backgroundImage = 'imagesFront/bt_infos_on.png';
	document.getElementById('div_'+nom_div2).style.display = 'none';
	document.getElementById('bt_'+nom_div2).backgroundImage = 'imagesFront/bt_infos_off.png';
	document.getElementById('div_'+nom_div3).style.display = 'none';
	document.getElementById('bt_'+nom_div3).backgroundImage = 'imagesFront/bt_infos_off.png';
}


// gestion des menus déroulant
window.onload=affiche_div;
function affiche_div(id){
	var div = document.getElementById('div_'+id);
	for (var i = 0; i<=100; i++) {
		if (document.getElementById('div_'+i)) {
		document.getElementById('div_'+i).style.display='none';
		}
	}
	if(div){
	document.getElementById('div_'+id).style.display='block';
	document.getElementById('div_'+id).style.marginBottom = '20px';
	}
}

function coloriserDt(div,color){
	document.getElementById('dt'+div).style.backgroundColor = color;
}

function coloriser(div){
	document.getElementById(div).style.backgroundColor = '#EBEBEB';
}
function divFondBlanc(div){
	document.getElementById(div).style.backgroundColor = '#FFFFFF';
}

window.onload=montre;
function montre(nameDD,id) {
var d = document.getElementById(nameDD+id);
	for (var i = 1; i<=100; i++) {
		if (document.getElementById(nameDD+i)) {
			//alert(nameDD+i);
			document.getElementById(nameDD+i).style.display='none';
		}
	}
	if(d){
		d.style.display='block';
	}
}

function verifSelectFichier(){
	if(document.form1.image_a_copier.value == ''){
	alert("Sélectionner une image à enregistrer");
	return false;
	}else{
	return true;
	}
}

function progression(){
	document.getElementById("progression").style.display = 'block';
}

