function oninit(){
  if($("divMeteoMenu")) affUrlInDiv("divMeteoMenu","/config_v3/73/G.v3/STANDARDAJX.FRANCAIS/librairie/bloc_html/meteo.php");
  //if($("calendrierMoteurMenu")) setCalendrierGeneral("gites73","1","","","calendrierMoteurMenu",clicCalendJsMenu,"inpt_dateDeb","","","lst_nbj","1","");
  refreshCalDateArr();
  if($("inpt_ville")) appelAjaxToFunc("/lib/ajax/infosCGI.php","typeInfo=LISTALLCOMMUNE",setChmpCommuneAutoCompleter);
  afficheCapaciteGEGS();
}

function lanceRechercheMoteurAjxAcc(){
  document.location.href='http://www.gites-de-france-savoie.com/liste?'+getQueryStringByForm($('frm_moteurAjxAcc'));
}

function clicCalendJsMenu(evt,jour,mois,annee,etat){
  $("inpt_dateDeb").value=jour+mois+annee;
  afficheEffaceCalendJsMenu("calendrierMoteurMenu");
}

function afficheEffaceCalendJsMenu(nomDiv){
  if($(nomDiv).showing==true){
    Effect.BlindUp(nomDiv);       
    $(nomDiv).showing=false;
  }
  else{
    Effect.BlindDown(nomDiv);       
    $(nomDiv).showing=true;
  }
}

function affichePlusCrit(nomDiv,span,fcQdOuvert){
  if($(nomDiv).showing==true){
    Effect.BlindUp(nomDiv);       
    $(nomDiv).showing=false;
    $(span).innerHTML="+";
  }
  else{
    Effect.BlindDown(nomDiv);       
    $(nomDiv).showing=true;
    $(span).innerHTML="-";
    if(fcQdOuvert) fcQdOuvert();    
  }
}

function setCGIForLstCommune(li){
    if ( navigator.appName == 'Microsoft Internet Explorer' ){
      var commune = li.getElementsByTagName("span")[0].getAttribute("commune_reelle");
    }
    else{
      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;
    setListByForm($('frmMoteurGeneral'));
}

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 changeRegion(){
  $("radioRegion").checked=true;
  $("lst_rubriques").value="";
  $("inpt_ville_libcommune").value="";
  $("inpt_ville").value="Commune";
  setListByForm($('frmMoteurGeneral'));  
}

function changeDomaine(){
  $("radioDomaine").checked=true;
  $("micro_reg").value="";
  $("inpt_ville_libcommune").value="";
  $("inpt_ville").value="Commune";
  setListByForm($('frmMoteurGeneral'));  
}

function changeCommune(){
  $("radioCommune").checked=true;
  $("micro_reg").value="";
  $("lst_rubriques").value="";  
}

function checkMaxi(){
  if($("acc_maxi").value!="G"){ 
    $("acc_maxi").value="G";
    $("spe_maxi").value="12"; 
    supprGdf();
    supprChalet();
    supprAlpage();
    $("lst_nbp").options[$("lst_nbp").options.selectedIndex].value = "";
    refreshCalDateArr();
  }
  else supprMaxi();
}
function checkAlpag(){
  if($("acc_alpag").value!="G"){
    $("acc_alpag").value="G";
    $("spe_alpag").value="ALPAG";
    $("inpt_bas").value="H";
    supprGdf();
    supprChalet();
    supprMaxi(); 
    refreshCalDateArr();
  }
  else supprAlpage();
}
function checkChalet(){
  if($("acc_chalet").value!="G"){ 
    $("acc_chalet").value="G";
    $("spe_chalet").value="CHALETSLOISIRS";   
    supprGdf();
    supprAlpage();
    supprMaxi();
    refreshCalDateArr();
  }
  else supprChalet();
}

function checkGDF(){
  $("radio_GDF").checked=true;
  supprMaxi();
  supprAlpage();
  supprChalet();
  refreshCalDateArr();  
}
function supprMaxi(){
  $("acc_maxi").value="";
  $("spe_maxi").value="";
  $("inpt_maxi").checked=false;
}
function supprAlpage(){
  $("acc_alpag").value="";
  $("spe_alpag").value=""; 
  $("inpt_bas").value="G";
}
function supprChalet(){
  $("acc_chalet").value="";
  $("spe_chalet").value="";
}
function supprGdf(){
  $("inpt_g").checked=false;
  $("inpt_h").checked=false;
  $("inpt_t").checked=false;
  $("inpt_e").checked=false;
  $("inpt_c").checked=false;
}


function refreshCalDateArr(){
	if ($("calendrierMoteurMenu")){
		if(($("inpt_h") && $("inpt_h").checked) || ($("lst_type") && $("lst_type").value=="H")){
	       	setCalendrierGeneral("gites73","1","","H","calendrierMoteurMenu",clicCalendJsMenu,"inpt_dateDeb","","","lst_nbj","1","");
		}else{
		 	setCalendrierGeneral("gites73","1","","G","calendrierMoteurMenu",clicCalendJsMenu,"inpt_dateDeb","","","lst_nbj","1","");
		}
	}
}

function valideDate(){
  if((!$("inpt_dateDeb").value) || ($("lst_nbj").value=="")) alertAMalibu("Vous devez saisir la date d'arriv&eacute;e et la dur&eacute;e de votre s&eacute;jour !");
  else setListByForm($('frmMoteurGeneral'));
} 

function afficheCapaciteGEGS(){
	if($("inpt_t").checked){
		var lst_nbp = $("lst_nbp");
		var optionGEGS = new Element("option", {'class':'optionGEGS','value':'in (10,11,12,13,14,15,16,17,18,19)'});
		optionGEGS.insert("De 10	à 19 ");
		lst_nbp.insert({bottom:optionGEGS});
		
		var optionGEGS = new Element("option", {'class':'optionGEGS','value':'in (20,21,22,23,24,25,26,27,28,29)'});
		optionGEGS.insert("De 20	à 29 ");
		lst_nbp.insert({bottom:optionGEGS});
		
		var optionGEGS = new Element("option", {'class':'optionGEGS','value':'in (30,31,32,33,34,35,36,37,38,39)'});
		optionGEGS.insert("De 30	à 39 ");
		lst_nbp.insert({bottom:optionGEGS});
		
		var optionGEGS = new Element("option", {'class':'optionGEGS','value':'in (40,41,42,43,44,45,46,47,48,49)'});
		optionGEGS.insert("De 40	à 49 ");
		lst_nbp.insert({bottom:optionGEGS});
		
		var optionGEGS = new Element("option", {'class':'optionGEGS','value':'in (50,51,52,53,54,55,56,57,58,59)'});
		optionGEGS.insert("De 50	à 59 ");
		lst_nbp.insert({bottom:optionGEGS});
	}else{
		$$(".optionGEGS").each(Element.remove);
	}
}



