			var isDebugEnabled = false;
			var filtre = "";
			var isDiscount = "";
			var isBrand = "";
			var isSubtype = "";
			var timeout = false;
			var isInitialized = false;
			var ajaxCpt = 0;

			function errorHandler(msg) {
				if (isDebugEnabled) alert(msg);
			}
			DWREngine.setErrorHandler(errorHandler);

			function putTimeout(){
				timeout = true;
			}

			function setSelectedValue(select,value) {
				for(i=0;i<select.length;i++) {
					if (select[i].value==value) {
						select[i].selected = true;
						break;
					}
				}
			}


			var sizeCallback = function(sizes) {
				setSelect(sizes,'selectSize','Taille');
				ajaxCpt--;
				enableDropDownLists();
			}

			var typeProduitCallback1 = function(brands) {
				setSelect(brands,'selectMainCategory','Type de produit');
				ajaxCpt--;
				enableDropDownLists();
			}

			var brandCallback2 = function(brands) {
				setSelect(brands,'selectSecondCategory','Marque');
				ajaxCpt--;
				enableDropDownLists();
			}

			var typeProduitCallback2 = function(brands) {
				setSelect(brands,'selectSecondCategory','Type de produit');
				ajaxCpt--;
				enableDropDownLists();
			}

			var brandCallback1 = function(brands) {
				setSelect(brands,'selectMainCategory','Marque');
				ajaxCpt--;
				enableDropDownLists();
			}

			var colorCallback = function(colors) {
				setSelect(colors,'selectColor','Couleur');
				isInitialized = true;
				ajaxCpt--;
				enableDropDownLists();
			}

			function attend() {
			}

			function setInitSelectValue() {




				var sel1 = document.getElementById('selectMainCategory');
				var sel2 = document.getElementById('selectSecondCategory');
				var sel3 = document.getElementById('selectColor');
				var sel4 = document.getElementById('selectSize');


				setSelectedValue(sel1,initCat1);
				setSelectedValue(sel2,initCat2);
				setSelectedValue(sel3,initColor);
				setSelectedValue(sel4,initSize);

			}

			function setSelect(elements,selectId,selectLabel) {
				if (elements != null) {
					var selectOptions = document.getElementById(selectId);
					selectValue = selectOptions[selectOptions.selectedIndex].value;
					DWRUtil.removeAllOptions(selectId);
					var option = new Option(selectLabel, '');
					selectOptions[selectOptions.length]=option;
					DWRUtil.addOptions(selectId, elements, 'value', 'label');
					setSelectedValue(selectOptions,selectValue)
				}
			}

			function onchangeSize() {
				refresh();
			}

			function onchangeColor() {
				refresh();
			}

			function onchangeSecondaryCategory() {
				refresh();
			}

			function onchangeMainCategory() {
				refresh();
			}

			function enableDropDownLists() {
				if (ajaxCpt == 0) {
					document.getElementById('selectMainCategory').disabled = false;
					document.getElementById('selectSecondCategory').disabled = false;
					document.getElementById('selectColor').disabled = false;
					document.getElementById('selectSize').disabled = false;
				}
			}

			function refresh() {
				var isDiscount = ( document.getElementById('discount')!=null && document.getElementById('discount').value == 'true' );
				var categoryId1 = document.getElementById('selectMainCategory').value;
				var categoryId2 = document.getElementById('selectSecondCategory').value;
				var colorId = document.getElementById('selectColor').value;
				var sizeId = document.getElementById('selectSize').value.toUpperCase();

				document.getElementById('selectMainCategory').disabled = true;
				document.getElementById('selectSecondCategory').disabled = true;
				document.getElementById('selectColor').disabled = true;
				document.getElementById('selectSize').disabled = true;

				refresh0(isDiscount,categoryId1,categoryId2,colorId,sizeId);

			}

			function refresh0(isDiscount,categoryId1,categoryId2,colorId,sizeId) {

				if (isDebugEnabled) {alert("categoryId1 : " + categoryId1 + "\n categoryId2 : " + categoryId2 + "\n filtre : " + filtre + "\n colorId : " + colorId + "\n sizeId : " + sizeId);}
				if (isSubType) {
					ajaxHelper.getOrcantaElements( typeProduitCallback1,  categoryId2,filtre, colorId, sizeId, '', isDiscount, 'sousTypeProduit');ajaxCpt++;
					ajaxHelper.getOrcantaElements( sizeCallback, categoryId2,filtre , colorId, '', categoryId1, isDiscount, 'size');ajaxCpt++;
					ajaxHelper.getOrcantaElements( brandCallback2,  '',filtre, colorId, sizeId, categoryId1, isDiscount, 'brand');ajaxCpt++;
					ajaxHelper.getOrcantaElements( colorCallback, categoryId2,filtre, '', sizeId, categoryId1, isDiscount, 'color');ajaxCpt++;
				} else if (isBrand) {																		;
					ajaxHelper.getOrcantaElements( typeProduitCallback2,  categoryId1,'', colorId, sizeId, '', isDiscount, 'typeProduit');ajaxCpt++;
					ajaxHelper.getOrcantaElements( sizeCallback, categoryId1,categoryId2 , colorId, '', '', isDiscount, 'size');ajaxCpt++;
					ajaxHelper.getOrcantaElements( brandCallback1,  '',categoryId2, colorId, sizeId, '', isDiscount, 'brand');ajaxCpt++;
					ajaxHelper.getOrcantaElements( colorCallback, categoryId1,categoryId2, '', sizeId, '', isDiscount, 'color');ajaxCpt++;
				}	else if (!isSubType){
					ajaxHelper.getOrcantaElements( typeProduitCallback2,  categoryId1,'', colorId, sizeId, filtre, isDiscount, 'typeProduit');ajaxCpt++;
					ajaxHelper.getOrcantaElements( sizeCallback, categoryId1,categoryId2 , colorId, '', filtre, isDiscount, 'size');ajaxCpt++;
					ajaxHelper.getOrcantaElements( brandCallback1,  '',categoryId2, colorId, sizeId, filtre, isDiscount, 'brand');ajaxCpt++;
					ajaxHelper.getOrcantaElements( colorCallback, categoryId1,categoryId2, '', sizeId, filtre, isDiscount, 'color');ajaxCpt++;

				}
			}

			function init() {
					filtre = document.getElementById('filtre').value;
					isDiscount = ( document.getElementById('discount')!=null && document.getElementById('discount').value == 'true' );
					isBrand = ( document.getElementById('brand')!=null && document.getElementById('brand').value == 'true' );
					isSubType = ( document.getElementById('subProduct')!=null && document.getElementById('subProduct').value == 'true' );
					if (isBrand) document.getElementById("selectMainCategory").className="displayHid";
					if (isDiscount) filtre = '';
					//refresh0(isDiscount,initCat1,initCat2,initColor,initSize);
					// TO FIX. retrouver un handle qui sait lorsque les appels ajax sont finis.
					//puis lancer la fonction ci-dessous
					//setTimeout("setInitSelectValue()",700);
					//setInitSelectValue();
			 }

			init();