/** ZipShop scripts 2.0.00 2014-11-16 AIP Solutions Ltd'2008-2014 http://www.aip.solutions */ /* dynlite extensions */ if(!dl.c) dl.c = {}; if(!dl.o) dl.o = {}; dl.encode = dl.w.encodeURIComponent; dl.decode = dl.w.decodeURIComponent; /* cookie object */ dl.cookie=function(key,val,ttl) { //ttl is in hours if(!val){ /* get */ var re=new RegExp(key+"=([^;]+)"); return re.test(dl.d.cookie)? dl.decode(RegExp.$1) : false; } /* set */ var ttl = (ttl||24*30*12)*3600; //1 year in seconds var exp = new Date(Date.now()+(ttl*1000)); var out = [dl.encode(key)+'='+dl.encode(val), 'expires='+exp.toGMTString(), 'max-age='+ttl, 'domain='+dl.l.hostname, 'path=/']; var str=out.join('; '); //trace(str); dl.d.cookie=str; } /* dl.bar class */ dl.c.Accept = 'accept'; dl.o.bar = {}; dl.bar = function(id){ if(!id) return false; if(dl.o.bar[id]) return dl.o.bar[id]; if(!(this instanceof dl.bar)) return new dl.bar(id); this.id = id; this.el = null; this.val = null; this.btn= null; this.init(); } hideprice = function() { var hideprice = document.getElementsByClassName("example"); hideprice.classList.toggle("mystyle"); } dl.el('hide.promo').on('click', function(e){ this.toggle('hide'); dl.el('prd.promo').add('hide'); dl.el('prd.discount').add('hide'); dl.el('hide.promo').add('hide'); dl.el('show.promo').remove('hide'); }); dl.el('show.promo').on('click', function(e){ this.toggle('hide'); dl.el('prd.promo').remove('hide'); dl.el('prd.discount').remove('hide'); dl.el('hide.promo').remove('hide'); }); dl.Bar = dl.bar.prototype; dl.Bar.init = function(){ this.el = dl.el(this.id); this.val = dl.cookie(this.id); if(this.val == dl.c.Accept) return true; this.btn = dl.el(this.el.list('button')[0]); this.bind(); } dl.Bar.bind = function(){ this.btn.on('click', this.accept.bind(this)); this.render(); } dl.Bar.render = function(){ this.el.add('active'); } dl.Bar.accept = function(){ dl.cookie(this.id, dl.c.Accept); this.el.remove('active'); } changeImage = function(){ var bigPic = dl.el('ima'); var list = dl.list('img',dl.el('prd.img.cont')); var curr = dl.el(list[0]); curr.add('active'); for(var i=list.length;i--;){ dl.el(list[i]).on('click', function(){ curr.remove('active'); this.add('active'); curr=this; bigPic.attr('src',this.src); }) } } //onload execution dl.on('ready', function(e){ if(dl.w.init) dl.w.init(); //loading additional scripts var slist = dl.list('script[data-src]'); for(var i = slist.length; i--;) { var data = slist[i].dataset; if(data['start']) dl.include(data.src, false, function(){dl.w[data['start']]()}); else dl.include(data); } //auto object creation var list = dl.list('[data-dl]'); for(var i = list.length; i--; ) { var el = list[i]; var ls = dl.el(el).data('dl').split(','); for(var j = ls.length; j-- ; ) { var ob =ls[j]; if(dl[ob] && el.id) dl[ob](el.id); } } dl.el('prd.info.link').on('click', function(e){ this.toggle('active'); dl.el('prd.oem.link').remove('active'); dl.el('prd.alt.link').remove('active'); dl.el('prd.car.link').remove('active'); dl.el('prd.stock.link').remove('active'); }); dl.el('prd.oem.link').on('click', function(e){ this.toggle('active'); dl.el('prd.info.link').remove('active'); dl.el('prd.alt.link').remove('active'); dl.el('prd.car.link').remove('active'); dl.el('prd.stock.link').remove('active'); }); dl.el('prd.alt.link').on('click', function(e){ this.toggle('active'); dl.el('prd.info.link').remove('active'); dl.el('prd.oem.link').remove('active'); dl.el('prd.car.link').remove('active'); dl.el('prd.stock.link').remove('active'); }); dl.el('prd.car.link').on('click', function(e){ this.toggle('active'); dl.el('prd.info.link').remove('active'); dl.el('prd.oem.link').remove('active'); dl.el('prd.alt.link').remove('active'); dl.el('prd.stock.link').remove('active'); }); dl.el('prd.stock.link').on('click', function(e){ this.toggle('active'); dl.el('prd.info.link').remove('active'); dl.el('prd.oem.link').remove('active'); dl.el('prd.alt.link').remove('active'); dl.el('prd.car.link').remove('active'); }); //navigation initialization if(dl.w.load) load(); dl.el('menu.btn').on('click', function(e){ this.toggle('active'); // remember the last status of the menu if(dl.el('menu.btn').className.indexOf('active') < 0) dl.session.set('showMenu', false) else dl.session.set('showMenu', true) }); /* dl.el('top.nav').on('click', function(e){ this.toggle('active'); }); */ //banner if(dl.is.el('banner')) dl.banner('banner'); //gallery if(dl.is.el('gallery')) dl.banner('gallery'); //shopping cart if(dl.is.el('cart')) dl.el('cart').load('ajax.cart.php'); //wishlist cart if(dl.is.el('wishlist')) dl.el('wishlist').load('wishlist.ajax.php'); //loads dynamically the products if(dl.lazy) dl.lazy(); //handles sticky menu if(dl.sticky) dl.sticky(); //product list if(dl.is.el('product.list')){ dl.on('hashchange', function(){ var qry = dl.l.hash.replace('#','?'); if(_filter) qry+='&'+_filter; dl.el('product.list').load('product.list.ajax.php'+qry); }) } //new product list /* decided to precash also availability and price for faster render if(dl.is.el('product.list.local')){ var list = dl.list('[data-availability]'); for(var i=list.length;i--;) { var el = dl.el(list[i]); el.load('product.availability.ajax.php?Id='+el.data('id')); } } */ //product image if(dl.is.el('product.image')) { dl.zoom('product.image'); dl.preview('product.image'); } //contact map if(dl.is.el('map.google')) { dl.map.load('map.google'); } //form validation for safari frmList = dl.list('form'); if((frmList.length > 0) && /^((?!chrome).)*safari/i.test(dl.n.userAgent)) { for(var i in frmList){ var frm = frmList[i]; //trace(frm); dl.el(frm).on('submit', function(e){ var el = e.srcElement; if(!el.checkValidity()) { e.preventDefault(); var list = el.list("input[required],select[required],textarea[required]"); for(var j in list){ var sub = list[j]; if(sub.validity) { if(sub.validity.valid) sub.style.outline = "none"; else sub.style.outline = "2px solid red"; } } } }); } } // testing quickSearch if(dl.is.el('quickSearch')) { } }); //onresize event handler dl.on('resize', function(e){ //loads dynamically the products if(dl.lazy) dl.lazy(); }) //onmobile switch handler dl.on('mobile', function(w){ dl.image('img'); //navigation initialization dl.el('top.nav').on('click', function(e){ this.toggle('active'); }); }); //ontablet switch handler dl.on('tablet', function(w){ dl.image('img'); //navigation initialization dl.el('top.nav').on('click', function(e){ this.toggle('active'); }); // check and retrieve the last menu status if(dl.session && dl.session.get('showMenu')) if(JSON.parse(dl.session.get('showMenu'))) dl.el('menu.btn').className = dl.el('menu.btn').className + ' active'; //initialize image swap if(dl.swap) dl.swap(); //image enlarging if(dl.enlarge) dl.enlarge(); }); //ondesktop switch handler dl.on('desktop', function(w){ dl.image('img'); // check and retrieve the last menu status if(dl.session.get('showMenu')) dl.el('menu.btn').className = dl.el('menu.btn').className + ' active'; //initialize image swap if(dl.swap) dl.swap(); //image enlarging if(dl.enlarge) dl.enlarge(); }); //onscroll event handler dl.on('scroll', function(t){ //loads dynamically the products if(dl.lazy) dl.lazy(); //handles sticky menu if(dl.sticky) dl.sticky(); }) //initialization dl.response(); //additional classes dl.cart={ url: function(){ if(dl.is.el('checkout.frm')) return dl.el('checkout.frm').data('url'); else return dl.el('cart.frm').data('url'); return ''; }, //adds product to the shipping cart add : function(id) { if(!id || !dl.is.el('product.'+id)) return false; var url=dl.el('product.'+id).data('url'); if(url) dl.l.href=url; }, //updates product parameters prepare : function(frm){ dl.submit(frm, 'product.info.ajax.php', function(data){ var info = JSON.parse(data); if(!info) return false; if(dl.is.el('price') && info.total) { dl.el('price').data('status', info.status); if(info.status == 'ok') dl.el('price').val(info['total.f']); else dl.el('price').val('-'); } }) }, //product purchase purchase : function(frm){ //add price and note var fd = new FormData(dl.el(frm)); if(dl.is.el('note')) fd.append('product[note]', dl.el('note').val()); dl.submit(fd, 'ajax.cart.php?langId='+dl.el('purchase.btn').data('lang'), function(data){ dl.el('cart').html(data); dl.delay(function(){dl.el('cart.popup').show();}, 10); }) }, purchaseQuick_ : function(e){ e.stopPropagation(); e.preventDefault(); var el = dl.el(e.target); var fd = new FormData(); fd.append('product[Id]', el.data('prod')); fd.append('product[quantity]', el.data('qtty')); fd.append('product[type]', el.data('type')); dl.submit(fd, 'ajax.cart.php', function(data){ dl.el('cart').html(data); dl.el('car.product.cont').className = 'product-list popshow'; dl.el('uni.product.cont').className = 'product-list popshow'; dl.delay(function(){dl.el('cart.popup').show();}, 10); }) }, purchaseQuick : function(id){ //e.stopPropagation(); //e.preventDefault(); var el = dl.el(id); var fd = new FormData(); fd.append('product[Id]', el.data('prod')); fd.append('product[quantity]', el.value); fd.append('product[type]', el.data('type')); dl.submit(fd, 'ajax.cart.php', function(data){ dl.el('cart').html(data); //dl.el('car.product.cont').className = 'product-list popshow'; //dl.el('uni.product.cont').className = 'product-list popshow'; dl.delay(function(){dl.el('cart.popup').show();}, 10); }) }, update : function(what, info){ if(what == 'quantity.up') { if(!dl.is.el('quantity.'+info)) return false; var val = +dl.el('quantity.'+info).value; if(val != parseInt(val)) val = 0; dl.el('quantity.'+info).value = ++val; } if(what == 'quantity.down') { if(!dl.is.el('quantity.'+info)) return false; var val = +dl.el('quantity.'+info).value; if(val != parseInt(val)) val = 0; val--; if(val < 1) val = 1; dl.el('quantity.'+info).value = val; } if(dl.is.el('cart.frm')) dl.el('cart.frm').submit(); }, remove : function(id, mess){ if(confirm(mess)) var url = this.url(); var separator = url.includes('?') ? '&' : '?'; dl.l.href = url + separator + 'remove=' +id; }, clear : function(mess){ if(confirm(mess)) dl.l.href=this.url()+'?clear=1'; }, close : function(){ dl.el('car.product.cont').className = 'product-list'; dl.el('uni.product.cont').className = 'product-list'; dl.el('cart.popup').hide(); }, check : function(page){ var frm = dl.el(page+'.frm'); frm.action = page+'.php?check=true'; frm.submit(); }, clearChecked : function(mess, page){ if(confirm(mess)){ var frm = dl.el(page+'.frm'); frm.action = page+".php?clear=true"; frm.submit(); } }, checkoutChecked : function(){ var frm = dl.el('cart.frm'); frm.action = "checkout.php?checkout=true&langId="+indexLang; frm.submit(); // console.log(frm.action); } } dl.product={ // checks if the product is ok for purchase check : function(what){ if(what == 'purchase') { //check if all options are selected var list = dl.list('[data-option]'); var done = 0; for(var i=list.length;i--;) if(dl.el(list[i]).has('selected')) done++; if(done != list.length) { dl.el('purchase.error').show(); return false; } //check if the status is ok if(!dl.is.el('prd.price')) return false; if(dl.el('prd.price').data('status') != 'ok') { dl.el('purchase.error').show(); return false; } dl.el('purchase.error').hide(); return true; } else if(what == 'wishlist' || what == 'quote') { //check if all options are selected var list = dl.list('[data-option]'); var done = 0; for(var i=list.length;i--;) if(dl.el(list[i]).has('selected')) done++; if(done != list.length) { dl.el('purchase.error').show(); return false; } dl.el('purchase.error').hide(); return true; } return false; }, update : function(what, info){ if(what == 'option') { if(!info) return false; if(dl.is.el('productOption'+info.parameterId)) { dl.el('productOption'+info.parameterId).add('selected'); //add selected text var el = dl.el('productOption'+info.parameterId+info.valueId); dl.el('selected.'+info.parameterId+'.name').html(el.data('name')); dl.el('selected.'+info.parameterId+'.price').html(el.data('price')); dl.el('productOption'+info.parameterId).remove('active'); dl.el('purchase.error').hide(); dl.cart.prepare('product'); return true; } } if(what == 'quantity.up') { if(!dl.is.el('quantity')) return false; var val = +dl.el('quantity').value; if(val != parseInt(val)) val = 0; dl.el('quantity').value = ++val; return true; } if(what == 'quantity.down') { if(!dl.is.el('quantity')) return false; var val = +dl.el('quantity').value; if(val != parseInt(val)) val = 0; val--; if(val < 1) val = 1; dl.el('quantity').value = val; return true; } return false; } } dl.wishlist={ url: function(){ return dl.el('wishlist.frm').data('url')}, //add to wishlist add : function(frm){ if(!frm) return false; if(frm*1 == frm) { //id passed from the list page if(!dl.is.el('product.'+frm)) return false; var url=dl.el('product.'+frm).data('url'); if(url) dl.l.href=url; return true; } if(!dl.product.check('wishlist')) return false; //add price and note var fd = new FormData(dl.el(frm)); dl.submit(fd, 'wishlist.ajax.php?langId='+dl.el('wishlist.btn').data('lang'), function(data){ dl.el('wishlist').html(data); dl.w.setTimeout(function(){dl.el('wishlist.popup').show();}, 10); }) }, update : function(what, info){ if(what == 'quantity.up') { if(!dl.is.el('quantity.'+info)) return false; var val = +dl.el('quantity.'+info).value; if(val != parseInt(val)) val = 0; dl.el('quantity.'+info).value = ++val; } if(what == 'quantity.down') { if(!dl.is.el('quantity.'+info)) return false; var val = +dl.el('quantity.'+info).value; if(val != parseInt(val)) val = 0; val--; if(val < 1) val = 1; dl.el('quantity.'+info).value = val; } if(dl.is.el('wishlist.frm')) dl.el('wishlist.frm').submit(); }, close : function(){ dl.el('wishlist.popup').hide(); }, remove : function(id, mess){ if(confirm(mess)) dl.l.href=this.url()+'?remove='+id; }, clear : function(mess){ if(confirm(mess)) dl.l.href=this.url()+'?clear=1'; }, share : function(e){ //if (!e) var e = window.event; //var el = e.target || e.srcElement; dl.popup('popup.wishlist.share.php?langId='+dl.el('wishlist.share.btn').data('lang')); } } dl.quote={ url: function(){ return dl.el('quote.frm').data('url')}, //quote add : function(frm){ if(!frm) return false; if(frm*1 == frm) { //id passed from the list page if(!dl.is.el('product.'+frm)) return false; var url=dl.el('product.'+frm).data('url'); if(url) dl.l.href=url; return true; } if(!dl.product.check('quote')) return false; //add price and note var fd = new FormData(dl.el(frm)); dl.submit(fd, 'quote.ajax.php?langId='+dl.el('quote.btn').data('lang'), function(data){ dl.el('quote').html(data); dl.w.setTimeout(function(){dl.el('quote.popup').show();}, 10); }) }, update : function(what, info){ if(what == 'quantity.up') { if(!dl.is.el('quantity.'+info)) return false; var val = +dl.el('quantity.'+info).value; if(val != parseInt(val)) val = 0; dl.el('quantity.'+info).value = ++val; } if(what == 'quantity.down') { if(!dl.is.el('quantity.'+info)) return false; var val = +dl.el('quantity.'+info).value; if(val != parseInt(val)) val = 0; val--; if(val < 1) val = 1; dl.el('quantity.'+info).value = val; } if(dl.is.el('quote.frm')) dl.el('quote.frm').submit(); }, close : function(){ dl.el('quote.popup').hide(); }, remove : function(id, mess){ if(confirm(mess)) dl.l.href=this.url()+'?remove='+id; }, clear : function(mess){ if(confirm(mess)) dl.l.href=this.url()+'?clear=1'; }, } newsletter={id:'', state:0} newsletter.init=function(id){ this.id = id || 'newsletter'; this.bind(); } newsletter.bind=function(id){ dl.el(this.id+'.email').on('change', this.update.bind(this)) dl.el(this.id+'.accept').on('click', this.update.bind(this)) dl.el(this.id+'.button').on('click', this.captcha.bind(this)) dl.el(this.id+'.captcha.button').on('click', this.submit.bind(this)) dl.el(this.id+'.captcha.reload').on('click', this.reload.bind(this)) } newsletter.update=function(){ if(dl.el(this.id+'.email').validity.valid && dl.el(this.id+'.accept').checked) dl.el(this.id+'.error').hide(); } newsletter.reload=function(){ dl.el(this.id+'.captcha.image').src = 'ajax.captcha.php?'+Math.random(); } newsletter.captcha=function(){ if(!dl.el(this.id+'.email').value || !dl.el(this.id+'.email').validity.valid || !dl.el(this.id+'.accept').checked) { dl.el(this.id+'.error').show(); return false; } this.reload(); dl.el(this.id+'.loading').hide(); dl.el(this.id+'.success').hide(); dl.el(this.id+'.failure').hide(); dl.el(this.id+'.captcha').show(); dl.el(this.id+'.captcha.field').value = ''; } newsletter.submit=function(){ if(!dl.el(this.id+'.captcha.field').value) return false; dl.el(this.id+'.captcha').hide(); if(!dl.el(this.id+'.email').validity.valid || !dl.el(this.id+'.accept').checked) { dl.el(this.id+'.error').show(); return false; } var self = this; var lang = dl.list('html')[0].getAttribute('lang'); dl.el(this.id+'.loading').show(); dl.el(this.id+'.success').hide(); dl.el(this.id+'.failure').hide(); dl.submit(new FormData(dl.el(this.id+'.frm')), 'newsletter.ajax.php?action=subscribe&lang='+lang, function(data){ dl.el(self.id+'.loading').hide(); if(data.indexOf('success') != -1) { dl.el(self.id+'.success').show(); dl.el(self.id+'.failure').hide(); } else { dl.el(self.id+'.success').hide(); dl.el(self.id+'.failure').html(data.replace('failure', '')); dl.el(self.id+'.failure').show(); } }) } //authentication handling class login={id:'', active:false, timer:null} login.open = function(id, frm){ this.id = id || 'login'; dl.el('popupbg').className = 'popupbg show'; dl.popup('login.popup.php?action=login', {w:650}) } login.submit = function(){ var frm = dl.el(this.id+'.frm'); if(!dl.el('login.username').val() || !dl.el('login.password').val()) { dl.el('login.err').show(); return false; } frm.submit(); } login.checkout = function(){ login.open(); dl.w.scrollTo(0,0); } login.logout = function(){ dl.popup('login.popup.php?action=logout', {w:650}); } login.close = function(){ popup.close(); dl.el('popupbg').className = 'popupbg hiden'; } changeListener = function(){ var select = dl.el('showOfiice'), text = dl.el('onOffice'); select.addEventListener('change', function () { text.className = this.value; }); text.className = select.value; } formstock = function(){ if (dl.el('typebrd').checked) { dl.el('car.brand').disabled = true; dl.el('car.model').disabled = true; dl.el('car.othermod').disabled = false; } else { dl.el('car.brand').disabled = false; dl.el('car.othermod').disabled = true; } } dl.discount = {}; dl.discount.load = function(id){ dl.el('discount.cont.'+id).load('ajax.discount.info.php?Id='+id+'&langId='+indexLang); } //end of code. enjoy...