function log(txt){
	if(window.console && window.console.firebug && FW.browser.gecko) console.log(txt);
}
function dir(obj){
	if(window.console	&& window.console.firebug && FW.browser.gecko) console.dir(obj);
}


var Ajax = function() { this.initialize.apply(this, arguments);}; //only call the initialize
Ajax.prototype = {
	options : {
		method : 'get',
		url : '',
		async : true,
		noCache : true,
		data : {}
	},
	
	constructor : Ajax,
	initialize : function(options) { //constructor
		var _self = this;
		this.setOptions(options);
		this.xhr = this.getXHR();
		this.xhr.onreadystatechange = function() {
			_self.onReadyStateChange();
		};
	},
	
	onReadyStateChange : function(fromAsync) {
		if(!this.options.async && !fromAsync) {return;} //si mode synchrone, alors cette fonction ne doit pas etre executee
		if (this.xhr.readyState == 4) {/* 4 : etat "complete" */
			if (this.xhr.status == 200) { /* 200 : code HTTP pour OK */
				this.fireEvent('onSuccess');
			} else {
				this.fireEvent('onError');
			}
		}
	},
	
	send : function(data) {
		var o = this.options;
		this.setData(data);
		this.fireEvent('onStart');
		switch(this.options.method.toLowerCase()) {
			case "get":
				var url = this.dataStr.length>0 ? o.url + "?" + this.dataStr : o.url;
				this.xhr.open("GET", this.addNoCache(url), o.async);
				this.xhr.send(null);
				break;
			case "post":
				this.xhr.open("POST", this.addNoCache(o.url), o.async);
				this.xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
				this.xhr.send(this.dataStr);
				break;
			default :
				return false;
		}
		if (!o.async) {
			this.onReadyStateChange(true);
		}
	},
	
	
	addData : function(data) {
		var i;
		if (!data) {return;}
		if (typeof data=='string') {
			var dataArr = data.split('&');
			data={};
			for (i=0; i<dataArr.length; i++) {
				var vals = dataArr[i].split('=');
				data[vals[0]] = vals[1];
			}
		}
		for (i in data) {
			if (data[i]!==null) {
				this.options.data[i] = data[i];
			}
		}
	},
	
	setData : function(data) {
		if (typeof data=='string') {
			this.dataStr = data;
		} else {
			this.addData(data);
			var dataArr = [];
			for (var i in this.options.data) {
				if (typeof this.options.data[i]!='function') {
					dataArr.push(i+'='+this.options.data[i]);
				}
			}
			this.dataStr = dataArr.join('&');
		}
	},
	
	addNoCache : function(url) {
		if (this.options.noCache) {
			if (url.indexOf("?")==-1) {
				url+="?";
			} else if (url.charAt(url.length-1)!="&") {
				url+="&";
			}
			url += "nocache"+ parseInt(Math.random()*1000000,10)+ "=" + parseInt(Math.random()*1000000,10);
		}
		return url;
	},
	
	fireEvent : function(event) {
		if (this.options[event] && typeof this.options[event]=='function') {
			this.options[event](this.xhr);
		}
	},
	
	getXHR : function() {
		if(window.XMLHttpRequest) {
			return new XMLHttpRequest();
		} else {
			if(window.ActiveXObject) {
				var x = ['Msxml2', 'Microsoft'];
				for (var i=0; i<x.length; i++) {
					try {
						return new ActiveXObject(x[i]+'.XMLHTTP');
					} catch (e) {}
				}
			}
		}
		return null;
	},
	
	setOptions : function(options) {
		if (!options){return;}
		var savedOpt = this.options;
		this.options = {};
		for (var i in savedOpt) this.options[i] = savedOpt[i];
		for (var i in options) this.options[i] = options[i];
	}
};



/* XMLF : 
	objet de parcours du DOM XML 
	getContent(node) : retourne la valeur du noeud. // gere les values simples ou les CDATA
	xml2obj(node) : retourne un objet depuis le noeud XML passe en parametre
*/
var XMLF = {
	xml2obj : function(node, arrayForcedNodes) {
		var arrayForced = arrayForcedNodes ? new RegExp('\\b(' + arrayForcedNodes.join('|') + ')\\b') : null;
		var x2o = XMLF.xml2obj;
		var obj = {};
		
		var xmlNodes = 0;
		for (var i=0; i<node.childNodes.length; i++) {
			var n = node.childNodes[i];
			var name = n.nodeName;
			if (n.nodeType==1) {
				xmlNodes++;
				if (obj[name]==null) {
					var tmpObj = x2o(n,arrayForcedNodes);
					obj[name] = arrayForced && name.match(arrayForced) ? [tmpObj] : tmpObj;
				} else {
					if(!(obj[name] instanceof Array)) {
						obj[name]=[obj[name]];
					}
					obj[name].push(x2o(n,arrayForcedNodes));
				}
			}
		}
		if (xmlNodes==0) {
			var val = XMLF.getContent(node);
			
			
			if (!val) {
				if (node.attributes.length==0) {
					val = '';
				} else {
					var val = XMLF.getAttributes(node);
				}
			} else if (val.match(/^\s*true|false\s*$/))  {
				val=eval(val);
			}
			return val;
		} else if(node.attributes && node.attributes.length>0) {
				obj.attr = XMLF.getAttributes(node);
		}
		
		return obj
	},
	getContent : function(node) {
		var str = [];
		for (var i=0; i<node.childNodes.length; i++) {
			str.push(node.childNodes[i].nodeValue);
		}
		return str.join('');
	},
	
	getAttributes : function(node) {
		var val = {};
		for (var i=0; i<node.attributes.length; i++) {
			var attr = node.attributes[i];
			val[attr.nodeName] = attr.nodeValue;
		}
		return val;
	}
}



/** objet d'animaion simple: width height opacity**/
var simpleFX = function() { this.initialize.apply(this, arguments);};
	simpleFX.prototype = {
		options : {
			duration:500,
			fps: 50,
			unity:"px"
		},
		
		constructor : simpleFX,
		
		initialize : function(options) {
			this.setOptions(options);
			this.target = this.options.target;
			this.interval = 1000/this.options.fps;
			this.running = false; // 
			this.onComplete = this.options.onComplete || function (){};
		},
	
		
		
		start: function (oParam){
			if(this.TO) clearInterval(this.TO);
			this.args = [];
			var $tmp = [];
			this.startTime = new Date().getTime();
			// [prop, startVal, endVal, step]
			for(obj in oParam){
				// propriete
				$tmp.push(obj)
				// startVal
				var startVal = isNaN(oParam[obj]) ? 
					oParam[obj][0] : 
						this.target.style[obj] ?
							parseFloat(this.target.style[obj]) :
							this.target["offset"+obj[0].toUpperCase()+obj.substr(1)];
				this.target.style[obj] = startVal + "px";
				$tmp.push(startVal);
				// endVal
				var endVal = oParam[obj].each ? oParam[obj][1] : oParam[obj];
				$tmp.push(endVal);
				// step
				var step = (endVal-startVal)/(this.options.duration);
				$tmp.push(step);
				this.args.push($tmp);
				$tmp = [];
			}
			// engine
			this.running = true;
			this.TO = setInterval(function(obj){
				return function (){
					var currentTime = new Date().getTime();
					for(var i=0;i<obj.args.length;i++){
						//log(obj.args[i]);
						obj.target.style[obj.args[i][0]] = obj.args[i][1] + (currentTime - obj.startTime)* obj.args[i][3] + obj.options.unity;
						if( currentTime >= obj.startTime + obj.options.duration ) {
							obj.target.style[obj.args[i][0]] = obj.args[i][2] + obj.options.unity;
							clearInterval(obj.TO);
							obj.TO = null;
							obj.running = false;
						}
					}
					if(!obj.running) obj.onComplete();
				}
			}(this), 40);
		},

		//obj.target.style.opacity = endValue;
		//obj.target.style.filter = "alpha(opacity=" + endValue*100 + ")";

		stop : function (){
			if(this.TO) {
				clearInterval(this.TO);
				delete this.TO;
				this.TO = null; // là, il existe plus !
			}
		},
		
		setOptions : function(options) {
			if (!options){return;}
			var savedOpt = this.options;
			this.options = {};
			for (var i in savedOpt) this.options[i] = savedOpt[i];
			for (var i in options) this.options[i] = options[i];
		}
		
	}
	

	
/**********************************************************************
	skeenableSelect : 
			REMPLACE UN SELECT OPTION PAR UN A - UL LI A 
			le UL gere l'aspect graphique du select
			TOUT L'ASPECT GRAPHIQUE EST GERE  VIA CSS
			
			TODO refaire ver module
			prevoir des groupes de select pour le closeAll
*/

var skeenedSelect = [];
var skeenableSelect = function() { 
	this.initialize.apply(this, arguments);
};
	
	skeenableSelect.prototype = {
		options : {},
		constructor : skeenableSelect,
		
		initialize : function(select, form, elementIndex, groupIndex) {
			this.select = select;
			skeenedSelect[select.id] = this;			
			this.form = form;
			this.index = elementIndex;
			this.focusableElms = this.form.getFocusable(this.select);
			//console.log(groupIndex)
			this.groupIndex = groupIndex;
			//
			this.open = false;
			this.fromTheMouse = false;
			this.selectedIndex = this.select.selectedIndex;
			this.onTop = this.select.className.match(/\bskeenableSelect_top\b/);
			this.withImg = this.select.className.match(/\bskeenableSelect_img\b/);
			this.selectSize = this.select.className.match(/\bskeenableSelect-size\b/);
			this.bodyChild = this.select.className.match(/\bskeenable_overflow\b/);
			this.maxHeight = this.select.className.match(/\bskeenableSelect_[0-9]*\b/);
			if(this.maxHeight) this.maxHeight = this.maxHeight[0].split("_")[1];
			this.$tmp = this.select.className.match(/\bskeenableId_[a-zA-Z]*\b/);
			this.childOf = null;
			if(this.$tmp) this.childOf = this.$tmp[0].split('_')[1];
			this.fromKeyboard = true;
			
			//
			this.label = this.form.getLabel(this.select);
			if(this.label) this.label.style.display = "none";
			this.opts = this.select.options;
			//log(this.opts);
			this.defaultText = this.label ? this.label.innerHTML : this.opts[0].innerHTML;
			this.focusByScript = true;
			//
			this.build();		
			//
			FW(this.select).addEvent('click', 
				function(obj) {
					return function (){
						return false;
						//obj.a.focus();
					}
				}(this));
			//	
			
			this.select.oldOnChange = this.select.onchange;
			
			this.select.onchange = function(obj) {
				  return function (){
					if(obj.focusByScript){
						obj.update(obj.as[this.selectedIndex]);
						obj.a.focus();
					}
					if(typeof obj.select.oldOnChange == "function") obj.select.oldOnChange();
					obj.focusByScript = true;
					return false;
				  }
			    }(this)
			
			FW(this.select).addEvent('focus', 
				function(obj) {
					return function (){
						return false;
					//	obj.a.focus();
					}
				}(this))
			//
			this.a.onclick =  function (obj){
				return function (){
					obj.display(!obj.open);
					obj.fromKeyboard = false;
					return false;
				}
			}(this);
			//
			
			this.a.onfocus =  function (obj){
				return function (){
					obj.giveKeyEvent(true);
					obj.selectedIndex = obj.select.selectedIndex;
					return false;
				}
			}(this);
			//
			this.a.onblur = function (obj){
				return function (){
					if(!obj.overUL) {
						obj.display(false);
						obj.giveKeyEvent(false);
					}
					return false;
				}
			}(this);
			//
			this.ul.onmouseover = function (obj){
				return function (){
					obj.overUL = true;
					return false;
				}
			}(this);
			//
			this.ul.onmouseout = function (obj){
				return function (){
					obj.overUL = false;
					return false;
				}
			}(this);
			//
			//log(this.opts.length)
			if(this.opts.length < 2 || this.select.getAttribute('disabled')) this.disable();
			else {
				this.update(this.as[this.selectedIndex]);
				this.display(false);
			}
		},
		
		update : function (a){
			if(!a) return;
			this.span.innerHTML = a.innerHTML;
			this.span.className += " selected";
			this.select.selectedIndex = a.getAttribute('index');
			if(typeof this.select.onchange == "function" && pageLoaded) {
				this.focusByScript = false;
				this.select.onchange();
			}
			this.oldIndex = this.select.selectedIndex;
			// si besoin d'une image
			if(this.withImg) {
				this.span.innerHTML = "<img src='css/skin/misc/"+this.opts[this.select.selectedIndex].value+".png' />";
			}
		},
		
		disable: function (){
			this.a.className += " inactive";
			this.select.selectedIndex = 0;
			this.selectedIndex = 0;
			this.span.innerHTML = this.defaultText;
			this.span.className = this.span.className.replace(/selected/g, '')
		},
		
		display: function (bool){
			if(this.opts.length < 2 || this.select.getAttribute('disabled')) {
				this.disable();
				return;
			}
			this.positionate();
			this.ul.style.display = bool ? "block" : "none";
			if (bool){
				this.form.closeAllSelect(this.select);
				this.span.innerHTML = this.defaultText;
				this.span.className = this.span.className.replace(/selected/g, "");
				this.ul.className += " open";
				this.a.className += " skeenableSelected";
				//alert(this.a.className);
				this.a.focus();
			}
			else {
				this.ul.className = this.ul.className.replace(/open/g, "");
				this.a.className = this.ul.className.replace(/skeenableSelected/g, "");
				if (this.span.innerHTML == this.defaultText) this.update(this.as[this.oldIndex]);
				if(this.scroll) this.scroll.destroy(this);
			}
			this.open = bool;
		},
		
		positionate: function (){
			this.ul.style.visibility = "hidden";
			this.ul.style.display = "block";			
			//log(FW(this.ul).getStyle('border-left-width'))
			//calcul pour le select auto
			this.width2apply = this.a.offsetWidth - parseInt(FW(this.ul).getStyle('border-left-width')) - parseInt(FW(this.ul).getStyle('border-right-width'));
			if(this.width2apply < 0) this.width2apply = 0;
			//this.ul.style.width = this.ul.offsetWidth >= this.width2apply ? this.ul.offsetWidth + "px" : this.width2apply  + "px";
			
			this.ul.style.width = this.width2apply  + "px";
			if(this.maxHeight && this.ul.scrollHeight > this.maxHeight) {
				this.ul.style.height = this.maxHeight  + "px";
				this.ul.style.overflowY = "auto";
				this.ul.style.overflowX = "hidden";
				//this.scroll = new scrollerManager(this.ul);
			}
			if(!this.bodyChild && !this.childOf){
				this.ul.style.marginLeft = - (this.a.parentNode.offsetLeft - this.a.offsetLeft) + "px";
				this.ul.style.marginTop = this.a.offsetHeight - 5 + "px";
			}
			else if (this.bodyChild){
				var coo = FW(this.select).getPosition();
				this.a.style.left = coo.x + "px";
				this.a.style.top = coo.y + "px";
				this.ul.style.left = coo.x + "px";
				this.ul.style.top = coo.y + this.a.offsetHeight - 5 + "px";
			}
			else {
				var coo = FW(this.a).getPosition();
				var coo2 = FW(document.getElementById(this.childOf.toString())).getPosition();
				if(!coo || !coo2) return;
				this.ul.style.left = coo.x-coo2.x + "px";
				this.ul.style.top = coo.y-coo2.y + this.a.offsetHeight - 5 + "px";
			}
			if (this.onTop){
				//log(this.ul.offsetHeight)
				this.ul.style.marginTop = -(this.ul.offsetHeight-5) + "px";
			}
			this.ul.style.display = "none";			
			this.ul.style.visibility = "visible";

		},
		
		build: function(){
			
						
			// div prenant comme class l'id sinon le name du formulaire, ==> facilite le ciblage css
			// .myForm1 ul.skeenable 
			this.div = document.createElement('div');
			this.div.className = this.form.form.getAttribute("id") || this.form.form.getAttribute("name") //|| this.form.form.name ne marche pas...; 
			
						
			
			// A SPAN remplace le select  ==> span pour le systeme type btn
			this.a = document.createElement('a');
			this.a.className = this.select.className;
			this.a.href = "javascript:;";
			this.a.style.position = "absolute"; // à passer en CSS ?
			this.span = document.createElement('span');
			this.span.innerHTML = this.defaultText;
			this.a.appendChild(this.span);
			
			// UL LI A remplace les options ==> a pour le :hover pour ie6...
			this.ul = document.createElement('ul');
			//this.ul.style.position = "absolute";
			this.ul.style.visibility = "hidden";
			this.ul.className = this.select.className;
			
			//
			this.lis = [];
			this.as = [];
			for(var i = 0, l=this.opts.length;i<l;i++){
				var li  = document.createElement('li');
				if(i==0) li.className = "first";
				if(i==this.opts.length-1) li.className = "last";
				var a  = document.createElement('a');
				a.href = "#"+this.opts[i].value;
				a.setAttribute('index',i);
				a.innerHTML = this.opts[i].innerHTML;
				if(this.withImg) a.className += " "+this.opts[i].value;
				li.appendChild(a);
				this.lis.push(li);
				this.as.push(a);
				this.ul.appendChild(li);

				a.onclick = function (obj){
					return function (){
						obj.update(this);
						obj.display(false);
						return false;
					}
				}(this);
				
				a.onmouseover = function (obj, index){
					return function (){
						obj.manageFocusOnLiA(index);
						return false;
					}
				}(this, i);
			};
			
			// insert into DOM
			
			if (this.bodyChild){
				this.div.className = this.select.parentNode.className;
				document.body.appendChild(this.div);
				//this.select.parentNode.insertBefore(this.a, this.select);
				this.div.appendChild(this.a);
				this.div.appendChild(this.ul);
				this.a.style.width = this.select.parentNode.offsetWidth - FW(this.a).getIntStyle("padding-left") + 'px'; // hackable en CSS avec un !important
			}
			else if(!this.bodyChild && !this.childOf){
				this.select.parentNode.insertBefore(this.a, this.select);
				this.select.parentNode.insertBefore(this.ul, this.select);
				this.a.style.width = this.select.parentNode.offsetWidth - FW(this.a).getIntStyle("padding-left") + 'px'; // hackable en CSS avec un !important
			}
			else if(this.childOf){
				this.$tmp = document.getElementById(this.childOf.toString());
				this.select.parentNode.insertBefore(this.a, this.select);
				this.div.appendChild(this.ul)
				this.$tmp.appendChild(this.div)
				this.a.style.width = this.select.parentNode.offsetWidth - FW(this.a).getIntStyle("padding-left") + 'px'; // hackable en CSS avec un !important
			}
			if (this.selectSize){
				this.a.style.width = this.select.offsetWidth - FW(this.a).getIntStyle("padding-left") + 'px'; // hackable en CSS avec un !important
			}
		},
		
		giveKeyEvent: function (giveEvent){ // boolean
			var one2select = 0;
			switch(giveEvent){
				case true:
					document.onkeydown = function (obj){
						return function (e){
							if (!e) e = window.event;
							if(e.keyCode == 9){
								if(!e.shiftKey){obj.focusableElms[1].focus();return false;}//tab
								if(e.shiftKey) {obj.focusableElms[0].focus();return false;}//ctrl+tab
							}
							if(e.keyCode == 13) {if(!obj.as[obj.hoveredIndex]) return false;obj.update(obj.as[obj.hoveredIndex]);obj.display(false);return false;} //ENTER
							if(e.keyCode == 40) one2select = 1; //fl bas
							if(e.keyCode == 38) one2select = -1; //fl ht
							if(e.keyCode == 33 || e.keyCode == 36) one2select = -obj.as.length; // debut + pagedown
							if(e.keyCode == 35 || e.keyCode == 34) one2select = obj.as.length;  // fin + pageup
							if(one2select != 0){obj.doFocus(one2select);return false;}
							if(e.keyCode > 64 && e.keyCode < 91){obj.searchLetter(e.keyCode);return false;} // a --> z

						}
					}(this);
			break;
				case false:
					document.onkeydown = null;
					break;
			}
		},
		
		doFocus: function(sens){
			// 
			this.fromKeyboard = true;
			this.selectedIndex += sens;
			if(this.selectedIndex >= this.as.length) this.selectedIndex = this.as.length-1;
			if(this.selectedIndex < 0) this.selectedIndex = 0;
			this.manageFocusOnLiA(this.selectedIndex);
		},
		
		searchLetter: function(key){
			currentKey = String.fromCharCode(key);
			currentKey = currentKey.toLowerCase();
			return;
			var start = this.selectedIndex+1;
			var flag = false;
			for(var i=start,l=this.opts.length;i<l;i++){
				if(this.opts[i].value.toLowerCase().substr(0,1) == currentKey) {
					this.update(this.as[i]);
					flag = true;
					return;
				}
			}
			if(!flag){
				for(var i=start,l=this.opts.length;i<l;i++){
					if(this.opts[i].value.toLowerCase().substr(0,1) == currentKey) {
						this.update(this.as[i]);
						return;
					}
				}
			}
		},
		
		manageFocusOnLiA: function(index){
			if(index == this.hoveredIndex) return;
			if(this.as[this.hoveredIndex]) this.as[this.hoveredIndex].className = this.as[this.hoveredIndex].className.replace(/hover/g, "");
			this.hoveredIndex = index;
			this.as[this.hoveredIndex].className += " hover";
			if(this.fromKeyboard) this.update(this.as[this.selectedIndex]);
			this.a.focus();			
		},
		
		reinit: function(optList){
			//console.log(optList);
			this.form.reinitSelectGroup(this.select.getAttribute('groupName'), this.groupIndex);
			this.oldChange = this.select.onchange;
			this.select.onchange = function(){};
			this.select.innerHTML = "";
			//console.log(optList.push);
			
			if(typeof optList == "string"){
				this.select.innerHTML = optList;
			}
			else{
				var frag = document.createDocumentFragment();
				for(var i=0,l=optList.length;i<l;i++){
					var li = document.createElement("option");
					with(li){
						value = optList[i].value || optList[i][0];
						innerHTML = optList[i].text || optList[i][1];
					}
					frag.appendChild(li)
					
				}
				this.select.appendChild(frag);
			}
			this.select.selectedIndex = 0;
			this.oldIndex = 0;
			this.selectedIndex = 0;
			this.select.setAttribute("disabled", "");
			this.span.innerHTML = this.defaultText;
			this.span.className = this.span.className.replace(/selected/g, '')
			if(this.open) this.fromTheMouse = false;
			this.totalRefresh();
			this.display(false);
			if(typeof this.oldChange== 'function') this.select.onchange = this.oldChange;
			return;
			
			for(var i=0,l=newOpt.length;i<l;i++){
				var opt = createOption(newOpt[i][0],newOpt[i][1], d);
				sel.el.appendChild(opt);
			}
			for(var i=0;i<array.length;i++){
				var s = array[i];
				//console.log(s)
				FW(s).el.innerHTML = "";
				skeenedSelect[s].reinit();
			}
			//console.log('----------------------');
		
			
		},
		
		totalRefresh : function (){
			for(var cn=this.ul.childNodes,i=cn.length-1;i>0;i--){
				cn[i].parentNode.removeChild(cn[i]);
			}
			this.opts = this.select.options;
			//console.log(this.opts);
			this.ul.innerHTML = "";
			//
			this.lis = [];
			this.as = [];
			for(var i = 0, l=this.opts.length;i<l;i++){
				var li  = document.createElement('li');
				if(i==0) li.className = "first";
				if(i==this.opts.length-1) li.className = "last";
				var a  = document.createElement('a');
				a.href = "#"+this.opts[i].value;
				a.setAttribute('index',i);
				a.innerHTML = this.opts[i].innerHTML;
				if(this.withImg) a.className += " "+this.opts[i].value;
				li.appendChild(a);
				this.lis.push(li);
				this.as.push(a);
				this.ul.appendChild(li);

				a.onclick = function (obj){
					return function (){
						obj.update(this);
						obj.display(false);
						return false;
					}
				}(this);
				
				a.onmouseover = function (obj, index){
					return function (){
						obj.manageFocusOnLiA(index);
						return false;
					}
				}(this, i);
			};
		},
		
		clear: function(){
			return;
			this.select.selectedIndex = 0;
			this.selectedIndex = 0;
			this.span.innerHTML = this.defaultText;
			this.span.className = this.span.className.replace(/selected/g, '')
			if(this.open) this.fromTheMouse = false;
			this.totalRefresh();
			this.display(false);
		}
		
	}

/**********************************************************************
	skeenableRadio : 
*/
/** objet d'animaion simple: width height opacity**/
var skeenableRadios = function() { 
	this.initialize.apply(this, arguments);
};

skeenableRadios.prototype = {
		options : {},
		constructor : skeenableRadios,
		
		initialize : function(radios, form) {
			this.elms = radios;
			this.form = form;
			this.objs = [];
			for(var i=0;i<radios.length;i++){
				this.objs.push(new skeenableRadio(radios[i], this, true))
			}
		},
		
		checkAll : function (){
			for(var i=0;i<this.objs.length;i++){
				this.objs[i].checkChecked();
			};
		},
		
		reset : function (){
			for(var i=0;i<this.objs.length;i++){
				this.objs[i].elm.checked = this.objs[i].elm.defaultChecked;
				this.objs[i].checkChecked();
			};
		}
	}


var skeenableRadio = function() { 
	this.initialize.apply(this, arguments);
};
	
	skeenableRadio.prototype = {
		options : {},
		constructor : skeenableRadio,
		
		initialize : function(radio, manager, listener) {
			this.elm = radio;
			this.manager = manager;
			this.ctn = document.createElement('a');
			this.ctn.href = "#";
			this.ctn.className = this.elm.className;
			this.elm.parentNode.insertBefore(this.ctn, this.elm);
			this.checkChecked();
			this.autoFocus = false;
			this.focusableElms = this.manager.form.getFocusable(this.elm);
			// if(listener){
				// setInterval(function(obj){return function(){obj.manager.checkAll()}}(this),1000)
			// }
			
			this.elm.onclick = function (obj){
				return function (){
					obj.manager.checkAll();
					obj.ctn.focus();
				}
			}(this);
			//
			this.elm.onfocus = function (obj){
				return function (){
					obj.ctn.focus();
					obj.autoFocus = false;
				}
			}(this);
			//
			this.ctn.onfocus = function (obj){
				return function (){
					obj.manager.checkAll();
					//obj.manager.form.manageTabKey(true, obj);
				}
			}(this);
			//
			this.ctn.onblur = function (obj){
				return function (){
					//obj.manager.form.manageTabKey(false, obj);
				}
			}(this);
			//
			this.ctn.onclick = function (obj){
				return function (){
					obj.elm.checked = true;
					obj.manager.checkAll();
					return false;
				}
			}(this);
		},
		
		checkChecked : function (){
			this.curStyle = FW(this.ctn).getStyle("background-positionX");
			
			
			if(FW.browser.FF2 || FW.browser.webkit){
			/* bug firefox 2 connu : https://bugzilla.mozilla.org/show_bug.cgi?id=316981 - on en profite pour ajouter le mode a webkit qui ne gerait pas bien non plus les background - */
				if(this.elm.checked) FW(this.ctn).addClass('selected')
				else FW(this.ctn).removeClass('selected')
			}else{	
				if(this.elm.checked) this.ctn.style.backgroundPosition = this.curStyle +" bottom"
				else this.ctn.style.backgroundPosition = this.curStyle + " top";
			}
			
			
		}
		
	}

var skeenableCheckboxes = function() { 
	this.initialize.apply(this, arguments);
};

skeenableCheckboxes.prototype = {
		options : {},
		constructor : skeenableCheckboxes,
		
		initialize : function(checks, form) {
			this.elms = checks;
			this.form = form;
			this.objs = [];
			for(var i=0;i<checks.length;i++){
				this.objs.push(new skeenableCheckbox(checks[i], this, true))
			}
		}
	}


	
var skeenableCheckbox = function() { 
	this.initialize.apply(this, arguments);
};
	
	skeenableCheckbox.prototype = {
		options : {},
		constructor : skeenableCheckbox,
		
		initialize : function(check, form) {
			//log(check)
			this.elm = check;
			this.form = form;
			this.ctn = document.createElement('a');
			this.ctn.href = "#";
			this.ctn.className = this.elm.className;
			this.elm.parentNode.insertBefore(this.ctn, this.elm);
			this.checkChecked();
			setInterval(function(obj){return function(){obj.checkChecked()}}(this),1000)
			//
			this.elm.onclick =  function (obj){
				return function (){
					//this.checked = !this.checked;
					obj.checkChecked();
					//return false;
				}
			}(this);
			//
			this.elm.onfocus = function (obj){
				return function (){
					//obj.ctn.focus();
				}
			}(this);
			//
			this.ctn.onclick = function (obj){
				return function (){
					obj.elm.checked = !obj.elm.checked;
					obj.checkChecked();
					return false;
				}
			}(this);
		},
		
		checkChecked : function (){
			this.curStyle = FW(this.ctn).getStyle("background-positionX");
			
			
			if(FW.browser.gecko || FW.browser.webkit){/* bug firefox 2 connu : https://bugzilla.mozilla.org/show_bug.cgi?id=316981 - on en profite pour ajouter le mode a webkit qui ne gerait pas bien non plus les background - */
				if(this.elm.checked) FW(this.ctn).addClass('selected')
				else FW(this.ctn).removeClass('selected')
			}else{
				if(this.elm.checked) this.ctn.style.backgroundPosition = this.curStyle +" bottom"
				else this.ctn.style.backgroundPosition = this.curStyle + " top";
			}
		},
		
		reset : function (){
			this.elm.checked = this.elm.defaultChecked;
			this.checkChecked();
		}
		
	}

var skeenableInput = function(input, form, simpleBtn) { 
	//return;
	this.elm = input;
	this.originalWidth = this.elm.parentNode.offsetWidth;
	this.form = form;
	this.ctn1 = document.createElement('span');
	this.ctn1.className = this.elm.className;
	// width = input.width - span.padding
	
	this.ctn2 = document.createElement('span');
	this.ctn1.appendChild(this.ctn2);
	this.elm.parentNode.insertBefore(this.ctn1, this.elm);
	this.frag = document.createDocumentFragment();
	this.frag.appendChild(this.elm);
	this.ctn2.appendChild(this.frag);
	if(!simpleBtn){
		this.ctn2.style.width = this.originalWidth - FW(this.ctn1).getIntStyle("padding-left", true) - FW(this.ctn2).getIntStyle("padding-right", true)  + "px";
		if(FW.browser.ie6 && this.originalWidth != 0) this.ctn2.style.width = this.originalWidth  - FW(this.ctn2).getIntStyle("padding-right", true) - 12  + "px";
	}
	if(this.elm.className.match(/labelInside/) ){
		this.label = this.form.getLabel(this.elm);
		if(this.label) {
			this.labelValue = this.elm.value = this.label.innerHTML;
			this.label.innerHTML = "";
			this.label.style.display = "none";
		}
		else if(this.elm.getAttribute('label')){
			this.labelValue = this.elm.value = this.elm.getAttribute('label')
		}
		
	}
	
	// REMOVED
	/*FW(this.elm).addEvent('focus', function(obj, input) {
		return function (){
			if(input.value == obj.labelValue){
				input.value = "";
				obj.elm.className += " filled";
			}
		}}(this, this.elm))
	FW(this.elm).addEvent('blur', function(obj, input) {
		return function (){
			if(input.value == ""){
				input.value = obj.labelValue;
				obj.elm.className = obj.elm.className.replace(/filled/, "");
			}
		}}(this, this.elm))*/
}

// pas trop generique
var incrementialInput = function() { 
	this.initialize.apply(this, arguments);
};
	
	
	incrementialInput.prototype = {
		options : {},
		constructor : incrementialInput,
		
		initialize : function(input, form) {
			this.elm = input;
			this.form = form;
			this.div = document.createElement('div');
			this.div.className = this.elm.className;

			// detect if this is a remove button or if it's a
			// +/- button
			if(this.elm.className.match(/suppressBtn/)) {				
				this.close = document.createElement('a');
				this.close.href = "javascript:;";
				this.close.style.cssFloat = "left";
				
				
				if(this.elm.className.match(/BtnBig/)) {
					this.close.className = this.elm.className.replace("suppressBtn","suppressBtnBig");
					this.div.style.paddingTop="8px";
				} else {
					this.close.className = this.elm.className;
				}
				
				this.div.appendChild(this.close);
				
				var removeFunc = new Function("id", this.elm.getAttribute("onclickremove"));
		
				this.close.onclick = removeFunc;
			} else {
				this.up = document.createElement('a');
				this.up.href = "javascript:;";
				this.up.style.cssFloat = "left";
				
				this.up.className = "incrementBtn "+this.elm.className;
				
				this.down = document.createElement('a');
				this.down.href = "javascript:;";
				
				if(this.elm.className.match(/BtnBig/)) {
					this.down.className = "decrementBtnBig "+this.elm.className;
				} else {
					this.down.className = "decrementBtn "+this.elm.className;
				}
				
				this.down.style.cssFloat = "left";
				this.div.appendChild(this.up);
				this.div.appendChild(this.down);
				
				var upFunc = new Function("id", this.elm.getAttribute("onclickup"));
				var downFunc = new Function("id", this.elm.getAttribute("onclickdown"));

				this.up.onclick = upFunc;
				this.down.onclick = downFunc;
			}
			
			this.elm.parentNode.insertBefore(this.div, this.elm);
		}
	}

/* ********************************************************************************** */
var $layer = {
	options : {
		id : 'insidePopup',
		templateHTML : [
			'<span class="layerTopCorners"><span></span></span>',
				'<div class="insidePopupContent">',
					'<a href="#" class="close popupCloseButton">__CLOSINGWORDING__</a>',
					'<div>',
						'__CONTENT__',
					'</div>',
				'</div>',
			'<span class="layerBottomCorners"><span></span></span>'
		].join(''),
		styles : {
			width: '700px'
		},
		position: 'center', // pour l'instant il ne prend que center et sera developpe plus tard pour prendre les valeurs left/right/center et top/bottom/center avec les combo 'left top', 'right top' etc, etc 
		mask : false, //mask sous le  layer
		maskPosition : null, // element HTML sur lequel le mask s'appliquera, si null, le parent le plus haut sera pris (<body>)
		maskClickClose : true, // click sur le mask ferme le layer
		content : '', //code HTML pour remplir le layer,
		contentFrom : null, //element contenant du code HTML pour l'afficher dedans
		elmToShow: null, // add by tibo, permet d'afficher une div presente dans la page 
		parent : null, //le parent du layer, par defaut c'est document.body
		fixLayerOnParent : false, // si on veut placer le layer au dessus d'un element, on peut specifier si on met le position:relative ou pas
		className : "", //une classe CSS posee sur la popup afin de customiser la popup si necessaire
		timerInterval : 100,
		offsetTop : 10,
		offsetLeft : 10,
		closingWording : ''
		
	},
	currentOptions : {},
	resetOptions : function() {this.currentOptions = {}; $extend(this.currentOptions, this.options);},	
	lastPositions : {},
	open : function(options) {
		var _self = this;
		var frag;
		this.close();
		this.resetOptions();
		if (options.styles && options.styles.opacity!=null) options.styles.filter = 'alpha(opacity='+options.styles.opacity*100+')'; // compatible IE
		if (options.contentFrom!=null) {
			options.contentFrom = FW(options.contentFrom).el;
			options.content = options.contentFrom.innerHTML
		}
		// add by tibo
		if (options.elmToShow!=null) {
			options.content = "";
			this.currentElmId = options.elmToShow;
		}
		//
		if (this.currentOptions.over) this.currentOptions.over = FW(this.currentOptions.over).el;
		for (var i in options) {
			if (i!='styles') this.currentOptions[i] = options[i];
		}
		if (options.styles)
			for (var i in options.styles) {
				this.currentOptions.styles[i] = options.styles[i];
			}
		
		this.options.lastScrollTop = this.options.offsetTop;
		this.options.lastScrollLeft = this.options.offsetLeft;
		
		if (!FW(this.currentOptions.id).el)  this.createLayer();
		if (this.currentOptions.mask)  this.createMask();
		// add by tibo
		this.layer.innerHTML = this.layer.innerHTML.replace(/__CONTENT__/g, this.currentOptions.content).replace(/__CLOSINGWORDING__/, this.currentOptions.closingWording);
		if(this.currentOptions.elmToShow) {
			//FW(this.currentOptions.elmToShow).addClass('layered');
			FW(this.currentOptions.elmToShow).el.style.display = "block";
		}
		//
		//this.layer.innerHTML = this.layer.innerHTML.replace(/__CONTENT__/g, this.currentOptions.content).replace(/__CLOSINGWORDING__/, this.currentOptions.closingWording);
		this.correctIE(this.layer);
		this.initActionsButtonsOnLayer();
		
		this.layer.style.width = this.layer.clientWidth - FW(this.layer).getHStyle() + 'px';
		this.setSize();
		this.setPosition();
		this.timerRefresh = setInterval(function() {
			_self.refreshSizeAndPosition()
		},this.options.timerInterval)
		this.lastPositions = {
			scrollLeft : document.documentElement.scrollLeft,
			scrollTop : document.documentElement.scrollTop
		}
		this.refreshSizeAndPosition();
		this.layer.style.visibility = 'visible';
		
		
	},
	close : function() {
		if (this.timerRefresh) clearInterval(this.timerRefresh);
		var elmW = FW(this.currentOptions.id);
		if (elmW.el) {
			elmW.el.parentNode.removeChild(elmW.el);
		}
		if (this.currentOptions.parent) 
			this.currentOptions.parent.style.height  = '';
		if (this.mask){
			if (this.mask.$layerIframe) 
				this.mask.$layerIframe.parentNode.removeChild(this.mask.$layerIframe);
			this.mask.parentNode.removeChild(this.mask);
		}
		try {
			delete this.layer;
			delete this.content;
			delete this.mask;
		} catch(e) {}
		if (typeof window.CollectGarbage == 'function') {
		  CollectGarbage();
		}
		if(this.currentElmId){
			FW(this.currentElmId).el.style.display = "none";
			FW(this.currentElmId).removeClass('layered');
			this.currentElmId = null;
		}
	},
	createLayer : function() {
		var layer = document.createElement('div');
		layer.className += ' '+this.currentOptions.className || "";
		layer.id = this.currentOptions.id;
		$extend(layer.style, this.currentOptions.styles);
		$extend(layer.style, {left:0, top:0, display:'block', visibility:'hidden'});
		layer.innerHTML = this.currentOptions.templateHTML;
		if (this.currentOptions.over) {
			(this.currentOptions.parent || document.body).appendChild(layer);
			if (this.currentOptions.fixLayerOnParent) {
				this.currentOptions.parent.style.position = 'relative';
			} else 
				this.currentOptions.position = 'byElement';
		} else 
			document.body.appendChild(layer);
		this.layer = layer;
		FW(this.layer).addEvent('click', function(e) {FW.event.stop(e);});
		this.layerContent = FW(layer).getElement({nodeName:'div', className:'insidePopupContent'}).el;
		return this.layer;
	},
	createMask : function() {
		var mask  = document.createElement('div');
		this.mask = mask;
		mask.id = 'insidePopupMask';
		this.correctIE(mask);
		
		document.body.appendChild(mask);
		if (this.currentOptions.maskClickClose) {
			FW(mask).addEvent('click', function(e) {
				FW.event.stop(e);
				$layer.close();
			})
		}
	},
	setPosition : function() {
		var styles = {};
		var currStyles = this.currentOptions.styles;
		switch(this.currentOptions.position) {
			case 'center' : 
				var parentToUse = window.opera ? document.body : document.documentElement;
				var top = (parentToUse.clientHeight-this.layer.offsetHeight)/2+document.documentElement.scrollTop;
				var left = (parentToUse.clientWidth-this.layer.offsetWidth)/2+document.documentElement.scrollLeft;
				//opera.postError(top+','+left);
				if (this.layer.offsetHeight>parentToUse.clientHeight)
					top = (this.lastPositions.scrollTop || 0) + this.options.offsetTop;
				else 
					this.lastPositions.scrollTop = document.documentElement.scrollTop;
				if (this.layer.offsetWidth>parentToUse.clientWidth)
					left = (this.lastPositions.scrollLeft || 0) + this.options.offsetLeft;
				else 
					this.lastPositions.scrollLeft = document.documentElement.scrollLeft
				styles = {
					left : left+'px',
					top : top+'px'
				};
				break;
			case 'user' :
				styles = {
					left : currStyles.left,
					top : currStyles.top
				}
				break;
			case 'byElement' : 
				var pos = FW(this.currentOptions.over).getPosition();
				styles = {
					left : pos.x + 'px',
					top : pos.y + 'px'
				};
				break;
			default : 
				break;
		}
		$extend(this.layer.style, styles);
	},
	setSize : function() {
		if (!isNaN(parseInt(this.currentOptions.styles.height))) {
			this.layer.style.height = 'auto';
			var inside = FW(this.layer).getElement({nodeName:'div', className:'insidePopupContent'}).el;
			if (this.currentOptions.parent && inside && FW(inside).getStyle('position')!='absolute' && inside.offsetHeight > this.currentOptions.parent.offsetHeight) {
				this.currentOptions.parent.style.height = this.layer.offsetHeight+'px';
			} 
			if (this.layer.offsetHeight<parseInt(this.currentOptions.styles.height))
				this.layer.style.height = parseInt(this.currentOptions.styles.height)-FW(this.layer).getVStyle(this.layer)+'px';
		}
	},
	refreshSizeAndPosition : function() {
		var parentToUse = window.opera ? document.body : document.documentElement;
		if (
			(this.mask && this.mask.offsetHeight<this.layer.offsetHeight) ||
			this.lastPositions.layerHeight != this.layer.offsetHeight || 
			this.lastPositions.width != parentToUse.clientWidth ||  
			this.lastPositions.height != parentToUse.clientHeight || 
			this.lastPositions.scrollLeft != document.documentElement.scrollLeft || 
			this.lastPositions.scrollTop != document.documentElement.scrollTop
		) {
			this.setPosition();
			if (this.mask && (this.lastPositions.width != document.documentElement.clientWidth || this.lastPositions.height != document.documentElement.clientHeight)) {
				var height =(document.body.clientHeight < document.documentElement.clientHeight ? 
								document.documentElement.clientHeight : 
									(document.body.scrollHeight>document.documentElement.scrollHeight ? 
										document.body.scrollHeight : document.documentElement.scrollHeight
									)
							)
				if(!height) height = document.documentElement.scrollHeight;
				$extend(this.mask.style, {
					height : height+'px',
					width : document.documentElement.scrollWidth > document.documentElement.clientWidth ? document.documentElement.scrollWidth+'px' : "100%"
				});
			}	
			this.lastPositions.layerHeight = this.layer.offsetHeight;
			this.lastPositions.width = parentToUse.clientWidth;
			this.lastPositions.height = parentToUse.clientHeight;
			
			this.correctIE(this.layer);
			this.correctIE(this.mask);
			
		}
	},
	initActionsButtonsOnLayer : function() {
		var closeButtons = FW(this.layer).getElements({className:'(close|insidePopupCloseButton)'});
		if(this.currentElmId) {
			closeButtons = FW(this.currentElmId).getElements({className:'(close|insidePopupCloseButton)'});
		}
		closeButtons.each(function(btn) {
			btn.onclick = function() {
				$layer.close();
				return false;
			}
		})
	},
	correctIE : function(element) {
		if(!element) return;
		if (!element.$layerIframe && FW.browser.ie6) {
			var ifr = document.createElement('<iframe style="filter:alpha(opacity=0);width:100%;height:100%;position:absolute;top:0;left:0;z-index:-1;">');
			element.$layerIframe = (this.options.maskClickClose && element==this.mask ? document.body : element).appendChild(ifr);
			if (element==this.mask)
				element.$layerIframe.style.zIndex = 1;
		}
		if (element.$layerIframe)
			element.$layerIframe.style.height = element.offsetHeight+'px';
	

	}
}

var layerMod = {
	options:{
		template : '',
		content : '',
		width : '500px',
		over:null
	},
	xmlUrl: 'popups.xml',
	xmlObject: null,
	
	checkXML: function(callback){
		var xmlObj = layerMod.xmlObject;
		if (xmlObj){
			callback(xmlObj);
		}else{
			new Ajax({
				url : 'popups.xml',
				onSuccess : function(xhr) {
					//alert(XMLF.xml2obj(xhr.responseXML));
					var xmlObj = layerMod.xmlObject = XMLF.xml2obj(xhr.responseXML);
					callback(xmlObj);
				}
			}).send();
		}
	},
	
	openLayer: function(options){
		if (!XMLF) return;
		if (options){
			layerMod.options.template = options.template?options.template:'';
			layerMod.options.content = options.content?options.content:'';
			layerMod.options.width = options.width?options.width:layerMod.options.width;
			if(options.over){
				layerMod.options.over = options.over;
				layerMod.options.position = 'byElement';
			}
		}
		this.checkXML(function(xmlObj) {
			var options = {
				templateHTML: xmlObj.templates.structures[layerMod.options.template],
				content : xmlObj.templates.contents[layerMod.options.content],
				mask:true,
				styles : {
					width: layerMod.options.width
				}
			};
			if(layerMod.options.over){
				options.over = layerMod.options.over;
				options.position = 'byElement';
			}
			$layer.open(options);
			var pop = FW('insidePopup');
			if(pop.el != null) pop.addClass('forceDisplayTabs');
			FW.initializer.launch(pop.el);
			if(pop.el != null) pop.removeClass('forceDisplayTabs');

		})
	}
	
}

var layerMod2 = {
	openLayer: function(id){
		var options = {
			elmToShow: id,
			mask:true,
			maskClickClose : true,
			templateHTML : "<div>__CONTENT__</div>"
				
		};
		var pop = FW(id);
		$layer.open(options);
		pop.removeClass('forceDisplayTabs');
		}
}


/* FW(window).addEvent('load',function(){
	layerMod.openLayer({template:'tabsLayer',content:'tabsContent',width:'770px'});
});
 */
 

 var cartManager = { 
		initialize : function(elm) {
			this.btn = elm;
			this.cart = FW("myCart").el;
			this.close  = FW("cartClose").el;
			FW(this.btn).addEvent("click", function(obj){
				return function (){
					obj.display(!obj.open);
					return false;
				}
			}(this))
			FW(this.close).addEvent("click", function(obj){
				return function (){
					obj.display(false);
					if(obj.cart.className.match(/layered/)) $layer.close();
					return false;
				}
			}(this))
		},
		
		display: function (open){
			this.cart.style.display = "";
			this.positionate();
			if(open){
				this.btn.className += " current";
				this.cart.className += " layered";
				this.cart.className = this.cart.className.replace(/hidden/g, "");
				this.open = true;
			}
			else {
				this.cart.className += " hidden";
				this.cart.className = this.btn.className.replace(/layered/g, "");
				this.btn.className = this.btn.className.replace(/current/g, "");
				this.open = false;
			
			}
		},
		
		positionate : function (){
			var coo = FW("openCart").getPosition();
			this.cart.style.left = coo.x - 194 + "px"
			this.cart.style.top = coo.y + 33 + "px"
		},
		
		refreshBasket : function (input, nbItems){
			var paymentPage = false;
			this.input = input;
			this.nbItems = nbItems;
			
			if(FW("paymentForm").el == null){
				paymentPage = false;
				this.td = this.input.parentNode.parentNode.parentNode.parentNode;
			}else{
				paymentPage = true;
				this.td = this.input.parentNode.parentNode.parentNode;
			}
			this.prixUnitaire = this.td.getAttribute("pu");
			this.texteARemplacer = this.td.getElementsByTagName("td")[2];
			this.nouvelleValeur = this.prixUnitaire * this.nbItems;
			this.nouvelleValeur = parseFloat(this.nouvelleValeur);
			
			if(paymentPage){
				this.nouvelleValeur = this.formatPrix(this.nouvelleValeur, true);
			}else{
				this.nouvelleValeur = this.formatPrix(this.nouvelleValeur, false);
			}
			
			this.texteARemplacer.innerHTML = this.nouvelleValeur;
		},
		
		calculateTotal : function (){
			var paymentPage = false;
			this.total = 0;
			
			if(FW("paymentForm").el == null){
				this.trs = FW("rightCol").getElements("tr");
				paymentPage = false;
			}else{
				this.trs = FW("paymentForm").getElements("tr");
				paymentPage = true;
			}
			for(var i=0, lenTrs = this.trs.length; i < lenTrs; i++){
				if(this.trs[i].getAttribute("pu")){					
					this.valueToFloat = this.trs[i].getElementsByTagName("td")[2].innerHTML;
					if(paymentPage){
						this.valueToFloat = this.valueToFloat.replace(/<\/?[^>]+>/gi, '');
					}
					this.valueToFloat = this.valueToFloat.replace(/,/g,"\.");
					this.total += parseFloat(this.valueToFloat);
				}
			}
			
			this.total = this.formatPrix(this.total, false);			
			if(paymentPage){
				this.tdResult = FW("paymentForm").getElements("tfoot");
			}else{
				this.tdResult = FW("rightCol").getElements("tfoot");
			}
			
			this.tdResult = this.tdResult[0].getElementsByTagName("td")[1];
			//log(this.tdResult.innerHTML = this.total);
			this.tdResult.innerHTML = this.total;
		},
		
		formatPrix: function(valeur, paymentPage){
			var isChiffre;
			var hasVirgule;
			
			valeur = valeur.toString();
			valeur = valeur.replace(/\./g,",");
			
			isChiffre = valeur.split(",")[0];
			if(isChiffre != undefined){			
				if(isChiffre.length == 1){
					valeur = "0"+valeur;
				}
			}
			
			hasVirgule = valeur.split(",")[1];
			if(hasVirgule != undefined){
				if(hasVirgule.length == 1){
					valeur += "0";
				}
			}else{
				valeur += ",00";
			}
			
			if(paymentPage){
				valeur = "<span>" + valeur.split(",")[0]+ "</span>," +valeur.split(",")[1] ;
			}
			
			valeur += "&euro;";
			return valeur;
		},
		
		removeItem: function (elm){
			var tr = this.getTr(elm);
			//log(tr.nextSibling)
			if(tr.className.match(/gradientLineTable/)){
				var next  = tr.nextSibling && tr.nextSibling.nodeType == 3 ? tr.nextSibling.nextSibling : tr.nextSibling;
				if(next) next.className += " gradientLineTable"; 
			
			}
			tr.parentNode.removeChild(tr);
			this.calculateTotal();
		},
		
		getTr: function(elm){
			return elm.parentNode.nodeName == "TR" ? elm.parentNode : this.getTr(elm.parentNode);
		}
		
	}

function layerShortCut(num){
	layerMod2.openLayer('layerHomeCtn');
	var tabs = FW("layerHomeCtn").getElement({nodeName:'ul', className:'tabs'}).getElements('li');
	var tabsContent = FW("layerHomeCtn").getElement({nodeName:'div', className:'body'}).getChildsNodes({nodeName:'div', className:'tabCtn'});
	tabs.each(function(tab, index) {FW(tab).removeClass('current');});
	tabsContent.each(function(tab, index) {FW(tab).removeClass('tabCurrent');});
	FW(tabs[num]).addClass('current');
	FW(tabsContent[num]).addClass('tabCurrent');
	return false;
}


