/* $VERSION: windows.js 3.1.032.1.2011.02.09.09.11	 */
// $VERSION: windows.js 1.25 (06-02-2009)
/*
	pour la gestion du navigateur
*/

function lib_bwcheck()
{
	 //Browsercheck (needed)
	this.ver = navigator.appVersion
	this.agent = navigator.userAgent
	this.dom = document.getElementById ? 1 : 0
	this.opera5 = this.agent.indexOf("Opera 5") > -1
	this.firefox = this.agent.indexOf("Firefox") > -1
	this.ie5 = (this.ver.indexOf("MSIE 5") > -1 && this.dom && !this.opera5) ? 1 : 0;
	this.ie6 =(this.ver.indexOf("MSIE 6") > -1 && this.dom && !this.opera5) ? 1 : 0;
	this.ie4 =(document.all && !this.dom && !this.opera5) ? 1 :0;
	this.ie = this.ie4 || this.ie5 || this.ie6
	this.mac = this.agent.indexOf("Mac") > -1
	this.ns6 = (this.dom && parseInt(this.ver) >= 5) ? 1 : 0;
	this.ns4 = (document.layers && !this.dom) ? 1 : 0;
	this.bw = (this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5)
	return this;
}
var bw=new lib_bwcheck()

/*== class win pour la gestion du fenetrage */
function win(input){
	var win = this;

	this.titre = 'titre de la fenetre';
	this.x = 100;
	this.y = 100;
	this.width = 100;
	this.height = 100;
	this.minx = 10;
	this.miny = 10;
	this.minh = 100;
	this.minw = 100;
	this.contenu = 'contenu';
}

win.prototype.toString = function ()
{
	return '[win Object]';
}

win.prototype.init = function ()
{
	win = document.createElement('div');
	win.className = 'clWin';
	Element.setStyle(win,{left:'0px'});
	Element.setStyle(win,{top:'0px'});
	this.win = win;
	this.move = false;
	this.resize = false;

	//entete
	head = document.createElement('div');
	head.className = 'clWinHead';
	head.appendChild(document.createTextNode(this.titre));
	this.head = head;
	win.appendChild(head);

	// contenu
	text = document.createElement('div');
	text.className = 'clWindow';
	win.appendChild(text);
	this.wintext = text;
	//this.dotext();

	//resize
	resize = document.createElement('div');
	resize.className = 'clWinResize';

	win.appendChild(resize);

	//bouton fermer
	clos = document.createElement('div');
	clos.className = 'clWinClose';
	win.appendChild(clos);

	var win = this;

	clos.onclick = function () { win.hide(); };

	if (head.attachEvent)
		head.attachEvent('onmousedown', function() {win.onheadmousedown();});
	if (head.addEventListener)
		head.addEventListener('mousedown', function (event) { win.onheadmousedown(event)}, true);

	if (resize.attachEvent)
		resize.attachEvent('onmousedown', function() {win.onresizemousedown();});
	if (resize.addEventListener)
		resize.addEventListener('mousedown', function (event) { win.onresizemousedown(event)}, true);

	if (document.attachEvent)
		document.attachEvent('onmousemove', function() {win.onmousemove();});
	if (document.addEventListener)
		document.addEventListener('mousemove', function (event) { win.onmousemove(event)}, true);

	if (document.attachEvent)
		document.attachEvent('onmouseup', function() {win.onmouseup();});
	if (document.addEventListener)
		document.addEventListener('mouseup', function (event) { win.onmouseup(event)}, true);

}

win.prototype.show  = function ()
{
	if (!this.win)
	{
		this.init();
	}
	if (this.input)
	{
		var pos =  Position.page(this.input);
		this.x = pos[0];
		this.y = pos[1];
	}
	this.dotext();
	if (!this.win.parentNode || !this.win.parentNode.tagName)
		document.getElementsByTagName('body')[0].appendChild(this.win);
	this.arrange();
	css = bw.dom||bw.ie4 ? this.win.style : this.win;
	css.visibility = 'visible';
}
win.prototype.isvisible = function ()
{
	css = bw.dom||bw.ie4 ? this.win.style : this.win;

	return (css.visibility == 'visible')
}
win.prototype.hide = function ()
{
	css = bw.dom||bw.ie4 ? this.win.style : this.win;

	css.visibility = 'hidden';

	combos = document.getElementsByTagName('SELECT');
	for (var i = 0; combo = combos[i]; i++)
	{
		if (combo.isvisible)
			combo.style.visibility = 'visible';
	}

}

win.prototype.max = function ()
{
	this.sizeto(500,500)
}

win.prototype.min = function ()
{
	this.sizeto(this.minw,this.minh)
}

win.prototype.onheadmousedown = function (e)
{
	if (!e) e = event;
	this.posX = ((bw.ns4 || bw.ns6)?e.pageX:e.x||e.clientX) - this.x;
	this.posY = ((bw.ns4 || bw.ns6)?e.pageY:e.y||e.clientY) - this.y;
	this.move = true;
}

win.prototype.onresizemousedown = function (e)
{

	if (!e) e = event;
	this.posX = ((bw.ns4 || bw.ns6)? e.pageX:e.x || e.clientX) - this.x ;
	this.posY = ((bw.ns4 || bw.ns6)?e.pageY:e.y || e.clientY) - this.y;

	this.resize = true;
}

win.prototype.onmousemove= function (e)
{
	if (this.move)
	{
		if (!e) e = event;
		x=(bw.ns4 || bw.ns6)?e.pageX:e.x||e.clientX;
		y=(bw.ns4 || bw.ns6)?e.pageY:e.y||e.clientY;
		this.moveto(x - this.posX  , y - this.posY);
	}
	if (this.resize)
	{
		if (!e) e = event;
		x=(bw.ns4 || bw.ns6)? e.pageX: e.x||e.clientX;
		y=(bw.ns4 || bw.ns6)? e.pageY: e.y||e.clientY;

		if (bw.ie)
		{
			body = document.getElementsByTagName('body')[0];
			this.sizeto(x + body.scrollLeft  - this.x, y + body.scrollTop - this.y);
		}
		else
			this.sizeto(x - this.x, y - this.y);

	}
}

win.prototype.onmouseup= function (e)
{
	this.resize = false;
	this.move = false;
}

win.prototype.moveto = function (x,y)
{
	if (x > this.minx)
		this.x = x;
	if (y > this.miny)
		this.y=y;
	this.arrange();
}

win.prototype.sizeto = function (width, height)
{
	if (height >= this.minh)
		this.height = height;
	else
		this.height = this.minh;

	if (width >= this.minw)
		this.width = width;
	else
		this.width = this.minw;

	this.inresize();
	this.arrange();

}

win.prototype.arrange = function ()
{
	css = bw.dom||bw.ie4 ? this.win.style : this.win;

	if ((this.x + this.width)> document.documentElement.clientWidth)
		this.x = document.documentElement.clientWidth - this.width - 1
	if (this.x < 100 )
		this.x = 100;

	if ((this.y + this.height)> document.documentElement.clientHeight)
		this.y = document.documentElement.clientHeight - this.height - 1
	if (parseFloat(this.y) < 100 )
		this.y = '100';

	css.height = this.height+'px';
	css.width = this.width+'px';
	css.top = this.y+'px';
	css.left = this.x+'px';

	css = bw.dom||bw.ie4 ? this.wintext.style : this.win.text;

	if (bw.ie)
	{
		rec = this.win.getBoundingClientRect();
		divtop = rec.top;
		divleft = rec.left;
		divwidth = this.win.offsetWidth;
		divheight = this.win.offsetHeight;

		combos = document.getElementsByTagName('SELECT');
		for (var i = 0; combo = combos[i]; i++)
		{
			rec = combo.getBoundingClientRect();
			cbtop = rec.top;
			cbleft = rec.left;
			cbwidth = combo.offsetWidth;
			cbheight = combo.offsetHeight;

			combo.isvisible = true;
			combo.style.visibility = 'hidden';
			if (	( divleft < (cbleft + cbwidth) )
				&&	( (divleft + divwidth) >  cbleft )
				&&	( divtop < (cbtop + cbheight) )
				&&	( (divtop + divheight) >  cbtop)
				)
			{
				if (combo.style.visibility == '' || combo.style.visibility == 'visible')
				{
					combo.isvisible = true;
				}
				combo.style.visibility = 'hidden';
			}
			else
				combo.style.visibility = 'visible';
		}
	}


}

win.prototype.inresize = function ()
{

}

win.prototype.bg = function (color)
{
	if(bw.opera5)
		this.css.background = color
	else if(bw.dom || bw.ie4)
		this.css.backgroundColor = color
	else if(bw.ns4)
		this.css.bgColor=color
}

win.prototype.dotext = function ()
{
	this.wintext.appendChild(document.createTextNode(this.contenu));
}

/* === class calendrier extends win === */

function wincalendrier(input)
{
	this.titre = 'Choisissez la date';

	this.input = input;

	this.width = 200;
	this.height = 130;
	this.minw = 200;
	this.minh = 130;

	this.mois = '';
	this.annee = '';
	this.semaine = ["D", "L", "M", "M", "J", "V", "S" ];
	this.nommois = ["", "Janvier", "Février", "Mars", "Avril", "Mai", "Juin","Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre"];
	this.nbj = [31, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
	this.getvalue = true;

}

wincalendrier.prototype = new win;

wincalendrier.prototype.select = function(node)
{
	this.input.value = node.day;
	this.input.focus();
	try
	{
		fieldset = this.input.fieldset;
		for (var j = 0; j < fieldset.elements.length; j++){
			if (fieldset.elements[j] == this.input) break;
		}
		fieldset.elements[j+1].focus();
		if (fieldset.elements[j+1].select)
			fieldset.elements[j+1].select();

	} catch(e){};
	try
	{
		change = new Function(this.input.name + '_onchange()');
		try {change();} catch(e){};
	}catch(e){};
	this.hide();
}

wincalendrier.prototype.highlight = function(node)
{
	node.unfocusclassName = node.className;
	node.className = 'focus';
}

wincalendrier.prototype.unhighlight = function(node)
{
	node.className = node.unfocusclassName;
}

wincalendrier.prototype.go = function(node, num)
{
	this.mois += num ;
	if (this.mois < 1)
	{
		this.mois+=12;
		this.annee--;
	}
	if (this.mois > 12)
	{
		this.mois-=12;
		this.annee++;
	}
	this.getvalue = false;
	this.dotext();
	this.getvalue = true;
}


wincalendrier.prototype.dotext = function()
{
	if (this.getvalue)
		if (this.input.value != '')
		{
			var tableau = this.input.value.split("/");
			this.mois = Number(tableau[1]);
			this.annee = Number(tableau[2]);
		}
		else
		{
			var aujourdhui = new Date();
			this.mois = aujourdhui.getMonth()+1;
			this.annee = aujourdhui.getFullYear();
		}

	while (this.wintext.hasChildNodes())
	{
		this.wintext.removeChild(this.wintext.childNodes[0]);
	}

	var wincal = this;

	var table = document.createElement('table');
	table.className = 'calendrier';
	var tr = table.insertRow(0);

	cell = tr.insertCell(0);
			var img = document.createElement('img');
		img.src = '/composants/images/calendrier/precedent_d.gif';
		img.title = 'Année précédente';
	cell.appendChild(img);
//	cell.className = 'jour';
	cell.className = 'nav';
	if (cell.style.cursor)
		cell.style.cursor = 'pointer';

	cell.onmousedown = function() { wincal.go(this, -12);};

	cell = tr.insertCell(1);
		var img = document.createElement('img');
		img.src = '/composants/images/calendrier/precedent_s.gif';
		img.title = 'Mois précédent';

	cell.appendChild(img);
	//cell.className = 'jour';
	cell.className = 'nav';
	if (cell.style.cursor)
		cell.style.cursor = 'pointer';
	cell.onmousedown = function() { wincal.go(this, -1);};

	cell = tr.insertCell(2);
	cell.appendChild(document.createTextNode(this.nommois[this.mois] + ' ' + this.annee));
	cell.className = 'libelle-date';


	cell = tr.insertCell(3);
	var img = document.createElement('img');
		img.src = '/composants/images/calendrier/suivant_s.gif';
		img.title = 'Mois suivant';
	cell.appendChild(img);

	cell.onmousedown = function() { wincal.go(this, 1);};
	if (cell.style.cursor)
		cell.style.cursor = 'pointer';
	//cell.className = 'jour';
	cell.className = 'nav';

	cell = tr.insertCell(4);
	var img = document.createElement('img');
		img.src = '/composants/images/calendrier/suivant_d.gif';
		img.title = 'Année suivante';
	cell.appendChild(img);
	cell.onmousedown = function() { wincal.go(this, 12);};
	if (cell.style.cursor)
		cell.style.cursor = 'pointer';
	//cell.className = 'jour';
	cell.className = 'nav';
	this.wintext.appendChild(table);

	var table = document.createElement('table');
	table.className = 'calendrier';

  	// la ligne des jours
	var tr = table.insertRow(i);
	for (var i =0; i < 7; i++)
	{
		var cell = tr.insertCell(i);
		cell.appendChild(document.createTextNode(this.semaine[i]));
		cell.className = 'jour';
	}

	// le corps
	if (this.annee % 4 == 0)
	{
		this.nbj[2] = '29';
	}

	var vDate = new Date();

	vDate.setDate(1);
	vDate.setMonth(this.mois-1);
	vDate.setFullYear(this.annee);
	decal = vDate.getDay();
	var debut = this.nbj[this.mois-1] - decal + 1;
	nbj = this.nbj[this.mois - 1];
	var annee = '';
	var mois = '';
	var jour = '';
	jour = debut;
	mois = this.mois - 1;
	if (mois < 1)
	{
		annee = this.annee - 1;
		mois = 12;
	}
	else
		annee = this.annee;

	dansmois = false;
    for (var j = 0; j < 35; j++)
    {
		if (jour > nbj)
		{
			jour = 1;
			nbj = this.nbj[this.mois];
			dansmois = !dansmois
			mois++;
			if (mois > 12)
			{
				mois = 1;
				annee++;
			}
		}
		if (j%7 == 0)
			var tr = table.insertRow((j/7)+1);

		if (!dansmois)
			classname = 'horsmois';
		else if ((j%7 == 0)||(j%7 == 6))
			classname = 'weekend';
		else
			classname = '';

		var cell = tr.insertCell(j%7);
		cell.appendChild(document.createTextNode(jour));

		vJour = (jour.toString().length < 2) ? "0" + jour : jour;
		vMois = (mois.toString().length < 2) ? "0" + mois : mois;
		vAnnee = annee;

		cell.day = vJour + '/'+ vMois + '/' + vAnnee;
		if (cell.style.cursor)
			cell.style.cursor = 'pointer';
		cell.onmouseover = function() { wincal.highlight(this);};
		cell.onmouseout = function() { wincal.unhighlight(this);};
		cell.onmousedown = function() { wincal.select(this);};
		cell.className = classname;

		jour++;
	}

	this.wintext.appendChild(table);
}


/* === class assistant extends win === */
function winassistant(input)
{
	this.width = 450;
	this.height = 350;
	this.titre = 'Assistant';
	this.input = input;

	if (input.title)	this.titre = 'Assistant : ' + input.title;
	this.libelles = input.libelles.length > 0 ? input.libelles.split('_$_') : [];
	this.basevalues = input.inputs.length > 0 ? input.basevalues.split('_$_') : [];
	this.inputs = input.inputs.length > 0 ? input.inputs.split('_$_') : [];
	this.multi = input.multi;
	this.values = new Array();

	this.resetSqlValue = '';
	//Lors de l'affichage, on testera si valeur déjà sélectionnée pour la surligner
	this.tis_resetSqlValues = new Array();

	if(this.input.sqlValue && this.input.sqlValue != '')
	{
		this.resetSqlValue = this.input.sqlValue;
		tsSqlValeurs 	= this.resetSqlValue.split(',');

		for (var iValSql = 0; iValSql < tsSqlValeurs.length; iValSql++)
		{
			this.tis_resetSqlValues[tsSqlValeurs[iValSql]] = true;
		}
	}

	if(input.multi == 1 && input.value.indexOf(',',0) != -1)
	{
		input.forceaffiche = true;
	}

	this.db = new ACDB_Remote(' ')
	this.db.action = this.input.action;
	var ac = this;
	this.db.onmatch = function(matches) { ac.found(matches); }
}

winassistant.prototype = new win;

winassistant.prototype.populate = function()
{
	this.dosearch();
}

winassistant.prototype.inresize = function()
{
	if (this.indiv)
	{
		this.indiv.style.height = parseFloat(this.height - 100)+'px';
	}
}

winassistant.prototype.dosearch = function()
{
	var elements = '';
	var values = {};
	if (this.win && this.isvisible())
	{
		// récupération des valeurs dans les critères de l'assistant.
		finds = this.win.getElementsByTagName('input');
		for (var i = 0; find = finds[i]; i++)
		{
			this.values[Number(find.number)] = find.value;
			values[Number(find.number)] = find.value;
		 	elements += (Number(find.number) + ' ');
		}
		values['recherche'] = 'recherche';
	 	elements +=  'recherche ';
	}
	else
	{
		for (var i = 0; i < this.inputs.length; i++)
		{
			this.values[i] = '';
			if (this.inputs[i]  != '')
			{
				var obj =  getObj(this.inputs[i]);
				if (!obj) continue;
				if ((obj.type != 'text') &&(obj.type != 'hidden') &&(obj.tagName != 'SELECT')) continue;
				if (!values[obj.name.toLowerCase()])
					 elements += (obj.name.toLowerCase() + ' ');
				if (obj.type.toLowerCase() == 'text' && this.basevalues[i] == 'O' && obj.hasSqlValue)
				{
					this.values[i] = obj.sqlValue;
				}
				else
				{
					this.values[i] = obj.value;
				}
				if (obj.name != this.input.name)
					values[obj.name.toLowerCase()] = this.values[i];
				else
					values[obj.name.toLowerCase()] = obj.value;
			}
		}
	}

	values['SENDDATA'] = elements;
	try
	{
		values['PHPSESSID'] =  getValue("PHPSESSID");
	} catch(e) {};

	{
		elements = "";
		fieldset = this.input.fieldset;
		if (fieldset)
		{
			for (var i = 0; i < fieldset.elements.length; i++)
			{
				if (fieldset.elements[i].name == '') continue;
				if (!values[fieldset.elements[i].name.toLowerCase()])
				{
					values[fieldset.elements[i].name.toLowerCase()] = fieldset.elements[i].getValue();
					elements += (fieldset.elements[i].name.toLowerCase() + ' ');
				}
			}
		}
		else
		{
			inputs = document.getElementsByTagName("INPUT");
			for (i = 0; i < inputs.length; i++)
			{
				if (inputs[i].name == "ENVOI_PARAMETRE") continue;
				if (inputs[i].name == "ENVOI_TABLEAU_DYNAMIQUE") continue;
				if (inputs[i].name == "ACTION")	continue;
				if (inputs[i].name == "HISTORY") continue;
				if (inputs[i].name == "PHPSESSID")continue;
				if (inputs[i].type == 'submit')	continue;
				if (Element.hasClassName(inputs[i], 'bouton')) continue;
				if (inputs[i].name == "") continue;
				if (!values[inputs[i].name])
				{
					values[inputs[i].name] = getValue(inputs[i].name);
					elements += (inputs[i].name + ' ');
				}
			}

			inputs = document.getElementsByTagName("SELECT");
			for (i = 0; i < inputs.length; i++)
			{
				if (!values[inputs[i].name.toLowerCase()])
				{
					values[inputs[i].name.toLowerCase()] = inputs[i].value;
					elements += (inputs[i].name.toLowerCase() + ' ');
				}
			}
		}
		values['EXTRAPARAM'] = elements;
	}

	if (!this.input.auto && this.input.forceaffiche)
	{
		if (!this.win)
		{
			this.init();
			this.initialise();
		}
		this.show();
		this.showcriteres();
		this.input.forceaffiche = false;
	}
	else
	{
		string = $H(values).toQueryString();
		this.db.search(string);
	}
}

winassistant.prototype.found = function(matches)
{
	this.matches = matches;
	if (matches.length == 1)
	{
		for (i = 0; input = this.inputs[i]; i++)
		{
			if (this.basevalues[i] == "O")
				setSqlValue(input, matches[0][i]);
			else
			{
				var obj = getObj(input);
				obj.changed = false;
				setValue(input, matches[0][i]);
			}
		}
		if (!this.input.forceaffiche)
		{
			if (this.win)
			{
				this.hide();
			}
			this.after();
			return;
		}
	}

	if (!this.win)
	{
		this.init();
		this.initialise();
	}
	this.show();

	var table = this.table;
	while (table.rows.length > 0)
	{
		table.deleteRow(table.rows.length-1);
	}
	table.deleteTHead();

  	if (matches.length > 0)
	{
		for (var iRow = 0; iRow < matches.length; iRow++)
		{
			var tr = table.insertRow(Number(iRow));
			if (iRow%2)
			{
				tr.className = 'paire';
			}
			else
			{
				tr.className = 'impaire';
			}
			if (this.multi == 1)
			{
				tr.check = false;
			}
			var col = 0;
			for (var k = 0 ; k < matches[iRow].length; k++)
			{
				if (this.libelles[k] == '') continue;
				cell = tr.insertCell(col++);
				cell.appendChild(document.createTextNode(matches[iRow][k]));

				if (this.multi == 1)
				{
					if(this.basevalues[k] == "O")
					{
						//if(tsValeurActuelles[k]['sqlvalues'][matches[iRow][k]])
						if(this.tis_resetSqlValues[matches[iRow][k]])
						{
							//On sélectionne automatiquement les valeurs qui étaient déjà présentes
							this.select(tr);
							this.highlight(tr);
						}
					}
				}
			}
			var win = this;
			tr.style.cursor = "pointer";
			tr.numRow = iRow;
			tr.onmousedown = function() { win.select(this); }
			tr.onmouseover = function() { win.highlight(this); }
			tr.onmouseout = function() { win.unhighlight(this); }
		}
		var tr = table.createTHead().insertRow(0);
		var col = 0;
		for (var i = 0; i < this.libelles.length; i++)
		{
			if (this.libelles[i] == '') continue;
			var cell = tr.insertCell(Number(col++));
			cell.appendChild(document.createTextNode(this.libelles[i]));
		}
		$A(tr.cells).each(function(element) {
			element.order = 1;
			element.type = 1;
			Event.observe(element, 'click', function(){theadtdonclick(element) }, false);
		});

		table.swapRow  = table_swapRow;
		table.sort = table_sort;
		table.compare = table_compare;
		table.getValue = table_getvalue;

		this.dobarre(false);
	}
	else
	{
		this.showcriteres();
	}
}

winassistant.prototype.initialise = function()
{
	var win = this;

	var barre =  document.createElement('div');
	barre.className = 'assistantbarre';
	this.wintext.appendChild(barre);
	this.barre = barre;

	var div = document.createElement('div');
	div.className = 'assistanttable';
	this.indiv = div;
	this.inresize();
	this.wintext.appendChild(div);

	var table = document.createElement('table');
	table.className = 'tableau';
	div.appendChild(table);
	this.table = table;

	var blocbas = document.createElement('div');
	blocbas.className = 'bloc_bas';
	this.wintext.appendChild(blocbas);
	this.blocbas = blocbas;
}

winassistant.prototype.after = function(){
	try {
		getObj(this.input.name).valOk = true;
		traitenattente();
		traiteattente = function (){};
	}catch(e){};
	try {
		variable =  this.input.name + '_afteronassistant();';
		afteronassistant = new Function(variable);
		afteronassistant();
	}catch(e){};
}

winassistant.prototype.select = function(node)
{
	if (this.multi == 0)
	{
		for (var i = 0; input = this.inputs[i]; i++)
		{
			var obj = getObj(input);
			obj.valueAssistant = this.matches[node.numRow][i];
		}

		for (var i = 0; input = this.inputs[i]; i++)
		{
			if (this.basevalues[i] == "O")
			{
				setSqlValue(input, this.matches[node.numRow][i]);
			}
			else
			{
				setValue(input, this.matches[node.numRow][i]);
			}
		}
		this.hide();
		this.after();
	}
	else
	{
		node.checked = !node.checked;
	}
}

winassistant.prototype.highlight = function(node)
{
	if (node.className != 'focus')
		node.oldClassName = node.className;
	node.className = 'focus';
}

winassistant.prototype.unhighlight = function(node)
{
	if (this.multi == 0)
	{
		node.className = node.oldClassName;
	}
	else if  (!node.checked)
	{
		node.className = node.oldClassName;
	}
}


winassistant.prototype.dobarre = function(critere)
{
	var win = this;
//on vire les boutons avant leurs (re)crécration si besoin
	valider_on = this.blocbas.getElementsByTagName('input');
	num_input = valider_on.length -1;
	for (var i = num_input  ; i >= 0; i--)
	this.blocbas.removeChild(valider_on[i]);

//on vire le menu avant sa (re)crécration si besoin
	ssmenus = this.barre.getElementsByTagName('div');
	num = ssmenus.length -1;
	for (var i = num  ; i >= 0; i--)
		this.barre.removeChild(ssmenus[i]);

	if (critere)
	{

		//menu stylé
		var ssmenu = document.createElement('div')
			ssmenu.className = 'img-shadow-1';
			ssmenu.style.width = '56px';

			var ul = document.createElement('ul')
				ul.className = 'sousmenu_assist';

				var li = document.createElement('li')
				// lancement de la recherche
					var img = document.createElement('img')
						img.onclick = function() { win.find(); }
						img.src = '/composants/images/search_assistant.gif';
						img.title = 'Lancer la recherche';
					li.appendChild(img);
				ul.appendChild(li);

				var li = document.createElement('li')
				// on efface
					var img = document.createElement('img')
						img.src = '/composants/images/erase.gif';
						img.title = 'Effacer les critères de la recherche';
						img.onclick = function() { win.clear(); }
					li.appendChild(img);
				ul.appendChild(li);

		ssmenu.appendChild(ul);

		this.barre.appendChild(ssmenu);

		if (this.db.len == 0)
		{

			if (!this.input.forceaffiche)
			{

			var div_attention = document.createElement('div');
			div_attention.className = 'attention_ico_assist';
			div_attention.appendChild(document.createTextNode("Aucun élement ne répond à vos critères."))
			this.barre.appendChild(div_attention);

			}
		}
		if (this.db.len == 999)
		{
			var div_attention = document.createElement('div');
			div_attention.className = 'attention_ico_assist';
			div_attention.appendChild(document.createTextNode("Trop d'élements répondent à votre critères, affinez votre recherche"))
			this.barre.appendChild(div_attention);
		}

		//bouton annulation
		var input_annule = document.createElement('input');
			input_annule.type = 'button';
			Element.addClassName(input_annule,'bouton');
			Element.addClassName(input_annule,'annuler');
			input_annule.name ='annuler';
			input_annule.value = 'Annuler';
			input_annule.onclick = function() { win.hide(); }

			this.blocbas.appendChild(input_annule);
	}
	else
	{
	var ssmenu = document.createElement('div')
			ssmenu.className = 'img-shadow-1';
			ssmenu.style.width = '31px';

			var ul = document.createElement('ul')
				ul.className = 'sousmenu_assist';

				var li = document.createElement('li')
					var img = document.createElement('img')
					img.onclick = function() { win.showcriteres(); }
					img.src = '/composants/images/search_assistant.gif';
					img.title = 'Voir les critères de sélection';

					li.appendChild(img);
				ul.appendChild(li);

		ssmenu.appendChild(ul);

		this.barre.appendChild(ssmenu);

	//boutons annulation et validation si multiselection
		var input_annule = document.createElement('input');
			input_annule.type = 'button';
			Element.addClassName(input_annule,'bouton');
			Element.addClassName(input_annule,'annuler');
			input_annule.name ='annuler';
			input_annule.value = 'Annuler';
			input_annule.onclick = function() { win.hide(); }

			this.blocbas.appendChild(input_annule);

			if (this.multi == 1 )
				{
				var input_valider = document.createElement('input');
					input_valider.type = 'button';
					Element.addClassName(input_valider,'bouton');
					Element.addClassName(input_valider,'valider');
					input_valider.name ='valider';
					input_valider.value = 'Valider';
					input_valider.onclick = function() { win.valider(); }

					this.blocbas.appendChild(input_valider);
				}


		var div_info = document.createElement('div');
		div_info.className = 'info_ico_assist ';
		if (this.matches.length == 1)
			div_info.appendChild(document.createTextNode("1 élement répond à vos critères."))
		else
			div_info.appendChild(document.createTextNode(this.matches.length + " élements répondent à vos critères."))

		this.barre.appendChild(div_info);
	}
	function menuonmouseout(li){
	if (li.style)
		li.className = '';
	}

	function menuonmouseover(li){
		if (li.style)
			li.style.cursor = 'pointer';
			li.className = 'sousmenu_assist_hover';
	}
	$$('.sousmenu_assist li').each(function(element) {
			Event.observe(element, 'mouseout', function(){menuonmouseout(element) }, false);
			Event.observe(element, 'mouseover', function(){menuonmouseover(element) }, false);
		});
}

winassistant.prototype.dotext = function()
{
}

winassistant.prototype.showcriteres = function ()
{
	while (this.table.rows.length > 0)
	{
		this.table.deleteRow(this.table.rows.length - 1);
	}
	this.table.deleteTHead();
	var iRow = 0;
	for (var i = 0 ; i < this.libelles.length; i++ )
	{
		var tr = this.table.insertRow(iRow++);
		tr.insertCell(0).appendChild(document.createTextNode(this.libelles[i]));
		var input = document.createElement("input");
		if (this.libelles[i]=='')
			input.type = 'hidden';
		input.number = i;
		input.value = this.values[i];
		tr.insertCell(1).appendChild(input);
		if (this.libelles[i]=='')
		{
			$(tr).hide();
		}
	}
	this.dobarre(true);
	this.recherche = true;

}

winassistant.prototype.find = function()
{
	this.dosearch();
}

winassistant.prototype.valider = function()
{
	retour = "";
	virgule = "";
	var retourVal = "";

	for (var i = 1; row =this.table.rows[i]; i++)
	{
		if (row.checked)
		{
			retour +=(virgule + row.cells[0].innerHTML);
			retourVal +=(virgule + row.cells[1].innerHTML);
			virgule = ",";
		}
	}
	this.input.value = retourVal;
	this.input.sqlValue = retour;
	this.input.hasSqlValue = true;
	this.resetSqlValue = retour;

	this.tis_resetSqlValues = new Array();

	if(this.input.sqlValue && this.input.sqlValue != '')
	{
		this.resetSqlValue = this.input.sqlValue;
		tsSqlValeurs 	= this.resetSqlValue.split(',');

		for (var iValSql = 0; iValSql < tsSqlValeurs.length; iValSql++)
		{
			this.tis_resetSqlValues[tsSqlValeurs[iValSql]] = true;
		}
	}

	getObj(this.input.name).valOk = true;
	this.hide();
}

winassistant.prototype.clear = function()
{
	finds = this.win.getElementsByTagName('input');
	for (var i = 0; find = finds[i]; i++)
	{
		if (finds[i].type.toLowerCase() != 'text')  continue;
		find.value = '';
	}
}


// Copyright (c) 2006 SÃ©bastien Gruhier (http://xilinus.com, http://itseb.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// VERSION 0.95


var Window = Class.create();
Window.prototype = {
	// Constructor
	// Available parameters : className, title, minWidth, minHeight, maxWidth, maxHeight, width, height, top, left, bottom, right, resizable, zIndex, opacity,
	//                        hideEffect, showEffect, showEffectOptions, hideEffectOptions, effectOptions, url, draggable, closable, minimizable, maximizable, parent, onload
	initialize: function(id) {
		this.hasEffectLib = String.prototype.parseColor != null;
		this.options = Object.extend({
		  className:         "dialog",
      minWidth:          100,
      minHeight:         20,
      resizable:         true,
      closable:          true,
      minimizable:       true,
      maximizable:       true,
      draggable:         true,
      userData:          null,
      showEffect:        (this.hasEffectLib ? Effect.Appear : Element.show),
      hideEffect:        (this.hasEffectLib ? Effect.Fade : Element.hide),
      showEffectOptions: {},
      hideEffectOptions: {},
      effectOptions:     null,
      parent:            document.getElementsByTagName("body").item(0),
      title:             "&nbsp;",
      url:               null,
      onload:            Prototype.emptyFunction,
      width:             200,
      height:            300,
      opacity:           1
    }, arguments[1] || {});

	  if (this.options.effectOptions) {
	    Object.extend(this.options.hideEffectOptions, this.options.effectOptions);
	    Object.extend(this.options.showEffectOptions, this.options.effectOptions);
	  }
		if (this.options.hideEffect == Element.hide)
		  this.options.hideEffect = function(){ Element.hide(this.element); if (this.destroyOnClose) this.destroy(); }.bind(this)

		this.element = this._createWindow(id);

		// Bind event listener
    this.eventMouseDown = this._initDrag.bindAsEventListener(this);
  	this.eventMouseUp   = this._endDrag.bindAsEventListener(this);
  	this.eventMouseMove = this._updateDrag.bindAsEventListener(this);
  	this.eventKeyPress  = this._keyPress.bindAsEventListener(this);
  	this.eventOnLoad    = this._getWindowBorderSize.bindAsEventListener(this);
    this.eventMouseDownContent = this.toFront.bindAsEventListener(this);

		this.topbar = $(this.element.id + "_top");
		this.bottombar = $(this.element.id + "_bottom");
    this.content = $(this.element.id + "_content");

		Event.observe(this.topbar, "mousedown", this.eventMouseDown);
		Event.observe(this.bottombar, "mousedown", this.eventMouseDown);
		Event.observe(this.content, "mousedown", this.eventMouseDownContent);
		Event.observe(window, "load", this.eventOnLoad);

		if (this.options.draggable)  {
			this.bottombar.addClassName("bottom_draggable");
			this.topbar.addClassName("top_draggable");
    }

		if (this.options.resizable) {
			this.sizer = $(this.element.id + "_sizer");
    	Event.observe(this.sizer, "mousedown", this.eventMouseDown);
    }

    this.useLeft = null;
    this.useTop = null;
		if (arguments[1].left != null) {
			this.element.setStyle({left: parseFloat(arguments[1].left) + 'px'});
			this.useLeft = true;
		}
		if (arguments[1].right != null) {
			this.element.setStyle({right: parseFloat(arguments[1].right) + 'px'});
			this.useLeft = false;
		}
    if (this.useLeft == null) {
	    this.element.setStyle({left: "0px"});
			this.useLeft = true;
    }

		if (arguments[1].top != null) {
			this.element.setStyle({top: parseFloat(arguments[1].top) + 'px'});
			this.useTop = true;
		}
		if (arguments[1].bottom != null) {
			this.element.setStyle({bottom: parseFloat(arguments[1].bottom) + 'px'});
			this.useTop = false;
		}
    if (this.useTop == null) {
			this.element.setStyle({top: "0px"});
			this.useTop = true;
    }

    this.storedLocation = null;

		this.setOpacity(this.options.opacity);
		if (arguments[1].zIndex)
			this.setZIndex(arguments[1].zIndex)

		this.destroyOnClose = false;

    this._getWindowBorderSize();
		this.setSize(this.options.width, this.options.height);
		this.setTitle(this.options.title)
		Windows.register(this);
  },

	// Destructor
 	destroy: function() {
		Windows.notify("onDestroy", this);

  	Event.stopObserving(this.topbar, "mousedown", this.eventMouseDown);
  	Event.stopObserving(this.bottombar, "mousedown", this.eventMouseDown);
  	Event.stopObserving(this.content, "mousedown", this.eventMouseDownContent);

		Event.stopObserving(window, "load", this.eventOnLoad);
		Event.stopObserving(this.content, "load", this.options.onload);

		if (this.sizer)
    		Event.stopObserving(this.sizer, "mousedown", this.eventMouseDown);

		if (this.options.url)
		  this.content.src = null

	 	if(this.iefix)
			Element.remove(this.iefix);

    Element.remove(this.element);
		Windows.unregister(this);
	},

	// Sets window deleagte, should have functions: "canClose(window)"
	setDelegate: function(delegate) {
		this.delegate = delegate
	},

	// Gets current window delegate
	getDelegate: function() {
		return this.delegate;
	},

	// Gets window content
	getContent: function () {
		return this.content;
	},

	// Sets the content with an element id
	setContent: function(id, autoresize, autoposition) {
		var d = null;
		var p = null;

		if (autoresize)
			d = Element.getDimensions(id);
		if (autoposition)
			p = Position.cumulativeOffset($(id));

		var content = this.getContent()
		content.appendChild($(id));
		$(id).show();
		if (autoresize)
			this.setSize(d.width, d.height);
		if (autoposition)
		  this.setLocation(p[1] - this.heightN, p[0] - this.widthW);
	},

	setAjaxContent: function(url, options, showCentered, showModal) {
	  this.showFunction = showCentered ? "showCenter" : "show";
	  this.showModal = showModal || false;

	  if (options == null)
	    options = {}
	  this.onComplete = options.onComplete;
	  options.onComplete = this._setAjaxContent.bind(this);

	  new Ajax.Request(url, options);
	},

	_setAjaxContent: function(originalRequest) {
	  this.getContent().innerHTML = originalRequest.responseText;
	  if (this.onComplete)
	    this.onComplete(originalRequest);
	  this[this.showFunction](this.showModal)
	},

	// Stores position/size in a cookie, by default named with window id
	setCookie: function(name, expires, path, domain, secure) {
		name = name || this.element.id;
		this.cookie = [name, expires, path, domain, secure];

		// Get cookie
		var value = WindowUtilities.getCookie(name)
		// If exists
		if (value) {
			var values = value.split(',');
			var x = values[0].split(':');
			var y = values[1].split(':');

			var w = parseFloat(values[2]), h = parseFloat(values[3]);
			var mini = values[4];
			var maxi = values[5];

		  this.setSize(w, h);
			if (mini == "true")
		    this.doMinimize = true; // Minimize will be done at onload window event
			else if (maxi == "true")
			  this.doMaximize = true; // Maximize will be done at onload window event

			this.useLeft = x[0] == "l";
			this.useTop = y[0] == "t";

			this.element.setStyle(this.useLeft ? {left: x[1]} : {right: x[1]});
			this.element.setStyle(this.useTop ? {top: y[1]} : {bottom: y[1]});
		}
	},

	// Gets window ID
	getId: function() {
		return this.element.id;
	},

	// Detroys itself when closing
	setDestroyOnClose: function() {
	  Object.extend(this.options.hideEffectOptions, {afterFinish:  this.destroy.bind(this)});
		this.destroyOnClose = true;
	},

	// initDrag event
	_initDrag: function(event) {
    // Get pointer X,Y
  	this.pointer = [Event.pointerX(event), Event.pointerY(event)];

    // Resize
		if (Event.element(event) == this.sizer) {
			this.doResize = true;
    	this.widthOrg = this.width;
    	this.heightOrg = this.height;
    	this.bottomOrg = parseFloat(this.element.getStyle('bottom'));
    	this.rightOrg = parseFloat(this.element.getStyle('right'));
			Windows.notify("onStartResize", this);
		}
    else {
		  this.doResize = false;

  		// Check if click on close button,
  		var closeButton = $(this.getId() + '_close');
  		if (closeButton && Position.within(closeButton, this.pointer[0], this.pointer[1]))
  			return;

  		this.toFront();

  		if (! this.options.draggable)
  		  return;
  		Windows.notify("onStartMove", this);
    }
  	// Register global event to capture mouseUp and mouseMove
  	Event.observe(document, "mouseup", this.eventMouseUp, false);
    Event.observe(document, "mousemove", this.eventMouseMove, false);

  	// Add an invisible div to keep catching mouse event over iframes
  	WindowUtilities.disableScreen('__invisible__', '__invisible__', false);

    // Stop selection while dragging
    document.body.ondrag = function () { return false; };
    document.body.onselectstart = function () { return false; };

    Event.stop(event);
  },

  // updateDrag event
	_updateDrag: function(event) {
   	var pointer = [Event.pointerX(event), Event.pointerY(event)];
		var dx = pointer[0] - this.pointer[0];
		var dy = pointer[1] - this.pointer[1];

		// Resize case, update width/height
		if (this.doResize) {
			this.setSize(this.widthOrg + dx , this.heightOrg + dy);

      dx = this.width - this.widthOrg
      dy = this.height - this.heightOrg

		  // Check if it's a right position, update it to keep upper-left corner at the same position
			if (! this.useLeft)
				this.element.setStyle({right: (this.rightOrg -dx) + 'px'});
			// Check if it's a bottom position, update it to keep upper-left corner at the same position
			if (! this.useTop)
				this.element.setStyle({bottom: (this.bottomOrg -dy) + 'px'});
		}
		// Move case, update top/left
		else {
		  this.pointer = pointer;

			if (this.useLeft)
				this.element.setStyle({left: parseFloat(this.element.getStyle('left')) + dx + 'px'});
			else
				this.element.setStyle({right: parseFloat(this.element.getStyle('right')) - dx + 'px'});

			if (this.useTop)
				this.element.setStyle({top: parseFloat(this.element.getStyle('top')) + dy + 'px'});
		  else
				this.element.setStyle({bottom: parseFloat(this.element.getStyle('bottom')) - dy + 'px'});
		}
		if (this.iefix)
			this._fixIEOverlapping();

		this._removeStoreLocation();
    Event.stop(event);
	},

	 // endDrag callback
 	_endDrag: function(event) {
		// Remove temporary div over iframes
 	  WindowUtilities.enableScreen('__invisible__');

		if (this.doResize)
			Windows.notify("onEndResize", this);
		else
			Windows.notify("onEndMove", this);

		// Release event observing
		Event.stopObserving(document, "mouseup", this.eventMouseUp,false);
    Event.stopObserving(document, "mousemove", this.eventMouseMove, false);

		// Store new location/size if need be
		this._saveCookie()

    Event.stop(event);

    // Restore selection
    document.body.ondrag = null;
    document.body.onselectstart = null;
  },

	_keyPress: function(event) {
		//Dialog.cancelCallback();
	},

	// Creates HTML window code
	_createWindow: function(id) {
	  var className = this.options.className;
		var win = document.createElement("div");
		win.setAttribute('id', id);
		win.className = "dialog";

		var content;
		if (this.options.url)
			content= "<IFRAME name=\"" + id + "_content\"  id=\"" + id + "_content\" SRC=\"" + this.options.url + "\"> </IFRAME>";
		else
			content ="<DIV id=\"" + id + "_content\" class=\"" +className + "_content\"> </DIV>";

		var closeDiv = this.options.closable ? "<div class='"+ className +"_close' id='"+ id +"_close' onclick='Windows.close(\""+ id +"\")'> </div>" : "";
		var minDiv = this.options.minimizable ? "<div class='"+ className + "_minimize' id='"+ id +"_minimize' onclick='Windows.minimize(\""+ id +"\")'> </div>" : "";
		var maxDiv = this.options.maximizable ? "<div class='"+ className + "_maximize' id='"+ id +"_maximize' onclick='Windows.maximize(\""+ id +"\")'> </div>" : "";
		var seAttributes = this.options.resizable ? "class='" + className + "_sizer' id='" + id + "_sizer'" : "class='"  + className + "_se'";

    win.innerHTML = closeDiv + minDiv + maxDiv + "\
      <table id='"+ id +"_row1' class=\"top table_window\">\
        <tr>\
          <td class='"+ className +"_nw'>&nbsp;</td>\
          <td class='"+ className +"_n'><div id='"+ id +"_top' class='"+ className +"_title title_window'>"+ this.options.title +"</div></td>\
          <td class='"+ className +"_ne'>&nbsp;</td>\
        </tr>\
      </table>\
      <table id='"+ id +"_row2' class=\"mid table_window\">\
        <tr>\
          <td class='"+ className +"_w'></td>\
            <td id='"+ id +"_table_content' class='"+ className +"_content' valign='top'>"+ content +"</td>\
          <td class='"+ className +"_e'></td>\
        </tr>\
      </table>\
        <table id='"+ id +"_row3' class=\"bot table_window\">\
        <tr>\
          <td class='"+ className +"_sw'>&nbsp;</td>\
            <td class='"+ className +"_s'><div id='"+ id +"_bottom' class='status_bar'>&nbsp;</div></td>\
            <td " + seAttributes + ">&nbsp;</td>\
        </tr>\
      </table>\
    ";

		Element.hide(win);
		this.options.parent.insertBefore(win, this.options.parent.firstChild);
		Event.observe($(id + "_content"), "load", this.options.onload);
		return win;
	},

	// Sets window location
	setLocation: function(top, left) {
	  if (top < 0)
	    top = 0;
    if (left < 0)
      left= 0
		this.element.setStyle({top: top + 'px'});
		this.element.setStyle({left: left + 'px'});
		this.useLeft = true;
		this.useTop = true;
	},

	// Gets window size
	getSize: function() {
	  return {width: width, height: height};
	},

	// Sets window size
	setSize: function(width, height) {
	  width = parseFloat(width);
	  height = parseFloat(height);

		// Check min and max size
		if (width < this.options.minWidth)
			width = this.options.minWidth;

		if (height < this.options.minHeight)
			height = this.options.minHeight;

		if (this.options. maxHeight && height > this.options. maxHeight)
			height = this.options. maxHeight;

		if (this.options. maxWidth && width > this.options. maxWidth)
			width = this.options. maxWidth;

  	this.width = width;
		this.height = height;
		this.element.setStyle({width: width + this.widthW + this.widthE + "px"})
		this.element.setStyle({height: height  + this.heightN + this.heightS + "px"})

		// Update content height
		var content = $(this.element.id + '_content')
		content.setStyle({height: height  + 'px'});
		content.setStyle({width: width  + 'px'});
	},

	// Brings window to front
	toFront: function() {
    this.setZIndex(Windows.maxZIndex + 20);
	},

	// Displays window modal state or not
	show: function(modal) {
		if (modal) {
			WindowUtilities.disableScreen(this.options.className);
			this.modal = true;
			this.setZIndex(Windows.maxZIndex + 20);
			Windows.unsetOverflow(this);
			Event.observe(document, "keypress", this.eventKeyPress);
		}

		// To restore overflow if need be
		if (this.oldStyle)
		  this.getContent().setStyle({overflow: this.oldStyle});

		this.setSize(this.width, this.height);
		if (this.options.showEffect != Element.show && this.options.showEffectOptions )
			this.options.showEffect(this.element, this.options.showEffectOptions);
		else
			this.options.showEffect(this.element);

    this._checkIEOverlapping();
	},

	// Displays window modal state or not at the center of the page
	showCenter: function(modal) {
		this.setSize(this.width, this.height);
		this._center();

		this.show(modal);
	},

	_center: function() {
		var windowScroll = WindowUtilities.getWindowScroll();
		var pageSize = WindowUtilities.getPageSize();

    this.setLocation(windowScroll.top + (pageSize.windowHeight - (this.height + this.heightN + this.heightS))/2,
                     windowScroll.left + (pageSize.windowWidth - (this.width + this.widthW + this.widthE))/2);
    this.toFront();
	},

	// Hides window
	hide: function() {
		if (this.modal) {
			WindowUtilities.enableScreen();
			Windows.resetOverflow();
			Event.stopObserving(document, "keypress", this.eventKeyPress);
		}
		// To avoid bug on scrolling bar
	  this.oldStyle = this.getContent().getStyle('overflow');
		this.getContent().setStyle({overflow: "hidden"});

		this.options.hideEffect(this.element, this.options.hideEffectOptions);

	 	if(this.iefix)
			this.iefix.hide();
	},

  minimize: function() {
    var r2 = $(this.getId() + "_row2");
    var dh = r2.getDimensions().height;

    if (r2.visible()) {
      var h  = this.element.getHeight() - dh
      r2.hide()
  		this.element.setStyle({height: h + "px"})
  		if (! this.useTop) {
  		  var bottom = parseFloat(this.element.getStyle('bottom'));
			  this.element.setStyle({bottom: (bottom + dh) + 'px'});
		  }
    }
    else {
      var h  = this.element.getHeight() + dh;
      this.element.setStyle({height: h + "px"})
  		if (! this.useTop) {
  		  var bottom = parseFloat(this.element.getStyle('bottom'));
			  this.element.setStyle({bottom: (bottom - dh) + 'px'});
		  }
      r2.show();

      this.toFront();
    }
    Windows.notify("onMinimize", this);

    // Store new location/size if need be
		this._saveCookie()
  },

  maximize: function() {
    if (this.storedLocation != null) {
      this._restoreLocation();
      if(this.iefix)
  			this.iefix.hide();
    }
    else {
      this._storeLocation();
      Windows.unsetOverflow(this);

      var windowScroll = WindowUtilities.getWindowScroll();
  		var pageSize = WindowUtilities.getPageSize();

			this.element.setStyle(this.useLeft ? {left: windowScroll.left} : {right: windowScroll.left});
  		this.element.setStyle(this.useTop ? {top: windowScroll.top} : {bottom: windowScroll.top});

      this.setSize(pageSize.windowWidth - this.widthW - this.widthE, pageSize.windowHeight - this.heightN - this.heightS)
      this.toFront();
      if (this.iefix)
  			this._fixIEOverlapping();
    }
		Windows.notify("onMaximize", this);

		// Store new location/size if need be
		this._saveCookie()
  },

  isMinimized: function() {
    var r2 = $(this.getId() + "_row2");
    return !r2.visible();
  },

  isMaximized: function() {
    return (this.storedLocation != null);
  },

	setOpacity: function(opacity) {
		if (Element.setOpacity)
			Element.setOpacity(this.element, opacity);
	},

	setZIndex: function(zindex) {
		this.element.setStyle({zIndex: zindex});
		Windows.updateZindex(zindex, this);
	},

  setTitle: function(newTitle) {
  	if (!newTitle || newTitle == "")
  	  newTitle = "&nbsp;";

  	Element.update(this.element.id + '_top', newTitle);
  },

	setStatusBar: function(element) {
		var statusBar = $(this.getId() + "_bottom");

    if (typeof(element) == "object") {
      if (this.bottombar.firstChild)
        this.bottombar.replaceChild(element, this.bottombar.firstChild);
      else
        this.bottombar.appendChild(element);
    }
    else
		  this.bottombar.innerHTML = element;
	},

	_checkIEOverlapping: function() {
    if(!this.iefix && (navigator.appVersion.indexOf('MSIE')>0) && (navigator.userAgent.indexOf('Opera')<0) && (this.element.getStyle('position')=='absolute')) {
        new Insertion.After(this.element.id, '<iframe id="' + this.element.id + '_iefix" '+ 'style="display:none;position:absolute;filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);" ' + 'src="javascript:false;" frameborder="0" scrolling="no"></iframe>');
        this.iefix = $(this.element.id+'_iefix');
    }
    if(this.iefix)
			setTimeout(this._fixIEOverlapping.bind(this), 50);
	},

	_fixIEOverlapping: function() {
	    Position.clone(this.element, this.iefix);
	    this.iefix.style.zIndex = this.element.style.zIndex - 1;
	    this.iefix.show();
	},

	_getWindowBorderSize: function(event) {
    // Hack to get real window border size!!
    var div = this._createHiddenDiv(this.options.className + "_n")
		this.heightN = Element.getDimensions(div).height;
		div.parentNode.removeChild(div);

    var div = this._createHiddenDiv(this.options.className + "_s")
		this.heightS = Element.getDimensions(div).height;
		div.parentNode.removeChild(div);

    var div = this._createHiddenDiv(this.options.className + "_e")
		this.widthE = Element.getDimensions(div).width;
		div.parentNode.removeChild(div);

    var div = this._createHiddenDiv(this.options.className + "_w")
		this.widthW = Element.getDimensions(div).width;
		div.parentNode.removeChild(div);
		// Safari size fix
		if (/Konqueror|Safari|KHTML/.test(navigator.userAgent))
		  this.setSize(this.width, this.height);
		if (this.doMaximize)
		  this.maximize();
		if (this.doMinimize)
		  this.minimize();
  },

  _createHiddenDiv: function(className) {
    var objBody = document.getElementsByTagName("body").item(0);
    var win = document.createElement("div");
		win.setAttribute('id', this.element.id+ "_tmp");
		win.className = className;
		win.style.display = 'none';
		win.innerHTML = '';
		objBody.insertBefore(win, objBody.firstChild);
		return win
  },

	_storeLocation: function() {
	  if (this.storedLocation == null) {
	    this.storedLocation = {useTop: this.useTop, useLeft: this.useLeft,
	                           top: this.element.getStyle('top'), bottom: this.element.getStyle('bottom'),
	                           left: this.element.getStyle('left'), right: this.element.getStyle('right'),
	                           width: this.width, height: this.height };
	  }
	},

  _restoreLocation: function() {
    if (this.storedLocation != null) {
      this.useLeft = this.storedLocation.useLeft;
      this.useTop = this.storedLocation.useTop;

      this.element.setStyle(this.useLeft ? {left: this.storedLocation.left} : {right: this.storedLocation.right});
  		this.element.setStyle(this.useTop ? {top: this.storedLocation.top} : {bottom: this.storedLocation.bottom});
		  this.setSize(this.storedLocation.width, this.storedLocation.height);

		  Windows.resetOverflow();
		  this._removeStoreLocation();
    }
  },

  _removeStoreLocation: function() {
    this.storedLocation = null;
  },

  _saveCookie: function() {
    if (this.cookie) {
  		var value = "";
  		if (this.useLeft)
  			value += "l:" +  (this.storedLocation ? this.storedLocation.left : this.element.getStyle('left'))
  		else
  			value += "r:" + (this.storedLocation ? this.storedLocation.right : this.element.getStyle('right'))
  		if (this.useTop)
  			value += ",t:" + (this.storedLocation ? this.storedLocation.top : this.element.getStyle('top'))
  		else
  			value += ",b:" + (this.storedLocation ? this.storedLocation.bottom :this.element.getStyle('bottom'))

  		value += "," + (this.storedLocation ? this.storedLocation.width : this.width);
  		value += "," + (this.storedLocation ? this.storedLocation.height : this.height);
  		value += "," + this.isMinimized();
  		value += "," + this.isMaximized();
  		WindowUtilities.setCookie(value, this.cookie)
    }
  }
};

// Windows containers, register all page windows
var Windows = {
  windows: [],
  observers: [],
  focusedWindow: null,
  maxZIndex: 0,

  addObserver: function(observer) {
    this.removeObserver(observer);
    this.observers.push(observer);
  },

  removeObserver: function(observer) {
    this.observers = this.observers.reject( function(o) { return o==observer });
  },

  notify: function(eventName, win) {  //  onStartResize(), onEndResize(), onStartMove(), onEndMove(), onClose(), onDestroy(), onMinimize(), onMaximize()
    this.observers.each( function(o) {if(o[eventName]) o[eventName](eventName, win);});
  },

  // Gets window from its id
  getWindow: function(id) {
	  return this.windows.detect(function(d) { return d.getId() ==id });
  },

  // Gets the last focused window
  getFocusedWindow: function() {
	  return this.focusedWindow;
  },

  // Registers a new window (called by Windows constructor)
  register: function(win) {
    this.windows.push(win);
  },

  // Unregisters a window (called by Windows destructor)
  unregister: function(win) {
    this.windows = this.windows.reject(function(d) { return d==win });
  },

  // Closes a window with its id
  close: function(id) {
  	var win = this.getWindow(id);
  	// Asks delegate if exists
    if (win) {
	  	if (win.getDelegate() && ! win.getDelegate().canClose(win))
	  		return;

  			this.notify("onClose", win);
  			win.hide();
  	}
  },

  // Closes all windows
  closeAll: function() {
    this.windows.each( function(w) {Windows.close(w.getId())} );
  },

  // Minimizes a window with its id
  minimize: function(id) {
  	var win = this.getWindow(id)
  	if (win)
  	  win.minimize();
  },

  // Maximizes a window with its id
  maximize: function(id) {
  	var win = this.getWindow(id)
  	if (win)
  	  win.maximize();
  },

  unsetOverflow: function(except) {
  	this.windows.each(function(d) { d.oldOverflow = d.getContent().getStyle("overflow") || "auto" ; d.getContent().setStyle({overflow: "hidden"}) });
  	if (except && except.oldOverflow)
  		except.getContent().setStyle({overflow: except.oldOverflow});
  },

  resetOverflow: function() {
	  this.windows.each(function(d) { if (d.oldOverflow) d.getContent().setStyle({overflow: d.oldOverflow}) });
  },

  updateZindex: function(zindex, win) {
  	if (zindex > this.maxZIndex)
  		this.maxZIndex = zindex;
    this.focusedWindow = win;
  }
};

var Dialog = {
  dialogId: null,
 	win: null,
  onCompleteFunc: null,
  callFunc: null,
  parameters: null,
  content:null,
  message:null,
  type:0,
  zonefocus :null,
	confirm: function(content, parameters) {
	  // Get Ajax return before
	  if (typeof content != "string") {
	    Dialog._runAjaxRequest(content, parameters, Dialog.confirm);
	    return
	  }

	  parameters = parameters || {};
	  	var okLabel = parameters.okLabel ? parameters.okLabel : "Ok";
		var cancelLabel = parameters.cancelLabel ? parameters.cancelLabel : "Cancel";
		var windowParam = parameters.windowParameters || {};
		windowParam.className = windowParam.className || "alert";

    okButtonClass = "class ='" + (parameters.buttonClass ? parameters.buttonClass + " " : "") + " ok_button'"
    cancelButtonClass = "class ='" + (parameters.buttonClass ? parameters.buttonClass + " " : "") + " cancel_button'"
		var content = "\
			<div class='" + windowParam.className + "_message'>" + content  + "</div>\
				<div class='" + windowParam.className + "_buttons'>\
					<input type='button' class='bouton valider' value='" + okLabel.gsub(/\'/,'&rsquo;') + "' onclick='Dialog.okCallback()'" + okButtonClass + "/>\
					<input type='button'  class='bouton annuler' value='" + cancelLabel + "' onclick='Dialog.cancelCallback()' " + cancelButtonClass + "/>\
				</div>\
		";
	  this._openDialog(content, parameters)
	  return this.win
	},

	alert: function(content, parameters) {
	  // Get Ajax return before
	  if (typeof content != "string") {
	    Dialog._runAjaxRequest(content, parameters, Dialog.alert);
	    return
	  }

	  parameters = parameters || {};
		var okLabel = parameters.okLabel ? parameters.okLabel : "Ok";

		var windowParam = parameters.windowParameters || {};
		windowParam.className = windowParam.className || "alert";

    okButtonClass = "class ='" + (parameters.buttonClass ? parameters.buttonClass + " " : "") + " ok_button'"
		var content = "\
			<div class='" + windowParam.className + "_message'>" + content  + "</div>\
				<div class='" + windowParam.className + "_buttons'>\
					<input type='button' value='" + okLabel + "' onclick='Dialog.okCallback()'" + okButtonClass + "/>\
				</div>";
		return this._openDialog(content, parameters)
	},

	info: function(content, parameters) {
	  // Get Ajax return before
	  if (typeof content != "string") {
	    Dialog._runAjaxRequest(content, parameters, Dialog.info);
	    return
	  }

	  parameters = parameters || {};
	  parameters.windowParameters = parameters.windowParameters || {};

		var className = parameters.windowParameters.className || "alert";

		var content = "<div id='modal_dialog_message' class='" + className + "_message'>" + content  + "</div>";
		if (parameters.showProgress)
		  content += "<div id='modal_dialog_progress' class='" + className + "_progress'>	</div>";

		parameters.windowParameters.ok = null;
		parameters.windowParameters.cancel = null;
    parameters.windowParameters.className = className;

		return this._openDialog(content, parameters)
	},

	setMessage: function(message) {
		this.message = message;
	},
	setType: function(type) {
		this.type = type;
	},

	setInfoMessage: function(message) {
		$('modal_dialog_message').update(message);
	},

	closeInfo: function() {
		Windows.close(this.dialogId);
	},

	_openDialog: function(content, parameters) {
		// remove old dialog
		if (this.win)
			this.win.destroy();

    if (! parameters.windowParameters.height && ! parameters.windowParameters.width) {
      parameters.windowParameters.width = WindowUtilities.getPageSize().pageWidth / 2;
    }
    this.dialogId = parameters.id ? parameters.id : 'modal_dialog'

    // compute height or width if need be
    if (! parameters.windowParameters.height || ! parameters.windowParameters.width) {
  		var objBody = document.getElementsByTagName("body").item(0);
  		var tmpObj = document.createElement("div");
  		tmpObj.setAttribute('id', this.dialogId);

  		if (parameters.windowParameters.height)
  		  tmpObj.style.height = parameters.windowParameters.height + "px"
		  else
		    tmpObj.style.width = parameters.windowParameters.width + "px"

  		tmpObj.style.position = 'absolute';
  		tmpObj.style.top = '0';
  		tmpObj.style.left = '0';
 		  tmpObj.style.display = 'none';

      tmpObj.innerHTML = content;
  		objBody.insertBefore(tmpObj, objBody.firstChild);
  		if (parameters.windowParameters.height)
  		  parameters.windowParameters.width = $(this.dialogId).getDimensions().width + 5
		  else
		    parameters.windowParameters.height = $(this.dialogId).getDimensions().height + 5
  		objBody.removeChild(tmpObj)
    }
		var windowParam = parameters && parameters.windowParameters ? parameters.windowParameters : {};
		windowParam.resizable = windowParam.resizable || false;

		windowParam.effectOptions = windowParam.effectOptions || {duration: 1};
    windowParam.minimizable = false;
    windowParam.maximizable = false;
    windowParam.closable = false;
		this.win = new Window(this.dialogId, windowParam);
		this.win.getContent().innerHTML = content;
  	this.win.showCenter(true);

		this.win.cancelCallback = parameters.cancel;
		this.win.okCallback = parameters.ok;

		if (! this.eventResize)
		  this.eventResize = this.recenter.bindAsEventListener(this);

  	Event.observe(window, "resize", this.eventResize);
  	Event.observe(window, "scroll", this.eventResize);

		return this.win;
	},

	_getAjaxContent: function(originalRequest)  {
      Dialog.callFunc(originalRequest.responseText, Dialog.parameters)
  },

  _runAjaxRequest: function(message, parameters, callFunc) {
    if (message.options == null)
	    message.options ={}
	  Dialog.onCompleteFunc = message.options.onComplete;
    Dialog.parameters = parameters;
    Dialog.callFunc = callFunc;

	  message.options.onComplete = Dialog._getAjaxContent;
    new Ajax.Request(message.url, message.options);
  },

	okCallback: function() {
		Event.stopObserving(window, "resize", this.eventResize);
		Event.stopObserving(window, "scroll", this.eventResize);

		if (!this.win.okCallback || this.win.okCallback(this.win))
	    this.win.hide();
	    try
	    {
	    	window.zonefocus.focus();
	    } catch(e){};
	},

	cancelCallback: function() {
		this.win.hide();
		Event.stopObserving(window, "resize", this.eventResize);
		Event.stopObserving(window, "scroll", this.eventResize);

		if (this.win.cancelCallback)
			this.win.cancelCallback(this.win);
	    try
	    {
	    	window.zonefocus.focus();
	    } catch(e){};
	},

	recenter: function(event) {
		var pageSize = WindowUtilities.getPageSize();
		// set height of Overlay to take up whole page and show
		if ($('overlay_modal')) {
		  $('overlay_modal').style.height = (pageSize.pageHeight + 'px');
		  $('overlay_modal').style.width = (pageSize.pageWidth + 'px');
    }
		this.win._center();
	}
}
/*
	Based on Lightbox JS: Fullsize Image Overlays
	by Lokesh Dhakar - http://www.huddletogether.com

	For more information on this script, visit:
	http://huddletogether.com/projects/lightbox/

	Licensed under the Creative Commons Attribution 2.5 License - http://creativecommons.org/licenses/by/2.5/
	(basically, do anything you want, just leave my name and link)
*/

var isIE = navigator.appVersion.match(/MSIE/) == "MSIE";

var WindowUtilities = {
  // From script.aculo.us
  getWindowScroll: function() {
    var w = window;
      var T, L, W, H;
      with (w.document) {
        if (w.document.documentElement && documentElement.scrollTop) {
          T = documentElement.scrollTop;
          L = documentElement.scrollLeft;
        } else if (w.document.body) {
          T = body.scrollTop;
          L = body.scrollLeft;
        }
        if (w.innerWidth) {
          W = w.innerWidth;
          H = w.innerHeight;
        } else if (w.document.documentElement && documentElement.clientWidth) {
          W = documentElement.clientWidth;
          H = documentElement.clientHeight;
        } else {
          W = body.offsetWidth;
          H = body.offsetHeight
        }
      }
      return { top: T, left: L, width: W, height: H };

  },
  //
  // getPageSize()
  // Returns array with page width, height and window width, height
  // Core code from - quirksmode.org
  // Edit for Firefox by pHaez
  //
  getPageSize: function(){
  	var xScroll, yScroll;

  	if (window.innerHeight && window.scrollMaxY) {
  		xScroll = document.body.scrollWidth;
  		yScroll = window.innerHeight + window.scrollMaxY;
  	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
  		xScroll = document.body.scrollWidth;
  		yScroll = document.body.scrollHeight;
  	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
  		xScroll = document.body.offsetWidth;
  		yScroll = document.body.offsetHeight;
  	}

  	var windowWidth, windowHeight;

  	if (self.innerHeight) {	// all except Explorer
  		windowWidth = self.innerWidth;
  		windowHeight = self.innerHeight;
  	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
  		windowWidth = document.documentElement.clientWidth;
  		windowHeight = document.documentElement.clientHeight;
  	} else if (document.body) { // other Explorers
  		windowWidth = document.body.clientWidth;
  		windowHeight = document.body.clientHeight;
  	}
  	var pageHeight, pageWidth;

  	// for small pages with total height less then height of the viewport
  	if(yScroll < windowHeight){
  		pageHeight = windowHeight;
  	} else {
  		pageHeight = yScroll;
  	}

  	// for small pages with total width less then width of the viewport
  	if(xScroll < windowWidth){
  		pageWidth = windowWidth;
  	} else {
  		pageWidth = xScroll;
  	}

  	return {pageWidth: pageWidth ,pageHeight: pageHeight , windowWidth: windowWidth, windowHeight: windowHeight};
  },

 	disableScreen: function(className, id, hideSelect) {
 	  id = id || 'overlay_modal'
 	  hideSelect = hideSelect || true
		WindowUtilities.initLightbox(id, className);
		var objBody = document.getElementsByTagName("body").item(0);

		// prep objects
	 	var objOverlay = $(id);

		var pageSize = WindowUtilities.getPageSize();

		// Hide select boxes as they will 'peek' through the image in IE
		if (hideSelect && isIE) {
      $$('select').each(function(element) {element.style.visibility = "hidden"});
	    $$('#'+id+' select').each(function(element) {element.style.visibility = "visible"});
		}

		// set height of Overlay to take up whole page and show
		objOverlay.style.height = (pageSize.pageHeight + 'px');
		objOverlay.style.width = (pageSize.windowWidth + 'px');
		objOverlay.style.display = 'block';
	},

 	enableScreen: function(id) {
 	  id = id || 'overlay_modal'
	 	var objOverlay =  $(id);
		if (objOverlay) {
			// hide lightbox and overlay
			objOverlay.style.display = 'none';

			// make select boxes visible
			if (isIE) {
        $$('select').each(function(element) {element.style.visibility = "visible"});
			}
			objOverlay.parentNode.removeChild(objOverlay);
		}
	},

	// initLightbox()
	// Function runs on window load, going through link tags looking for rel="lightbox".
	// These links receive onclick events that enable the lightbox display for their targets.
	// The function also inserts html markup at the top of the page which will be used as a
	// container for the overlay pattern and the inline image.
	initLightbox: function(id, className) {
		// Already done, just update zIndex
		if ($(id)) {
			Element.setStyle(id, {zIndex: Windows.maxZIndex + 10});
		}
		// create overlay div and hardcode some functional styles (aesthetic styles are in CSS file)
		else {
			var objBody = document.getElementsByTagName("body").item(0);
			var objOverlay = document.createElement("div");
			objOverlay.setAttribute('id', id);
			objOverlay.className = "overlay_" + className
			objOverlay.style.display = 'none';
			objOverlay.style.position = 'absolute';
			objOverlay.style.top = '0';
			objOverlay.style.left = '0';
			objOverlay.style.zIndex = Windows.maxZIndex + 10;
		 	objOverlay.style.width = '100%';
			objBody.insertBefore(objOverlay, objBody.firstChild);
		}
	},

	setCookie: function(value, parameters) {
    document.cookie= parameters[0] + "=" + escape(value) +
      ((parameters[1]) ? "; expires=" + parameters[1].toGMTString() : "") +
      ((parameters[2]) ? "; path=" + parameters[2] : "") +
      ((parameters[3]) ? "; domain=" + parameters[3] : "") +
      ((parameters[4]) ? "; secure" : "");
  },

  getCookie: function(name) {
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1) {
      begin = dc.indexOf(prefix);
      if (begin != 0) return null;
    } else {
      begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1) {
      end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
  }
}


/*
FONCTION DE DEPLACEMENT, RETAILLEMENT, FERMERTURE DE FENETRE.
FONCTION D'INITIALISATION DE CES EVENEMENTS POUR UNE FENETRE
*/
var fen_WinResize = false;
var clWindow_WinResize = false;
var other_height_WinResize = false;
var X_WinResize = false;
var Y_WinResize = false;
function WinResize(e)
{
	if ( fen_WinResize ) return;

	if ( document.all )
		fen_WinResize = event.srcElement.parentNode;
	else
		fen_WinResize = e.target.parentNode;

	other_height_WinResize = 0;
	//recherche du bloc clWindow
	for ( var i=0; i<fen_WinResize.childNodes.length; i++ )
	{
		if ( !fen_WinResize.childNodes[i].className ) continue;
		if ( fen_WinResize.childNodes[i].className.search(/clWindow/) != -1 )
			clWindow_WinResize = fen_WinResize.childNodes[i];
		else if ( fen_WinResize.childNodes[i].className != "clWinClose" && fen_WinResize.childNodes[i].className != "clWinResize" )
		{
			other_height_WinResize += fen_WinResize.childNodes[i].offsetHeight;
		}
	}

	if ( document.all )
	{
		document.onselectstart = new Function("return false;");
	}

	X_WinResize = Event.pointerX(e) - fen_WinResize.offsetWidth;
	Y_WinResize = Event.pointerY(e) - fen_WinResize.offsetHeight;

	Event.observe(document,"mousemove",StartWinResize);
	Event.observe(document,"mouseup",StopWinResize);
}
function StopWinResize()
{
	if ( document.all )
	{
		document.onselectstart = new Function("return true;");
	}

	Event.stopObserving(document,"mousemove",StartWinResize);
	Event.stopObserving(document,"mouseup",StopWinResize);

	fen_WinResize = false;
}
function StartWinResize(e)
{
	if ( !fen_WinResize ) return;

	fen_WinResize.style.width = Event.pointerX(e) - X_WinResize;
	var hauteur = Event.pointerY(e) - Y_WinResize;
	fen_WinResize.style.height = hauteur;
	clWindow_WinResize.style.height = hauteur - other_height_WinResize - 12;
}

var fen_WinMove = false;
var X_WinMove = false;
var Y_WinMove = false;
function WinMove(e)
{
	if ( document.all )
		fen_WinMove = event.srcElement.parentNode;
	else
		fen_WinMove = e.target.parentNode;


	X_WinMove = Event.pointerX(e) - fen_WinMove.offsetLeft;
	Y_WinMove = Event.pointerY(e) - fen_WinMove.offsetTop;

  	if ( document.all )
  	{
  		X_WinMove -= document.body.scrollLeft;
  		Y_WinMove -= document.body.scrollTop;
  	}

	if ( document.all )
	{
		document.onselectstart = new Function("return false;");
		document.attachEvent('onmousemove', StartWinMove, true);
		document.attachEvent('onmouseup', StopWinMove, true);
	}
	else
	{
		document.addEventListener('mousemove', StartWinMove, true);
		document.addEventListener('mouseup', StopWinMove, true);
	}
}
function StopWinMove()
{
	if ( document.all )
	{
		document.detachEvent('onmousemove', StartWinMove, true);
		document.detachEvent('onmouseup', StopWinMove, true);
	}
	else
	{
		document.removeEventListener('mousemove', StartWinMove, true);
		document.removeEventListener('mouseup', StopWinMove, true);
	}
	fen_WinMove = false;
}
function StartWinMove(e)
{
	if ( !fen_WinMove ) return;

	fen_WinMove.style.left = parseInt(Event.pointerX(e)-X_WinMove)+'px';
	fen_WinMove.style.top = parseInt(Event.pointerY(e)-Y_WinMove)+'px';
}


Event.onDOMReady(function() {
	if ($('fenetre_formulaires'))
	{
		$$('#fenetre_formulaires div.clWinResize').each(function(element) {
			Event.observe(element, 'mousedown', function(e){ WinResize(e) }, false);
		});
		$$('#fenetre_formulaires div.clWinClose').each(function(element) {
			Event.observe(element, 'click', function(){ Element.hide(element.parentNode); }, false);
		});
		$$('#fenetre_formulaires div.clWinHead').each(function(element) {
			Event.observe(element, 'mousedown', function(e){WinMove(e) }, false);
		});
	}
});


/*FIN FONCTION FENETRE*/

