sfHover = function() {
        var sfEls = document.getElementById("menu").getElementsByTagName("LI");
        for (var i=0; i<sfEls.length; i++) {
                sfEls[i].onmouseover=function() {
                        this.className+=" sfhover";
                }
                sfEls[i].onmouseout=function() {
                        this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
                }
        }
}
if (window.attachEvent) window.attachEvent("onload", sfHover);


//Voila la fonction...

function OpenCenterPopUp(file){
var Left=window.screen.width/2-175;
var Top=window.screen.height/2-175;
//Videment faut modifier la config!!
var Configuration="'toolbar=no, menubar=no, location=no, directories=no, status=no, resizeable=no, width=400, height=350, left=" + Left + ", top=" + Top;
window.open(file,'NomDeMaPopUp',Configuration);
} 

// fonction afficher la photo...

function refreshImg(nom,fich){
     document.getElementById(nom).src = 'upload/'+ document.getElementById(fich).value;
   }
 
function NoModif() { 
  alert('Champ photo !!!! Vous ne devez ni modifier ni écrire. Pour ajouter une photo cliquez sur l\'icone à droite'); 
  }
  
function NoTexte() {
  document.post.mini_texte.style.border='1px solid #FF3300';
  document.post.mini_texte.focus(); 
  alert('Vous devez taper le texte de votre annonce dans le mini champ juste au dessus de celui ci. Il s\'écrira automatiquement dans cet emplacement.');
   
  }

  
  
function simulateClick1() {
  document.getElementById("photo1").select(); 
if (document.post.photo1.value != "") { 
  document.getElementById("mini11").innerHTML ="<strong>Photo 1 ajoutée : </strong>";
  document.getElementById("upload1").innerHTML ="<strong>Réussi : </strong>"; 
  setTimeout(function() { document.getElementById('mini11').click(); }, 500);
}  }
function demarrer1() {
  rcv1= setInterval(simulateClick1, 3000);
}
 
function simulateClick2() {
  document.getElementById("photo2").select();
if (document.post.photo2.value != "") {
  document.getElementById("mini22").innerHTML ="<strong>Photo 2 ajoutée : </strong>";
  document.getElementById("upload2").innerHTML ="<strong>Réussi : </strong>"; 
  setTimeout(function() { document.getElementById('mini22').click(); }, 500);
  }  } 
function demarrer2() {
  rcv2= setInterval(simulateClick2, 3000);
  }

function simulateClick3() {
  document.getElementById("photo3").select(); 
if (document.post.photo3.value != "") {
  document.getElementById("mini33").innerHTML ="<strong>Photo 3 ajoutée : </strong>";
  document.getElementById("upload3").innerHTML ="<strong>Réussi : </strong>"; 
  setTimeout(function() { document.getElementById('mini33').click(); }, 500);
  }  }
function demarrer3() {
  rcv3= setInterval(simulateClick3, 3000);
  }

function simulateClick4() {
  document.getElementById("photo4").select();  
if (document.post.photo4.value != "") {
  document.getElementById("mini44").innerHTML ="<strong>Photo 4 ajoutée : </strong>";
  document.getElementById("upload4").innerHTML ="<strong>Réussi : </strong>"; 
  setTimeout(function() { document.getElementById('mini44').click(); }, 500);
  }  }
function demarrer4() {
  rcv4= setInterval(simulateClick4, 3000);
  }
  
  // FONCTION COPIER COLLER INTERDIT
  
  function ejs_nodroit()
{
alert('Copier/Coller interdit');
return(false);
}
document.oncontextmenu = ejs_nodroit;
  
  // FONCTION ECRIRE DANS LE TEXTAREA
  
  function ajout_texte(texte) {
document.getElementById('texte').value += texte.substring(0,1);
document.getElementById('mini_texte').value = '';
}
function effacer() {
var champ = document.getElementById('texte').value;
var longueur = champ.length - 1;
document.getElementById('texte').value = champ.substr(0,longueur);
}
function touteffacer() {
var champ = document.getElementById('texte').value;
var longueur = champ.length - 1000;
document.getElementById('texte').value = champ.substr(0,longueur);
}

var oldText = '';
function pasteControl()
{ 
var text = document.getElementById("description").value;
if (text.length > (oldText.length+6))
document.getElementById("description").value = oldText;
else
oldText = text;
}
  
  // FONCTION VERIFICATION DU FORMULAIRE
  
  function couleur(obj) {
obj.style.backgroundColor = "#FFFFFF";
}

function check() {
var msg = "";

if (document.post.id_categorie.value == "") {
msg += "Veuillez indiquer votre région\n";
document.post.id_categorie.style.backgroundColor = "#FF99FF";
}
else
    {
document.post.id_categorie.style.backgroundColor = "#FFFFFF";
    }
    
if (document.post.id_sous_categories.value == "") {
msg += "Veuillez indiquer votre département\n";
document.post.id_sous_categories.style.backgroundColor = "#FF99FF";
}
else
    {
document.post.id_sous_categories.style.backgroundColor = "#FFFFFF";
    }
    
if (document.post.id_rubriques.value == "") {
msg += "Veuillez choisir une rubrique\n";
document.post.id_rubriques.style.backgroundColor = "#FF99FF";
}
else
    {
document.post.id_rubriques.style.backgroundColor = "#FFFFFF";
    }

if (document.post.nom.value == "") {
msg += "Veuillez saisir un titre pour votre annonce\n";
document.post.nom.style.border='1px solid #FF3300';
document.post.nom.focus();
}
else
    {
document.post.nom.style.border='1px solid #29cf48';
    }
    
if (document.post.texte.value != "") {
Mot1 = document.post.texte.value.indexOf('donne');
Mot2 = document.post.texte.value.indexOf('Donne');
Mot3 = document.post.texte.value.indexOf('don');
Mot4 = document.post.texte.value.indexOf('Don');
Mot5 = document.post.texte.value.indexOf('Offre');
Mot6 = document.post.texte.value.indexOf('Offres');
Mot7 = document.post.texte.value.indexOf('voyance');
Mot8 = document.post.texte.value.indexOf('Voyance');
Mot9 = document.post.texte.value.indexOf('medium');
Mot10 = document.post.texte.value.indexOf('Medium');
Mot11 = document.post.texte.value.indexOf('médium');
Mot12 = document.post.texte.value.indexOf('Médium');
Mot13 = document.post.texte.value.indexOf('pret');
Mot14 = document.post.texte.value.indexOf('Pret');
Mot15 = document.post.texte.value.indexOf('prèt');
Mot16 = document.post.texte.value.indexOf('Prèt');
Mot17 = document.post.texte.value.indexOf('gratuit');
if ((Mot1 < 0) && (Mot2 < 0) && (Mot3 < 0) && (Mot4 < 0) && (Mot5 < 0) && (Mot6 < 0) && (Mot7 < 0) && (Mot8 < 0) && (Mot9 < 0) && (Mot10 < 0) && (Mot11 < 0) && (Mot12 < 0) && (Mot13 < 0) && (Mot14 < 0) && (Mot15 < 0) && (Mot16 < 0) && (Mot17 < 0)) {
document.post.texte.style.border='1px solid #29cf48';
}
else
    { 
document.post.texte.style.border='1px solid #FF3300';
document.post.mini_texte.style.border='2px solid #FF3300';
msg += "Il y a des mots interdits dans le texte de votre annonce.\n";
document.post.texte.value = "";
document.post.mini_texte.focus();

    }
}

if (document.post.texte.value != "") {
Espaces = document.post.texte.value.indexOf('   ');
if ((Espaces < 0)) {
document.post.texte.style.border='1px solid #29cf48';
}
else
    { 
document.post.texte.style.border='1px solid #FF3300';
document.post.mini_texte.style.border='2px solid #FF3300';
msg += "Vous ne pouvez pas mettre plusieurs espaces de suite dans le texte de votre annonce. Tapez votre texte normalement vous pourrez faire la mise en page une fois votre annonce validée .\n";
document.post.texte.value = "";
document.post.mini_texte.focus();

    }
}
    
if (document.post.texte.value == "") {
msg += "Veuillez saisir le texte de votre annonce\n";
document.post.mini_texte.style.border='1px solid #FF3300';
document.post.mini_texte.focus();
}
else
    {
    document.post.mini_texte.style.border='1px solid #29cf48';
    document.post.texte.style.border='1px solid #29cf48';
    }
    
if (document.post.auteur.value == "") {
msg += "Veuillez saisir votre nom\n";
document.post.auteur.style.border='1px solid #FF3300';
document.post.auteur.focus();
}
else
    {
document.post.auteur.style.border='1px solid #29cf48';
    }
    
if (document.post.email2.value != "") {
indexAroba = document.post.email2.value.indexOf('@');
indexPoint = document.post.email2.value.indexOf('.');
if ((indexAroba < 0) || (indexPoint < 0)) {
document.post.email2.style.border='1px solid #FF3300';
msg += "Adresse email incorrecte\n";
document.post.email2.focus();
}
else
    {
document.post.email2.style.border='1px solid #29cf48';
    }
}
else {
document.post.email2.style.border='1px solid #FF3300';
msg += "Veuillez saisir votre adresse email.\n";
}


if (document.post.code_postal.value == "") {
msg += "Veuillez saisir votre code postal\n";
document.post.code_postal.style.border='1px solid #FF3300';
document.post.code_postal.focus();
}
else
    {
document.post.code_postal.style.border='1px solid #29cf48';
    }
    
if(document.post.telephone2.value == "") {
alert("Veuillez saisir votre numéro de téléphone!");
document.post.telephone2.style.border='1px solid #FF3300';
document.post.telephone2.focus();
return false;
}
var chkZ = 1;
for(i=0;i<document.post.telephone2.value.length;++i)
if(document.post.telephone2.value.charAt(i) < "0"
|| document.post.telephone2.value.charAt(i) > "9")
if(document.post.telephone2.value.charAt(i) > " ")
if(document.post.telephone2.value.charAt(i) > ".")
if(document.post.telephone2.value.charAt(i) > "/")
chkZ = -1;
if(chkZ == -1) {
alert("Votre numéro de téléphone est invalide!");
document.post.telephone2.style.border='1px solid #FF3300';
document.post.telephone2.value = "";
document.post.telephone2.focus();
return false;
}
else
    {
document.post.telephone2.style.border='1px solid #29cf48';
    }

if (msg == "") return(true);
else {
alert(msg);
return(false);
}
}
