var Equalizer = new Class({ initialize: function(elements) { this.elements = $$(elements); }, equalize: function(hw) { if(!hw) { hw = 'height'; } var max = 0, prop = (typeof document.body.style.maxHeight != 'undefined' ? 'min-' : '') + hw; //ie6 ftl offset = 'offset' + hw.capitalize(); this.elements.each(function(element,i) { var calc = element[offset]; if(calc > max) { max = calc; } },this); this.elements.each(function(element,i) { element.setStyle(prop,max - (element[offset] - element.getStyle(hw).toInt())); }); return max; } }); var Site = { Page: { 'getBaseUrl': '', 'getBaseUrlWithServer': 'http://www.essix.be' }, init: function() { if($('addcart')){ var cart = $('addcart'); $('addcart').dispose(); $('center').adopt(cart); } $$('.learnmore').addEvent('click', function (e) { if(e.target.get('href')) var a = e.target; else var a = e.target.getParent('a'); var popup = Utils.popup(a.get('href'), 'learnmore', 650, 1000); if (popup) { popup.focus(); } e.stop(); }); if ($('collection')) { Site.collection(); } if ($('product')) { Site.product(); } if ($('last-product')) { Site.viewedProducts(); } if ($('home')) { Site.home(); } if ($('glossary')) { Site.glossary(); } if ($('fact_table')) { Site.orderaddress(); } if ($('outlets')) { Site.outlets(); } if ($('private_sales')) { Site.privatesales(); } if ($('current-private-sales')) { Site.mainprivatesales(); } Site.help(); Site.mainmenu(); Site.menuLeft(); Site.menuHover(); Site.sfHover(); Site.boutonHover(); Site.popupChangeLanguage(); if (!$('body_en')) { Site.showTips(); } }, viewedProducts : function() { new SlideItMoo({ overallContainer: 'thumb-gallery-wrap', elementScrolled: 'thumb-gallery', thumbsContainer: 'thumb-container', itemsVisible:3, elemsSlide:1, duration:200, navs: { 'bk': '.slider-bk-a', 'fwd': '.slider-fwd-b' }, itemsSelector: '.slider-product', itemWidth: 45, showControls:1, startIndex:1, onChange: function(index){} }); $$('.slider-product').addEvent('mouseenter', function(el){ var text = el.target.getParent('div').get('id'); $('viewedprod-name').set('html', text); }); $$('.slider-product').addEvent('mouseleave', function(el){ $('viewedprod-name').set('html', ''); }); }, mainmenu : function() { $$('.menu-cont').slide('hide'); $$('.menu-cont').getParent('div').setStyles({ position:'absolute', left:0, top:31, zIndex:9, width:'949px' }); $$('.main-cat').each( function(elem){ if (Browser.Engine.trident4) { var iframe = new Element('iframe'); iframe.setStyles({ position:'absolute', left:0, top:31, border: 'none', display: 'none', zIndex:8, width:'949px', background: '#6E635D', visibility: 'hidden', opacity: 0 }); elem.adopt(iframe); } var list = elem.getElement('.menu-cont'); elem.addEvents({ 'mouseenter' : function(){ list.setStyle('display','block'); list.set('slide', {duration: '500'}); list.slide('in'); var size = list.measure(function(){ return this.getSize(); }); if (Browser.Engine.trident4) { iframe.fade('in', {duration: '10000'}); iframe.setStyles({ display: 'block', height: size.y }); } }, 'mouseleave' : function(){ list.set('slide', {duration: '500'}); list.slide('out'); if (Browser.Engine.trident4) { iframe.fade('out'); iframe.setStyle('display','none'); } } }); }) }, menuLeft : function() { $$('.sub-categories').each(function(main){ if(!main.getParent('li').hasClass('on')){ main.slide('hide'); } }); $$('.menu-left li:not(li.sub-category)').each(function(elem){ if(!elem.hasClass('on')){ elem.addEvents({ 'mouseenter' : function(){ elem.addClass('on'); }, 'mouseleave' : function(){ elem.removeClass('on'); } }); } }); $$('li.category').each(function(elem){ var list = elem.getElement('ul.sub-categories'); if(list !== null){ if(!elem.hasClass('on')){ elem.addEvents({ 'mouseenter' : function(){ list.set('slide'); list.slide('in'); }, 'mouseleave' : function(){ list.set('slide'); list.slide('out'); } }); } } }); }, home: function() { var home = $('home'); if (home) { // Animation Flash /* new Swiff(Site.Page.getBaseUrl + '/flash/alex_turpault.swf', { id: 'alex_turpault_flash', width: 949, height: 390, container: $('homeflashmovie'), params: { quality: 'high', wMode: 'transparent', allowFullScreen: 'false', allowScriptAccess: 'sameDomain', bgcolor: '#f0edec' } });*/ } var privateSalePopupLogin = $('private-sale-login'); var overlay = new Overlay({ 'onClick': function(e) { this.hide(); }, 'container': $(document.body) }); if(privateSalePopupLogin){ var privateSalePopupLogin = $('private-sale-login').clone(); $('private-sale-login').dispose(); privateSalePopupLogin.set('id', 'private-sale-login'); privateSalePopupLogin.getElement('.private-sale-form-login').set('id', 'private-sale-form-login'); privateSalePopupLogin.fade('hide'); document.body.grab(privateSalePopupLogin, 'top'); var privateSalePopUp = function(){ if(!$('private-sale-subscribe') || $('private-sale-subscribe').getStyle('visibility') == 'hidden'){ privateSalePopupLogin.setStyle('display', ''); privateSalePopupLogin.fade('in'); overlay.show(); } $$('.modalcloselogin').addEvent('click', function() { $('private-sale-login').fade('hide'); overlay.hide(); }); } $$('.news-link').each(function(el){ if(el.getAttribute('href') == '' || el.getAttribute('href') == null){ el.addEvent('click', privateSalePopUp); } }); if($('private-sale-subscribe')){ overlay.show(); $('modal-close-subscribe').addEvent('click', function() { $('private-sale-subscribe').fade('hide'); overlay.hide(); }); } //privateSalePopupLogin.setStyle('display', 'none'); } }, privatesales: function() { var max_height = 0; $$('.listprod').each(function(privatesales){ privatesales.getElements('.product-wrap').each(function(el){ if(el.getElement('.tipzoom')){ var zoomButton = el.getElement('.privatesale-product-zoom'); if(zoomButton){ zoomButton.store('tip:text', el.getElement('.tipzoom')); el.getElement('.tipzoom').dispose(); tip = new Tips(zoomButton, { onShow: function(tip, image){ tip.fade('in'); tip.setStyle('opacity', 0.4); }, onHide: function(tip, image){ tip.fade('out'); tip.setStyle('opacity', 1); }, offset: {'x': 62, 'y': 0}, fixed: true }); } } }); }); }, mainprivatesales: function() { var privateSalePopupLogin = $('private-sale-login'); var overlay = new Overlay({ 'onClick': function(e) { this.hide(); }, 'container': $(document.body) }); if(privateSalePopupLogin){ var privateSalePopupLogin = $('private-sale-login').clone(); $('private-sale-login').dispose(); privateSalePopupLogin.set('id', 'private-sale-login'); privateSalePopupLogin.getElement('.private-sale-form-login').set('id', 'private-sale-form-login'); privateSalePopupLogin.fade('hide'); document.body.grab(privateSalePopupLogin, 'top'); var privateSalePopUp = function(){ if(!$('private-sale-subscribe') || $('private-sale-subscribe').getStyle('visibility') == 'hidden'){ privateSalePopupLogin.setStyle('display', ''); privateSalePopupLogin.fade('in'); overlay.show(); } $$('.modalcloselogin').addEvent('click', function() { $('private-sale-login').fade('hide'); overlay.hide(); }); } $$('.big-link').each(function(el){ if(el.getAttribute('href') == '' || el.getAttribute('href') == null){ el.addEvent('click', privateSalePopUp); } }); $$('.sale-pic').each(function(el){ if(el.getAttribute('href') == '' || el.getAttribute('href') == null){ el.addEvent('click', privateSalePopUp); } }); $$('.vp-link').each(function(el){ if(el.getAttribute('href') == '' || el.getAttribute('href') == null){ el.addEvent('click', privateSalePopUp); } }); } if($('private-sale-subscribe')){ overlay.show(); $('modal-close-subscribe').addEvent('click', function() { $('private-sale-subscribe').fade('hide'); overlay.hide(); }); } privateSalePopUp(); }, collection: function() { var collection = $('collection'); if (collection) { // Panier Site.cart(); // Affichage des descriptions var accordion = new Fx.Accordion(collection.getElements('.details .container h4'), collection.getElements('.details .container p'), { onActive: function(toggler, element) { toggler.addClass('on'); }, onBackground: function(toggler, element) { toggler.removeClass('on'); } }); // Zoom if (collection.getElement('.main-pict a')) { var a = collection.getElement('.main-pict a'); a.addEvent('click', function (ev) { var popup = Utils.popup(a.get('href'), 'productzoom', 680, 680); if (popup) { popup.focus(); } ev.stop(); }); } if (collection.getElements('.pict-product a')) { collection.getElements('.pict-product a').each(function(pictProduct) { if(pictProduct.hasClass('pict-01') || pictProduct.hasClass('pict-02')){ pictProduct.addEvent('click', function (ev) { var popup = Utils.popup(pictProduct.get('href'), 'productzoom', 680,680); if (popup) { popup.focus(); } ev.stop(); }); } }); } if(collection.getElement('.pict-01 img')){ var pict01 = collection.getElement('.pict-01 img'); pict01.addEvent('click', function(ev){ buildMinClick(Utils.basename(pict01.get('src')), Utils.dirname(Utils.dirname(pict01.get('src')))); collection.getElements('.selected').each(function(el){ el.removeClass('selected'); }); pict01.getParent('div').addClass('selected'); getProductInfo(ev); }); pict01.setStyle('cursor', 'pointer'); } if(collection.getElement('.pict-02 img')){ var pict02 = collection.getElement('.pict-02 img'); pict02.addEvent('click', function(ev){ buildMinClick(Utils.basename(pict02.get('src')), Utils.dirname(Utils.dirname(pict02.get('src')))); collection.getElements('.selected').each(function(el){ el.removeClass('selected'); }); pict02.getParent('div').addClass('selected'); //getProductInfo(ev); }); pict02.setStyle('cursor', 'pointer'); } // Affichage de la description if (collection.getElement('.details .description')) { var description = collection.getElement('.details .description').set('slide', {transition: 'quad:in'}).slide('hide'); var summary = collection.getElement('.details .summary').set('slide', {transition: 'quad:out'}); $('collection-get-description').addEvent('click', function (ev) { ev.stop(); summary.slide('out').get('slide').chain(function() { description.slide('in'); }); }); } // Envoyer à un ami collection.getElement('.sendfriend').addEvent('click', function (e) { var a = e.target.getParent('a'); var popup = Utils.popup(a.get('href'), 'sendfriend', 665, 635); if (popup) { popup.focus(); } e.stop(); }); // Affichage des produits var productsContainer = null; var productsReferences = []; var form = null; var request = null; var delay = null; var sumProducts = function(ev) { ev.target.removeEvents(); //ev.stop(); delay = null; var isSelectColor = false; var productSelected = false; if(ev.target.hasClass('product-color')){ isSelectColor = true; var idProduct = ev.target.getParent('tr').getElement('a.collection-product').get('id'); var id = idProduct.split('_')[0]; document.getElements('img[id^=img_]').each(function(el){ var elId = el.get('id').split('_')[1]; if(elId == id && el.getParent('div').hasClass('selected')){ productSelected = true; } }); } var requestProduct = new Request.HTML({ 'url': form.get('action') + '/partial/products', 'link': 'ignore', 'update': productsContainer, 'onRequest': function() { }, 'onComplete': function(el, el2) { // productsContainer.empty().adopt(el2); // el2.each(function(node) { // productsContainer.adopt(node); // } initProducts(); if(isSelectColor && productSelected){ document.getElements('img[id^=img_]').each(function(el){ var elId = el.get('id').split('_')[1]; if(elId == id){ var basename = Utils.basename(el.get('src')); var dirname = Utils.dirname(Utils.dirname(el.get('src'))); buildMinClick(basename, dirname); el.getParent('div').addClass('selected'); } }); } } }); requestProduct.send(form); } var sumProductsDelay = function(ev) { ev.target.removeEvents(); ev.stop(); if (null != delay) { $clear(delay); } delay = sumProducts.delay(1000, this, [ev]); } var getProductInfo = function(ev) { var referenceId = ev.target.get('id'); if(referenceId.split('_')[0] == 'img'){ var type = referenceId.split('_')[2]; var id = referenceId.split('_')[3]; } else { var type = referenceId.split('_')[1]; var id = referenceId.split('_')[2]; } var private = $$('input[type=hidden][name=private]'); if(private.length > 0){ var private_id = private.shift().get('value'); } if(private_id){ var datas = new Hash({'type' : type, 'id' : id, 'privatesale' : private_id}); } else { var datas = new Hash({'type' : type, 'id' : id}); } var container = $('collection-details'); new Request.HTML({ 'url' : Site.Page.getBaseUrl + '/collectionpartialdetails', 'update' : container, 'method' : 'post', 'onRequest' : container.fade('out'), 'onComplete' : function(){ (function(){container.fade('in')}).delay(300); var accordion = new Fx.Accordion(collection.getElements('.details .container h4'), collection.getElements('.details .container p'), { onActive: function(toggler, element) { toggler.addClass('on'); }, onBackground: function(toggler, element) { toggler.removeClass('on'); } }); Site.help(); }, 'data' : datas }).send(); //Selection de l'image correspondante au produit if(referenceId.split('_')[0] != 'img'){ var image = $('img_'+referenceId); if(image){ var basename = Utils.basename(image.get('src')); var dirname = Utils.dirname(Utils.dirname(image.get('src'))); buildMinClick(basename, dirname); collection.getElements('.selected').each(function(el){ el.removeClass('selected'); }); divPict = image.getParent('div'); divPict.addClass('selected'); } } } var initProducts = function() { productsContainer = collection.getElement('.products'); productsReferences = productsContainer.getElements('table tbody tr'); form = productsContainer.getElement('form'); request = new Request.HTML({ 'url': form.get('action') + '/partial/products', 'link': 'ignore', 'update': productsContainer, 'onRequest': function() { }, 'onComplete': function(el, el2) { // productsContainer.empty().adopt(el2); // el2.each(function(node) { // productsContainer.adopt(node); // } initProducts(); } }); $$('div.pict-product').each(function(pict){ if(!pict.hasClass('pict-01') && !pict.hasClass('pict-02')) pict.dispose(); }); productsReferences.each(function(productReference) { if (productReference.getElement('.collection-product')){ productReference.getElement('.collection-product').addEvent('click', getProductInfo); } if (productReference.getElement('img.product-quantity-plus')){ productReference.getElement('img.product-quantity-plus').addEvent('click', function(ev){ if(productReference.getElement('input.product-quantity')){ if(productReference.getElement('input.product-quantity').get('value') == '') var quantity = 0; else var quantity = productReference.getElement('input.product-quantity').get('value'); productReference.getElement('input.product-quantity').set('value', (parseInt(quantity) + 1)); sumProducts(ev); ev.target.removeEvents(); } }); } if (productReference.getElement('img.product-quantity-moins')){ productReference.getElement('img.product-quantity-moins').addEvent('click', function(ev){ if(productReference.getElement('input.product-quantity').get('value') == '') var quantity = 0; else var quantity = productReference.getElement('input.product-quantity').get('value'); if(productReference.getElement('input.product-quantity') && parseInt(quantity) > 0){ productReference.getElement('input.product-quantity').set('value', (parseInt(productReference.getElement('input.product-quantity').get('value')) - 1)); sumProducts(ev); ev.target.removeEvents(); } }); } var divOptions = document.getElement('.options'); if (productReference.getElement('.tipzoom')) { var basename = Utils.basename(productReference.getElement('.tipzoom').get('src')); var dirname = Utils.dirname(Utils.dirname(productReference.getElement('.tipzoom').get('src'))); var tip = null; var image = new Asset.image(dirname + '/100x100/' + basename, { onload: function () { tip = new Tips(productReference.getElement('.tipzoom'), { onShow: function(tip, el){ tip.fade('in'); tip.setStyle('opacity', 0.4); }, onHide: function(tip, el){ tip.fade('out'); tip.setStyle('opacity', 1); }, offset: {'x': 36, 'y': 0}, fixed: true }); productReference.getElement('.tipzoom').store('tip:text', image); } }); var pictMin = new Asset.image(dirname + '/91x91/' + basename); pictMin.set('id', 'img_'+ productReference.getElement('.collection-product').get('id')); pictMin.setStyle('cursor', 'pointer'); pictMin.addEvent('click', function(ev) { getProductInfo(ev); buildMinClick(basename, dirname); collection.getElements('.selected').each(function(el){ el.removeClass('selected'); }); divPict.addClass('selected'); }); var divContainer = $('pict-container'); var divPict = new Element('div'); divPict.addClass('pict-product'); divPict.adopt(pictMin); divContainer.adopt(divPict); } productReference.getElement('select.product-size').addEvent('change', sumProducts); productReference.getElement('select.product-color').addEvent('change', sumProducts); if (productReference.getElement('input.product-quantity')) { productReference.getElement('input.product-quantity').addEvents({ 'change': sumProducts, 'keyup': sumProductsDelay }); } }); new SlideItMoo({ overallContainer: 'pict-gallery-wrap', elementScrolled: 'pict-gallery', thumbsContainer: 'pict-container', itemsVisible:7, elemsSlide:1, duration:200, itemsSelector: '.pict-product', itemWidth: 97, showControls:1, startIndex:1, onChange: function(index){} }); } var buildMinClick = function(basename, dirname) { var pictA = new Element('a'); var imageContainer = document.getElement('.main-pict'); imageContainer.fade('out'); pictA.set('target', 'blank'); var imgZ = new Asset.image(dirname + '/318x318/' + basename, { onload: function () { pictA.set('href', Site.Page.getBaseUrl+'/imagepopup.html?image='+ imgZ.src.replace('/318x318', '')); pictA.src = imgZ.src; pictA.adopt(imgZ); pictA.addEvent('click', function (ev) { var popup = Utils.popup(pictA.get('href'), 'productzoom', 680, 680); if (popup) { popup.focus(); } ev.stop(); }); } }); var imgZoom = new Element('img'); imgZoom.addClass('zoom'); imgZoom.set('alt', 'zoom'); imgZoom.set('src', Site.Page.getBaseUrl + '/images/bt/zoom_01.gif'); pictA.adopt(imgZoom); imageContainer.empty(); imageContainer.adopt(pictA); (function(){imageContainer.fade('in')}).delay(300); } initProducts(); } }, product: function() { var product = $('product'); if (product) { // Panier Site.cart(); // Produits recement consultés // Affichage des descriptions var accordion = new Fx.Accordion(product.getElements('.details .container h4'), product.getElements('.details .container p'), { onActive: function(toggler, element) { toggler.addClass('on'); }, onBackground: function(toggler, element) { toggler.removeClass('on'); } }); // Envoyer à un ami product.getElement('.sendfriend').addEvent('click', function (e) { var a = e.target.getParent('a'); var popup = Utils.popup(a.get('href'), 'sendfriend', 665, 635); if (popup) { popup.focus(); } e.stop(); }); // Affichage des references var productContainer = null; var form = null; var request = null; var delay = null; var imageContainer = product.getElement('.main-pict'); var imagesCache = []; var sumProduct = function(ev) { request.send(form); requestDetail.send(form); ev.stop(); ev.target.removeEvents(); delay = null; } var sumProductDelay = function(ev) { if (null != delay) { $clear(delay); } ev.target.removeEvents(); delay = sumProduct.delay(1000, this, [ev]); ev.stop(); } var initProduct = function() { productContainer = product.getElement('.product'); productDetail = product.getElement('.product-details'); productReference = productContainer.getElement('table tbody tr'); form = productContainer.getElement('form'); request = new Request.HTML({ 'url': form.get('action') + '/partial/product', 'update': productContainer, 'link': 'ignore', 'encoding' : 'iso-8859-15', 'onRequest': function() { //productContainer.empty(); // Pour Safari 3 et 4 }, 'onComplete': initProduct }); requestDetail = new Request.HTML({ 'url' : form.get('action') + '/partial/productdetail', 'update' : productDetail, 'link': 'ignore', 'encoding' : 'ISO-8859-15' }); productReference.getElement('select.product-size').addEvent('change', sumProduct); productReference.getElement('select.product-color').addEvent('change', sumProduct); if (productReference.getElement('input.product-quantity')) { productReference.getElement('input.product-quantity').addEvents({ 'change': sumProduct, 'keyup': sumProductDelay }); } if (productReference.getElement('img.product-quantity-plus')){ productReference.getElement('img.product-quantity-plus').addEvent('click', function(ev){ if(productReference.getElement('input.product-quantity')){ productReference.getElement('input.product-quantity').set('value', (parseInt(productReference.getElement('input.product-quantity').get('value')) + 1)); sumProduct(ev); ev.target.removeEvents(); } }); } if (productReference.getElement('img.product-quantity-moins')){ productReference.getElement('img.product-quantity-moins').addEvent('click', function(ev){ if(productReference.getElement('input.product-quantity') && parseInt(productReference.getElement('input.product-quantity').get('value')) > 1){ productReference.getElement('input.product-quantity').set('value', (parseInt(productReference.getElement('input.product-quantity').get('value')) - 1)); sumProduct(ev); ev.target.removeEvents(); } }); } initImageMain(); if (productReference.getElement('input[name=reference-id]')) { crossSelling(productReference.getElement('input[name=reference-id]').get('value')); } requestDetail.send(form); } var initImageMain = function() { var refField = productReference.getElement('input[@name=reference-id]'); if (refField) { var ref = refField.get('value'); if (!imagesCache[ref]) { var url = productContainer.getElement('form').action; var slug = url.substring(url.lastIndexOf("/")+1); var jsonRequest = new Request.JSON({ url: Site.Page.getBaseUrl + "/js/json/image.php", onSuccess: function(images) { imagesCache[ref] = new Array(); i=0; images.each(function(image) { imagesCache[ref][i] = new Asset.image(image.src, { }); i++; }); majImage(ref); } }).get({'slug': slug, 'ref': ref}); } else { majImage(ref); } } } var majImage = function(ref) { if (imagesCache[ref]) { imageContainer.empty(); $$('div.pict-01').each(function(image1) { image1.empty() }); $$('div.pict-02').each(function(image2) { image2.empty() }); if (imagesCache[ref][0]) { imageContainer.adopt(buildImageMain(imagesCache[ref][0])); $$('div.pict-01').each(function (image1) { image1.adopt(buildImageMain(imagesCache[ref][0], 100, true)); }); } if (imagesCache[ref][1]) { $$('div.pict-02').each(function (image1) { image1.adopt(buildImageMain(imagesCache[ref][1], 100, true)); }); } } } var buildMinClick = function(basename, dirname) { var pictA = new Element('a'); var imageContainer = document.getElement('.main-pict'); imageContainer.fade('out'); pictA.set('target', 'blank'); var imgZ = new Asset.image(dirname + '/318x318/' + basename, { onload: function () { pictA.set('href', Site.Page.getBaseUrl+'/imagepopup.html?image='+ imgZ.src.replace('/318x318', '')); pictA.src = imgZ.src; pictA.adopt(imgZ); pictA.addEvent('click', function (ev) { var popup = Utils.popup(pictA.get('href'), 'productzoom', 680, 680); if (popup) { popup.focus(); } ev.stop(); }); } }); var imgZoom = new Element('img'); imgZoom.addClass('zoom'); imgZoom.set('alt', 'zoom'); imgZoom.set('src', Site.Page.getBaseUrl + '/images/bt/zoom_01.gif'); pictA.adopt(imgZoom); imageContainer.empty(); imageContainer.adopt(pictA); (function(){imageContainer.fade('in')}).delay(300); } var buildImageMain = function(image, size, withoutZoom) { if (!size) size = 318; var a = new Element('a'); // a.set('href', Site.Page.getBaseUrl+'/imagepopup.html?image=' + image.src); // a.set('target', '_blank'); var basename = Utils.basename(image.src); var dirname = Utils.dirname(image.src); var thumb = new Asset.image(dirname + '/' + size + 'x' + size + '/' + basename, { onload: function () { a.adopt(thumb); a.addEvent('click', function (ev) { // var popup = Utils.popup(a.get('href'), 'productzoom', 680, 680); // if (popup) { // popup.focus(); // } // ev.stop(); $$('.pict-01.selected').removeClass('selected'); $$('.pict-02.selected').removeClass('selected'); ev.target.getParent('div').addClass('selected'); buildMinClick(basename, dirname); }); } }); if (!withoutZoom) { var imgZoom = new Element('img'); imgZoom.addClass('zoom'); imgZoom.set('alt', 'zoom'); imgZoom.set('src', Site.Page.getBaseUrl + '/images/bt/zoom_01.gif'); a.adopt(imgZoom); } return a; } var crossSelling = function(ref) { new Request.HTML({ 'url': Site.Page.getBaseUrl + '/crossselling.html?id_reference=' + ref, 'update': 'cross-selling', 'link': 'cancel' }).send(); } new SlideItMoo({ overallContainer: 'pict-gallery-wrap', elementScrolled: 'pict-gallery', thumbsContainer: 'pict-container', itemsVisible:7, elemsSlide:1, duration:200, itemsSelector: '.pict-product', itemWidth: 97, showControls:1, startIndex:1, onChange: function(index){} }); initProduct(); } }, cart: function() { if ($('addcart')) { var cartPopup = $('addcart'); var setClearClosePopupDelay = null; cartPopup.setStyle('display', 'block'); var openPopup = function (ev) { cartPopup.fade('in'); } var openPopupDelay = function (ev) { cartPopup.fade('hide'); openPopup.delay(1000, this, [ev]); } var closePopup = function (ev) { cartPopup.fade('out'); } var closePopupDelay = function (ev) { setClearClosePopupDelay = closePopup.delay(8000, this, [ev]); } var clearClosePopupDelay = function (ev) { $clear(setClearClosePopupDelay); } cartPopup.addEvent('mouseenter', clearClosePopupDelay); cartPopup.addEvent('mouseleave', closePopupDelay); cartPopup.getElements('.button-close').each(function(el){ el.addEvent('click', closePopup); }); openPopupDelay(); closePopupDelay(); } }, glossary: function() { var glossary = $('glossary'); if (glossary) { var myAccordion = new Accordion(glossary, 'h4.toggler2', 'div.element2', { opacity: false, display:-1, onActive: function(toggler, element){ toggler.addClass('toggler2-on'); }, onBackground: function(toggler, element){ toggler.removeClass('toggler2-on'); } }); var found = 0; $$('h4.toggler2').each(function(link, i){ var hashId = window.location.hash.match(/#([0-9]+)/)[1]; if (window.location.hash.test(link.get('id'))){ found = i; link.addClass('toggler2-on'); myAccordion.display(i); } }); } }, help: function() { var slideHelpers = $$('.slide-helper'); if (slideHelpers) { slideHelpers.each(function(slideHelper) { new Accordion(slideHelper.getElement('.accordion'), slideHelper.getElements('.toggler'), slideHelper.getElements('.element'), { opacity: false, alwaysHide: true, display: -1 }); }); } var words = $$('def.glossary'); var i = 0; if (words) { var wordsRequest = []; var wordsReferences = new Hash(); var i = 0; words.each(function(word) { if(word.get('title')){ var dual = word.get('title').split('::'); if (dual.length > 1){ name = dual[0].trim(); } else { name = word.get('title').trim(); } if (!wordsRequest.contains(name)) { wordsRequest.push(name); wordsReferences.set(wordsReferences.getLength(), new Hash({'word': name, 'references': []})) } wordsReferences.each(function(value, key) { if (value.get('word') == name) { value.get('references').push(word); } }); } }); new Request.HTML({ url: Site.Page.getBaseUrl + '/glossarypartialwords', method: 'post', data: new Hash({'words': wordsRequest}).toQueryString(), link: 'cancel', onSuccess: function(responseTree, responseElements, responseHTML, responseJavaScript) { var interpreter = new Element('div').set('html', responseHTML); if (element = interpreter.getElement('*')) { element.getElements('.word').each(function (word) { var name = word.getElement('.name').get('text').trim(); wordsReferences.each(function(value, key) { if (value.get('word') == name) { value.get('references').each(function(reference){ reference.store('tip:title', ''); if(word.getElement('.description')){ reference.store('tip:text', word.get('html')); } }); } }); }); } interpreter.dispose(); var glossaryTips = new Tips('.glossary', {'hideDelay' : 2000}); glossaryTips.addEvents({ 'show': function(tip) { tip.fade('in', {duration : 'short'}); }, 'hide': function(tip) { tip.fade('out'); } }); } }); // }).send(); } }, orderaddress: function() { var slide = new Fx.Slide($('fact_table')); $('address_invoice_diff').addEvent('click', function() { if ($('address_invoice_diff').get('checked')) { slide.slideIn(); } else { slide.slideOut(); } }); if (!$('address_invoice_diff').get('checked')) { slide.hide(); } function deliveryFocus() { if (! $('delivery_address_0').get('checked')) { $('delivery_address_0').set('checked', true); } } $$('#delivery_id_civility', '#delivery_last_name', '#delivery_first_name', '#delivery_address_line_1', '#delivery_address_line_2', '#delivery_postal_code', '#delivery_city', '#delivery_phone_number').addEvent('focus', deliveryFocus); function invoiceFocus() { if (! $('invoice_address_0').get('checked')) { $('invoice_address_0').set('checked', true); } } $$('#invoice_id_civility', '#invoice_last_name', '#invoice_first_name', '#invoice_address_line_1', '#invoice_address_line_2', '#invoice_postal_code', '#invoice_city', '#invoice_id_country', '#invoice_phone_number').addEvent('focus', invoiceFocus); }, outlets : function() { var getRegionOutlets = function (ev) { var addressContainer = $('outlet-address'); var id = ev.target.get('id'); var request = new Request.HTML({ 'url': Site.Page.getBaseUrl + '/outletspartialaddress', 'update': addressContainer, 'data' : new Hash({'id_region' : id}), 'onRequest': function() { } }); request.send(); } var getCountryOutlets = function(ev) { var addressContainer = $('outlet-address'); var id = ev.target.get('value'); var request = new Request.HTML({ 'url': Site.Page.getBaseUrl + '/outletspartialaddress', 'update': addressContainer, 'data' : new Hash({'id_country' : id}), 'onRequest': function() { } }); request.send(); } $$('area.map-resellers').each(function(region){ region.addEvent('click', getRegionOutlets); }); $$('option.outlet-country').each(function(country){ country.addEvent('click', getCountryOutlets); }); var showAddress = function (address) { geocoder.getLatLng( address, function(point) { if (!point) { alert(address + " not found"); } else { map.setCenter(point, 13); var marker = new GMarker(point); map.addOverlay(marker); marker.openInfoWindowHtml(address); } } ); } if($('left-map-google')){ var map = new GMap2(document.getElementById("left-map-google")); var geocoder = new GClientGeocoder(); map.setUIToDefault(); var address = $$('p.address'); var city = $$('p.city'); var fullAddress = address.get('html') +', '+ city.get('html'); showAddress(fullAddress); } }, menuHover : function() { $$('img.hova').each(function(img) { var fire = img.getParent('li'); var src = img.getProperty('src'); var extension = src.substring(src.lastIndexOf('.'),src.length); fire.addEvents({ 'mouseenter' : function() { img.setProperty('src',src.replace(extension,'_ho' + extension)); }, 'mouseleave' : function() { img.setProperty('src',src); } }); }); }, sfHover : function() { $$('.listprod .product-wrap').each(function(sfh) { sfh.addEvents({ 'mouseenter' : function() { sfh.addClass('sfhover'); }, 'mouseleave' : function() { sfh.removeClass('sfhover'); } }); }); }, boutonHover : function() { $$('.button-full, .bouton-gris').each(function(sfh) { sfh.addEvents({ 'mouseenter' : function() { sfh.addClass('bouton-gris-hover'); }, 'mouseleave' : function() { sfh.removeClass('bouton-gris-hover'); } }); }); $$('.bouton-rouge').each(function(sfh) { sfh.addEvents({ 'mouseenter' : function() { sfh.addClass('bouton-rouge-hover'); }, 'mouseleave' : function() { sfh.removeClass('bouton-rouge-hover'); } }); }); }, showTips : function() { $$('.footer-tips .tip').setStyle('display','none'); $$('.footer-tips .tip').fade('out'); $$('.footer-tips').each( function(elem){ var tips = elem.getElement('div'); elem.addEvents({ 'mouseenter' : function(){ tips.setStyle('display','block'); tips.fade(0.85); }, 'mouseleave' : function(){ tips.fade('0'); } }); }) $$('.close-tip').each( function(elem){ var tips = elem.getParent('div'); elem.addEvents({ 'click' : function(){ tips.fade('0'); } }); }) }, popupChangeLanguage: function() { var changeLanguage = $('change-language'); var overlay = new Overlay({ 'onClick': function(e) { this.hide(); }, 'container': $(document.body) }); var link = changeLanguage.getChildren('a'); var popup = $('change-language-popup'); link.addEvent('click', function() { popup.setStyle('display', ''); popup.fade('in'); new Equalizer('.equalize').equalize('height'); overlay.show(); return false; }); $$('.modalcloselogin').addEvent('click', function() { popup.fade('out'); overlay.hide(); }); $('btn-yes').addEvent('click', function() { window.location.href = link.get('href'); }); $('btn-no').addEvent('click', function() { popup.fade('out'); overlay.hide(); }); } } function equalize() { var listProduct = new Equalizer('.listprod .product').equalize('height'); var list = new Equalizer('.equalize').equalize('height'); } window.addEvent('domready', Site.init);