//Fonction déroulant un bloc et rouvrant le bloc suivant son état
function deroule_bloc(id_bloc, id_lien, content_open, content_close, delay)
{
	if(!delay)
	{	delay=0.5;	}
	//alert("Delay : " + delay);
	if($(id_bloc).className == "openBloc")
	{
		new Effect.BlindDown(id_bloc,{duration:delay});
		$(id_bloc).className = "closeBloc";
		//$(id_lien).innerHTML = content_close;
		$(id_lien).innerHTML =  '<img src="images/'+content_close+'" alt="moins" />';
	}
	else
	{
		Effect.BlindUp(id_bloc,{duration:delay});
		$(id_bloc).className = "openBloc";
		//$(id_lien).innerHTML = content_open;
		$(id_lien).innerHTML =  '<img src="images/'+content_open+'" alt="plus" />';
	}
}

//Fonction déroulant un bloc et rouvrant le bloc suivant son état V2
function deroule_bloc2(id, delay)
{
	if(!delay)
	{	delay=0.5;	}

	//alert("Delay : " + delay);
	if($('manif_lst'+id).className == "sous-lst-manif-li openBloc")
	{
		new Effect.BlindDown('manif_lst'+id,{duration:delay});
		$('manif_lst'+id).className = "sous-lst-manif-li closeBloc";
		
		//$('manif_li'+id).className = "moins-manif";
		//$(id_lien).innerHTML = content_close;
		//$(id_lien).innerHTML =  '<img src="images/'+content_close+'" alt="moins" />';
	}
	else
	{
		Effect.BlindUp('manif_lst'+id,{duration:delay});
		$('manif_lst'+id).className = "sous-lst-manif-li openBloc";
		
		//$('manif_li'+id).className = "plus-manif";
		//$(id_lien).innerHTML = content_open;
		//$(id_lien).innerHTML =  '<img src="images/'+content_open+'" alt="plus" />';
	}
}


function select_sous_categorie(etat, id_them){
	//var t_them = new array();
	
	//alert(etat);
	if(etat){
		//document.getElementById('categ_').value = document.getElementById('categ').value + '';
		//document.getElementById('id_checkbox').value = document.getElementById('categ').value + '';
	}else{
		
	}
}


function load_animaux(heber,type)
{
//	alert("Heb:" + heber + " Typ:" + type);
	if($('chk_accessibilite') && $('chk_animaux'))
	{	var a,h;
		a=true;	h=true;
		switch(heber)
		{	case 30000011:
				switch(type)
				{	case '30000124':	//Aires d'accueil de camping car
						h=false;	a=false;	break;
					case '30000027':	//Aires naturelles de camping
						h=false;	a=true; 	break;
					case '30000026':	//Campings à la ferme
						h=false;	a=true; 	break;
					case '30000165':	//Chalets, Mobilehome, huttes
						h=true; 	a=false; 	break;
					case '30000025':	//Hotelerie de plein air
						h=true; 	a=true; 	break;
					case '30000015':	//Meublés
						h=true; 	a=true; 	break;
					case '30000153':	//Meublés clévacance
						h=true; 	a=true; 	break;
				}
				break;
			case 30000027:
				switch(type)
				{	case '30000017':	//Auberges de jeunesse
						h=false; 	a=false; 	break;
				}
				break;
			case 30000005:
				switch(type)
				{	case '30000019':	//Chambres d'hôtes
						h=false; 	a=true; 	break;
				}
				break;
			case 30000007:
				switch(type)
				{	case '30000016':	//Gites d'enfant
						h=false; 	a=false; 	break;
				}
				break;
			case 30000027:
				switch(type)
				{	case '30000018':	//Gites d'etape et sejour
						h=true; 	a=true; 	break;
					case '30000166':	//Résidences de tourisme
						h=true; 	a=true; 	break;
					case '30000021':	//Structures polyvalentes d'hébergemnt
						h=true; 	a=false; 	break;
					case '30000022':	//Villages de vacances
						h=true; 	a=true; 	break;
				}
				break;
			case 30000004:
				switch(type)
				{	case '30000014':	//Gites ruraux, Gites de France
						h=true; 	a=true; 	break;
					case '30000023':	//Hameaux de gite
						h=true; 	a=true; 	break;
				}
				break;
			case 30000003:
				switch(type)
				{	case '30000011':	//Hotels
						h=true; 	a=true; 	break;
				}
				break;
		}
		if(a || h)
		{	$$('.recherche_animaux').invoke('show');	}
		else
		{	$$('.recherche_animaux').invoke('hide');	}

		if(h)
		{	$('chk_accessibilite').show();	}
		else
		{	$('chk_accessibilite').hide();
			$('accessbilite_handicape_oui').checked=false;		}
		if(a)
		{	$('chk_animaux').show();	}
		else
		{	$('chk_animaux').hide();
			$('accessbilite_animaux_oui').checked=false;		}
	}
}
//Fonction de remplissage de la liste des classement en fonction dy type d'hépergement
function load_classement()
{
	var data ='action=load_classement&type_hebergement='+$('type_hebergement').value;
	var myAjax = new Ajax.Updater(
				'lst_classement',
				'../_includesV2/fonctions_ajax.php',
				{
					method: 'post',
					parameters: data
			});
}
function add_panier(produit)
{
	var data ='action=add_panier&produit='+produit;
	var myAjax = new Ajax.Updater(
				'msg_add_panier',
				'../_includesV2/fonctions_ajax.php',
				{
					method: 'post',
					parameters: data,
					onSuccess: function(){	$('msg_add_panier').show();	}
			});
}
function coch_all(lst_prods)
{

	var tab_prod = Array();
	if($("all_coch").className == "all_coch_prod")
	{
		$("all_coch").className = "no_coch_prod";
		tab_prod = document.getElementsByClassName('prod_coch')
		for(var i in tab_prod)
		{
			tab_prod[i].checked=true
		}

	}
	else
	{
		$("all_coch").className = "all_coch_prod";
		tab_prod = document.getElementsByClassName('prod_coch')
		for(var i in tab_prod)
		{
			tab_prod[i].checked=false
		}
	}
}
function overlay() {
	new Effect.Appear('panier_overlay', { duration: 0.2, from: 0.0, to: 0.8 });
	$('panier_overlay').appendChild(Builder.node('img', {src:'ajax-loader.gif'}));
	return false;
}

function delete_produit(produit)
{
	var data ='action=del_produit&produit='+produit;
	overlay()
	var myAjax = new Ajax.Updater(
				'lst_panier',
				'../_includesV2/fonctions_ajax.php',
				{
					method: 'post',
					parameters: data,
					onComplete: function () {
						new Effect.Fade('panier_overlay', { duration: 0.2 });
					}
			});
}
function delete_checked_produit()
{
	tab_prod = document.getElementsByClassName('prod_coch');
	var lst_prod;
	var pass = 0;
	var all_del = "no";
	for(var i = 0; i < tab_prod.length; i++)
	{
		if(tab_prod[i].checked==true)
		{
			if(pass == 0)
				lst_prod = tab_prod[i].value;
			else
				lst_prod = lst_prod + "," + tab_prod[i].value;

			pass = pass + 1;
		}

	}

	if($("all_coch").className == "no_coch_prod" || pass==tab_prod.length)
	{
		all_del = "yes";
	}
	var data ='action=del_multi_produit&lst_prod='+lst_prod+'&all_del='+all_del;
	var myAjax = new Ajax.Updater(
				'lst_panier',
				'../_includesV2/fonctions_ajax.php',
				{
					method: 'post',
					parameters: data
			});
}
function clear_field(id_field, value_field, action)
{
	if(action == 'clear')
	{
		if(document.getElementById(id_field).value==value_field)
			document.getElementById(id_field).value = ''
	}
	else
	{
		if(document.getElementById(id_field).value=='')
			document.getElementById(id_field).value = value_field;
	}
}
function update_dep(dept)
{
	var data ='action=updt_cmn_lst&dept='+dept;
	alert(data);
	new Ajax.Updater(
				'communes_lst',
				'../_includesV2/fonctions_ajax.php',
				{
					method: 'post',
					parameters: data,
					oncomplete:debug_fct
			});
}
function debug_fct(originalRequest)
{
	alert(originalRequest.responseText);
}

function appelcarto(fiche_produit)
{
chaine="http://www.tourisme-limousin.net/applications/geo/portail/crt/portmap.Asp?&num_user=85&aspect=164&schema=WEBACCESS&lurlfiche=" + fiche_produit
window.open(chaine,'CARTO_LEI','scrollbars=no,resizable=no,width=700,height=550, left=100, top=50').focus();
}

function loadgmap()
{	if(document.getElementById('adressegmap') && document.getElementById('gmapframe'))
	{
		url = $('adressegmap').value;
		document.getElementById('gmapframe').innerHTML='<iframe style="border:solid 2px #336601;margin-bottom:10px;" height="455" width="505" id="gmapframe" src="'+url+'" />';
	}
}