var Shop = { start : function(){ if(document.id('products')) Shop.makeScrollbar(); if (!Browser.Engine.trident) { if($('cartselect')) Shop.initPrice(); Shop.Tiptoes(); } else { if (!Browser.Engine.trident4) { Shop.Tiptoes(); } if($('cartselect') && $('country')){ dynSelect('country', 'blades_id', 'shafts_id'); } } if(document.id('masker')) { var sliders = document.id('masker').getElements('img'); if(sliders.length>1) Shop.PlaySliders(sliders); } //Shop.setUpScrollAnchors(); if(document.id('btn_buy')) Shop.buy(); if(document.id('btn-paddle')) { document.id('btn-paddle').addEvent('click', function(e) { e.stop(); Shop.AddtoCart('paddle'); }); } }, PlaySliders : function(sliders) { var slideshow = new viewer(sliders, { mode: 'alpha', interval: 3500 }); var controller= document.id('controller'); controller.setStyle('display','block') controller.addEvent('click', function(e) { e.stop(); if(controller.getStyle('background-position')=='0px 0px') { controller.setStyle('background-position','0px -32px') slideshow.play(); } else { controller.setStyle('background-position','0px 0px') slideshow.stop(); } }); }, Tiptoes : function() { var regExpressionNonObj= /;;/g; $$('a.tipz').each(function(element,index) { var content=element.get('title'); if(content) { var content=content.replace(regExpressionNonObj, '
'); var content = content.split('::'); element.store('tip:title', content[0]); element.store('tip:text', content[1]); } }); //create the tooltips var tipz = new Tips('.tipz',{ className: 'tipz', fixed: false, offsets:{'x':0, 'y':0}, hideDelay: 50, showDelay: 50 }); /* tipz.addEvents({ 'show': function(tip) { tip.fade('in'); }, 'hide': function(tip) { tip.fade('out'); } }); */ }, makeScrollbar:function(){ var ProdScroll = new ScrollBar('products', 'bar', 'knob', { slider: { offset: -1, onComplete: function(pos){ Shop.LightProds(pos); } } }); ProdScroll.set(0); Shop.InitProds(); }, InitProds:function(position) { var racings = $$("#products li a img.racing"); racings.each(function(el, i){ el.fade(1); el.addClass('fullhover'); }, this); }, LightProds: function(position) { //console.log(position); var alls= $$("#products li a img"); var racings = $$("#products li a img.racing"); var tourings = $$("#products li a img.touring"); var wws = $$("#products li a img.whitewater"); var canoes = $$("#products li a img.canoe-raft"); var outriggers = $$("#products li a img.outrigger"); var sups = $$("#products li a img.sup"); alls.each(function(el, i){ el.fade(0.7); }, this); if( position < 100) { tourings.each(function(el, i){ el.setProperty('class', 'touring'); }, this); wws.each(function(el, i){ el.setProperty('class', 'whitewater'); }, this); canoes.each(function(el, i){ el.setProperty('class', 'canoe-raft'); }, this); outriggers.each(function(el, i){ el.setProperty('class', 'outrigger'); }, this); sups.each(function(el, i){ el.setProperty('class', 'sup'); }, this); racings.each(function(el, i){ el.fade(1); el.addClass('fullhover'); }, this); } // touring middle pos=283 if(position >= 100 && position < 580) { racings.each(function(el, i){ el.setProperty('class', 'racing'); }, this); wws.each(function(el, i){ el.setProperty('class', 'whitewater'); }, this); canoes.each(function(el, i){ el.setProperty('class', 'canoe-raft'); }, this); outriggers.each(function(el, i){ el.setProperty('class', 'outrigger'); }, this); sups.each(function(el, i){ el.setProperty('class', 'sup'); }, this); tourings.each(function(el, i){ el.fade(1); el.addClass('fullhover'); }, this); } // whitewater middle pos=680 if(position >= 580 && position < 705) { racings.each(function(el, i){ el.setProperty('class', 'racing'); }, this); tourings.each(function(el, i){ el.setProperty('class', 'touring'); }, this); canoes.each(function(el, i){ el.setProperty('class', 'canoe-raft'); }, this); outriggers.each(function(el, i){ el.setProperty('class', 'outrigger'); }, this); sups.each(function(el, i){ el.setProperty('class', 'sup'); }, this); wws.each(function(el, i){ el.fade(1); el.addClass('fullhover'); }, this); } // canoe/raft middle pos=680 if(position >= 705 && position < 920) { racings.each(function(el, i){ el.setProperty('class', 'racing'); }, this); tourings.each(function(el, i){ el.setProperty('class', 'touring'); }, this); wws.each(function(el, i){ el.setProperty('class', 'whitewater'); }, this); outriggers.each(function(el, i){ el.setProperty('class', 'outrigger'); }, this); sups.each(function(el, i){ el.setProperty('class', 'sup'); }, this); canoes.each(function(el, i){ el.fade(1); el.addClass('canoehover'); }, this); } // outrigger middle pos=1017 if(position >= 920 && position < 1080) { racings.each(function(el, i){ el.setProperty('class', 'racing'); }, this); tourings.each(function(el, i){ el.setProperty('class', 'touring'); }, this); wws.each(function(el, i){ el.setProperty('class', 'whitewater'); }, this); canoes.each(function(el, i){ el.setProperty('class', 'canoe-raft'); }, this); sups.each(function(el, i){ el.setProperty('class', 'sup'); }, this); outriggers.each(function(el, i){ el.fade(1); el.addClass('canoehover'); }, this); } if(position >= 1080) { racings.each(function(el, i){ el.setProperty('class', 'racing'); }, this); tourings.each(function(el, i){ el.setProperty('class', 'touring'); }, this); wws.each(function(el, i){ el.setProperty('class', 'whitewater'); }, this); canoes.each(function(el, i){ el.setProperty('class', 'canoe-raft'); }, this); outriggers.each(function(el, i){ el.setProperty('class', 'outrigger'); }, this); sups.each(function(el, i){ el.fade(1); el.addClass('fullhover'); }, this); } }, CartAccept:function() { var acceptlbl=$('accept'); var is_checked=$('acceptance').checked; if(is_checked == false) { alert('Vous devez accepter les conditions de vente.'); return false; } else { $('lost').submit(); } }, UpdateLength : function(specs, specoptions, lengths, lengthoptions) { // get selectedIndex var i, shaftslt=specs.options[specs.selectedIndex]; // let's init the list to the single first option for(i=(lengthoptions.length - 1); i>=1; i--){ lengths.remove(i); } if(specs.options[specs.selectedIndex].value==0) { for (var i = 0; i < lengthoptions.length; i++) { if (lengthoptions[i].hasClass('select')) { // Clone the option from the hidden option pool and append it to the dynamic select box lengths.appendChild(lengthoptions[i].cloneNode(true)); } } } else { if(shaftslt.hasClass('vario')) { for (var i = 0; i < lengthoptions.length; i++) { if (lengthoptions[i].hasClass('vario')) { // Clone the option from the hidden option pool and append it to the dynamic select box lengths.appendChild(lengthoptions[i].cloneNode(true)); } } } if(shaftslt.hasClass('fixed')) { for (var i = 0; i < lengthoptions.length; i++) { if (lengthoptions[i].hasClass('fixed')) { // Clone the option from the hidden option pool and append it to the dynamic select box lengths.appendChild(lengthoptions[i].cloneNode(true)); } } } if(shaftslt.hasClass('ergo')) { for (var i = 0; i < lengthoptions.length; i++) { if (lengthoptions[i].hasClass('ergo')) { // Clone the option from the hidden option pool and append it to the dynamic select box lengths.appendChild(lengthoptions[i].cloneNode(true)); } } } } }, UpdatePrice : function(what, countryval, items, specs, itemoptions, specoptions) { // let's write the php euro list var expeuro = $('zoneuro'), expworld = $('zoneworld'); var listeuro = new Array('DE','AT','BE','ES','FI','FR','GR','IE','IT','LU','NL','PT','HU','PL','CY','CZ','DK','LV','GB','LT','SK','EE','SI','MT','SE','MC'); var i, j; if(what=='blades') { // let's init the list to the single first option for(i=(itemoptions.length - 1); i>=1; i--){ items.remove(i); } for(j=(specoptions.length - 1); j>=1; j--){ specs.remove(j); } if(countryval==0) { expeuro.setStyles({'display' : 'none', 'opacity': 0}); expworld.setStyles({'display' : 'none', 'opacity': 0}); for (var i = 0; i < itemoptions.length; i++) { if (itemoptions[i].hasClass('select')) { // Clone the option from the hidden option pool and append it to the dynamic select box items.appendChild(itemoptions[i].cloneNode(true)); } } for (var j = 0; j < specoptions.length; j++) { if (specoptions[j].hasClass('select')) { // Clone the option from the hidden option pool and append it to the dynamic select box specs.appendChild(specoptions[j].cloneNode(true)); } } } else { // let's inject according to country if (new RegExp('^(' + listeuro.join('|') + ')$').test(countryval)) { expworld.setStyles({'display' : 'none', 'opacity': 0}); expeuro.setStyles({'display' : 'block', 'opacity': 1}); for (var i = 0; i < itemoptions.length; i++) { if (itemoptions[i].hasClass('euro')) { // Clone the option from the hidden option pool and append it to the dynamic select box items.appendChild(itemoptions[i].cloneNode(true)); } } for (var j = 0; j < specoptions.length; j++) { if (specoptions[j].hasClass('euro')) { // Clone the option from the hidden option pool and append it to the dynamic select box specs.appendChild(specoptions[j].cloneNode(true)); } } // let's display the right notes about price } else { expeuro.setStyles({'display' : 'none', 'opacity': 0}); expworld.setStyles({'display' : 'block', 'opacity': 1}); for (var i = 0; i < itemoptions.length; i++) { if (itemoptions[i].hasClass('world')) { // Clone the option from the hidden option pool and append it to the dynamic select box items.appendChild(itemoptions[i].cloneNode(true)); } } for (var j = 0; j < specoptions.length; j++) { if (specoptions[j].hasClass('world')) { // Clone the option from the hidden option pool and append it to the dynamic select box specs.appendChild(specoptions[j].cloneNode(true)); } } } } } else { // case regular products var selects = $('cartselect').getElements('select'), i,j; var countries =document.getElements('input[name=country]'); // let's init the list to the single first option for (var i = 1; i=1; j--){ selects[i].remove(j); } } countries.setProperty('value', countryval); if(countryval==0) { expeuro.setStyles({'display' : 'none', 'opacity': 0}); expworld.setStyles({'display' : 'none', 'opacity': 0}); for (var i = 1; i < selects.length; i++) { for (var j = 0; j < itemoptions[i].length; j++) { if (itemoptions[i][j].hasClass('select')) { // Clone the option from the hidden option pool and append it to the dynamic select box selects[i].appendChild(itemoptions[i][j].cloneNode(true)); } } } } else { if (new RegExp('^(' + listeuro.join('|') + ')$').test(countryval)) { expworld.setStyles({'display' : 'none', 'opacity': 0}); expeuro.setStyles({'display' : 'block', 'opacity': 1}); for (var i = 1; i < selects.length; i++) { for (var j = 0; j < itemoptions[i].length; j++) { if (itemoptions[i][j].hasClass('euro')) { // Clone the option from the hidden option pool and append it to the dynamic select box selects[i].appendChild(itemoptions[i][j].cloneNode(true)); } } } } else { expeuro.setStyles({'display' : 'none', 'opacity': 0}); expworld.setStyles({'display' : 'block', 'opacity': 1}); for (var i = 1; i < selects.length; i++) { for (var j = 0; j < itemoptions[i].length; j++) { if (itemoptions[i][j].hasClass('world')) { // Clone the option from the hidden option pool and append it to the dynamic select box selects[i].appendChild(itemoptions[i][j].cloneNode(true)); } } } } } } }, initPrice : function() { if(document.id('blades_id')) { var items = document.id('blades_id'), specs = document.id('shafts_id'), itemoptions=items.getElements('option'), specoptions=specs.getElements('option'); var selects = $('cartselect').getElements('select'); if(selects[0].id=='country') { countryslt=document.id('country'); countrycontainer=countryslt.getParent('p.steps'); countryslt.addEvent('change', function(){ Shop.UpdatePrice('blades', selects[0].value, items, specs, itemoptions, specoptions); if(countrycontainer.hasClass('warn') && countryslt.value!='0' ) { countrycontainer.removeClass('warn'); } }); // let's init the function on domready Shop.UpdatePrice('blades', selects[0].value, items, specs, itemoptions, specoptions); } itemcontainer=items.getParent('p.steps'); items.addEvent('change', function(){ Shop.CalculatePrice(items, specs); if(itemcontainer.hasClass('warn') && items.value!='0' ) { itemcontainer.removeClass('warn'); } }); specscontainer=specs.getParent('p.steps'); specs.addEvent('change', function(){ if(specscontainer.hasClass('warn') && specs.value!='0' ) { specscontainer.removeClass('warn'); } }); if(document.id('paddle_lengths')) { var lengths=document.id('paddle_lengths'), lengthoptions=lengths.getElements('option') ; lengthcontainer=lengths.getParent('p.steps'); specs.addEvent('change', function(){ Shop.UpdateLength(specs, specoptions, lengths, lengthoptions); Shop.CalculatePrice(items, specs); var checklength=Shop.Checklength(); if(lengthcontainer.hasClass('warn') && checklength ) { lengthcontainer.removeClass('warn'); } }); // let's init the function on domready Shop.UpdateLength(specs, specoptions, lengths, lengthoptions); } document.id('showprice').setStyle('opacity',0); } else { var selects = $('cartselect').getElements('select'); var tempoptions=new Array(); for (var i = 1; i