function clicCalendJs(evt,jour,mois,annee,etat){
  $("inpt_dateDeb").value=jour+mois+annee;
  afficheEffaceCalendJsMenu("calendrierMoteur");
}

function afficheEffaceCalendJsMenu(nomDiv){
  if($(nomDiv).showing==true){
    Effect.BlindUp(nomDiv);       
    $(nomDiv).showing=false;
  }
  else{
    Effect.BlindDown(nomDiv);       
    $(nomDiv).showing=true;
  }
}

function lanceRecherche(form){
  document.location.href='/liste?'+getQueryStringByForm($(form));
}

function plusDeCriteres(div){
  $(div).morph("width:263px;");
}
function moinsDeCriteres(div){
  $(div).morph("width:0px;");
}

function foncQdMoteurCharge(){
  appelAjaxToFunc("/lib/ajax/infosCGI.php","typeInfo=LISTALLCOMMUNE",setChmpCommuneAutoCompleter);
  setCalendrierGeneral("gites78","1","","","calendrierMoteur",clicCalendJs,"inpt_dateDeb","","","lst_nbj","1","");
}

function setCGIForLstCommune(li){
    var commune = li.getElementsByTagName("span")[0].getAttribute("commune_reelle");
    document.getElementById("inpt_ville").value=commune;
    document.getElementById("inpt_ville").onfocus=function (evt){this.value='';document.getElementById("inpt_ville_libcommune").value='';}
    document.getElementById("inpt_ville").onblur=function (evt){document.getElementById("inpt_ville_libcommune").value=this.value;}
    
    document.getElementById("inpt_ville_libcommune").value=commune;
}

function setChmpCommuneAutoCompleter(reponse){
    var suffixe;
    var jsonarray=eval(reponse);
    var infos=[];
    for (var i=0;i<jsonarray.length;i++){
        (jsonarray[i].nb>1)?suffixe="s":suffixe="";
        infos.push(jsonarray[i].commune+" ("+Math.round(jsonarray[i].nb)+" réponse"+suffixe+")<span commune_reelle=\""+jsonarray[i].communeReelle+"\" />"); 
     }
    
    /**** champ commune ****/
    var typeahead = new Autocompleter.Local('inpt_ville', 'divLstCommunes_inpt_ville', infos, {
        frequency: 0.5,
        updateElement: setCGIForLstCommune
    });
}


function setChmpPrixToReglette(reponse){

    if (!reponse)return;
    eval("var infosPrix="+reponse);
 
    /**** reglette de prix *****/
      var reglette = $('slider_prix');
      if (reglette){
      var vals=new Array();   
      var pxMini=parseInt(infosPrix.prix_mini);
      var pxMaxi=parseInt(infosPrix.prix_maxi);
      
      $("infoPrix_prixMini").innerHTML=pxMini+"&nbsp;&euro;";
      $("infoPrix_prixMaxi").innerHTML=pxMaxi+"&nbsp;&euro;";
      
      for (var i=pxMini;i<=2500;i+=25)vals.push(i);
      new Control.Slider(reglette.select('.handle'), reglette, {
          range: $R(0, 2500),
          sliderValue: [pxMini, pxMaxi],
          restricted: true,
          values: vals,
          onSlide: function(values) {
            $("infoPrix_prixMini").innerHTML=values[0];
            $("infoPrix_prixMaxi").innerHTML=values[1];
          },
          onChange: function(values) { 
            $("inpt_pxmini").value=values[0];
            $("inpt_pxmaxi").value=values[1];
            setListByForm($('frmMoteurGeneral'));         
          }
        });
       }
}

function valideInscNews(){
    envoiMailByAjaxByForm('frm_newsletter','mesg_replace',false);
}

function envoiFormLabel(){
  envoiMailByAjaxByForm('frm_Obtlabel','div_form',true);
}
function envoiFormGuide(){
  envoiMailByAjaxByForm('frm_guide','div_form',true);
}
function envoiFormDeContact(){
  envoiMailByAjaxByForm("frm_contact","div_form",true);
}

