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 = ML.Store.firstLoad ? $('mainId').value || (preselected + '') || 'false' : 'false';
ML.Store.firstLoad = 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};
var dateFormats = [];
$$('.cssml_promoend_value,.cssml_promostart_value').each(function(item, index) {
dateFormats.push(item.readAttribute('data-format'));
})
pars.dateFormats = dateFormats.uniq().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 promostart = xhr.responseXML.getElementsByTagName('promostart');
var promoend = xhr.responseXML.getElementsByTagName('promoend');
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 preparationDelay = xhr.responseXML.getElementsByTagName('preparation-delay');
var deliveryOvercostHt = xhr.responseXML.getElementsByTagName('delivery-overcost-ht');
var deliveryOvercostTtc = xhr.responseXML.getElementsByTagName('delivery-overcost-ttc');
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) {
var option = objOption.options[0];
if (!option) {
option = new Option(texte, texte);
objOption.option[0] = option;
}
option.text = 'Sélectionnez...'
objOption.options.length=1;
} else {
objOption.options.length=0;
}
if(characteristic.length<=1) {
objOption.options.length=0;
}
var selectedIndex = 0;
for (var i=0 ; i 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)
}
}
}
if (window.ProductOptions) {
if (stock.length) ProductOptions.setStocks(stockValue);
if (!promoprice.length){
ProductOptions.setBasePrice(priceValue.replace(",", "."))
}else{
ProductOptions.setBasePrice(promo.replace(",", "."))
}
ProductOptions.onUpdateStoreDetail();
}
//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 = {
firstLoad : true
};
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;
}