
var MaxPictos = 33;
var char34 = String.fromCharCode(34);


function textePictos( ind, etat, offs ) {
var TabLib = new Array(MaxPictos);
TabLib[1] = "Centre Village";
TabLib[2] = "Bord de mer";
TabLib[3] = "Bord de rivière";
TabLib[4] = "Jardin/parc";
TabLib[5] = "Terrasse";
TabLib[6] = "Piscine";
TabLib[7] = "Accès handicapé";
TabLib[8] = "Aire de jeux";
TabLib[9] = "Plage aménagée";
TabLib[10] = "Balcon";
TabLib[11] = "Restaurant";
TabLib[12] = "Bar";
TabLib[13] = "Animaux admis";
TabLib[14] = "Parking";
TabLib[15] = "Accueil groupe";
TabLib[16] = "Point phone";
TabLib[17] = "Salon TV";
TabLib[18] = "TV dans les chambres";
TabLib[19] = "Sèche-cheveux";
TabLib[20] = "Ventilateur";
TabLib[21] = "Chauffage";
TabLib[22] = "Climatisation";
TabLib[23] = "Téléphone dans les chambres";
TabLib[24] = "Canal plus";
TabLib[25] = "TV Satellite";
TabLib[26] = "Lave-vaisselle";
TabLib[27] = "Lave-linge ou laverie";
TabLib[28] = "Cuisinette avec four";
TabLib[29] = "Réfrigérateur";
TabLib[30] = "Linge fourni";
TabLib[31] = "Animations";
TabLib[32] = "Bungalows";
TabLib[33] = "Barbecue";



if( etat == 1 ) {
	lib=TabLib[ind];
	document.f2.b1.value = lib;

//	document.forms[offs].b1.value = lib;
} else {
    document.f2.b1.value = "";
	//document.forms[offs].b1.value = "";
}
}




function traitePictos( TabP, offs ) {
  offs++;
  DebTab = "<table border='0' cellpadding='0' cellspacing='1'><tr>";
  document.write( DebTab );
  cp = 0;
  for (i = 0; i < MaxPictos; i++)  {
	   if( TabP[i] != null ) {
          LignePictos = "<td width='22' height='22'>";
		  LignePictos += "<a href='javascript:' onmouseover=" + char34 + "textePictos(" + i + ", 1," + offs + " );" + char34;
		  LignePictos += " onmouseout=" + char34 + "textePictos(" + i + ", 0," + offs + ");" + char34;
		  strim = 'images/p';
      //    strim = ( i > 55 ? "images/c" : "images/h" );
          LignePictos += "><table border='0' cellpadding='0' cellspacing='1' class='bggris1'><tr><td bgcolor='#FFFFFF'><img src='" + strim + i + ".gif' border='0'></td></tr></table></a></td>";
          LignePictos += "<td class='bgtest3' width='1'></td>";
          if( cp == 14 || cp == 29 )
            LignePictos += "</tr><tr>";
		 document.write( LignePictos );
         cp++;
	   }
  }
  document.write( "</tr></table>" );
}




var sendToPop = new Class( {
	
	initialize: function( el ) {
		
		this.element	= el;
		this.script 	= '';
		this.widthPop	= '750';
		this.heightPop	= '600';
		this.scrollPop	= 'auto';
		this._param		= '';
		
	},
	
	active: function( event, script ) {
		if( script != null ) {
			this.script = script;
		}
		this.element.addEvent( event, this.sendPop.bindAsEventListener(this) );
	},
	
	
	popup: function ( script ) {
		strhei = "height=" + this.heightPop;
		strwid = "width=" + this.widthPop;
		if( script!=null ) {
			this.script = script;
		}
		scrol = "scrollbars=" + this.scrollPop;
		strf = strhei + "," + strwid + "," + scrol;
		window.open( this.script + this._param, '', strf );
	},

	
	sendPop: function() {
		if( this.element.getValue() != 0 ) {
			this._param = '?id=' + this.element.getValue();
			this.element.options[0].selected = true;
		} 
		this.popup();
	}
	
} );






var listeToggle2 = new Class( {

	initialize: function(options) {
		this.listeTag	= '';
		this.groupTag	= '';
		this.width		= '100px';
		this.height		= 'auto';
		this.duration	= 300;
		this.showDelay  = 5000;
		this.options	= {};
		this.setParam(options);

	},

	setParam: function(options) {
		if( $chk( options ) ) {
			this.options = options;
		}
		if( $chk(this.options.groupTag) ) {
			this.groupTag = this.options.groupTag;
		}
		if( $chk(this.options.listeTag) ) {
			this.listeTag = this.options.listeTag;
		}
		if( $chk(this.options.height) ) {
			this.height = this.options.height;
		}
		if( $chk(this.options.width) ) {
			this.width = this.options.width;
		}
		if( $chk(this.options.duration) ) {
			this.duration = this.options.duration;
		}
		if( $chk(this.options.showDelay) ) {
			this.showDelay = this.options.showDelay;
		}
		if( $chk(this.options.listeStyle) ) {
			this.listeStyle = this.options.listeStyle;
		}
		$(this.groupTag).setStyle( 'width', this.width );
		$(this.listeTag).setStyle( 'height', this.height );
		$(this.listeTag).setStyle( 'width', this.width );

		$(this.listeTag).setStyles( this.listeStyle );
	},




	clickAction: function( link, groupe ) {
		if( $chk(groupe) ) { this.groupTag = groupe; }
		var sDelay = this.showDelay;
		var grTag = $(this.groupTag);
		var closeT;
		var fx = new Fx.Slide($(this.listeTag), {duration: this.duration});
		fx.hide();
		//alert( $(this.listeTag).getStyle('height') );
		/*if( $(this.listeTag).getStyle('height') == '0px' ) {
				alert( fx.vertical() );
		}*/
		$(link).addEvent('click', function(){
			fx.clearTimer();
			fx.toggle();
			grTag.addEvent( 'mouseout', function() {
				closeT = $clear(closeT);
				closeT = function() { fx.slideOut(); }.delay(sDelay);
			});
			grTag.addEvent( 'mouseover', function() {
				closeT = $clear(closeT);
			});
			//var closeT = function() { fx.toggle(); }.delay(sDelay);
		});
	}

});











var blocRefresh = new Class( {

	initialize: function( blocA, blocR ) {

		this.waitMessage		= '<div id="waiting">Chargement...</div>';
		this.method				= 'get';
		this.blocAction 		= blocA;
		this.blocResult 		= blocR;

		this.tabAction			= [];
		this.tabResult			= [];
		this.EventType			= [];

		this.param 				= '';
		this.ciblingTag 		= '';
		this.script 			= '';

		this.eventListenType 	= 'click';
		this.blocOnComplete		= '';

		this.onCompleteOptions	= {};
		this.tempTab = {};
	},



	showLoad: function() {
		if( !$('tb_load') ) {
			new Element('div').setProperty('id', 'tb_load').injectInside(this.blocAction);
			$('tb_load').innerHTML = '<p align="center"><img src="images/indicator_snake.gif" /><br/>Chargement...</p>';
			this.tbLoadPosition();
		}
	},


	hideLoad: function() {
		if( $('tb_load') ) {
			$('tb_load').remove();
		}
	},


	tbLoadPosition: function() {
		if( $('tb_load') ) {
			$('tb_load').setStyles({
							width: 'auto',
							margin: '50px auto',
							display: 'block'
					});
		}
	},


	setEventAjax: function( typeEvent ) {
		if( typeEvent != null ) {
			this.eventListenType = typeEvent;
		}
		$(this.blocAction).addEvent( this.eventListenType, this.traiteEvent.bind(this) );
	},


	setOnComplete: function( options ) {
		if( window.ie ) {
			options.evTypeOnComplete = 'click';
		}
		this.onCompleteOptions = options;
	},

	onComplete: function(e) {
		var e = new Event(e).stop();
		var el= e.target;
		this.param = el.name + '=' + el.value;
		new Ajax( this.onCompleteOptions.scriptOnComplete, { 	onStateChange: this.waitMessage,
											method: this.onCompleteOptions.method,
											postBody: this.param,
											update: this.onCompleteOptions.targetBloc }).request();
	},


	onCompleteAction: function(e) {
		this.hideLoad();
		if( $(this.blocOnComplete) ) {
			$(this.blocOnComplete).addEvent( this.eventListenType, this.traiteEvent.bind(this) );
		} else {
			$(this.onCompleteOptions.actionBloc).addEvent( this.onCompleteOptions.evTypeOnComplete, this.onComplete.bind(this) );
		}
	},



	traiteEvent: function(e) {
		var e = new Event(e).stop();
		var el= e.target;
		if( $(el).getTag() == this.ciblingTag ) {
			if( this.script=='' ) {
				this.ajaxAction( el.href );
			} else {
				this.param = el.name + '=' + el.value;
				this.ajaxAction( this.script );
			}
		}
	},

	ajaxAction: function( link ) {
		new Ajax( link, { 	onStateChange: this.showLoad(),
							method: this.method,
							update: this.blocResult,
							postBody: this.param,
							onComplete: this.onCompleteAction.bind(this) }).request();

	}

} );

















function init() {


	if( $('listeDispo') ) {	
		var popVisite = new sendToPop( $('listeDispo') );
		popVisite.scrollPop	= 'yes';
		popVisite.active( 'click', 'periodedispo.php3' );
	}
		
	
	if( $('grHeber') ) {
		$('sHeber').toggleClass( 'slidHeber' );
		$$('#listeTypeHeber div').toggleClass( 'listeHeber' );
		var listeTypeHeber = new listeToggle2({
			'width': '120px',
			'height': 'auto',
			'duration': 200,
			'showDelay': 100,
			'groupTag': 'grHeber',
			'listeTag': 'listeTypeHeber',
			'listeStyle': { overflow:'hidden'}
		});
		listeTypeHeber.clickAction( 'sHeber' );
	}

	if( $('grHeber2') ) {
		$('sHeber2').toggleClass( 'slidHeber' );
		$$('#listeTypeHeber2 div').toggleClass( 'listeHeber' );
		var listeTypeHeber2 = new listeToggle2({
			'width': '120px',
			'height': 'auto',
			'duration': 200,
			'showDelay': 100,
			'groupTag': 'grHeber2',
			'listeTag': 'listeTypeHeber2',
			'listeStyle': { overflow:'hidden'}
		});
		listeTypeHeber2.clickAction( 'sHeber2' );
	}

	if( $('grDispo') ) {
		$('sDispo').toggleClass( 'slidDispo' );
		$$('#listeDispo div').toggleClass( 'liste' );
		var listeTypeHeber2 = new listeToggle2({
			'width': '530px',
			'height': 'auto',
			'duration': 200,
			'showDelay': 800,
			'groupTag': 'grDispo',
			'listeTag': 'liste',
			'listeStyle': { overflow:'hidden'}
		});
		listeTypeHeber2.clickAction( 'sDispo' );
	}


	if( $('grActi') ) {
		$('sActi').toggleClass( 'slidActi' );
		$$('#listeTypeActi div').toggleClass( 'listeActi' );
		var listeTypeActi = new listeToggle2({
			'width': '120px',
			'height': 'auto',
			'duration': 200,
			'showDelay': 100,
			'groupTag': 'grActi',
			'listeTag': 'listeTypeActi',
			'listeStyle': { overflow:'hidden'}
		});
		listeTypeActi.clickAction( 'sActi' );
	}

/*	if($('stype1') ) {
		var liste1 = new listeToggle2({
			'width': '125px',
			'height': 'auto',
			'duration': 300,
			'showDelay': 100,
			'groupTag': 'typeSelect1',
			'listeTag': 'stype1',
			'listeStyle': { overflow:'hidden'}
		});
		liste1.clickAction( 'ltype1' );
	}*/


	if( $('stype2') ) {
	//	$('blocChoixAct').toggleClass( 'blocChoix2' );
		var liste2 = new listeToggle2({
			'width': '125px',
			'height': 'auto',
			'duration': 300,
			'showDelay': 100,
			'groupTag': 'typeSelect2',
			'listeTag': 'stype2',
			'listeStyle': { overflow:'hidden'}
		});
		liste2.clickAction( 'ltype2' );

	}

	if( $('_listeStruct') ) {
		var contenu2 = new blocRefresh( '_listeStruct', '_listeBloc' );
		contenu2.eventListenType = 'change';
		/*contenu2.setOnComplete( {	scriptOnComplete:'listebloc.php3',
									evTypeOnComplete:'change',
									actionBloc: '_listeStruct',
									targetBloc: '_listeBloc',
									method: 'post' } );		*/
		contenu2.ajaxAction( 'listebloc.php3' );
	}

}

Window.onDomReady( init );
