var IS_IE = document.all && window.print && !window.opera && ( !document.compatMode || /MSIE [56]/.test(navigator.userAgent) || (document.compatMode && document.compatMode=="BackCompat"));
var IE_NG = document.all && window.print && !window.opera && /MSIE [7-9]/.test(navigator.userAgent) && document.compatMode && document.compatMode!="BackCompat"; //variable pour IE7 et + si besoin.
var IS_quirks = IS_IE && document.compatMode && document.compatMode=="BackCompat"; // variable qui declare le quirksmode seulement utile pour IE
var IS_Webkit = /Konqueror|Safari|KHTML/.test(navigator.userAgent);
var IS_FF = /Firefox/.test(navigator.userAgent);
var IS_MS = /MSIE /.test(navigator.userAgent);
var heightPropertyToUse = IS_IE ? "height" : "minHeight"; //variable utilisee pour l'alignement en hauteur des elements.
var TrDisplayPropertyToUse =  IS_MS ? "block" : "table-row";  // utilisée pour le toggle des trs d'un table.
document.documentElement.className =" hasJS";
document.documentElement.className+= IS_IE ? " IS_IE" : "";


log = function (txt){ 
	if(window.console && IS_FF) console.log(txt);
}

/**
REMPLACE UN SELECT OPTION PAR UN UL LI A + un input hidden inclus dans une DIV
le UL gere l'aspect graphique du select
l'INPUT l'aspect formulaire
LA DIV RECUPERE LES CLASSES DU SELECT,
UTILES POUR SKINNER LE RESULTAT DU CHANGEMENT
TOUT L'ASPECT GRAPHIQUE EST GERE  VIA CSS
*/

var select2Skin = {
	init : function (){
		var sels = document.getElementsByTagName('select');
		this.selectObj = [];
		for(var www = sels.length-1; www >=  0; www--){
			if(sels[www] && sels[www].className.match(/\bskinableSelect\b/)) {
				var a = new skinableSelect(sels[www]);
				this.selectObj.push(a);
			}
		}
		
	},
	
	closeAll : function (obj){
		for(var i=0; i<this.selectObj.length;i++){
			if(obj != this.selectObj[i]) this.selectObj[i].displayOptions(false);
		}
	},
	
	reinit : function (){
		for(var i=0; i<this.selectObj.length;i++){
			this.selectObj[i].reinit();
		}
	}
}
var skinableSelect = function (elm){
	// check	
	if(elm.nodeName != "SELECT") return;
	
	//
	$('search_box').addEvent('click', function (){
		select2Skin.closeAll();
	})
	
	
	// set
	this.open = false; // ul masqué par défaut
	this.above = elm.className.match(/skinableSelect_top/) ? true : false;
	this.comeFromTheClick = false;
	this.maxSize = 150;

	// recupere le label associe	
	this.lab= this.getLabel(elm);
	this.lab.style.display = "none";
	this.headText = this.lab.innerHTML;

	// recupere les options du select
	this.opts = elm.getElementsByTagName('option');
	
	// INPUT HIDDEN ==> pour compenser de façon transparente la perte du select
	this.input = document.createElement('input');
	this.input.name = elm.name;
	this.input.value = "";
	this.input.type = 'hidden';
	elm.parentNode.appendChild(this.input);
	
	// modification et masquage su select d'origine
	elm.name = "old_"+elm.name;
	elm.disabled = "disabled";
	elm.style.visibility = "hidden"; 
	
	// A SPAN remplacant le select  ==> select pour regler la largeur
	this.a = document.createElement('a');
	this.a.className = elm.className;
	this.a.id = elm.id;
	this.a.href = "javascript:;";
	this.span = document.createElement('span');
	this.span.innerHTML = this.headText;
	this.a.appendChild(this.span);

	$(this.a).addEvent("click", function (obj){
		return function (e){
			(new Event(e)).stop();
			select2Skin.closeAll(obj);
			obj.displayOptions(!obj.open);
			if(!obj.initialized) 
			obj.fixPosition();
			skinableSelect.ZINDEX++;
			obj.ul.style.zIndex = skinableSelect.ZINDEX;
			return false;
		}
	}(this));
	
	this.a.onfocus = function (obj){
		return function (){
			obj.currentFocus = -1;
			obj.manageKeyboardEvent(obj, true);
			if(obj.comeFromTheClick) obj.manageKeyboardEvent(obj, false);
			return false;
		}
	}(this);
	
	
	// UL 
	this.ul = document.createElement('ul');
	this.ul.style.position = "relative";
	
	this.ul.className = elm.className;
	this.ul.style.zIndex =  skinableSelect.ZINDEX || "10000000";
	
	
	// LI A
	this.lis = [];
	this.as = [];
	
	
	
	for(var j = 0; j<this.opts.length; j++){
		var li  = document.createElement('li');
		var a  = document.createElement('a');
		a.href = "#"+this.opts[j].value;
		if(a.href == "#") a.href = this.opts[j].innerHTML;
		a.setAttribute('index',j);
		a.innerHTML = this.opts[j].innerHTML;

		a.onclick = function (obj){
			return function (){
				obj.update(this);
				obj.displayOptions(false);
				obj.a.focus();	
				
				return false;
			}
		}(this);
		a.onfocus = function (obj){
			return function (){
				obj.update(this);
			}
		}(this);
		li.appendChild(a);
		this.lis.push(li);
		this.as.push(a);
		this.ul.appendChild(li);
	};
	
	// insertion
	elm.parentNode.insertBefore(this.a, elm);
	elm.parentNode.replaceChild(this.ul, elm);
	this.ul.onblur = function (obj){
		return function (){
			obj.displayOptions(false);
			return false;
		}
	}(this);
												//elm.parentNode.replaceChild(this.a, elm);
												//$('reservation').appendChild(this.ul);
	
	//
	
	this.ul.style.display = "none";
}

// MAJ des champs au select
skinableSelect.prototype.update = function (a){
	this.span.innerHTML = a.innerHTML.length > 15 ? a.innerHTML.slice(0,15)+"..." : a.innerHTML;
	//this.fixSpan();
	this.span.className += " selected";
	this.input.value =  a.href.match(/Tout/) ? "" : a.href.substring(a.href.indexOf('#')+1);
	if(this.open) this.comeFromTheClick = true;
}

// harmonisation des largeurs
skinableSelect.prototype.fixWidth = function (el){
	el.style.whiteSpace = "nowrap";
	var bL = getCSSRule(el, "borderLeftWidth", true);
	var bR = getCSSRule(el, "borderRightWidth", true);
	this.aWidth = el.offsetWidth - bL - bR;
	el.style.whiteSpace = "normal";
	this.maxWidth = this.aWidth;
	for(var i = 0; i<this.lis.length; i++){
		if(this.as[i].offsetWidth > this.maxWidth) this.maxWidth = this.as[i].offsetWidth;
	}
	
	
	if(this.aWidth < this.maxWidth) {
		this.ul.style.width = this.maxWidth + "px";
		this.span.style.paddingRight = this.maxWidth - this.aWidth  + bL + bR + "px";
		this.initPad = getCSSRule(this.span, 'paddingRight', true);
	}
	else if (this.aWidth > this.maxWidth){
		this.ul.style.width = this.maxWidth + bL + bR + "px";
	}
	else {
		this.ul.style.width = this.maxWidth - bL - bR + "px";
	}
	
	this.ul.style.position = "absolute";

	
}
skinableSelect.prototype.fixSpan = function (el){
	if(this.a.offsetWidth < this.maxWidth) {
		this.span.style.paddingRight = this.maxWidth - this.a.offsetWidth  + "px";
	}
	
	else if (this.a.offsetWidth - getCSSRule(this.a, "borderLeftWidth", true) - getCSSRule(this.a, "borderRightWidth", true) > this.maxWidth){
		this.span.style.paddingRight = "662px";
	}
	else {
		this.span.style.paddingRight = "";	
	}

}

// des hauteurs
skinableSelect.prototype.fixHeight = function (ul){
	//alert((ul.offsetHeight));
	//alert()
	if(ul.scrollHeight > this.maxSize) {
		ul.style.height = this.maxSize + "px";
	}
	
} 


skinableSelect.prototype.fixPosition = function (){
	// fixPosition

	
	
	
	this.ul.style.left = this.a.offsetLeft - getCSSRule(this.a, "borderLeftWidth", true) - getCSSRule(this.a, "borderRightWidth", true) + "px";
	if (IS_MS) {
		this.ul.style.marginTop = this.a.offsetHeight - getCSSRule(this.a, "borderTopWidth", true) + "px";
	}
	if(this.above) this.ul.style.marginTop = - ( this.ul.offsetHeight + this.a.offsetHeight - getCSSRule(this.a, "borderTopWidth", true)) + 1 + "px";
	this.initialized = true;
	return;
	
}

// gestion de l'evtListener sur les touches fleches haut et bas
skinableSelect.prototype.manageKeyboardEvent = function(obj, giveEvent){
	switch(giveEvent){
		case true:
			document.onkeydown = function (e){
				if (!e) e = window.event;

				if(e.keyCode == 40) {obj.manageFocus(1);return false;} //fl bas
				if(e.keyCode == 35 || e.keyCode == 34) {sens = this.above ? -obj.as.length : obj.as.length; obj.manageFocus(sens);return false;} //fl bas
				
				if(e.keyCode == 38) {obj.manageFocus(-1);return false;} //fl haut
				if(e.keyCode == 33 || e.keyCode == 36) {sens = this.above ? obj.as.length : -obj.as.length; obj.manageFocus(sens);return false;} //fl haut
				
			};
			break;
		case false:
			document.onkeydown = null;
			break;
	}
}

// gestion de l'evt des touches pour gerer le deplacement du focus à l'interieur du ul 
skinableSelect.prototype.manageFocus = function (sens){
	this.currentFocus += sens;
	if(this.currentFocus >= this.as.length) this.currentFocus = this.as.length-1;
	if(this.currentFocus < 0) this.currentFocus = 0;
	if(this.open){
		if(this.as[this.currentFocus]) this.as[this.currentFocus].focus();
	}
	else {
		this.update(this.as[this.currentFocus]);
		this.comeFromTheClick = false;		
	}
};

// affiche / masque les lis du ul (sauf le 1er)
skinableSelect.prototype.displayOptions = function (willBeVisible){
	this.ul.style.display = willBeVisible ? "block" : "none";
	this.fixWidth(this.a);
	this.fixHeight(this.ul);
	this.manageKeyboardEvent(this, willBeVisible);
	if(willBeVisible) {
		this.span.innerHTML = this.headText;
		this.span.className = this.span.className.replace(/selected/g, "");
		this.input.value = "";
		this.ul.className += " open";
	}
	else {
		this.ul.className = this.ul.className.replace(/open/g, "");
	}
	this.open = willBeVisible;
};
 // fermer par defaut


skinableSelect.prototype.getLabel = function(field) {
	var labs = document.getElementsByTagName('label');
	for(var i = 0; i < labs.length; i++){
		var theFor = labs[i].getAttribute('for') || labs[i].getAttribute('htmlFor');
		if(theFor == field.id) {
			return labs[i];
		}
	}
} 

skinableSelect.prototype.reinit = function() {
	this.span.innerHTML = this.headText;
	this.span.className = this.span.className.replace(/selected/g, '')
	this.input.value =  "";
	if(this.open) this.comeFromTheClick = false;
}


/**
* gere le formulaire de recherche + les differents btns de la page
**/

var searcher = {
	init : function (){
		this.colBtns = $$('#search_color a');
		searcher.currentColor = this.colBtns[0];
		this.inputs = document.getElementById('gallery').getElementsByTagName('input');
		this.colBtns.each(function (el){
			el.onclick = function (){
				searcher.MAJcolor(this);
				return false;
			}
			el.onmouseover = function (){
				$('color_txt').innerHTML = this.innerHTML;
				return false;
			}
			el.onmouseout = function (){
				searcher.MAJcolor(searcher.currentColor);
				return false;
			}
		});
		$('randomize').onclick = function (){
			searcher.alreadyLaunch=false;
			searcher.request('');
			select2Skin.reinit();
			searcher.MAJcolor(searcher.colBtns[0])
		}
		/* $('latest').onclick = function (){
			searcher.alreadyLaunch=false;
			searcher.request('');
			select2Skin.reinit();
			searcher.MAJcolor(searcher.colBtns[0])
		} */
		$('accept').onclick = function (){
			if($('acceptBox').checked !=  true) {
				$('accept').parentNode.className += " wrong"
			} else {
				$('TC').style.display = "none";
				layer.fx2.start({'opacity': 0});
				createCookie("TC", 1, 365);
				
			}
		}
		this.ctn = $('photos');
		this.ctnTof = $$('#photos div.tof')[0];
		this.submit = $('search_submit');
		this.alreadyLaunch = false;
		this.submit.onclick = function (){
			var paramUrl = searcher.buildString();
			//paramUrl = ""//hairdresser=Contempory%20North%20East";
			searcher.request(paramUrl);
			return false;
		}
		this.request('');
		this.fx1 = new Fx.Morph($('scrollUp') ,  {duration: 'short'});
		this.fx2 = new Fx.Morph($('scrollDn') ,  {duration: 'short'});
		/*$('LPCollec').addEvent("click", function (){
			searcher.request('SalonName=1')
		})
		*/
		// Code pour afficher la derniere collection l'oreal gace au bouton. View Latest Collection (mika)
		$('latest').addEvent("click", function (){
			searcher.request('CollectionName=5')
		})
		this.ctn.addEvent("mouseenter", function (){
			//alert(searcher.lockedScroll)
			if(searcher.lockedScroll) return;
			searcher.fx1.start({'opacity': 1});
			searcher.fx2.start({'opacity': 1});
		})
		this.ctn.addEvent("mouseleave", function (){
			searcher.fx1.start({'opacity': 0, "zIndex": 9});
			searcher.fx2.start({'opacity': 0, "zIndex": 9});
		})
		searcher.lockedScroll = true;
		searcher.fx1.start({'opacity': 0, "zIndex": 9});
		searcher.fx2.start({'opacity': 0, "zIndex": 9});
		$('Colour').value = "";
	},
		
	request : function (paramUrl,event){
		this.myXHR = new Request({method: 'get', url: this.submit.href , onSuccess: function(){
			searcher.parseJSON(this.response.text);
		}}).send(paramUrl);
	},
	
	
	buildString : function (){
		this.qs = "";
		for(var i = 0; i < this.inputs.length; i++){
			this.qs += this.inputs[i].name + "=" + encodeURI(this.inputs[i].value) + "&";
		}
		return this.qs;
	},
	
	MAJcolor : function (a){
		this.colBtns.each(function (el){
			el.removeClass('selected');
		})
		$(a).addClass('selected');
		//alert(a.innerHTML)
		$('Colour').value = a.name == "Tout" ? "" : a.name;
		$('color_txt').innerHTML = a.innerHTML;
		searcher.currentColor = $(a);
	},
	
	scroll : function (sens){
		this.ctnTof.scrollTop = this.ctnTof.scrollTop + (77*sens);
	},
	
	parseJSON : function (json){
		json = json.replace(/:'/g, ':"' );
		json = json.replace(/(\r\n|\n|\r)',/g, '",' );
		json = json.replace(/',/g, '",' );
		//json = json.replace(/<BR>/g, ' ' );
		json = json.replace(/'}/g, '"}' );
		json = json.replace(/&/g, '&amp;' );
		if(!json.match(/urlSmall/)) { if(this.loader && this.loader.kill) this.loader.kill(this.loader); this.ctnTof.innerHTML = "<h2>D&eacute;sol&eacute;, il n'y a aucun r&eacute;sultat correspondant &agrave; vos crit&egrave;res de recherche. Veuillez modifier votre recherche.</h2>"; return;}
		//console.log(json);
		this.items = JSON.decode(json);
		//alert(this.items)
		this.items.pop();
		this.imgs = [];
		this.as = [];
		// 1st run
		if(!this.alreadyLaunch) {
			var random;
			for(var i=0, L = this.items.length-45; i< L; i++){
				if(this.items[i]) this.items[i].random = parseInt(Math.random()*1000);
				random = parseInt(Math.random()*searcher.items.length);
				searcher.items.splice(random, 1);
			}
			searcher.items.sort(function(a, b){return (a.random>b.random) ? 1 : -1;})
			this.alreadyLaunch = true;
		}
		this.ctnTof.scrollTop = this.ctnTof.scrollTop - this.ctnTof.scrollTop;
		this.ctnTof.innerHTML = "";
		this.items.each(function(elm, i){
			searcher.imgs.push("img/"+elm.urlSmall);
			if(i==0) var div = new Element('div', {'class':"itemPhoto loading"});
			else var div = new Element('div', {'class':"itemPhoto loading hidden"});
			var a = new Element('a', {'href':"#", "index":i});
			var img = new Element('img', {'src':'trans.gif', 'width':'74', 'height':'74' });
			div.appendChild(a);
			a.appendChild(img);
			a.onclick = function (){searcher.open(this)};
			searcher.as.push(img);
			searcher.ctnTof.appendChild(div);
		});
		if(this.loader) this.loader.kill(this.loader);
		this.loader = new preLoader(searcher.imgs, searcher.build, true, false);
	}, 
	
	build : function (img, wasCached, index, getError){
		if(getError){
		}
		else{
			if(searcher.as[index+1]) searcher.as[index+1].parentNode.parentNode.className = searcher.as[index+1].parentNode.parentNode.className.replace(/hidden/, "");
			searcher.as[index].src = img.src;
			//alert(searcher.as[index]);
		}
		if(index <= 44) searcher.lockedScroll = true;
		else {
			searcher.lockedScroll = false;
			searcher.fx1.start({'opacity': 1});
			searcher.fx2.start({'opacity': 1});
		}
	},
	
	open : function (a){
		var i = a.getAttribute('index');
		layer.show(i);
	}
}


/**
* gere le layer
**/
var layer = {
	init: function (index){
		this.fx1 = new Fx.Morph($('layer') ,  {duration: 'short'});
		this.fx2 = new Fx.Morph($('voile') ,  {duration: 'short'});
		this.fx3 = new Fx.Morph($('TC') ,  {duration: 'short'});
		//this.fx4 = new Fx.Morph($('howToSubmit') ,  {duration: 'short'});
		if(readCookie('TC') == 1){
			this.fx3.start({'opacity': 0});
			this.fx2.start({'opacity': 0});
			//this.fx4.start({'opacity': 0});
		}else{
			//this.fx3.start({'opacity': 1});
			this.fx3.start({'opacity': 0});
			//this.fx2.start({'opacity': 0.7});
			this.fx2.start({'opacity': 0});
		}
		this.voile = $('voile');
		this.layer = $('layer');
		this.img = $$('#layer img')[0];
		this.index = 0;
		this.voile.style.height = "718px";//document.body.scrollHeight + "px";
		
		$('layer').getElements('a.layerClose').each(function(elm,i){
			elm.onclick = function (){
				layer.close();
			}
		});
		$('searchCollection').onclick = function (){
			searcher.request("CollectionName="+($('CollectionName').value));
			layer.close();
		}
		$('CollectionName').value = "";
	},
	
	show : function (index){
		select2Skin.closeAll();
		this.fx1.start({'opacity': 1});
		//this.fx4.start({'opacity': 1});
		this.fx2.start({'opacity': 0.85});
		if(this.scrollerDiv) this.scrollerDiv.destroy();
		if (!isNaN(index)) 
			var obj = searcher.items[index];
		this.img.style.display = "none";
		if(this.preload) this.preload.kill(this.preload);
		if (obj) this.preload = new preLoader(['img/'+obj.urlBig], layer.changeIMG, true, false);
		//
		if (isNaN(index)){
			if($('layer').getElement('div.'+index)){
				var childsCtn = $('layer').getElement('div.layerCtn').getChildren();
				//console.info(childsCtn,index);
				childsCtn.each(function(elm,i){
					//console.info(elm);
					if(elm.hasClass(index)){
						//console.info(1);
						elm.setStyle('display','block');
					}else{
						//console.info(2);
						elm.setStyle('display','none');
					}
				});
			}
		}else{
			var childsCtn = $('layer').getElement('div.layerCtn').getChildren();
			childsCtn.each(function(elm,i){
				if(elm.hasClass('media')){
					elm.setStyle('display','block');
				}else{
					elm.setStyle('display','none');
				}
			});
			this.setText(obj);
		}
		//
		//$$('#layer p')[0].innerHTML = st;
		$('layer').style.display = "block"; 
		$('voile').style.display = "block";
		// check btn suivant et prev 
		if(index == searcher.items.length-1) $('layerNext').style.display = "none"; else $('layerNext').style.display = "block";
		if(index == 0) $('layerPrev').style.display = "none"; else $('layerPrev').style.display = "block";
		this.index = index;
		this.sizeBody();
	},
	
	next : function (){
		this.index++;
		this.show(this.index)
	},
	
	previous : function (){
		this.index--;
		this.show(this.index)	
	},
	
	
// ///////////////////////////////////////////////////////////////////////////////////////////////// POP-IN (ex ligne 500)
	displaySubmitLayer : function (bool){
		
	},
// ///////////////////////////////////////////////////////////////////////////////////////////////// POP-IN (ex ligne 500)

	
	changeIMG : function (img, wasCached, index, getError){
		layer.img.src = img.src;
		layer.img.style.display = "";
		if(getError) {layer.img.style.display = "none";}
	},
	
	setText : function (obj){
		$('CollectionName').value = obj.collectionCode;
		$('setCollection').innerHTML = obj.collection != "" ? obj.collection : "";
		if($('setCollection').innerHTML == ""){
			$('setCollection').parentNode.style.display = "none";
			$('searchCollection').style.display = "none";
		}
		else {
			$('setCollection').parentNode.style.display = "block";
			$('searchCollection').style.display = "";		
		}
		 
		$('setMakeup').innerHTML = obj.makeup;
		$('setMakeup').style.display = $('setMakeup').previousSibling.style.display  = obj.makeup == "" ? "none" : "block" ; 
		$('setStyling').innerHTML = obj.styling; 
		$('setStyling').style.display = $('setStyling').previousSibling.style.display  = obj.styling == "" ? "none" : "block" ;
		$('setPhotographer').innerHTML = obj.photographer; 
		$('setPhotographer').style.display = $('setPhotographer').previousSibling.style.display  = obj.photographer == "" ? "none" : "block" ;
		$('setAD').innerHTML = obj.artDirector; 
		$('setAD').style.display = $('setAD').previousSibling.style.display  = obj.artDirector == "" ? "none" : "block" ;
		
		var webTxt = obj.webSite.replace(/ /, "<br />");
		var webUrl = webTxt.match(/http(s)?:\/\//) ? webTxt : "http://"+webTxt;
		
		
		
		$('setSite').innerHTML = obj.webSite != "" ?  '<a href="'+webUrl+'" target="_blank" class="linkSpec" title="'+webTxt+'">'+webTxt.substr(0, 30)+"..."+'</a>' : ""; 
		//$('setSite').href == obj.webSite;
		$('setSite').style.display = $('setSite').previousSibling.style.display  = obj.webSite == "" ? "none" : "block" ;
		
		
		$('setPhone').innerHTML = obj.phone != "" ? obj.phone.replace(/,/, "<br />") : ""; 
		$('setPhone').style.display = $('setPhone').previousSibling.style.display  = obj.phone == "" ? "none" : "block" ;
		
		$('setEmail').innerHTML = obj.emailAdress != "" ? obj.emailAdress.replace(/,/, "<br />") : ""; 
		$('setEmail').style.display = $('setEmail').previousSibling.style.display  = obj.emailAdress == "" ? "none" : "block" ;
		
		/*$('setPress').innerHTML = obj.pressContact; 
		$('setPress').style.display = $('setPress').previousSibling.style.display  = obj.pressContact == "" ? "none" : "block" ;*/
		$('setAddress').innerHTML = obj.adress != "" ? obj.adress.replace(/, /, "<br />") : ""; 
		$('setAddress').style.display = $('setAddress').previousSibling.style.display  = obj.adress == "" ? "none" : "block" ;
		/*$('setName').innerHTML = obj.salonName; 
		$('setName').parentNode.style.display  = obj.salonName == "" ? "none" : "block" ;*/
		$('setName').innerHTML = obj.adress != "" ? obj.salonName.replace(/, /, "<br />") : ""; 
		$('setName').style.display = $('setName').previousSibling.style.display  = obj.salonName == "" ? "none" : "block" ;
		$('setHairdresser').innerHTML = obj.hairdresser; 
		$('setHairdresser').parentNode.style.display  = obj.hairdresser == "" ? "none" : "block" ;
		$('setAmbassadeur').innerHTML = obj.ambassadeur; 
		$('setAmbassadeur').parentNode.style.display  = obj.ambassadeur == "" ? "none" : "block" ;
	},
	
	sizeBody: function (){
		var maxHeight = 440;
		if ($("layerHead") && $("layerFooter") && $("layerBody")) {
			var headHeight = $("layerHead").offsetHeight;
			var footerHeight = $("layerFooter").offsetHeight;
			$("layerBody").style.height = ( maxHeight - headHeight - footerHeight ) + "px";
			if($("layerBody").scrollHeight-1 > $("layerBody").offsetHeight) this.scrollerDiv = new scrollerManager(document.getElementById("layerBody"));
		}
	},
	
	close: function(){
		$('CollectionName').value = "";
		this.fx1.start({'opacity': 0});
		this.fx2.start({'opacity': 0});
		if(this.scrollerDiv) this.scrollerDiv.destroy();		
	}
	
	
}



/**
* array : [], containing an array with the img attributes [url, altText, width, height ] OR a string with the img src 
* groupName: string, a string to identificate the array if multiple
* callBack: function, function called when img onload or complete with the DOM element and a boolean to know if the image was cached as parameter
* noCache: bool, at true always loading image from server

* var array = [['KA1_.jpg', 'kossi', 50, 20] , 'KA2_.jpg', 'KA3_.jpg', ['KA4_.jpg', 'dsdsfsde', 100, 200], 'KA5_.jpg', 'KA6_.jpg'];
* imgLoader.preload(array, "mygroupname", preloadCallback, true, true);

**/
var preLoader = function (array, callBack, isProgressive, noCache){
	this.array = array;
	this.timestamp = Math.floor((new Date()).getTime() / 1000);
	this.inCache = noCache ? "?"+this.timestamp : "";
	if(isProgressive) this.preloadProgressive(0, callBack);
	else this.preload(callBack);
}
	
preLoader.prototype.preloadProgressive = function (i ,callBack){
	if (i > this.array.length-1) return;
	this._IMG = new Image();
	this._IMG.alt = "";
	this._IMG.title = "";
	this._IMG.src = this.array[i]+this.inCache;
	if(this._IMG.complete){
		callBack(this._IMG, true, i, false);			
		this.preloadProgressive(i+1, callBack);			
	}
	else {
		this._IMG.onerror = function(obj){
		return function (){
			//alert('error')
			callBack(this, true, i, true);			
			obj.preloadProgressive(i+1, callBack);
		}
	}(this);
	this._IMG.onload = function(obj){
			return function (){
				//alert('load')
				callBack(this, false, i, false)
				obj.preloadProgressive(i+1, callBack);
			}
		}(this)
	}
}

preLoader.prototype.kill = function (instance){
	instance.array = [];
	if(instance._IMG){
		instance._IMG.src = "";
		instance._IMG.onload = null;
		instance._IMG.onerror = null;
		instance._IMG = null;
	}	
	delete instance;
}

/**
* scroller
**/
var scrollerManager = function(elm, extensible, speed) {
	// setVar
	var that = this;
	this.elm = elm;
	this.elm.scrollTop = 0;
	this.initWidth = elm.offsetWidth;
	this.initHeight = elm.offsetWidth;
	this.scHeight = elm.scrollHeight - elm.offsetHeight;
	this.percent = 0;
	if(!speed) this.speed = 0.10;
	this.liftClicked = false;
	/* TODO
	prévoir le cas ou elm est le body
	*/
	this.container = document.createElement('div');
	this.container.id = "scroller_"+((new Date()).getTime());
	this.container.style.zIndex  = "1000000000";
	
	document.body.appendChild(this.container);
	
	// creation des boutons du scroll 
	switch(extensible){
		case true:
			break;
		case false: default:
			this.imgTop = document.createElement('a');
			this.imgTop.className = "scrollerTop";
			this.container.appendChild(this.imgTop);
			
			this.imgRoad = document.createElement('a');
			this.imgRoad.className = "scrollerRoad";
			this.container.appendChild(this.imgRoad);
			
			this.imgBottom = document.createElement('a');
			this.imgBottom.className = "scrollerBottom";
			this.container.appendChild(this.imgBottom);

			this.imgLift = document.createElement('a');
			this.imgLift.className = "scrollerLift";
			this.container.appendChild(this.imgLift);
			break;
	}
	// placement dynamique des elms
	this.baseTop = getTop(elm);
	this.RoadHeight = elm.offsetHeight - this.imgTop.offsetHeight - this.imgBottom.offsetHeight;

	this.imgRoad.style.height = this.RoadHeight + "px";
	
	//
	this.container.style.overflow = "hidden";
	this.container.style.width = this.imgTop.offsetWidth + "px";
	this.container.style.height = this.initHeight + "px";
	this.container.style.position = "absolute";
	this.container.style.top = this.baseTop + "px";
	//
	elm.style.overflow = "hidden";
	//alert(getCSSRule(elm, "marginRight", false))
	elm.style.marginRight = getCSSRule(elm, "marginRight", false) + this.container.offsetWidth + "px";
	elm.style.width = elm.offsetWidth - this.container.offsetWidth + "px";
	this.container.style.left = getLeft(elm) + elm.offsetWidth + 'px';
	//if(IS_MS) this.container.style.left = getLeft(elm) + elm.offsetWidth + 25 + 'px';
	
	
	
	// calcul du débatement : calcul la vitesse de deplacement en px
	this.debatPx = this.imgRoad.offsetHeight-this.imgLift.offsetHeight;
	var htTot = this.scHeight-this.container.offsetHeight;
	this.deb = (this.debatPx/htTot)*this.speed;
	this.minTop = this.imgTop.offsetHeight;
	this.maxTop = this.debatPx + this.minTop;
	this.liftHeight = this.imgLift.offsetHeight;
	this.imgLift.style.top = this.minTop + "px";
	this.currentPos = this.minTop;
	
	
	/** EVENTS **/
	/*imgTop*/
	this.imgTop.onmousedown = function (obj){
		return function (){
			obj.moveScroll(obj.percent-obj.speed);
			obj.interval = setInterval(function(){obj.moveScroll(obj.percent-obj.speed);},100);
		}
	}(this);
	this.imgTop.onmouseup = this.imgTop.onmouseout = function (obj){
		return function (){
			obj.stopScroll();;
		}
	}(this);
	/*imgBottom */
	this.imgBottom.onmousedown = function (obj){
		return function (){
			obj.moveScroll(obj.percent+obj.speed);
			obj.interval = setInterval(function(){obj.moveScroll(obj.percent+obj.speed);},100);
		}
	}(this);
	this.imgBottom.onmouseup = this.imgBottom.onmouseout = function (obj){
		return function (){
			obj.stopScroll();
		}
	}(this);
	/*imgRoad*/
	this.imgRoad.onmousedown = function (obj){
		return function (e){
			if(!e) e = window.event;
			var Y = e.clientY;
			var sens = (Y > getTop(obj.imgLift)) ? 1 : -1; 
			obj.moveScroll(obj.percent+(obj.speed*sens));
			obj.interval = setInterval(function(e){
				if(sens == 1 && Y < getTop(obj.imgLift)+obj.liftHeight) obj.stopScroll();
				if(sens == -1 && Y > getTop(obj.imgLift)) obj.stopScroll();
				obj.moveScroll(obj.percent+(obj.speed*sens));
			},50);
		}
	}(this);
	this.imgRoad.onmouseup = this.imgRoad.onmouseout = function (obj){
		return function (e){
			obj.stopScroll();
		}
	}(this);
	
	/*imgLift*/	
	Drag.init(this.imgLift, null, 0, 0,this.minTop, this.maxTop, true, false);
	
	this.imgLift.onDrag = function (obj){
		return function (x,y){
			this.style.cursor = "s-resize";
			var delta = (y - obj.minTop)/ obj.debatPx;
			obj.moveScroll(delta, true);
		}
	}(this)
	this.imgLift.onDragEnd = function (obj){
		return function (x,y){
			this.style.cursor = "";
		}
	}(this)
	/*elm*/
	if(document.addEventListener){
	elm.addEventListener('DOMMouseScroll', function (obj){
		return function (e){
			var delta = e.detail;
			obj.moveScroll(obj.percent+(delta/100));
		}
	}(this), null);
	}
	else{
	elm.attachEvent('onmousewheel', function (obj){
		return function (e){
			if(!e) e = window.event;
			var delta = -e.wheelDelta/40;
			//alert(delta);			
			if(window.opera) delta = -delta;
			obj.moveScroll(obj.percent+(delta/100));
		}
	}(this));
	}
	
	
	return this;
}



	
scrollerManager.prototype.moveScroll = function (pourcent, fromDrag){
		if(pourcent>1) pourcent = 1;
		if(pourcent<0) pourcent = 0;
		this.percent = pourcent;
		this.elm.scrollTop = this.scHeight*pourcent;
		var newTop = this.debatPx * pourcent;
		if(!fromDrag) this.imgLift.style.top = newTop + this.minTop + "px";
}
	
scrollerManager.prototype.stopScroll = function (){
		if(this.interval) clearInterval(this.interval);
}
	
scrollerManager.prototype.destroy = function (instance){
		if(this.container.parentNode) this.container.parentNode.removeChild(this.container);
		this.elm.style.height = "";
		this.elm.style.marginRight = "";
		this.elm.style.width = "";
		if(instance){
			if(instance.interval) clearInterval(instance.interval);
			delete instance;
		}
}

/**
/ renvoie le left et le top d'un elm
**/
function getLeft(MyObject){
    if (MyObject.offsetParent)
	return (MyObject.offsetLeft + getLeft(MyObject.offsetParent));
    else
	return (MyObject.offsetLeft);
    }
function getTop(MyObject){
    if (MyObject.offsetParent)
	return (MyObject.offsetTop + getTop(MyObject.offsetParent));
    else
	return (MyObject.offsetTop);
    }


/**
/ renvoie la valeur CSS rule de l'elm cible --> withoutUnity n'a pas d'effet si rule == "all"
**/
function getCSSRule (cible, rule, withoutUnity){
	var CSSrule, cr;
	if(cible.currentStyle){
		cr = cible.currentStyle;
		CSSrule = cr[rule];
	}
	else {
		cr = window.getComputedStyle(cible, null);
		CSSrule = cr[rule];
	}
	if(rule == "all") {
		CSSrule = [];
		for(var a in cr){
			if (cr[a]!= "" && typeof(cr[a]) == 'string') 
				CSSrule.push([a, cr[a]]);
		}
	}
	if(withoutUnity && rule != "all") CSSrule = parseFloat(CSSrule);
	if(parseInt(CSSrule)/parseInt(CSSrule) != 1) {
		CSSrule = 0;
	}
	return parseFloat(CSSrule);	
}
/**
/  transforme rgb(0,0,0) en #000000
**/
function RGB2Hexa(rgb){
// samori powered
	if(rgb.indexOf('rgb') != -1){
		rgb = rgb.substring(4);
		rgb = rgb.substring(0, rgb.length-1);
		var s = [];
		rgb = rgb.split(',');
		for (x in rgb){
			if(parseInt(x)+1*2){ // si numeric
				var ind = parseInt(rgb[x]).toString(16);
				if(ind<10){ind = "0"+ind}
				s.push(ind);
			}
		}
		rgb = s.join("");
		rgb = "#"+rgb;
	
	}
	return rgb;
}
/***
* DOM-DRAG.js
*
***/

/**************************************************
 * dom-drag.js
 * 09.25.2001
 * www.youngpup.net
 **************************************************
 * 10.28.2001 - fixed minor bug where events
 * sometimes fired off the handle, not the root.
 **************************************************/



var Drag = {

	obj : null,

	init : function(o, oRoot, minX, maxX, minY, maxY, bSwapHorzRef, bSwapVertRef, fXMapper, fYMapper)
	{
		o.onmousedown	= Drag.start;

		o.hmode			= bSwapHorzRef ? false : true ;
		o.vmode			= bSwapVertRef ? false : true ;

		o.root = oRoot && oRoot != null ? oRoot : o ;

		if (o.hmode  && isNaN(parseInt(o.root.style.left  ))) o.root.style.left   = "0px";
		if (o.vmode  && isNaN(parseInt(o.root.style.top   ))) o.root.style.top    = "0px";
		if (!o.hmode && isNaN(parseInt(o.root.style.right ))) o.root.style.right  = "0px";
		if (!o.vmode && isNaN(parseInt(o.root.style.bottom))) o.root.style.bottom = "0px";

		o.minX	= typeof minX != 'undefined' ? minX : null;
		o.minY	= typeof minY != 'undefined' ? minY : null;
		o.maxX	= typeof maxX != 'undefined' ? maxX : null;
		o.maxY	= typeof maxY != 'undefined' ? maxY : null;

		o.xMapper = fXMapper ? fXMapper : null;
		o.yMapper = fYMapper ? fYMapper : null;

		o.root.onDragStart	= new Function();
		o.root.onDragEnd	= new Function();
		o.root.onDrag		= new Function();
	},

	start : function(e)
	{
		var o = Drag.obj = this;
		e = Drag.fixE(e);
		var y = parseInt(o.vmode ? o.root.style.top  : o.root.style.bottom);
		var x = parseInt(o.hmode ? o.root.style.left : o.root.style.right );
		o.root.onDragStart(x, y);

		o.lastMouseX	= e.clientX;
		o.lastMouseY	= e.clientY;

		if (o.hmode) {
			if (o.minX != null)	o.minMouseX	= e.clientX - x + o.minX;
			if (o.maxX != null)	o.maxMouseX	= o.minMouseX + o.maxX - o.minX;
		} else {
			if (o.minX != null) o.maxMouseX = -o.minX + e.clientX + x;
			if (o.maxX != null) o.minMouseX = -o.maxX + e.clientX + x;
		}

		if (o.vmode) {
			if (o.minY != null)	o.minMouseY	= e.clientY - y + o.minY;
			if (o.maxY != null)	o.maxMouseY	= o.minMouseY + o.maxY - o.minY;
		} else {
			if (o.minY != null) o.maxMouseY = -o.minY + e.clientY + y;
			if (o.maxY != null) o.minMouseY = -o.maxY + e.clientY + y;
		}

		document.onmousemove	= Drag.drag;
		document.onmouseup		= Drag.end;

		return false;
	},

	drag : function(e)
	{
		e = Drag.fixE(e);
		var o = Drag.obj;

		var ey	= e.clientY;
		var ex	= e.clientX;
		var y = parseInt(o.vmode ? o.root.style.top  : o.root.style.bottom);
		var x = parseInt(o.hmode ? o.root.style.left : o.root.style.right );
		var nx, ny;

		if (o.minX != null) ex = o.hmode ? Math.max(ex, o.minMouseX) : Math.min(ex, o.maxMouseX);
		if (o.maxX != null) ex = o.hmode ? Math.min(ex, o.maxMouseX) : Math.max(ex, o.minMouseX);
		if (o.minY != null) ey = o.vmode ? Math.max(ey, o.minMouseY) : Math.min(ey, o.maxMouseY);
		if (o.maxY != null) ey = o.vmode ? Math.min(ey, o.maxMouseY) : Math.max(ey, o.minMouseY);

		nx = x + ((ex - o.lastMouseX) * (o.hmode ? 1 : -1));
		ny = y + ((ey - o.lastMouseY) * (o.vmode ? 1 : -1));

		if (o.xMapper)		nx = o.xMapper(y)
		else if (o.yMapper)	ny = o.yMapper(x)

		Drag.obj.root.style[o.hmode ? "left" : "right"] = nx + "px";
		Drag.obj.root.style[o.vmode ? "top" : "bottom"] = ny + "px";
		Drag.obj.lastMouseX	= ex;
		Drag.obj.lastMouseY	= ey;

		Drag.obj.root.onDrag(nx, ny);
		return false;
	},

	end : function()
	{
		document.onmousemove = null;
		document.onmouseup   = null;
		Drag.obj.root.onDragEnd(	parseInt(Drag.obj.root.style[Drag.obj.hmode ? "left" : "right"]), 
									parseInt(Drag.obj.root.style[Drag.obj.vmode ? "top" : "bottom"]));
		Drag.obj = null;
	},

	fixE : function(e)
	{
		if (typeof e == 'undefined') e = window.event;
		if (typeof e.layerX == 'undefined') e.layerX = e.offsetX;
		if (typeof e.layerY == 'undefined') e.layerY = e.offsetY;
		return e;
	}
};



/**
**
**/
/*	fixPng :
	@function 	: 	fixe les images de fond png 24 bits sous IE6 (pour la transparent alpha) ainsi que les tags <img>
    @desc 			: 	cette fonction est appelée par la CSS pour un élément qui a un PNG24Bits en background,
							Un élément (<i> dans notre cas) est généré et mis en position:absolute avec z-index:-1 et des largeur/hauteur de 32000px, celui-ci contiendra l'image en PNG.afin de gérer les élément extensible. 
							Cette méthode a été utilisée afin de ne page avoir le bug ou certains contenus se retrouve désactivé (liens) lorsqu'on utilise le filter sur un élément.
							L'élément conteneur se verra appliqué un position:relative (si position de base est 'static') et un overflow:hidden afin de bien cacher le le dépassement de l'éménet qui contient l'image.
							Si on ne veut pas utiliser l'overflow:hidden ou on veut utiliser la methode 'crop' il est possible de passer des parametres à la fonction (cf @params)
							Fonctionne aussi avec les tag <img> on le nécessaire est faire pour remplacer l'image, sans la désactiver (cf @additional)
	@use				:   A utiliser dans la CSS, ex : 
							.myclass{
								background:url('skin/nav/backgroundnav.png) no-repeat left top; 
								filter:expression(pngFix(this));
							}
	@params		:	pngFix(element:HTMLElement, noOverflow:boolean, scale:boolean);
							- element : element HTML : passer  this dans la CSS.
							- noOverflow (true) :	par defaut on utilise un overflow:hidden, sur le parent conteneur, si cela, gêne, 
																il suffit de passer la valeur true pour ce parametre, et automatiquement on utilisera un overflow:visible;
							- scale (true): 	par défaut la methode du filter est 'crop', ce qui est le comportement normal d'une image de background. 
													Mais pour certaines raisons l'image a besoin de prendre tout le block , ex: une image de 1px répétée. 
													Donc pour cela, la seule manière est d'utiliser la méthode 'scale' du imageAlphaLoader.
	@additional	: Gère aussi les tag <img> qui seront automatiquement transformés en image avec transparence PNG. 
							En utilisant la méthode de base  (appel au filter), l'image est automatiquement gérée.
							Mais si on veut faire du cas par cas, il suffit de créer une classe CSS appelée pngFix, qui sera ensuite posée sur les tags <img>
								img.pngFix {filter:expression(pngFix(this));}
								<img src="img/myImage.png" class="pngFix" />
	@exemples	: 
						- filter:expression(pngFix(this))  //==> mode normal, un layer contenant le png dans le fond, est mis sur l'élément avec comme avantage
																				de pouvoir utiliser une image très grande, et automatiquement, 
																				le bloc peut etre extensible en largeur + hauteur.
						- filter:expression(pngFix(this, null, true))  //==> l'image prend toute la taille du bloc, ce qui est utile par exemple pour simuler un png répété sous les autres navigateurs
						- filter:expression(pngFix(this, true))  //==> on ne change que l'overflow par visible, ce qui du coup ne permet plus d'avoir un bloc extensible à 100% en largeur
	
	@TODO		:
						- Gérer les overflow:auto déclarés par défaut, et  caller automatiquement le layer indiquer cela dans une doc, qu'il faut obligatoirement un élément conteneur.
						- gérer les options en les mettant obligatoirement entre guillement, comme ça on pourra traiter facilement un dictionnaire de parametres type JSON.
						- gérer les background-position en utilisant le sizingMethod 'image '
			
*/
function pngFix(elm, noOverflow) {
	elm.style.filter = ' ';
	if (!(document.all && window.print && /MSIE /.test(navigator.userAgent))) return;
	var exec = (function(elm, noOverflow, scale) {
		return function() {
			var options = { noOverflow:noOverflow};
			var repeat = elm.currentStyle.backgroundRepeat.toLowerCase()=='repeat';
			elm.style.filter = ' ';
				// si l'élément est un tag img, on va en faire creer une balise qui encadrera cette image et ensuite traiter la balise comme si c'etait un élément qui avait une image de fond
				if (elm.nodeName=='IMG') {
					if (!elm.src.match(/.*\.png$/)) return;
					var imgContainer = document.createElement('i');
					with(imgContainer.style) {
						display = 'inline-block';
					}
					elm.parentNode.insertBefore(imgContainer, elm)
					imgContainer.appendChild(elm);
					imgContainer.style.backgroundImage = 'url('+elm.src+')';
					imgContainer.style.backgroundRepeat = 'no-repeat';
					elm.style.filter = 'alpha(opacity=0)';
					elm = imgContainer;
				}
				
				if (elm.currentStyle.backgroundImage == "" || elm.currentStyle.backgroundImage == "url()") return;
				var url = elm.currentStyle.backgroundImage.match(/^url\(["'](.*\.png)["']\)$/); //seulement les .png
				if (!url || url.length<2) return;
				var pngLayer = document.createElement('i'); // on genere un <i> en position:absolute (layer), qui viendra se placer sous le contenu du div  qui avait besoin du style.
				with(pngLayer.style) {
					if (options.noOverflow) {
						width = elm.offsetWidth + 'px';
						height = elm.offsetHeight + 'px';
					} else {
					 	width = '32000px';
						height = '32000px'; 
					}
					position = 'absolute';
					zIndex = -1;
					fontSize = '1%';
					filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod='" + (options.noOverflow ? 'crop' : 'image') + "', src='"+url[1]+"')";
					background = 'none'; //forcing car parfois il peut arriver qu'on ai une CSS qui vienne rajouter des images / couleurs de fond
					
				
							
					
					/* positionnement de l'image en fonction du background-position sur l'element */
					if (!repeat) {
						switch((elm.currentStyle.backgroundPositionX+'').toLowerCase()) {
							case 'left' : left=0; break; 
							case 'right' : right = 0; break;
							case 'center' : 
								left='50%'; 
								setTimeout(function(pngLayer) {
									return function() {
										pngLayer.style.marginLeft = -(pngLayer.offsetWidth/2)+'px'; 
									}
								}(pngLayer), 50);
								break;
							default : 
								left = elm.currentStyle.backgroundPositionX; 
						}

						switch((elm.currentStyle.backgroundPositionY+'').toLowerCase()) {
							case 'top' : top = 0; break;
							case 'bottom' : bottom = 0; break;
							case 'center' : 
								top='20%'; 
								setTimeout(function(pngLayer) {
									return function() {
										pngLayer.style.marginTop=-(pngLayer.offsetHeight/2)+'px'; 
									}
								}(pngLayer), 100);
								break;
							default : 
								top = elm.currentStyle.backgroundPositionY || 0; 
						}
					} else {
						left = 0; //elm.currentStyle.backgroundPositionX +'';
						top = 0; //elm.currentStyle.backgroundPositionY +'';
					}
				} 
				
					/* gestion automatique du sizingMethod='scale' ou sizingMethod='image', ne pouvant pas tester le backgroundRepeat correctement, on passe par une methode un peu plus tricky */
					setTimeout(function(elmN, pngLayerN, repeatN) {
						return function() {
							if (pngLayerN.filters['DXImageTransform.Microsoft.AlphaImageLoader'].sizingMethod=='image') {
								if (pngLayerN.offsetWidth<elmN.offsetWidth && repeatN) {
									pngLayerN.filters['DXImageTransform.Microsoft.AlphaImageLoader'].sizingMethod='scale';
								} else if (pngLayerN.offsetWidth>elmN.offsetWidth && elm.currentStyle.backgroundPositionX.match(/^(left|0%|0px|0)$/) && elm.currentStyle.backgroundPositionY.match(/^(top|0%|0px|0)$/)){
									pngLayerN.filters['DXImageTransform.Microsoft.AlphaImageLoader'].sizingMethod='crop';
								}
							} else {
								pngLayerN.sizingMethod = 'image';
							}
							if (elm.currentStyle.width.match(/^(0|[12](%|px)?)$/)) {
								pngLayerN.filters['DXImageTransform.Microsoft.AlphaImageLoader'].sizingMethod='image';
							}
							if (pngLayerN.style.right != 'auto' && pngLayerN.style.right !='')
								setTimeout(function() {
									pngLayerN.style.right = parseInt(pngLayerN.style.right) - (elm.offsetWidth%2 ? 1 : 0) + 'px';
								}, 50)
							
								
						}
					}(elm, pngLayer, repeat), 200);
				
				with (elm.style) {
					position = elm.currentStyle.position=="static" || elm.currentStyle.position=="" ? 'relative' : "";
					if (elm.currentStyle.overflow!='auto' && elm.currentStyle.overflow!='hidden') overflow = options.noOverflow ? 'visible' : (elm.currentStyle.width.match(/^(0|[12](%|px)?)$/) ? 'visible' : 'hidden');
					backgroundImage = 'none';
				}
				elm.appendChild(pngLayer);
		}
	})(elm, noOverflow);
	try{
		pngFixLoader.useOnload ? pngFixLoader.addFunc(exec) : exec();
	} catch(e) {};
}

/* pngFixLoader 
	@unction 		:	objet pour permet le lancement des modifications des png via pngFix en décalé sur le onload de la page.
							cela permet de contourner un bug d'internet explorer qui affiche un message d'erreur si le DOM est modifié pendant le chargement de la page.
*/
var pngFixLoader = {
	useOnload : true, // true : active l'execution du fixPng sur le load, et false, execute le fixPng dès qu'il est appelé par la CSS
	functions : [], // toutes les fonctions à éxécuter sur le onload de la page
	addFunc : function(func) {
		pngFixLoader.functions.push(func);
	},
	launch : function() {
			pngFixLoader.useOnload = false; //une fois la page chargée, il faut laisser s'executer automatiquement la fonction pour d'autres actions (ex : ouverture layer)
			var counter = 1;
			while(pngFixLoader.functions.length>0) {
				//setTimeout(pngFixLoader.functions.pop(), 20*counter);
				pngFixLoader.functions.pop()();
				counter++;
			}
	},
	init : function() {
		if (pngFixLoader.useOnload) {
			addEvent('domready', function() {
				setTimeout(pngFixLoader.launch, 100);
			});
		}
	}
}
//pngFixLoader.init();

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function eradiquateCookie(){
	var cook = document.cookie.split(";");
	for(var i = 0; i < cook.length; i++){
		eraseCookie(cook[i].split('=')[0]);
	}
}
