
var ANEOL = {

	validation: {//{{{
		validate: function(){//{{{
			var ok=true;
  			var i=0;			
			while(ok && i < arguments.length){
				ok = arguments[i](arguments[i+1]);
				i = i+2;
			}
			return ok;
		},//}}}
		execOnReturn: function(e, func){//{{{
			//var key = (e.keyPress) ? e.keyPress : e.which;
			var key = e.keyPress || e.which || e.keyCode;
			if(key == 13){
				func();		
				return false;
			}else{
				return true;
			}
		},//}}}
		required: function(o){//{{{
			if(o.field.value === ""){
				if(o.msg === undefined){
					if(o.label === undefined){
						o.label = o.field.name;
					}
					o.msg = "Le champs "+o.label+" est obligatoire !";
				}
				ANEOL.visualisation.displayMsg('Erreur !', o.msg, YAHOO.widget.SimpleDialog.ICON_WARN);
				o.field.focus();
				return false;
			}
			return true;
		},//}}}
		email: function(o){//{{{
			if(o.field.value !==""){
				var reg = /^[a-z0-9._-]+@[a-z0-9.-]{2,}[.][a-z]{2,3}$/;
				if(reg.exec(o.field.value)===null){
					if(o.msg === undefined){
						if(o.label === undefined){
							o.label = o.field.name;
						}
						o.msg = "Le champs "+o.label+" n'est pas valide !";
					}
					ANEOL.visualisation.displayMsg('Erreur !', o.msg, YAHOO.widget.SimpleDialog.ICON_WARN);
					o.field.focus();
					return false;
				}
			}		
			return true;
		},//}}}
		max: function(o){//{{{
			if(o.field.value !==""){
				if(o.field.value.length > o.size){
					if(o.msg === undefined){
						if(o.label === undefined){
							o.label = o.field.name;
						}
						o.msg = "Le champs "+o.label+" ne doit pas dépasser "+o.size+" caractères !";
					}
					ANEOL.visualisation.displayMsg('Erreur !', o.msg, YAHOO.widget.SimpleDialog.ICON_WARN);
					o.field.focus();
					return false;
				}
			}		
			return true;
		},//}}}
		range: function(o){//{{{
			if(o.field.value !==""){
				if(!o.field.value.NaN && o.field.value >= o.min && o.field.value <= o.max){
					return true;
				}else{
					if(o.msg === undefined){
						if(o.label === undefined){
							o.label = o.field.name;
						}
						o.msg = "Le champs "+o.label+" doit être un nombre compris entre "+o.min+" et "+o.max+" !";
					}
					ANEOL.visualisation.displayMsg('Erreur !', o.msg, YAHOO.widget.SimpleDialog.ICON_WARN);
					o.field.focus();
					return false;
				}
			}
		}//}}}
	},//}}} 
	visualisation:{//{{{
		showElement: function (id){//{{{
			try{
				var elt = document.getElementById(id);
				elt.style.display = "block";
				elt.style.visibility = "visible";
			}catch(e){ }
		},//}}}
		hideElement: function (id){//{{{
			try{
				var elt = document.getElementById(id);
				elt.style.display = "none";
				elt.style.visibility = "hidden";
			}catch(e){ }
		},//}}}
		showHide: function (id){//{{{
				var elt = document.getElementById(id);
				if(elt.style.display == "none"){
					ANEOL.visualisation.showElement(id);			
				}else{
					ANEOL.visualisation.hideElement(id);			
				}
		},//}}}
		displayMsg: function (titre, text, icon){//{{{
			var handleClose = function(){
				this.hide();
			};
			var msg = document.getElementById('msg');
			msg.innerHTML = "";
			var dialog = new YAHOO.widget.SimpleDialog('msg',  {
				width: "300px", 
				fixedcenter: true, 
				visible: false, 
				draggable: true, 
				close: false, 
				modal: YAHOO.env.ua.ie === 0, 
				'text': text, 
				'icon': icon, 
				constraintoviewport: true, 
				buttons: [ { text:"Fermer", handler:handleClose, isDefault:true } ] 
			}); 
			dialog.setHeader(titre); 
			dialog.render(document.body); 
			dialog.show();
		}//}}}
	},//}}}
	lang:{//{{{
		extend:function(son, father, args){
			son.superclass = father;
			son.prototype = new son.superclass();
			son.superclass.apply(son, args);
			delete son.superclass;
		}
	},//}}}
	internationalisation:{//{{{
		FrenchCalendar:{
			"title":"Sélectionnez une date:",
			"close":true,
			"LOCALE_WEEKDAYS": "short",
			"START_WEEKDAY": 1, 
			"MULTI_SELECT": false,
			"DATE_FIELD_DELIMITER": "/",
			"MDY_DAY_POSITION": 1, 
			"MDY_MONTH_POSITION": 2, 
			"MDY_YEAR_POSITION": 3, 
			"MD_DAY_POSITION": 1, 
			"MD_MONTH_POSITION": 2, 
			"MONTHS_SHORT":   ["Janv", "Févr", "Mars", "Avr", "Mai", "Juin", "Juil", "Août", "Sept", "Oct", "Nov", "Déc"],
			"MONTHS_LONG":    ["Janvier", "Février", "Mars", "Avril", "Mai", "Juin", "Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre"],
			"WEEKDAYS_1CHAR": ["D", "L", "M", "M", "J", "V", "S"],
			"WEEKDAYS_SHORT": ["Di", "Lu", "Ma", "Me", "Je", "Ve", "Sa"],
			"WEEKDAYS_MEDIUM":["Dim", "Lun", "Mar", "Mer", "Jeu", "Ven", "Sam"],
			"WEEKDAYS_LONG":  ["Dimanche", "Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi"]
		}
	},//}}}
	DataTable:function(o){//{{{
		if(o === undefined){
			o = {};	
		}
		this.first = o.first || 0;
		this.action = o.action || '';
		this.tableElt = o.tableElt || '';
		this.listeNbpp = o.listeNbpp || [10,20,30];
		this.nbpp = o.nbpp || this.listeNbpp[0];
		this.name = o.name || '';
		this.url = o.url || '/index.php';
		this.params = o.params || {};

		this.get = function(first){//{{{
			var that = this; 
			if(first !== undefined){
				that.first = first;
			}
			var handler = {
				success: function(o) {
					var te = document.getElementById(that.tableElt);				 
					te.innerHTML = o.responseText;					 
				},
				failure: function(o){ ANEOL.visualisation.displayMsg('Erreur !', o.statusText, YAHOO.widget.SimpleDialog.ICON_WARN); }
			};
			var trans = YAHOO.util.Connect.asyncRequest('POST', this.url, handler, "action="+this.action+"&DataTableParams="+YAHOO.lang.JSON.stringify(that));
		};//}}}
		this.setNbpp = function(nb){//{{{
			this.nbpp = nb;
			this.get(Math.floor(this.first / this.nbpp) * this.nbpp); 
		};//}}}
		this.unselectLAll = function(){//{{{
			var table = document.getElementById(this.name+'_table');
			var lignes = table.getElementsByTagName('tr');
			for(var i=0;i<lignes.length;i++){
				var tr = lignes[i];
				if(tr.className != 'th'){
					tr.className = (i%2) ? 'regular' : 'alternate';
				}
			}
		};//}}}
		this.selectLine = function(elt){//{{{
			this.unselectLAll(elt);
			while(elt !== undefined && elt.nodeName != 'TR'){
				elt = elt.parentNode;
			}
			if(elt !== undefined){
				elt.className='selected';
			}
		};//}}}
		this.orderBy = function(field){//{{{
			if(this.params.orderField == field){
				if(this.params.orderDirection == 'asc'){
					this.params.orderDirection = 'desc';
				}else{
					this.params.orderDirection = 'asc';
				}
			}else{
				this.params.orderField = field;
				this.params.orderDirection = 'asc';
			}
		};//}}}

	},//}}}
	Dialog:function(o){//{{{

		if(o === undefined){
			o = {};	
		}
		this.template = o.template || undefined;
		this.params = o.params || {};
		this.url = o.url || '/index.php';

		this.container = undefined;
		this.panel = undefined;
		var that = this;

		this.show = function(){//{{{
			var handler = {
				success: function(o){
					that.container = document.createElement('div');
					document.body.appendChild(that.container);
					that.container.innerHTML = o.responseText;
					that.init();
				},
				failure: function(o){ ANEOL.visualisation.displayMsg('Erreur !', o.statusText, YAHOO.widget.SimpleDialog.ICON_WARN); }
			};
			var trans = YAHOO.util.Connect.asyncRequest('POST', that.url, handler, "action="+that.template+"&params="+YAHOO.lang.JSON.stringify(that.params));
		};//}}}
		this.init = function(){//{{{
			that.panel = new YAHOO.widget.Dialog(that.container, { 
				width : "700px",
				
				visible : false, 
				modal: YAHOO.env.ua.ie === 0,
				constraintoviewport : true,
				buttons : [ { text:"Fermer", handler:that.hide, isDefault:true } ]
			});
			that.panel.render();
			that.panel.show();
		};//}}}
		this.hide = function(){//{{{
			that.panel.destroy();
		};//}}}
	
		this.help = function(){//{{{
			window.open('/index/help/topic.html');
		};//}}}

	},//}}}
	Tooltip:function(o){//{{{

		this.c = document.createElement('span');
		this.c.id = i+'_div';
		document.body.appendChild(this.c);

		this.t = new YAHOO.widget.Tooltip(this.c, {
			context:o.id, 
			text:o.content,
			hidedelay:1000,
			effect:{effect:YAHOO.widget.ContainerEffect.FADE,duration:0.25} 
		});

		var that = this;

		YAHOO.util.Event.addListener(this.c, 'mouseover', function(e){
		});

		YAHOO.util.Event.addListener(this.c, 'mouseout', function(e){
			that.t.hide();
		});

	},//}}}
	global:{}

};

/* ------------------------------------------------------------------------------------------------- */

	DndBox = function(id, sGroup, config) {//{{{
		DndBox.superclass.constructor.apply(this, arguments);
		this.initBox(id, sGroup, config);
	};//}}}
	YAHOO.extend(DndBox, YAHOO.util.DDProxy, {//{{{
		initBox: function(id, sGroup, config) {//{{{
			if (!id) { 
				return; 
			}
			this.setHandleElId(id+'_handler');
			this.isTarget = false;
			var el = this.getDragEl();

			YAHOO.util.Dom.setStyle(el, "borderColor", "transparent");
			YAHOO.util.Dom.setStyle(el, "opacity", 0.76);
			// specify that this is not currently a drop target
			this.originalStyles = [];
			this.startPos = YAHOO.util.Dom.getXY( this.getEl() );
		},//}}}
		startDrag: function(x, y) {//{{{
			var Dom = YAHOO.util.Dom;
			// Copie de l'élément dans le proxy
			var proxy = this.getDragEl();
			var source = this.getEl();
			this.startContainer = source.parentNode.id;
			proxy.innerHTML = source.innerHTML; 
			proxy.className = source.className;

			Dom.setStyle(proxy, "color",  Dom.getStyle(source, "color"));
			Dom.setStyle(proxy, "backgroundColor", Dom.getStyle(source, "backgroundColor"));
			Dom.setStyle(source, "opacity", 0.1);
			// Modifie le style (par target) des cibles du même groupe
			var targets = YAHOO.util.DDM.getRelated(this, true);
			for(var i=0; i<targets.length; i++) {
				YAHOO.util.Dom.removeClass(targets[i].id, 'container'); 
				YAHOO.util.Dom.addClass(targets[i].id, 'container-target'); 
			}
		},//}}}
		onDragDrop: function(e, id) {//{{{
			var dest = document.getElementById(id);
			var source = this.getEl();
			var prev = YAHOO.util.Dom.getLastChild(id);
			var boxes = YAHOO.util.Dom.getElementsByClassName('box-over');

			for(i=0;i<boxes.length;i++){
				YAHOO.util.Dom.removeClass(boxes[i], 'box-over'); 
			}
			while(prev){
				var region = YAHOO.util.Region.getRegion(prev);
				if(region.intersect(YAHOO.util.DragDropMgr.interactionInfo.point)){
					dest.insertBefore(source, prev);
					return;
				}
				prev = YAHOO.util.Dom.getPreviousSibling(prev);
			}
			dest.appendChild(source);
		},//}}}
		endDrag: function(e) {//{{{
			YAHOO.util.Dom.setStyle(this.getEl(), "opacity", 1);
			var targets = YAHOO.util.DDM.getRelated(this, true);
			for (var i=0; i<targets.length; i++) {
				YAHOO.util.Dom.removeClass(targets[i].id, 'container-target'); 
				YAHOO.util.Dom.removeClass(targets[i].id, 'container-over'); 
				YAHOO.util.Dom.addClass(targets[i].id, 'container'); 
			}
			if(this.startContainer == this.getEl().parentNode.id){
				updateContainer(this.startContainer);
			}else{
				updateContainer(this.startContainer);
				updateContainer(this.getEl().parentNode.id);
			}
		},//}}}
		onDragOver: function(e, id) {//{{{
			YAHOO.util.Dom.removeClass(id, 'container'); 
			YAHOO.util.Dom.addClass(id, 'container-over'); 

			var prev = YAHOO.util.Dom.getLastChild(id);
			while(prev){
				var region = YAHOO.util.Region.getRegion(prev);
				if(region.intersect(YAHOO.util.DragDropMgr.interactionInfo.point)){
					YAHOO.util.Dom.addClass(prev, 'box-over'); 
				}else{
					YAHOO.util.Dom.removeClass(prev, 'box-over'); 
				}
				prev = YAHOO.util.Dom.getPreviousSibling(prev);
			}
		},//}}}
		onDragOut: function(e, id) {//{{{
			YAHOO.util.Dom.removeClass(id, 'container-over'); 
			YAHOO.util.Dom.addClass(id, 'container'); 

			var prev = YAHOO.util.Dom.getLastChild(id);
			while(prev){
				YAHOO.util.Dom.removeClass(prev, 'box-over'); 
				prev = YAHOO.util.Dom.getPreviousSibling(prev);
			}
		}//}}}
	});//}}}

	DndPanelBox = function(id, sGroup, config) {//{{{
		DndPanelBox.superclass.constructor.apply(this, arguments);
		this.initBox(id, sGroup, config);
	};//}}}
	YAHOO.extend(DndPanelBox, YAHOO.util.DDProxy, {//{{{
		initBox: function(id, sGroup, config) {//{{{
			if (!id) { 
				return; 
			}
			this.isTarget = false;
			var el = this.getDragEl();
			YAHOO.util.Dom.setStyle(el, "borderColor", "transparent");
			YAHOO.util.Dom.setStyle(el, "opacity", 0.76);
			// specify that this is not currently a drop target
			this.originalStyles = [];
			this.startPos = YAHOO.util.Dom.getXY( this.getEl() );
		},//}}}
		startDrag: function(x, y) {//{{{
			var Dom = YAHOO.util.Dom;
			// Copie de l'élément dans le proxy
			var proxy = this.getDragEl();
			var source = this.getEl();

			proxy.innerHTML = source.innerHTML; 
			var imgs = proxy.getElementsByTagName('img');
			for(var i=0;i<imgs.length;i++){
				proxy.removeChild(imgs[i]);
			}

			proxy.className = source.className;
			Dom.setStyle(proxy, "color",  Dom.getStyle(source, "color"));
			Dom.setStyle(proxy, "backgroundColor", Dom.getStyle(source, "backgroundColor"));
			Dom.setStyle(source, "opacity", 0.1);
			Dom.setStyle(proxy, "cursor",  'move');

			// La boite est elle deja presente ?
			this.allowed = true;
			id_box = "box_"+source.id.substring(10, source.id.length);
			var boxes = YAHOO.util.Dom.getElementsByClassName('box');
			for(i=0;i<boxes.length;i++){
				if(boxes[i].id == id_box){
					YAHOO.util.Dom.addClass(boxes[i].id, 'box-forbidden'); 
					this.allowed = false;
					Dom.setStyle(proxy, "cursor",  'not-allowed');
				}
			}

			if(this.allowed){
				// Modifie le style (par target) des cibles du même groupe
				var targets = YAHOO.util.DDM.getRelated(this, true);
				for(var i=0; i<targets.length; i++) {
					YAHOO.util.Dom.removeClass(targets[i].id, 'container'); 
					YAHOO.util.Dom.addClass(targets[i].id, 'container-target'); 
				}
			}
		},//}}}
		onDragDrop: function(e, id) {//{{{
			if(this.allowed){
				var boxes = YAHOO.util.Dom.getElementsByClassName('box');
				for(i=0;i<boxes.length;i++){
					YAHOO.util.Dom.removeClass(boxes[i].id, 'box-over'); 
				}
				var dest = document.getElementById(id);
				var source = this.getEl();
				var prev = YAHOO.util.Dom.getLastChild(id);
				while(prev){
					var region = YAHOO.util.Region.getRegion(prev);
					if(region.intersect(YAHOO.util.DragDropMgr.interactionInfo.point)){
						// creation de la boite
						var callback = {
							success:function(o){
								if(o.responseText !== ''){
									var newBox = document.createElement('div');
									newBox.id = 'box_'+source.id.substring(10, source.id.length);
									newBox.innerHTML = o.responseText;
									YAHOO.util.Dom.addClass(newBox, "box");
									dest.insertBefore(newBox, prev);
									var dndb = new DndBox(newBox.id, "dnd");
									updateContainer(dest.id);
								}
							},
							failure: function(o){ ANEOL.visualisation.displayMsg('Erreur !', o.statusText, YAHOO.widget.SimpleDialog.ICON_WARN); }
						};
						YAHOO.util.Connect.asyncRequest('POST', '/index.php?action=addBox', callback, "id_box="+source.id.substring(10, source.id.length));
						return;
					}
					prev = YAHOO.util.Dom.getPreviousSibling(prev);
				}

				// creation de la boite
				var callback = {
					success:function(o){
						if(o.responseText !== ''){
							newBox = document.createElement('div');
							newBox.id = 'box_'+source.id.substring(10, source.id.length);
							newBox.innerHTML = o.responseText;
							YAHOO.util.Dom.addClass(newBox, "box");
							dest.appendChild(newBox);
							var dndb = new DndBox(newBox.id, "dnd");
							updateContainer(dest.id);
						}
					},
					failure: function(o){ ANEOL.visualisation.displayMsg('Erreur !', o.statusText, YAHOO.widget.SimpleDialog.ICON_WARN); }
				};
				YAHOO.util.Connect.asyncRequest('POST', '/index.php?action=addBox', callback, "id_box="+source.id.substring(10, source.id.length));
			}

		},//}}}
		endDrag: function(e) {//{{{
			YAHOO.util.Dom.setStyle(this.getEl(), "opacity", 1);
			var targets = YAHOO.util.DDM.getRelated(this, true);
			for (var i=0; i<targets.length; i++) {
				YAHOO.util.Dom.removeClass(targets[i].id, 'container-target'); 
				YAHOO.util.Dom.removeClass(targets[i].id, 'container-over'); 
				YAHOO.util.Dom.addClass(targets[i].id, 'container'); 
			}

			if(!this.allowed){
				var boxes = YAHOO.util.Dom.getElementsByClassName('box');
				for(i=0;i<boxes.length;i++){
					YAHOO.util.Dom.removeClass(boxes[i].id, 'box-forbidden'); 
				}
			}
		},//}}}
		onDragOver: function(e, id) {//{{{
			if(this.allowed){
				YAHOO.util.Dom.removeClass(id, 'container'); 
				YAHOO.util.Dom.addClass(id, 'container-over'); 
				var prev = YAHOO.util.Dom.getLastChild(id);
				while(prev){
					var region = YAHOO.util.Region.getRegion(prev);
					if(region.intersect(YAHOO.util.DragDropMgr.interactionInfo.point)){
						YAHOO.util.Dom.addClass(prev, 'box-over'); 
					}else{
						YAHOO.util.Dom.removeClass(prev, 'box-over'); 
					}
					prev = YAHOO.util.Dom.getPreviousSibling(prev);
				}
			}
		},//}}}
		onDragOut: function(e, id) {//{{{
			if(this.allowed){
				YAHOO.util.Dom.removeClass(id, 'container-over'); 
				YAHOO.util.Dom.addClass(id, 'container'); 

				var prev = YAHOO.util.Dom.getLastChild(id);
				while(prev){
					YAHOO.util.Dom.removeClass(prev, 'box-over'); 
					prev = YAHOO.util.Dom.getPreviousSibling(prev);
				}
			}
		}//}}}
	});//}}}

// Gestion des pages
var tree = undefined;

	DndNode = function(id, sGroup, config) {//{{{
		DndNode.superclass.constructor.apply(this, arguments);
		this.initBox(id, sGroup, config);
	};//}}}
	YAHOO.extend(DndNode, YAHOO.util.DDProxy, {//{{{
		initBox: function(id, sGroup, config) {//{{{
			if (!id) { 
				return; 
			}
			//this.isTarget = false;
			var el = this.getDragEl();
			YAHOO.util.Dom.setStyle(el, "borderColor", "transparent");
			YAHOO.util.Dom.setStyle(el, "opacity", 0.76);
			// specify that this is not currently a drop target
			this.originalStyles = [];
			this.startPos = YAHOO.util.Dom.getXY( this.getEl() );
		},//}}}
		startDrag: function(x, y) {//{{{
			var Dom = YAHOO.util.Dom;
			// Copie de l'élément dans le proxy
			var proxy = this.getDragEl();
			var source = this.getEl();
			proxy.innerHTML = YAHOO.util.Dom.getFirstChild(source).innerHTML; 
			Dom.setStyle(proxy, "color",  Dom.getStyle(source, "color"));
			Dom.setStyle(proxy, "backgroundColor", Dom.getStyle(source, "backgroundColor"));
			Dom.setStyle(source, "opacity", 0.1);
			// Modifie le style (par target) des cibles du même groupe
			var targets = YAHOO.util.DDM.getRelated(this, true);
			for(var i=0; i<targets.length; i++) {

				var tgt = tree.getNodeByElement(document.getElementById(targets[i].id));

				if(tgt.isDescendant(tree.getNodeByElement(source)) === false){
					YAHOO.util.Dom.addClass(targets[i].id, 'node-target'); 
				}else{
					YAHOO.util.Dom.addClass(targets[i].id, 'node-forbidden'); 
				}
			}
		},//}}}
		onDragDrop: function(e, id) {//{{{
			var src = tree.getNodeByElement(document.getElementById(this.getEl().id));
			var dest = tree.getNodeByElement(document.getElementById(id));
			if(dest.isDescendant(src) === false){
				tree.popNode(src);
				src.appendTo(dest);
				tree.refresh();
			}
		},//}}}
		endDrag: function(e) {//{{{
			YAHOO.util.Dom.setStyle(this.getEl(), "opacity", 1);
			var targets = YAHOO.util.DDM.getRelated(this, true);
			for (var i=0; i<targets.length; i++) {
				YAHOO.util.Dom.removeClass(targets[i].id, 'node-target'); 
				YAHOO.util.Dom.removeClass(targets[i].id, 'node-over'); 
				YAHOO.util.Dom.removeClass(targets[i].id, 'node-forbidden'); 
				YAHOO.util.Dom.addClass(targets[i].id, 'node'); 
			}
		},//}}}
		onDragOver: function(e, id) {//{{{
			var src = tree.getNodeByElement(document.getElementById(this.getEl().id));
			var dest = tree.getNodeByElement(document.getElementById(id));
			if(dest.isDescendant(src) === true){
				YAHOO.util.Dom.setStyle(this.getDragEl(), "cursor", 'not-allowed');
			}else{
				YAHOO.util.Dom.setStyle(this.getDragEl(), "cursor", 'move');
				YAHOO.util.Dom.addClass(id, 'node-over'); 
			}
		},//}}}
		onDragOut: function(e, id) {//{{{
			YAHOO.util.Dom.removeClass(id, 'node-over'); 
			YAHOO.util.Dom.addClass(id, 'node-target'); 
		}//}}}
	});//}}}

		Arbo = function(){//{{{
			ANEOL.lang.extend(this, ANEOL.Dialog, arguments);
			this.url = '/page.php';
			this.template = 'getArbo';
			var that = this;

			this.init = function(){//{{{
				that.panel = new YAHOO.widget.Dialog(that.container, { 
					width : "500px",
					fixedcenter:false,
					context:['tt_arbo','bl'],
					visible : false, 
					close:false,
					modal: YAHOO.env.ua.ie === 0,
					constraintoviewport : true,
					buttons : [ { text:"Fermer", handler:that.hide, isDefault:true } ]
				});
				that.panel.render();

				var callback = {
					success:function(o){
						var treeLit = YAHOO.lang.JSON.parse(o.responseText);
						tree = new YAHOO.widget.TreeView("tree", treeLit);
						tree.subscribe("dblClickEvent", function(e) { 
							tree.updatePage(e.node.data.idPage); 
						});
						tree.draw();
						tree.refresh();
						that.panel.center();
						that.panel.show();
					},
					failure:function(o){ console.warn("failure"); }
				};
				YAHOO.util.Connect.asyncRequest('POST', that.url, callback, "action=getPagesTree");

			};//}}}
			this.hide = function(){//{{{
				that.panel.destroy();
				window.location = window.location;
			};//}}}

		};//}}}
 		PageFrm = function(o){//{{{

			ANEOL.lang.extend(this, ANEOL.Dialog, arguments);
			this.url = '/page.php';
			this.params = o;
			this.template = "getFrm";
			this.panel = undefined;
			var that = this;

			this.submit = function(){//{{{
				var frm = document.getElementById('page_frm');
				var ok = ANEOL.validation.validate(
					ANEOL.validation.required, {'field': frm.title}
				);
				if(ok){
					var handler = {
						success: function(o){
							if(o.responseText !== ''){
								var oData = YAHOO.lang.JSON.parse(o.responseText); 							
								var parentNode = tree.getNodeByProperty('idPage', that.params.id_parent);
								var newNode = new YAHOO.widget.HTMLNode(oData, parentNode);
								tree.refresh();
								that.hide();
							}else{
								tree.refresh();
								that.hide();
								var title = document.getElementById('page_'+frm.id_page.value);
								title.innerHTML = frm.title.value;
							}
						},
						failure: function(o){ ANEOL.visualisation.displayMsg('Erreur !', o.statusText, YAHOO.widget.SimpleDialog.ICON_WARN); }
					};
					YAHOO.util.Connect.setForm(frm);
					var trans = YAHOO.util.Connect.asyncRequest('POST', that.url, handler);
				}
			};//}}}
			this.init = function(){//{{{
				this.panel = new YAHOO.widget.Dialog("page_dialog", { 
					width : "450px",
					visible : false, 
					modal: YAHOO.env.ua.ie === 0,
					constraintoviewport : true,
					buttons : [ { text:"Valider", handler:that.submit, isDefault:true }, { text:"Annuler", handler:that.hide } ]
				});

				this.panel.render(); 

				var lstTemplate = document.getElementById('id_template');
				YAHOO.util.Event.addListener(lstTemplate, "change", this.getTemplatePic);
				this.getTemplatePic();

				this.panel.center();
				this.panel.show();
			};//}}}
			this.getTemplatePic = function(e){//{{{
				var lstTemplate = document.getElementById('id_template');
				var handler = {
					success: function(o){
						if(o.responseText !== ''){
							var pic = document.getElementById('template_pic');
							pic.src = o.responseText;
						}
					},
					failure: function(o){ ANEOL.visualisation.displayMsg('Erreur !', o.statusText, YAHOO.widget.SimpleDialog.ICON_WARN); }
				};
				var trans = YAHOO.util.Connect.asyncRequest('POST', that.url, handler, "action=getTemplatePic&id_template="+lstTemplate.value);
			};//}}}

		};//}}}
	YAHOO.widget.Node.prototype.isDescendant = function(node) {//{{{
		var me = this;
		while(me.parent !== null){
			if(me.parent == node){
				return true;
			}
			me = me.parent;		
		}
		return false;	
	};//}}}
	YAHOO.widget.TreeView.prototype.moveUp = function(id){//{{{
		var currentNode = this.getNodeByProperty("idPage", id);
		if(currentNode.previousSibling){
			currentNode.insertBefore(currentNode.previousSibling);
			this.refresh();
			currentNode.expand();
		}
	};//}}}
	YAHOO.widget.TreeView.prototype.moveDown = function(id){//{{{
		var currentNode = this.getNodeByProperty("idPage", id);
		if(currentNode.nextSibling){
			currentNode.insertAfter(currentNode.nextSibling);
			this.refresh();
			currentNode.expand();
		}
	};//}}}
	YAHOO.widget.TreeView.prototype.refresh = function(){//{{{
		this.render();
		var ddl = YAHOO.util.Dom.getElementsByClassName('pageNode');
		for(i=0;i<ddl.length;i++){
			var dndp = new DndNode(ddl[i].id, "pageDnd");
			tree.getNodeByElement(document.getElementById(ddl[i].id)).expand();
		}
		var tb = YAHOO.util.Dom.getElementsByClassName('tool_box');
		for(i=0;i<tb.length;i++){
			ANEOL.visualisation.hideElement(tb[i].id);
		}
		this.commit();
	};//}}}
	YAHOO.widget.TreeView.prototype.commit = function(){//{{{
		var nodes = [];
		var count = this.getNodeCount();
		for(var i=0;i<count;i++){
			var node = this.getNodeByIndex(i+1);
			if(node !== null){
				var n = {'id_page':node.data.idPage , 'parent':node.parent.data.idPage, 'order':0};
				while(node = node.previousSibling){
					n.order++;
				}
				nodes[nodes.length] = n;
			}
		}
		var callback = {
			success:function(o){ },
			failure:function(o){ console.warn("failure"); }
		};
		YAHOO.util.Connect.asyncRequest('POST', '/page.php?action=updatePagesTree', callback, "nodes="+YAHOO.lang.JSON.stringify(nodes));
	};//}}}
	YAHOO.widget.TreeView.prototype.addPage = function(id){//{{{
		pageFrm = new PageFrm({'id_parent':id});
		pageFrm.show();
	};//}}}
	YAHOO.widget.TreeView.prototype.updatePage = function(id){//{{{
		ANEOL.pageFrm = new PageFrm({'id_page':id});
		ANEOL.pageFrm.show();
	};//}}}
	YAHOO.widget.TreeView.prototype.dropPage = function(id){//{{{
		var handleYes = function(){
			var callback = {
				success:function(o){
					var node = tree.getNodeByProperty('idPage', id);
					tree.removeNode(node);
					confirmDialog.hide();
					tree.refresh();
				},
				failure:function(o){ console.warn("failure"); }
			};
			YAHOO.util.Connect.asyncRequest('POST', '/page.php?action=delete', callback, "id_page="+id);
		};
		var handleNo = function(){
			this.hide();
		};

		var text = "Voulez-vous vraiment supprimer cette page ?";
		var node = tree.getNodeByProperty('idPage', id);
		if(node.hasChildren()){
			text = "Voulez-vous vraiment supprimer cette rubrique et l'ensemble de son contenu ?";
		}

		var confirmDialog = new YAHOO.widget.SimpleDialog("Confirmation",  {
			width: "300px", 
			fixedcenter: true, 
			visible: false, 
			draggable: true, 
			close: false, 
			modal: true, 
			text: text, 
				icon: YAHOO.widget.SimpleDialog.ICON_WARN, 
				constraintoviewport: true, 
				buttons: [ { text:"Oui", handler:handleYes, isDefault:true }, 
									 { text:"Non",  handler:handleNo } ] 
		}); 
		confirmDialog.render(document.body); 
		confirmDialog.show();

	};//}}}

/* ------------------------------------------------------------------------------------------------- */

	ANEOL.reloadListingsByTopic = function(id_topic){//{{{
		var handler = {
			success: function(o){
				var boxes = YAHOO.lang.JSON.parse(o.responseText);
				for(var i=0;i<boxes.length;i++){
					if(document.getElementById('box_'+boxes[i]) !== undefined){
						ANEOL.reloadListingBox(boxes[i]);
					}
				}
			},
			failure: function(o){ ANEOL.visualisation.displayMsg('Erreur !', o.statusText, YAHOO.widget.SimpleDialog.ICON_WARN); }
		};
		var trans = YAHOO.util.Connect.asyncRequest('POST', "/topic.php", handler, "action=getBoxes&id_topic="+id_topic);
	};//}}}
	ANEOL.reloadListingBox = function(id_box){//{{{
		var handler = {
			success: function(o){
				var box = document.getElementById('box_'+id_box);
				box.innerHTML = o.responseText;
			},
			failure: function(o){ ANEOL.visualisation.displayMsg('Erreur !', o.statusText, YAHOO.widget.SimpleDialog.ICON_WARN); }
		};
		var trans = YAHOO.util.Connect.asyncRequest('POST', "/listing.php", handler, "action=boxGetListing&id_box="+id_box);
	};//}}}

// Gestion des éléments et des listings
	ElementFrm = function(o){//{{{
		ANEOL.lang.extend(this, ANEOL.Dialog, arguments);
		this.url = '/element.php';
		this.template = 'getFrm';
		var that = this;

		this.submit = function(){//{{{

			var handler = {
				success: function(o){
					// Cas ajout
					if(o.responseText !== ''){
						var ret = YAHOO.lang.JSON.parse(o.responseText); 
						newBox = document.createElement('div');
						newBox.id = 'box_'+ret.id_box;
						newBox.innerHTML = ret.content;
						YAHOO.util.Dom.addClass(newBox, "box");
						var b = new DndBox(newBox.id, "dnd");
						if(that.params.after !== undefined){
							var after = document.getElementById(that.params.after);
							YAHOO.util.Dom.insertAfter(newBox, after);
							updateContainer(after.parentNode.id);
						}else if(that.params.before !== undefined){
							var before = document.getElementById(that.params.before);
							YAHOO.util.Dom.insertBefore(newBox, before);
							updateContainer(before.parentNode.id);
						}else{
							var destination = document.getElementById(that.params.destination);
							if(destination.childNodes.length > 0){
								YAHOO.util.Dom.insertBefore(newBox, destination.childNodes[0]);
							}else{
								destination.appendChild(newBox);
							}
							updateContainer(destination.id);
						}
					// Cas update
					}else{
						that.reloadBox();
					}
					that.hide();
				},
				failure: function(o){ ANEOL.visualisation.displayMsg('Erreur !', o.statusText, YAHOO.widget.SimpleDialog.ICON_WARN); }
			};

			var frm = document.getElementById('frm_element');
			var ok = ANEOL.validation.validate(
				ANEOL.validation.required, {'field': frm.title, 'msg':"Veuillez saisir un titre."}
			);
			if(ok){
				frm.content.value = FCKeditorAPI.GetInstance('editor_area').GetHTML();
				YAHOO.util.Connect.setForm(frm);
				var trans = YAHOO.util.Connect.asyncRequest('POST', that.url, handler);
			}
		};//}}}
		this.init = function(){//{{{
			that.panel = new YAHOO.widget.Dialog(that.container, { 
				width : "700px",
				visible : false, 
				modal: YAHOO.env.ua.ie === 0,
				close:false,
				constraintoviewport : true,
				buttons : [ /*{text:'Aide', handler:that.help},*/ { text:"Enregistrer", handler:that.submit, isDefault:true }, { text:"Annuler", handler:that.hide } ]
			});
			that.panel.render();

			var editor = new FCKeditor( 'editor_area' ) ;
			editor.Height = 420 ;
			editor.ReplaceTextarea() ;

			that.panel.center();
			that.panel.show();
			 
		};//}}}
		this.reloadBox = function(){//{{{
			var handler = {
				success: function(o){
					var box = document.getElementById('box_'+that.params.id_box);
					box.innerHTML = o.responseText;
				},
				failure: function(o){ ANEOL.visualisation.displayMsg('Erreur !', o.statusText, YAHOO.widget.SimpleDialog.ICON_WARN); }
			};
			var trans = YAHOO.util.Connect.asyncRequest('POST', that.url, handler, "action=boxGetElement&id_box="+that.params.id_box);
		};//}}}

	};//}}}
	ListingFrm = function(o){//{{{
		ANEOL.lang.extend(this, ANEOL.Dialog, arguments);
		this.url = '/listing.php';
		this.template = 'getFrm';
		var that = this;

		this.submit = function(){//{{{
			var frm = document.getElementById('frm_listing');
			var ok = ANEOL.validation.validate(
				ANEOL.validation.required, {'field': frm.title},
				ANEOL.validation.required, {'field': frm.nb_items},
				ANEOL.validation.range, {'field': frm.nb_items, 'min':1, 'max':100},
				ANEOL.validation.required, {'field': frm.preview_length},
				ANEOL.validation.range, {'field': frm.preview_length, 'min':100, 'max':1000}
			);
			if(ok){
				var handler = {
					success: function(o){
						// Cas ajout
						if(o.responseText !== ''){
							var ret = YAHOO.lang.JSON.parse(o.responseText); 
							newBox = document.createElement('div');
							newBox.id = 'box_'+ret.id_box;
							newBox.innerHTML = ret.content;
							YAHOO.util.Dom.addClass(newBox, "box");
							var b = new DndBox(newBox.id, "dnd");
							if(that.params.after !== undefined){
								var after = document.getElementById(that.params.after);
								YAHOO.util.Dom.insertAfter(newBox, after);
								updateContainer(after.parentNode.id);
							}else if(that.params.before !== undefined){
								var before = document.getElementById(that.params.before);
								YAHOO.util.Dom.insertBefore(newBox, before);
								updateContainer(before.parentNode.id);
							}else{
								var destination = document.getElementById(that.params.destination);
								if(destination.childNodes.length > 0){
									YAHOO.util.Dom.insertBefore(newBox, destination.childNodes[0]);
								}else{
									destination.appendChild(newBox);
								}
								updateContainer(destination.id);
							}
							that.hide();
						// Cas update
						}else{
							that.reloadBox();
							that.hide();
						}
					},
					failure: function(o){ ANEOL.visualisation.displayMsg('Erreur !', o.statusText, YAHOO.widget.SimpleDialog.ICON_WARN); }
				};
				YAHOO.util.Connect.setForm(frm);
				var trans = YAHOO.util.Connect.asyncRequest('POST', that.url, handler);
			}
		};//}}}
		this.init = function(){//{{{
			that.panel = new YAHOO.widget.Dialog(that.container, { 
				width : "480px",
				visible : false, 
				modal: YAHOO.env.ua.ie === 0,
				close:false,
				constraintoviewport : true,
				buttons : [ { text:"Valider", handler:that.submit, isDefault:true }, { text:"Annuler", handler:that.hide } ]
			});
			that.panel.render();
			that.panel.center();
			that.panel.show();
		};//}}}
		this.reloadBox = function(){//{{{
			var handler = {
				success: function(o){
					var box = document.getElementById('box_'+that.params.id_box);
					box.innerHTML = o.responseText;
				},
				failure: function(o){ ANEOL.visualisation.displayMsg('Erreur !', o.statusText, YAHOO.widget.SimpleDialog.ICON_WARN); }
			};
			var trans = YAHOO.util.Connect.asyncRequest('POST', that.url, handler, "action=boxGetListing&id_box="+that.params.id_box);
		};//}}}

	};//}}}

// Gestion des articles + topics
	ArticlesDialog = function(o){//{{{
		ANEOL.lang.extend(this, ANEOL.Dialog, arguments);
		this.url = '/article.php';
		this.template = 'getListDialog';
		this.dt = new ANEOL.DataTable({action:'getListDatagrid', tableElt:'dt_articles', name:'ANEOL.articlesDialog.dt', url:this.url, 'params':this.params});
		var that = this;

		that.dt.get = function(first){//{{{
			if(first !== undefined){
				that.dt.first = first;
			}
			var handler = {
				success: function(o) {
					var te = document.getElementById(that.dt.tableElt);				 
					te.innerHTML = o.responseText;					 
					that.panel.center();
					that.panel.show();
				},
				failure: function(o){ ANEOL.visualisation.displayMsg('Erreur !', o.statusText, YAHOO.widget.SimpleDialog.ICON_WARN); }
			};
			var trans = YAHOO.util.Connect.asyncRequest('POST', this.url, handler, "action="+this.action+"&DataTableParams="+YAHOO.lang.JSON.stringify(that.dt));
		};//}}}
		this.init = function(){//{{{
			var that = this;
			this.panel = new YAHOO.widget.Dialog(this.container, { 
				width : "700px",
				fixedcenter:false,
				visible : false, 
				close : false, 
				modal: YAHOO.env.ua.ie === 0,
				constraintoviewport : true,
				buttons : [ { text:"Fermer", handler:that.hide } ]
			});
			this.panel.render();
			that.dt.get();

		};//}}}
		this.deleteArticle = function(id_article){//{{{
			var that = this;
			var handleNo = function(){
				this.hide();
			};
			var handleYes = function(){
				var handler = {
					success: function(o){
						that.dt.get();
						confirmDialog.hide();
						ANEOL.reloadListingsByTopic(that.params.id_topic);
					},
					failure: function(o){ ANEOL.visualisation.displayMsg('Erreur !', o.statusText, YAHOO.widget.SimpleDialog.ICON_WARN); }
				};
				var trans = YAHOO.util.Connect.asyncRequest('POST', that.url, handler, "action=delete&id_article="+id_article);
			};
			var confirmDialog = new YAHOO.widget.SimpleDialog("Confirmation",  {
				width: "300px", 
				fixedcenter: true, 
				visible: false, 
				draggable: true, 
				close: false, 
				modal: YAHOO.env.ua.ie === 0, 
				text: "Voulez vous vraiment supprimer cette actualité ?", 
					icon: YAHOO.widget.SimpleDialog.ICON_WARN, 
					constraintoviewport: true, 
					buttons: [ { text:"Oui", handler:handleYes, isDefault:true }, 
										 { text:"Non",  handler:handleNo } ] 
			}); 
			confirmDialog.render(document.body); 
			confirmDialog.show();
		 };//}}}
	};//}}}
	ArticleFrm = function(o){//{{{
		ANEOL.lang.extend(this, ANEOL.Dialog, arguments);
		this.url = '/article.php';
		this.template = 'getFrm';
		var that = this;

		this.init = function(){//{{{
			that.panel = new YAHOO.widget.Dialog(that.container, { 
				width : "700px",
				visible : false, 
				modal: YAHOO.env.ua.ie === 0,
				close:false,
				constraintoviewport : true,
				buttons : [ { text:"Valider", handler:that.submit, isDefault:true }, { text:"Fermer", handler:that.hide } ]
			});
			that.panel.render();
			var editor = new FCKeditor( 'editor_area' ) ;
			editor.Height = 420 ;
			editor.ReplaceTextarea() ;
			that.panel.center();
			that.panel.show();
		};//}}}
		this.submit = function(){//{{{
			var handler = {
				success: function(o){
					if(ANEOL.articlesDialog !== undefined){
						ANEOL.articlesDialog.dt.get();
					}
					ANEOL.reloadListingsByTopic(that.params.id_topic);
					that.hide();
				},
				failure: function(o){ ANEOL.visualisation.displayMsg('Erreur !', o.statusText, YAHOO.widget.SimpleDialog.ICON_WARN); }
			};
			var frm = document.getElementById('frm_article');
			frm.content.value = FCKeditorAPI.GetInstance('editor_area').GetHTML();
			YAHOO.util.Connect.setForm(frm);
			var trans = YAHOO.util.Connect.asyncRequest('POST', that.url, handler);
		};//}}}

	};//}}}
	TopicsDialog = function(o){//{{{
		ANEOL.lang.extend(this, ANEOL.Dialog, arguments);
		this.url = '/topic.php';
		this.template = 'getListDialog';
		this.dt = new ANEOL.DataTable({action:'getListDatagrid', tableElt:'dt_topics', name:'ANEOL.topicsDialog.dt', url:this.url, 'params':this.params});
		var that = this;

		that.dt.get = function(first){//{{{
			if(first !== undefined){
				that.dt.first = first;
			}
			var handler = {
				success: function(o) {
					var te = document.getElementById(that.dt.tableElt);				 
					te.innerHTML = o.responseText;					 
					that.panel.center();
					that.panel.show();
				},
				failure: function(o){ ANEOL.visualisation.displayMsg('Erreur !', o.statusText, YAHOO.widget.SimpleDialog.ICON_WARN); }
			};
			var trans = YAHOO.util.Connect.asyncRequest('POST', this.url, handler, "action="+this.action+"&DataTableParams="+YAHOO.lang.JSON.stringify(that.dt));
		};//}}}
		this.init = function(){//{{{
			var that = this;
			this.panel = new YAHOO.widget.Dialog(this.container, { 
				width : "500px",
				fixedcenter:false,
				visible : false, 
				close : false, 
				modal: YAHOO.env.ua.ie === 0,
				constraintoviewport : true,
				buttons : [ { text:"Fermer", handler:that.hide } ]
			});
			this.panel.render();
			that.dt.get();

			/*that.panel.beforeHideEvent.subscribe(that.hide, that.panel, true);*/

		};//}}}
		this.deleteTopic = function(id_topic){//{{{
			var that = this;
			var handleNo = function(){
				this.hide();
			};
			var handleYes = function(){
				var handler = {
					success: function(o){
						that.dt.get();
						confirmDialog.hide();
						window.location.reload();
					},
					failure: function(o){ ANEOL.visualisation.displayMsg('Erreur !', o.statusText, YAHOO.widget.SimpleDialog.ICON_WARN); }
				};
				var trans = YAHOO.util.Connect.asyncRequest('POST', that.url, handler, "action=delete&id_topic="+id_topic);
			};
			var confirmDialog = new YAHOO.widget.SimpleDialog("Confirmation",  {
				width: "300px", 
				fixedcenter: true, 
				visible: false, 
				draggable: true, 
				close:false, 
				modal: YAHOO.env.ua.ie === 0, 
				text: "Voulez vous vraiment supprimer ce thème et ses actualités ?", 
					icon: YAHOO.widget.SimpleDialog.ICON_WARN, 
					constraintoviewport: true, 
					buttons: [ { text:"Oui", handler:handleYes, isDefault:true }, 
										 { text:"Non",  handler:handleNo } ] 
			}); 
			confirmDialog.render(document.body); 
			confirmDialog.show();
		 };//}}}
		this.reloadBox = function(){//{{{
			var handler = {
				success: function(o){
					var box = document.getElementById('box_'+that.params.id_box);
					box.innerHTML = o.responseText;
				},
				failure: function(o){ ANEOL.visualisation.displayMsg('Erreur !', o.statusText, YAHOO.widget.SimpleDialog.ICON_WARN); }
			};
			var trans = YAHOO.util.Connect.asyncRequest('POST', "/listing.php", handler, "action=getBox&id_box="+that.params.id_box);
		};//}}}

	};//}}}
	TopicFrm = function(o){//{{{
		ANEOL.lang.extend(this, ANEOL.Dialog, arguments);
		this.url = '/topic.php';
		this.template = 'getFrm';
		var that = this;

		this.init = function(){//{{{
			that.panel = new YAHOO.widget.Dialog(that.container, { 
				width : "400px",
				visible : false, 
				modal: YAHOO.env.ua.ie === 0,
				constraintoviewport : true,
				buttons : [ { text:"Valider", handler:that.submit, isDefault:true }, { text:"Fermer", handler:that.hide } ]
			});
			that.panel.render();
			that.panel.center();
			that.panel.show();
		};//}}}
		this.submit = function(){//{{{
			var handler = {
				success: function(o){
					if(ANEOL.topicsDialog !== undefined){
						ANEOL.topicsDialog.dt.get();
					}
					that.hide();
				},
				failure: function(o){ ANEOL.visualisation.displayMsg('Erreur !', o.statusText, YAHOO.widget.SimpleDialog.ICON_WARN); }
			};
			var frm = document.getElementById('frm_topic');
			YAHOO.util.Connect.setForm(frm);
			var trans = YAHOO.util.Connect.asyncRequest('POST', that.url, handler);
		};//}}}
		this.reloadBox = function(){//{{{
			var handler = {
				success: function(o){
					var box = document.getElementById('box_'+that.params.id_box);
					box.innerHTML = o.responseText;
				},
				failure: function(o){ ANEOL.visualisation.displayMsg('Erreur !', o.statusText, YAHOO.widget.SimpleDialog.ICON_WARN); }
			};
			//var trans = YAHOO.util.Connect.asyncRequest('POST', '/listing.php', handler, "action=getBox&id_box="+that.params.id_box);
		};//}}}

	};//}}}

// Configuration + Redacteurs + pages privees + Contact
	ConfigFrm = function() {//{{{
		ANEOL.lang.extend(this, ANEOL.Dialog, arguments);
		this.url = '/index.php';
		this.template = 'configFrm';
		var that = this;

		this.init = function(){//{{{
			that.panel = new YAHOO.widget.Dialog(that.container, { 
				width : "300px",
				visible : false, 
				close:false,
				modal: YAHOO.env.ua.ie === 0,
				constraintoviewport : true,
				buttons : [ { text:"Fermer", handler:that.hide } ]
			});
			this.panel.render();
			this.panel.center();
			this.panel.show();

		};//}}}
	};//}}}
	RedactorsDialog = function(){//{{{

		ANEOL.lang.extend(this, ANEOL.Dialog, arguments);
		this.url = '/redactor.php';
		this.template = 'getListDialog';
		this.dt = new ANEOL.DataTable({action:'getListDatagrid', tableElt:'dt', name:'ANEOL.redactorsDialog.dt', url:this.url});
		var that = this;

		that.dt.get = function(first){//{{{
			if(first !== undefined){
				that.dt.first = first;
			}
			var handler = {
				success: function(o) {
					var te = document.getElementById(that.dt.tableElt);				 
					te.innerHTML = o.responseText;					 
					that.panel.center();
					that.panel.show();
				},
				failure: function(o){ ANEOL.visualisation.displayMsg('Erreur !', o.statusText, YAHOO.widget.SimpleDialog.ICON_WARN); }
			};
			var trans = YAHOO.util.Connect.asyncRequest('POST', this.url, handler, "action="+this.action+"&DataTableParams="+YAHOO.lang.JSON.stringify(that.dt));
		};//}}}
		this.init = function(){//{{{
			var that = this;
			this.panel = new YAHOO.widget.Dialog(this.container, { 
				width : "500px",
				visible : false, 
				modal: YAHOO.env.ua.ie === 0,
				close:false,
				constraintoviewport : true,
				buttons : [ { text:"Fermer", handler:that.hide } ]
			});
			this.panel.render();
			that.dt.get();
		};//}}}
		this.deleteRedactor = function(id_redactor){//{{{
			var that = this;
			var handleNo = function(){
				this.hide();
			};
			var handleYes = function(){
				var handler = {
					success: function(o){
						that.dt.get();
						confirmDialog.hide();
					},
					failure: function(o){ ANEOL.visualisation.displayMsg('Erreur !', o.statusText, YAHOO.widget.SimpleDialog.ICON_WARN); }
				};
				var trans = YAHOO.util.Connect.asyncRequest('POST', that.url, handler, "action=delete&id_redactor="+id_redactor);
			};
			var confirmDialog = new YAHOO.widget.SimpleDialog("Confirmation",  {
				width: "300px", 
				fixedcenter: true, 
				visible: false, 
				draggable: true, 
				close: false, 
				modal: YAHOO.env.ua.ie === 0, 
				text: "Voulez-vous vraiment supprimer ce rédacteur ?", 
					icon: YAHOO.widget.SimpleDialog.ICON_WARN, 
					constraintoviewport: true, 
					buttons: [ { text:"Oui", handler:handleYes, isDefault:true }, 
										 { text:"Non",  handler:handleNo } ] 
			}); 
			confirmDialog.render(document.body); 
			confirmDialog.show();
		 };//}}}

	};//}}}
	RedactorFrm = function(o){//{{{
		ANEOL.lang.extend(this, ANEOL.Dialog, arguments);
		this.url = '/redactor.php';
		this.template = 'getFrm';
		var that = this;

		this.init = function(){//{{{
			that.panel = new YAHOO.widget.Dialog(that.container, { 
				width : "400px",
				visible : false, 
				modal: YAHOO.env.ua.ie === 0,
				close:false,
				constraintoviewport : true,
				buttons : [ { text:"Valider", handler:that.submit, isDefault:true }, { text:"Fermer", handler:that.hide } ]
			});
			that.panel.render();
			that.panel.center();
			that.panel.show();
		};//}}}
		this.submit = function(){//{{{
			var handler = {
				success: function(o){
					if(ANEOL.redactorsDialog !== undefined){
						ANEOL.redactorsDialog.dt.get();
					}
					that.hide();
				},
				failure: function(o){ ANEOL.visualisation.displayMsg('Erreur !', o.statusText, YAHOO.widget.SimpleDialog.ICON_WARN); }
			};
			var frm = document.getElementById('frm_redactor');
			var ok = ANEOL.validation.validate(
				ANEOL.validation.required, {'field': frm.name},
				ANEOL.validation.required, {'field': frm.surname},
				ANEOL.validation.required, {'field': frm.login},
				ANEOL.validation.email, {'field': frm.login},
				ANEOL.validation.required, {'field': frm.password},
				ANEOL.validation.required, {'field': frm.confirmation}
			);
			if(ok){
				if(frm.password.value != frm.confirmation.value){
					ANEOL.visualisation.displayMsg('Erreur !', "Le mot de passe n'est pas valide.", YAHOO.widget.SimpleDialog.ICON_WARN);
					frm.password.focus();
				}
				YAHOO.util.Connect.setForm(frm);
				var trans = YAHOO.util.Connect.asyncRequest('POST', that.url, handler);
			}
		};//}}}

	};//}}}
		PrivPage = function(){//{{{

			ANEOL.lang.extend(this, ANEOL.Dialog, arguments);
			this.url = '/redactor.php';
			this.template = 'getPrivateFrm';
			var that = this;

			this.submit = function(){//{{{
				var handler = {
					success: function(o){
						if(o.responseText != ""){
							ANEOL.visualisation.displayMsg('Erreur !', o.responseText, YAHOO.widget.SimpleDialog.ICON_WARN);
						}else{
							that.hide();
						}
					},
					failure: function(o){ ANEOL.visualisation.displayMsg('Erreur !', o.statusText, YAHOO.widget.SimpleDialog.ICON_WARN); }
				};
				var frm = document.getElementById('private_frm');
				var ok = ANEOL.validation.validate(
					ANEOL.validation.required, {'field': frm.ancien, 'msg':"Veuillez saisir l'ancien mot de passe."},
					ANEOL.validation.required, {'field': frm.password},
					ANEOL.validation.required, {'field': frm.confirmation}
				);
				if(ok){
					if(frm.password.value != frm.confirmation.value){
						ANEOL.visualisation.displayMsg('Erreur !', "Le mot de passe n'est pas valide.", YAHOO.widget.SimpleDialog.ICON_WARN);
						frm.password.focus();
						return false;
					}
					YAHOO.util.Connect.setForm(frm);
					var trans = YAHOO.util.Connect.asyncRequest('POST', that.url, handler);
				}
			};//}}}
			this.init = function(){//{{{
				that.panel = new YAHOO.widget.Dialog("private", { 
					width : "500px",
					visible : false, 
					modal: YAHOO.env.ua.ie === 0,
					close:false,
					constraintoviewport : true,
					buttons : [ { text:"Valider", handler:that.submit, isDefault:true }, { text:"Fermer", handler:that.hide, isDefault:true } ]
				});
				that.panel.render();
				that.panel.center();
				that.panel.show();
			};//}}}

		};//}}}
	ContactFrm = function() {//{{{
		ANEOL.lang.extend(this, ANEOL.Dialog, arguments);
		this.url = '/index.php';
		this.template = 'contactFrm';
		var that = this;

		this.submit = function(){//{{{
			var formu = document.getElementById('contact_form');
			var ok = ANEOL.validation.validate(
				ANEOL.validation.required, {'field': formu.contact_recipient, 'msg':"Le champ destinataire n'est pas valide."},
				ANEOL.validation.email, {'field': formu.contact_recipient, 'msg':"Le champ destinataire n'est pas valide."}
			);
			if(ok){
				var handler = {
					success: function(o){
						that.panel.hide();
					},
					failure: function(o){ ANEOL.visualisation.displayMsg('Erreur !', o.statusText, YAHOO.widget.SimpleDialog.ICON_WARN); }
				};
				formu.contact_message.value = FCKeditorAPI.GetInstance('editor_area').GetHTML();
				YAHOO.util.Connect.setForm(formu);
				var trans = YAHOO.util.Connect.asyncRequest('POST', "/index.php", handler);
			}
		};//}}}
		this.init = function(){//{{{
			that.panel = new YAHOO.widget.Dialog(that.container, { 
				width : "700px",
				visible : false, 
				modal: YAHOO.env.ua.ie === 0,
				close:false,
				constraintoviewport : true,
				buttons : [ { text:"Valider", handler:that.submit, isDefault:true }, { text:"Annuler", handler:that.hide } ]
			});
			this.panel.render();
			var editor = new FCKeditor( 'editor_area' ) ;
			editor.Height = 250 ;
			editor.ReplaceTextarea() ;
			this.panel.center();
			this.panel.show();
		};//}}}
	};//}}}

// Edition CSS / HTML et gestion themes
	StyleFrm = function(){//{{{

		ANEOL.lang.extend(this, ANEOL.Dialog, arguments);
		this.url = '/theme.php';
		this.template = 'styleFrm';
		var that = this;

		this.submit = function(){//{{{
			var handler = {
				success: function(o){
					 window.open(window.location);
				},
				failure: function(o){ ANEOL.visualisation.displayMsg('Erreur !', o.statusText, YAHOO.widget.SimpleDialog.ICON_WARN); }
			};
			var frm = document.getElementById('frm_css');
			YAHOO.util.Connect.setForm(frm);
			var trans = YAHOO.util.Connect.asyncRequest('POST', '/theme.php', handler, "action=styleUpdateFile");
		}//}}}
		this.init = function(){//{{{
			that.panel = new YAHOO.widget.Dialog("dialog", { 
				width : "800px",
				visible : false, 
				modal: YAHOO.env.ua.ie === 0,
				close:false,
				constraintoviewport : true,
				buttons : [{ text:"Enregistrer et visualiser", handler:that.submit, isDefault:true }, { text:"Fermer", handler:that.hide } ]
			});
			that.panel.render();
			that.panel.center();
			that.panel.show();

		};//}}}
		this.getStyle = function(file){//{{{
			var handler = {
				success: function(o){
					var fn = document.getElementById('filename');
					fn.value = file;
					var txt = document.getElementById('file_content');
					txt.value = o.responseText;
				},
				failure: function(o){ ANEOL.visualisation.displayMsg('Erreur !', o.statusText, YAHOO.widget.SimpleDialog.ICON_WARN); }
			};
			var trans = YAHOO.util.Connect.asyncRequest('POST', '/theme.php', handler, "action=styleGetFile&filename="+file);
		};//}}}

	};//}}}
		ThemeSelector = function(){//{{{
			ANEOL.lang.extend(this, ANEOL.Dialog, arguments);
			this.url = '/theme.php';
			this.template = 'themeSelector';
			var that = this;

			this.init = function(){//{{{
				that.panel = new YAHOO.widget.Dialog(that.container, { 
					width : "700px",
					visible : false, 
					modal: YAHOO.env.ua.ie === 0,
					close:false,
					constraintoviewport : true,
					buttons : [{ text:"Appliquer", handler:that.applyTheme, isDefault:true }, { text:"Fermer", handler:that.hide } ]
				});
				
				var themes = YAHOO.util.Dom.getElementsByClassName('theme');
				for(i=0;i<themes.length;i++){
					YAHOO.util.Event.addListener(themes[i].id, "click", that.selectTheme); 
				}

				that.panel.render();
				that.panel.center();
				that.panel.show();
				that.panel.cfg.config.buttons.value[0].htmlButton.disabled = true;

			};//}}}
			this.selectTheme = function(e){//{{{
				var themes = YAHOO.util.Dom.getElementsByClassName('theme');
				for(i=0;i<themes.length;i++){
					YAHOO.util.Dom.removeClass(themes[i], 'selected'); 
				}
				document.getElementById('theme').value = this.id;
				YAHOO.util.Dom.addClass(this, "selected");
				that.panel.cfg.config.buttons.value[0].htmlButton.disabled = false;
			};//}}}
			this.applyTheme = function(){//{{{
				var handler = {
					success: function(o){
						that.hide();
						window.location.reload(true);
					},
					failure: function(o){ ANEOL.visualisation.displayMsg('Erreur !', o.statusText, YAHOO.widget.SimpleDialog.ICON_WARN); }
				};
				var trans = YAHOO.util.Connect.asyncRequest('POST', '/theme.php', handler, "action=applyTheme&theme="+document.getElementById('theme').value);
			};//}}}

		};//}}}

// Edition Header / Footer
		BannerFrm = function(o) {//{{{
			ANEOL.lang.extend(this, ANEOL.Dialog, arguments);
			this.url = '/index.php';
			this.template = 'bannerFrm';
			var that = this;

			this.init = function(){//{{{
				this.panel = new YAHOO.widget.Dialog(that.container, { 
					width : "500px",
					visible : false, 
					modal: YAHOO.env.ua.ie === 0,
					close:false,
					constraintoviewport : true,
					buttons : [ { text:"Valider", handler:that.submit, isDefault:true }, { text:"Annuler", handler:that.hide }]
				});
				this.panel.render();
				that.panel.center();
				this.panel.show();

				var btSelectBackground = document.getElementById("btSelectBackground"); 
				YAHOO.util.Event.addListener(btSelectBackground, "click", that.selectBackground); 
				var btResetBackground = document.getElementById("btResetBackground"); 
				YAHOO.util.Event.addListener(btResetBackground, "click", that.resetBackground); 

				var btSelectBackground = document.getElementById("btSelectLogo"); 
				YAHOO.util.Event.addListener(btSelectBackground, "click", that.selectLogo); 
				var btResetBackground = document.getElementById("btResetLogo"); 
				YAHOO.util.Event.addListener(btResetBackground, "click", that.resetLogo); 

				hb = document.getElementById('hidden_block');
				hb.style.display = 'none';
			};//}}}
			this.submit = function(){//{{{
				var handler = {
					success: function(o){
						that.hide();
						window.location = window.location;
					},
					failure: function(o){ ANEOL.visualisation.displayMsg('Erreur !', o.statusText, YAHOO.widget.SimpleDialog.ICON_WARN); }
				};
				var frm = document.getElementById('frm_banner');
				YAHOO.util.Connect.setForm(frm);
				var trans = YAHOO.util.Connect.asyncRequest('POST', "/index.php", handler);
			};//}}}

			this.selectBackground = function(){//{{{
				BrowseServer('header_bg_image');
			};//}}}
			this.resetBackground = function(){//{{{ 
				var img = document.getElementById('bg');
				img.src = "/images/fond_banner.jpg";
				document.getElementById('header_bg_image').value = "";
			};//}}}
			this.selectLogo = function(){//{{{
				BrowseServer('header_logo');
			};//}}}
			this.resetLogo = function(){//{{{
				var img = document.getElementById('logo_img');
				img.src = "/images/fond_banner.jpg";
				document.getElementById('header_logo').value = "";
			};//}}}

		};//}}}
		FooterFrm = function() {//{{{
			ANEOL.lang.extend(this, ANEOL.Dialog, arguments);
			this.url = '/index.php';
			this.template = 'footerFrm';
			var that = this;

			this.init = function(){//{{{
				that.panel = new YAHOO.widget.Dialog(that.container, { 
					width : "700px",
					visible : false, 
					modal: YAHOO.env.ua.ie === 0,
					close:false,
					constraintoviewport : true,
					buttons : [ { text:"Valider", handler:that.submit, isDefault:true }, { text:"Fermer", handler:that.hide } ]
				});
				that.panel.render();
				var editor = new FCKeditor( 'editor_area' ) ;
				editor.Height = 420 ;
				editor.ReplaceTextarea() ;
				that.panel.center();
				that.panel.show();

			};//}}}
			this.submit = function(){//{{{
				var handler = {
					success: function(o){
						that.hide();
						window.location = window.location;
					},
					failure: function(o){ ANEOL.visualisation.displayMsg('Erreur !', o.statusText, YAHOO.widget.SimpleDialog.ICON_WARN); }
				};
				var frm = document.getElementById('frm_footer');
				frm.content.value = FCKeditorAPI.GetInstance('editor_area').GetHTML();
				YAHOO.util.Connect.setForm(frm);
				var trans = YAHOO.util.Connect.asyncRequest('POST', '/index.php', handler);
			};//}}}

		};//}}}

// Periode selector
		CalendarSelector = function(){//{{{
			ANEOL.lang.extend(this, ANEOL.Dialog, arguments);
			this.url = '/index.php';
			this.template = 'calendarSelector';
			this.calendar = undefined;
			this.deb = this.fin = undefined;
			var that = this;

			this.init = function(){//{{{
				that.panel = new YAHOO.widget.Dialog(that.container, { 
					width : "430px",
					height : "300px",
					visible : false, 
					modal: YAHOO.env.ua.ie === 0,
					close:false,
					constraintoviewport : true,
					buttons : [ { text:"Valider", handler:that.submit, isDefault:true }, { text:"Fermer", handler:that.hide } ]
				});
				that.panel.render();

				that.calendar = new YAHOO.example.calendar.IntervalCalendar("calInterval");

				that.calendar.selectEvent.subscribe(function() {
					var interval = this.getInterval();
					that.deb = interval[0];
					that.fin = interval[1];
					/*
					*/
				}, that.calendar, true);
				that.calendar.render();

				that.panel.show();
				that.panel.center();

			};//}}}
			this.submit = function(){//{{{
				var duree = ((that.fin - that.deb)/86400000);
				if(duree > 62){
					ANEOL.visualisation.displayMsg('Erreur !', "La période maximale est de deux mois.", YAHOO.widget.SimpleDialog.ICON_WARN);
				}else{
					that.hide();
					window.location = '/index/analytics/'+that.deb.getFullYear() +'-'+ (that.deb.getMonth() + 1) +'-'+ that.deb.getDate()+'/'+that.fin.getFullYear() +'-'+ (that.fin.getMonth() + 1) +'-'+ that.fin.getDate()+'.html';
				}
				console.log(duree);
			};//}}}

		}//}}}


