function updateURL (url, filterOut, replacement) {
	url = ((url||document.location) +"").replace(/^.*?(\?|$)/gi, ""); 
	var rgx = new RegExp("&?("+ filterOut +")=[^&]*", "gi");
	var prefixRgx = new RegExp("^&", "gi");
	var oldQuery = url.replace(rgx, ""); 
	if (prefixRgx.test(oldQuery)) 
			oldQuery = oldQuery.replace(prefixRgx, "")
	if (replacement != '') {
		oldQuery += (oldQuery.length ? "&" : "") + replacement;
	} 
	return "?"+ oldQuery;
}

function updateListFilter (field) {
	var url = field.selectedIndex ? field.name +"="+ escape(field.value) : "";
	url = updateURL($('idml_filterUrl_input').value, field.name, url);
	$('idml_filterUrl_input').value = url;
}

function applyListFilter () {
	document.location = $('idml_filterUrl_input').value;
}

function doSearch() {
	var url = document.location
	if ($('idml_searchStore_input').value=="1") {
		url = updateURL(url, "cat", "cat=");
	}
	url = updateURL(url, "q|idp|char", "q="+ escape($('idml_search_input').value)) ;
	document.location = url;
}

function updateProduct(car, forcePreselect) {
	var url = '/_include/store/liveupdate.asp';
	var preselected = /(&char=|_char-)([^&]*)(?:&|$)/gi.exec(document.location.search);
	var c = [];
	if (preselected) {
		c = preselected[1].split("|"); 
	}
	var preselect = $('mainId').value || (preselected +'') || 'false';
	if (!forcePreselect) {
		for(var i=0; i<3; i++) {
			var select = window["SelectCharacteristic"+ (i+1)];
			c[i] = ((select&&select.options.length) ? encodeURIComponent(select.value) : "") || c[i] || "";
		}
	} 
	var pars = ["c1=", c[0], "&c2=", c[1], "&c3=", c[2], "&ref="+ js_mainReference, "&preselect="+ preselect].join("");
	var myAjax = new Ajax.Request( url, {method: 'get',parameters: pars, onLoading: showLoad, onComplete: updateStoreDetail, onFailure: updateStoreDetailFail} );
}


function updateStoreDetailFail(xhr){
   alert('failure');
}

function showLoad(){
	if ($('divLoad')){
		$('divLoad').style.display='block'
	}
}

function hideLoad(){
	if ($('divLoad')){
		$('divLoad').style.display='none'
	}
}




function updateStoreDetail(xhr){
	
	var idf = xhr.responseXML.getElementsByTagName('idf');
	
	var price = xhr.responseXML.getElementsByTagName('price');
	var priceht = xhr.responseXML.getElementsByTagName('price-ht');
	var pricettc = xhr.responseXML.getElementsByTagName('price-ttc');
	var regularprice = xhr.responseXML.getElementsByTagName('regularprice');
	var promoprice = xhr.responseXML.getElementsByTagName('promoprice');
	var promopriceht = xhr.responseXML.getElementsByTagName('promoprice-ht');
	var promopricettc = xhr.responseXML.getElementsByTagName('promoprice-ttc');
	var reduction = xhr.responseXML.getElementsByTagName('reduction');
	var image = xhr.responseXML.getElementsByTagName('image');
	var stock = xhr.responseXML.getElementsByTagName('stock');
	var reference = xhr.responseXML.getElementsByTagName('reference');
	var deliveryTime = xhr.responseXML.getElementsByTagName('delivery-time');
	var deliveryDate = xhr.responseXML.getElementsByTagName('delivery-date');
	var ean13 = xhr.responseXML.getElementsByTagName('ean13');
	var weight = xhr.responseXML.getElementsByTagName('weight');
	var ecotax = xhr.responseXML.getElementsByTagName('ecotax');
	var partnumber = xhr.responseXML.getElementsByTagName('partnumber');
	
	var characteristic1 = xhr.responseXML.getElementsByTagName('characteristic1');
	var characteristic2 = xhr.responseXML.getElementsByTagName('characteristic2');
	var characteristic3 = xhr.responseXML.getElementsByTagName('characteristic3');
	
//try {
	
	var productObj = new ML.Store.Product();

	if (idf.length){
		$('mainId').value = idf[0].firstChild.nodeValue;
		productObj.setId($('mainId').value);
	}
	for(var cIdx=1; cIdx<=3; cIdx ++) {
		var characteristic = eval("characteristic"+ cIdx);
		if (characteristic.length){
			characteristic = characteristic[0].getElementsByTagName('option');
			var objOption= eval("SelectCharacteristic"+ cIdx);
			var divOption= eval("ObjCharacteristic"+ cIdx);
			
			if (!objOption) {
				if (divOption) {
					divOption.style.display = "none";
				}
				continue;
			}
			if (!idf.length) {//objOption.options[0] && objOption.options[0].value=="") {
				objOption.options.length=1;
			} else {
				objOption.options.length=0;
			}
			var selectedIndex = 0;
			for (var i=0 ; i<characteristic.length ; i++){
				var charOption = characteristic[i];
				var texte=charOption.firstChild.nodeValue.replace(/&#8364;/gi,'€');
				
				//var valeur=charOption.getAttribute("id");
				var option = new Option(texte, texte); 
				selectedIndex = objOption.length;
				objOption.options[objOption.length] = option;
				option.selected = !!charOption.getAttribute("selected");
				//if (!!charOption.getAttribute("selected"))
				//	objOption.selectedIndex = selectedIndex;
			}
			
			if (divOption) {
				if (objOption.options.length==0){
					divOption.style.display="none"
				} else {
					divOption.style.display=""
				}
			}
		}
	} 
	
	//remplace les elements du panier par les nouveaux du fichier xml
	var promo = "0";
	var regular = "0";
	var priceValue = "0";
	var clearPromoDivs = false;
	var clearRegularPriceDivs = false;
	
	if (price.length) {
	    priceValue = price[0].textContent || price[0].text
	}
	
	//mise à jour du prix normal dans le cas d'un prix secondaire
	if (regularprice.length){
		regular = regularprice[0].textContent || regularprice[0].text;
		if (parseFloat(regular.replace(",", "."))) {
			$$('.cssml_regularprice_detail').each(function(elmt) {
				elmt.innerHTML = regular +'&nbsp;'+ js_SigneMonnaie +'';
			});
		} else {
			clearRegularPriceDivs = true;
		}
	} else {
		clearRegularPriceDivs = true;
	}	
	
	// Mise à jour des variables promo price
	if (promoprice.length){
		promo = promoprice[0].textContent || promoprice[0].text;
		if (parseFloat(promo.replace(",", "."))) {
			/* Remplacé au profit de boucles type prototype pour atteindre TOUS les éléments de prix et pas seulement le premier.
			if ($('idml_price_detail')) {
				$('idml_price_detail').innerHTML = promo +'&nbsp;'+ js_SigneMonnaie +'';
			}
			$('idml_promo_price_detail').innerHTML = priceValue + '&nbsp;' + js_SigneMonnaie + '';
			*/
			$$('.cssml_price_detail').each(function(elmt) {
				elmt.innerHTML = promo +'&nbsp;'+ js_SigneMonnaie +'';
			});
			$$('.cssml_promo_price_detail').each(function(elmt) {
				elmt.innerHTML = priceValue +'&nbsp;'+ js_SigneMonnaie +'';
			});
			//ProductOptions.setBasePrice(promo.replace(",", "."));
		} else {
			clearPromoDivs = true;
		}
	} else {
		clearPromoDivs = true;
	}
	if (clearPromoDivs) {
		$$('.cssml_promo_price_detail').each(function(elmt) {
			elmt.innerHTML = '';
		});
		if (objPromo) {
			objPromo.style.display="none"
		} 
	} else {
		if (objPromo) {
			objPromo.style.display=""
		} 
	}
	
	if (clearRegularPriceDivs) {
		$$('.cssml_regularprice_detail').each(function(elmt) {
			elmt.innerHTML = '';
		});
		if (objRegularPrice) {
			objRegularPrice.style.display="none"
		} 
	} else {
		if (objRegularPrice) {
			objRegularPrice.style.display=""
		} 
	}	
	

	// Mise à jour des variables price
	if (price.length && promo==0){
		$$('.cssml_price_detail').each(function(elmt) {
			elmt.innerHTML = priceValue +'&nbsp;'+ js_SigneMonnaie +'';
		});
		/* Remplacé au profit de boucles type prototype pour atteindre TOUS les éléments de prix et pas seulement le premier.
	    $('idml_price_detail').innerHTML = priceValue + '&nbsp;' + js_SigneMonnaie + ''
		*/		
	}

	var promoht = 0;
	var pricehtValue = "0";
	clearPromoDivs = false;
	if (priceht.length) {
	    pricehtValue = priceht[0].textContent || priceht[0].text;
	}
	// Mise à jour des variables promo price en HT
	if (promopriceht.length){
		promoht = promopriceht[0].textContent || promopriceht[0].text;
		if (parseFloat(promoht.replace(",", "."))) {
			/* Remplacé au profit de boucles type prototype pour atteindre TOUS les éléments de prix et pas seulement le premier.
			if ($('idml_price_detail_ht')) {
				$('idml_price_detail_ht').innerHTML = promoht +'&nbsp;'+ js_SigneMonnaie +'';
			}
			$('idml_promo_price_detail_ht').innerHTML = pricehtValue + '&nbsp;' + js_SigneMonnaie + '';
			*/
			$$('.cssml_price_detail_ht').each(function(elmt) {
				elmt.innerHTML = promoht +'&nbsp;'+ js_SigneMonnaie +'';
			});
			$$('.cssml_promo_price_detail_ht').each(function(elmt) {
				elmt.innerHTML = pricehtValue +'&nbsp;'+ js_SigneMonnaie +'';
			});
		} else {
			clearPromoDivs = true;
		}
	} else {
		clearPromoDivs = true;
	}
	if (clearPromoDivs) {
		$$('.cssml_promo_price_detail_ht').each(function(elmt) {
			elmt.innerHTML = '';
		});
		if (objPromo) {
			objPromo.style.display="none"
		}
	}
	// Mise à jour des champs price en HT
	if (priceht.length && promoht==0){
		$$('.cssml_price_detail_ht').each(function(elmt) {
			elmt.innerHTML = pricehtValue +'&nbsp;'+ js_SigneMonnaie +'';
		});
		/* Remplacé au profit de boucles type prototype pour atteindre TOUS les éléments de prix et pas seulement le premier.
	    $('idml_price_detail_ht').innerHTML = pricehtValue + '&nbsp;' + js_SigneMonnaie + ''
		*/
	}

	var promottc = 0;
	var pricettcValue = "0";
	clearPromoDivs = false;
	if (pricettc.length) {
	    pricettcValue = pricettc[0].textContent || pricettc[0].text;
	}
	if (promopricettc.length){
		promottc = promopricettc[0].firstChild.nodeValue;
		if (parseFloat(promottc.replace(",", "."))) {
			/* Remplacé au profit de boucles type prototype pour atteindre TOUS les éléments de prix et pas seulement le premier.
			if ($('idml_price_detail_ttc')) {
				$('idml_price_detail_ttc').innerHTML = promottc +'&nbsp;'+ js_SigneMonnaie +'';
			}
			$('idml_promo_price_detail_ttc').innerHTML = pricettcValue + '&nbsp;' + js_SigneMonnaie + '';
			*/
			$$('.cssml_price_detail_ttc').each(function(elmt) {
				elmt.innerHTML = promottc +'&nbsp;'+ js_SigneMonnaie +'';
			});
			$$('.cssml_promo_price_detail_ttc').each(function(elmt) {
				elmt.innerHTML = pricettcValue +'&nbsp;'+ js_SigneMonnaie +'';
			});
		} else {
			clearPromoDivs = true;
		}
	} else {
		clearPromoDivs = true;
	}
	// Mise à jour des champs price en TTC
	if (pricettc.length && promottc==0){
		$$('.cssml_price_detail_ttc').each(function(elmt) {
			elmt.innerHTML = pricettcValue +'&nbsp;'+ js_SigneMonnaie +'';
		});
		/* Remplacé au profit de boucles type prototype pour atteindre TOUS les éléments de prix et pas seulement le premier.
	    $('idml_price_detail_ttc').innerHTML = pricettcValue + '&nbsp;' + js_SigneMonnaie + ''
		*/
	}		

	if (window.ProductOptions) {
		if (!promoprice.length){
		    ProductOptions.setBasePrice(priceValue.replace(",", "."))
		}else{
			ProductOptions.setBasePrice(promo.replace(",", "."))
		}
		ProductOptions.onUpdateStoreDetail();
	}
	
	if (reduction.length && promo!=0){
		$$('.cssml_reduction_detail').each(function(elmt) {
			elmt.innerHTML = (-parseFloat(reduction[0].textContent || reduction[0].text)) + '%';
			elmt.style.display = "";
		});
		/* Remplacé au profit de boucles type prototype pour atteindre TOUS les éléments de prix et pas seulement le premier.
		$('idml_reduction_obj').innerHTML = '-' + (reduction[0].textContent || reduction[0].text) + '%';
		$('idml_reduction_obj').style.display = "";
		*/
	} else {
		$$('.cssml_reduction_detail').each(function(elmt) {
			elmt.style.display = "none";
		});
	}
	
	if (reference.length){
		$$('.cssml_reference_detail').each(function(elmt) {
			elmt.innerHTML = reference[0].textContent || reference[0].text || "";
		});
		/*
		if ($('idml_reference_detail')){
		    $('idml_reference_detail').innerHTML = reference[0].textContent || reference[0].text;
		}
		*/
	}

	if (deliveryTime.length){
		$$('.cssml_delivery_time_detail').each(function(elmt) {
			elmt.innerHTML = deliveryTime[0].textContent || deliveryTime[0].text || "";
		});
		$$('.cssml_delivery_date_detail').each(function(elmt) {
			elmt.innerHTML = deliveryDate[0].textContent || deliveryDate[0].text || "";
		});
		$$('#idml_delivery_obj', '').each(function(elmt) {
			elmt.style.display = "";
		});
		/*
		if ($('idml_delivery_time_detail')){
		    $('idml_delivery_time_detail').innerHTML = deliveryTime[0].textContent || deliveryTime[0].text;
		}
		if ($('idml_delivery_date_detail')){
		    $('idml_delivery_date_detail').innerHTML = deliveryDate[0].textContent || deliveryDate[0].text;
		}
		if ($('idml_delivery_obj')){
			$('idml_delivery_obj').style.display='';
		}
		*/
	}else{
		$$('#idml_delivery_obj', '.cssml_delivery_obj').each(function(elmt) {
			elmt.style.display = "none";
		});
		/*
		if ($('idml_delivery_obj')){$('idml_delivery_obj').style.display='none';}
		*/
	}

	if (partnumber.length){
		$$('.cssml_partnumber_detail').each(function(elmt) {
			elmt.innerHTML = partnumber[0].textContent || partnumber[0].text || "";
		});
		/*
		if ($('idml_partnumber_detail')){
			$('idml_partnumber_detail').innerHTML = partnumber[0].textContent || partnumber[0].text;
		}
		*/
	}

	if (ean13.length){
		$$('.cssml_ean13_detail').each(function(elmt) {
			elmt.innerHTML = ean13[0].textContent || ean13[0].text || "";
		});
		/*
		if ($('idml_ean13_detail')){
			$('idml_ean13_detail').innerHTML = ean13[0].textContent || ean13[0].text;
		}
		*/
	}

	if (weight.length){
		productObj.setProperty('weight', weight[0].textContent || weight[0].text);
		$$('.cssml_weight_detail').each(function(elmt) {
			elmt.innerHTML = productObj.getProperty('weight');
		});
		/*
		if ($('idml_weight_detail')){
			$('idml_weight_detail').innerHTML = productObj.getProperty('weight');
		}
		*/
	}

	if (ecotax.length){
		$$('.cssml_ecotax_detail').each(function(elmt) {
			elmt.innerHTML = (ecotax[0].textContent || ecotax[0].text) +'&nbsp;'+js_SigneMonnaie+''
		});
		if ($('idml_ecotax_detail')){
			$('idml_ecotax_detail').innerHTML = (ecotax[0].textContent || ecotax[0].text) +'&nbsp;'+js_SigneMonnaie+''
		}
		ecotax = xhr.responseXML.getElementsByTagName('ecotax-ht');
		$$('.cssml_ecotax_detail_ht').each(function(elmt) {
			elmt.innerHTML = (ecotax[0].textContent || ecotax[0].text) +'&nbsp;'+js_SigneMonnaie+''
		});
		ecotax = xhr.responseXML.getElementsByTagName('ecotax-ttc');
		$$('.cssml_ecotax_detail_ttc').each(function(elmt) {
			elmt.innerHTML = (ecotax[0].textContent || ecotax[0].text) +'&nbsp;'+js_SigneMonnaie+''
		});
	}

	if (stock.length){
		var stockValue = stock[0].textContent || stock[0].text;
		productObj.setProperty('stock', stockValue);
		$$('.cssml_stock_detail').each(function(elmt) {
			elmt.innerHTML = stockValue;
		});
		/*
		if ($('idml_stock_detail')){
		    $('idml_stock_detail').innerHTML = stockValue;
		}
		*/
		//detection pour changer le texte du stock
		if (stockValue > 0) {
			if (objStock){objStock.style.display='';}
			if (objStockOk){objStockOk.style.display='';}
			if (objStockkO){objStockkO.style.display='none'}
		}else{
			if (objStock){objStock.style.display='none';}
			if (objStockOk){objStockOk.style.display='none';}
			if (objStockkO){objStockkO.style.display='';}
		}
	}	
	
	if (image.length){
		var mainImg = $('idml_image_main_img')
		if (mainImg && !mainImg.hasClassName('cssml_no-liveupdate')) {
			if (image[0].firstChild.nodeValue!=''){
				swpMainPics(image[0].firstChild.nodeValue,js_mainPicSize,js_mainPicSizeZoom)
			}else{
				swpMainPics(js_mainPicName,js_mainPicSize,js_mainPicSizeZoom)
			}
		}
	}
	
	//modifi l'id de la fiche pour prendre la sous référence

//} catch(any) {
//	alert(any);
//}	
	//verifie que le logo de chargement soit bien supprimé
	setTimeout("hideLoad()",100);

	if (typeof(onUpdateStoreDetail)=='function'){
		onUpdateStoreDetail();
	}
}

//verification si les options obligatoire sont bien rempli et ajouter au panier
function addToCart(idf,mainId){
	var qt=($('qt_'+mainId))?$('qt_'+mainId).value:'1';
	document.location.href='/_include/cart/cart.asp?action=add&idf='+idf+'&qt='+qt
}


function submitCart(){
	var bad=0
	
	if (SelectCharacteristic1){
		if (SelectCharacteristic1.value==''&&SelectCharacteristic1.options.length>1){bad=1}
	}
	if (SelectCharacteristic2){
		if (SelectCharacteristic2.value==''&&SelectCharacteristic2.options.length>1){bad=1}
	}
	if (SelectCharacteristic3){
		if (SelectCharacteristic3.value==''&&SelectCharacteristic3.options.length>1){bad=1}
	}
	
	if (bad==0){
		document.getElementById('detailProduct').submit();
	}else{
		alert("Vous devez sélectionner les options avant d'ajouter au panier.")
	}
}

function swpMainPics(name,size,zoom){
	mainPic=$('idml_image_main_img')
	mainPicA=$('idml_image_main_img_a')
	if (mainPic){
		if (mainPicA){
			mainPic.src='/images/store/'+size+'/'+name;
			mainPicA.href='/images/store/'+zoom+'/'+name;
			$$('.microzoom').each(function(elmt) {
				if (elmt.href.match('/images/store/'+zoom+'/'+name)&&elmt.id!='idml_image_main_img_a'&&elmt.rel=='gallery[mlstore]'){
					elmt.rel='';
				}else{
					if (elmt.rel==''){elmt.rel='gallery[mlstore]'};
				}
			});
			Lightview.updateViews();
		}else{
			mainPic.src='/images/store/'+size+'/'+name
			if (zoom>0){
				mainPic.onclick=function(){eval('modalDiv.show("'+name+'","'+zoom+'")')}
			}else{
				mainPic.onclick=null
			}
		}
	}
}


var modalDiv = {
	construct : function(){
		var divs_transparentDiv
		divs_transparentDiv = document.createElement('DIV');
		divs_transparentDiv.id='modaldiv';
		divs_transparentDiv.style.left='0px';
		divs_transparentDiv.style.top='0px';
		divs_transparentDiv.style.backgroundColor='#000000' 
		divs_transparentDiv.style.filter='alpha(opacity=75)' 
		divs_transparentDiv.style.opacity='0.75' 
		divs_transparentDiv.style.position='absolute'
    	divs_transparentDiv.style.width = document.body.scrollWidth + 'px';
    	divs_transparentDiv.style.height = document.body.scrollHeight + 'px';
		divs_transparentDiv.style.zIndex="200";
		divs_transparentDiv.style.cursor="pointer";
		divs_transparentDiv.onclick=function(){modalDiv.hide();};
		document.body.appendChild(divs_transparentDiv);
		
		div_picture = document.createElement('DIV');
		div_picture.id='idml_imageZoom_div';
		div_picture.className='cssml_imageZoom_div';
		div_picture.style.position='absolute'
		div_picture.style.border='1px solid #000000'	
		div_picture.style.backgroundColor='#FFFFFF' 
		div_picture.style.padding='8px'		
		div_picture.style.zIndex="201";
		//div_picture.style.display='none';
		div_picture.style.top='-400px'	
		document.body.appendChild(div_picture);	
		//$('idml_zoom_div').style.display='none'
	},
	
	hide : function(){
		$('modaldiv').style.display='none'
		$('idml_imageZoom_div').style.visibility='hidden'
		$('idml_imageZoom_div').style.top='-400px'	
		window.onscroll=null
	},
	
	show : function(imageName,Size){
		
		ModalObj=$('modaldiv')
		if (!ModalObj){
			modalDiv.construct();
			ModalObj=$('modaldiv')
		}
		


		pictureZoom=$('idml_pictureZoom_img')
		if (!pictureZoom){
			pictureZoom=document.createElement('IMG');
			pictureZoom.id='idml_pictureZoom_img';
			pictureZoom.onerror=function(){setDefaultPics(this,Size);}
			pictureZoom.onload=function(){centerPopup('idml_imageZoom_div')}
			pictureZoom.src='/images/store/'+Size+'/'+imageName
			pictureZoom.style.cursor="pointer";
			pictureZoom.onclick=function(){modalDiv.hide();};
			$('idml_imageZoom_div').appendChild(pictureZoom);

			
		}else{
			pictureZoom.src='/images/store/'+Size+'/'+imageName
		
		}
		
		
		
		window.onscroll=function(){
			centerPopup('idml_imageZoom_div')
		}
		
		$('modaldiv').style.display=''
		$('idml_imageZoom_div').style.display=''
		
		//centerPopup('idml_imageZoom_div')

				
	},
	
	resize : function(){
    	$('modaldiv').style.width = document.body.offsetWidth + 'px';
    	$('modaldiv').style.height = document.body.offsetHeight + 'px';
	}

}


function setDefaultPics(obj,Size){
	obj.src='/images/store/'+Size+'/error.png';
	obj.onclick=null;
	obj.style.cursor='';
}

function centerPopup(element) {
	document.getElementById(element).style.visibility=''
	
	var height=document.getElementById(element).offsetHeight;//hauteur de l'élément à positionner
	var width=document.getElementById(element).offsetWidth;//largeur de l'élément à positionner
	//alert(document.getElementById(element).offsetHeight+'--'+pHeight+'--'+-sTop)



	var myParent=document.getElementById(element).parentNode;
	var pHeight=myParent.clientHeight;//Hauteur de l'élément parent
	var pWidth=myParent.offsetWidth;//Largeur de l'élément parent
	var sTop=myParent.scrollTop;//Hauteur de défilement de l'élément parent
	var sLeft=myParent.scrollLeft;//Longueur de défilement de l'élément parent
//	var posY=(pHeight/2)-(height/2)+sTop;//Calcul de la position en Y
//	var posX=(pWidth/2)-(width/2)+sLeft;//Calcul de la position en X


	//alert(document.getElementById(element).offsetHeight+'--'+pHeight+'--'+-sTop)
	
	var posY=(pHeight-height)/2+sTop;//Calcul de la position en Y
	var posX=(pWidth/2)-(width/2)+sLeft;//Calcul de la position en X

	document.getElementById(element).style.left=posX+"px";
	document.getElementById(element).style.top=posY+"px";

}

function zoom(nomImage,sizeImage){
	alert('test')
	//modalDiv.show(nomImage,sizeImage);
}



function loadMlStoreListe(){

	objPriceHidden=$$('.cssml_price_span_hidden')[0]
	if (objPriceHidden){
		$$('.cssml_price_hidden').each(function(elmt) {
			elmt.hide()
		});		
	}else{
		$$('.cssml_price_hidden').each(function(elmt) {
			elmt.show()
		});		
	}

}


function loadMlStore(){
	//definition des varibles
	SelectCharacteristic1=$('id_characteristic_01')
	SelectCharacteristic2=$('id_characteristic_02')
	SelectCharacteristic3=$('id_characteristic_03')
 
	//detection pour masquer le tritre des Caractéristiques (option) 
	ObjCharacteristic1=$('idml_characteristic1_obj')
	ObjCharacteristic2=$('idml_characteristic2_obj')
	ObjCharacteristic3=$('idml_characteristic3_obj')
	
	objStock=$('idml_stock_obj')
	objStockOk=$('idml_stockok_obj')
	objStockkO=$('idml_stockko_obj')
	
	
	objReference=$('idml_reference_detail')
	
	//detection pour masquer le tritre des detail supplémentaires 
	objSupplement=$('idml_supplement_obj')
	tableSupplement=$('idml_supplement_table')
	if (objSupplement&&!tableSupplement){objSupplement.style.display="none"}
	
	objFavoriteProducts=$('idml_favorite_products_obj')
	tableFavoriteProducts=$('idml_favorite_products_table')
	if (objFavoriteProducts&&!tableFavoriteProducts){objFavoriteProducts.style.display="none"}
	
	objPromoProducts=$('idml_promo_products_obj')
	tablePromoProducts=$('idml_promo_products_table')
	if (objPromoProducts&&!tablePromoProducts){objPromoProducts.style.display="none"}
	
	objRelatedProducts=$('idml_related_products_obj')
	tableRelatedProducts=$('idml_related_products_table')
	if (objRelatedProducts&&!tableRelatedProducts){objRelatedProducts.style.display="none"}	
	
	
	objNewProducts=$('idml_new_products_obj')
	tableNewProducts=$('idml_new_products_table')
	if (objNewProducts&&!tableNewProducts){objNewProducts.style.display="none"}
	
	objExcluProducts=$('idml_exclu_products_obj')
	tableExcluProducts=$('idml_exclu_products_table')
	if (objExcluProducts&&!tableExcluProducts){objExcluProducts.style.display="none"}		
	
	objTopProducts=$('idml_top_products_obj')
	tableTopProducts=$('idml_top_products_table')
	if (objTopProducts&&!tableTopProducts){objTopProducts.style.display="none"}	

	
	objReviews=$('idml_reviews_obj')
	divReviews=$('idml_reviews_div')
	if (objReviews&&!divReviews){objReviews.style.display="none"}
	
	objReviews=$('idml_images_auto_obj')
	divReviews=$('idml_images_auto_table')
	if (objReviews&&!divReviews){objReviews.style.display="none"}	
	
	objPromo=$('idml_promo_obj')
	spanPromo=$('idml_promo_price_detail')
	if (objPromo&&spanPromo){
		if (spanPromo.innerHTML==''){
			objPromo.style.display="none"
		}
	}
	
	objRegularPrice=$('idml_regularprice_obj')
	spanRegularPrice=$('idml_regularprice_detail')
	if (objRegularPrice&&spanRegularPrice){
		if (spanRegularPrice.innerHTML==''){
			objRegularPrice.style.display="none"
		}
	}	
	
	objPriceHidden=$$('.cssml_price_span_hidden')[0]
	if (objPriceHidden){
		$$('.cssml_price_hidden').each(function(elmt) {
			elmt.hide()
		});		
	}else{
		$$('.cssml_price_hidden').each(function(elmt) {
			elmt.show()
		});		
	}

	
	objButtonAddToCart=$('id_button_addtocart')
	
	//gestion du bouton ajouter au panier
	if (objButtonAddToCart){
		objButtonAddToCart.onclick=addToCart;
		objButtonAddToCart.style.cursor='pointer';
	}
	
	updateProduct('', true);

	for (var cIdx=1; cIdx<=3; cIdx++) {
		var objOption= eval("SelectCharacteristic"+ cIdx);
		var divOption= eval("ObjCharacteristic"+ cIdx);
		
		if (!objOption) {
			if (divOption) {
				divOption.style.display = "none";
			}
		}
	}
	ProductOptions.onUpdateStoreDetail();
}

/*Store.js v2.0*/
ML.Store = {};

ML.Store.Product = Class.create({
	initialize: function() {
		this._ppty = {};
		ML.Store.Product.current = this;
	},
	
	updateDisplay: function() {
	},
	
	setId: function(value) {
		// déréférence l'ancien id
		var id = this._id;
		delete(ML.Store.Product._instances[id])
		// référence le nouvel id
		this._id = value;
		ML.Store.Product._instances[value] = this;
	},
	
	setProperty: function(name, value) {
		this._ppty[name] = value;
	},
	
	getProperty: function(name) {
		var value = this._ppty[name];
		return  typeof value != 'undefined' ? value : null;
	}
});
ML.Store.Product._instances = {};
ML.Store.Product.getById = function(id) {
	return ML.Store.Product._instances[id] || null;
}
