function mouseIsOverWorkaround(what){ var temp = what.parent().find(":hover"); return temp.length > 0; } function swap_images(pid, img) { if ($('galery_1_' + pid)) { // $('galery_0_' + pid).toggle(); // $('galery_1_' + pid).toggle(); if(mouseIsOverWorkaround(jQuery('#galery_0_' + pid))==false) { $('galery_0_' + pid).setStyle('display', 'block'); $('galery_1_' + pid).setStyle('display', 'none'); } else { $('galery_0_' + pid).setStyle('display', 'none'); $('galery_1_' + pid).setStyle('display', 'block'); } } else { var req = new Request({ method : 'post', url : '/ajax/searcher/swap_gallery/', data : { "pid" : pid, 'img' : img }, onComplete : function(data) { if (data.trim() != "") { if (!$('galery_1_' + pid)) { var nElement = new Element('div', { id : 'galery_1_' + pid }); nElement.set('html', data); // nElement.set('onmouseout','swap_out('+pid+')'); nElement.setStyle('z-index', '1000'); if ($('pttitle_' + pid)) { $('pttitle_' + pid).appendChild(nElement); if ($('pttthums_0_' + pid)) $('pttitle_' + pid).grab(nElement, 'top'); } else { $('imgcont_' + pid).appendChild(nElement); } // $('galery_0_' + pid).setStyle('display', 'none'); if(mouseIsOverWorkaround(jQuery('#galery_0_' + pid))==false) { $('galery_0_' + pid).setStyle('display', 'block'); $('galery_1_' + pid).setStyle('display', 'none'); } else { $('galery_0_' + pid).setStyle('display', 'none'); $('galery_1_' + pid).setStyle('display', 'block'); } } } } }).send(); } } function swap_out(pid) { // $('galery_0_'+pid).toggle(); // $('galery_1_'+pid).toggle(); if(mouseIsOverWorkaround(jQuery('#galery_0_' + pid))==false) { $('galery_0_' + pid).setStyle('display', 'block'); $('galery_1_' + pid).setStyle('display', 'none'); } } function swap_out_pt(event, t, pid) { var obj=event.relatedTarget; while(obj!=null){ if(obj==t){ return; } obj=obj.parentNode; } swap_out(pid); } function swap_images2(pid,newimg) { var req = new Request({ method: 'post', url: '/ajax/searcher/swap_gallery/', data: {"pid":pid,'newimg':newimg}, onComplete: function(data) { if(data!="") { if($('galery_1_'+pid)) { $('galery_1_'+pid).set('html',data); } } } }).send(); } function change_view(t) { getId('type_list').value=t; getId('ctl').submit(); } function filter_set(t,v,n) { v=v.replace(/"/gi,""); v=v.replace(/%/gi,""); n=n.replace(/"/gi,""); n=n.replace(/%/gi,""); var n1=n.split('('); var v1=v.split('~'); if(v1[0]==0) n1[0]=0; console.log('/f/'+t+'/'+v+'/'+n1[0]+'.html'); window.location.href= '/f/'+t+'/'+v+'/'+n1[0]+'.html'; } function slideContent() { if($('filter_slide_content')) { // if(Cookie.read('filter_slide')=='true') { console.log(111); $('filter_slide_content').show(); if($('filter_slide_on')) $('filter_slide_on').hide(); if($('filter_slide_off')) $('filter_slide_off').show(); } if(Cookie.read('filter_slide')=='false') { console.log(222); $('filter_slide_content').hide() ; if($('filter_slide_off')) $('filter_slide_off').hide(); if($('filter_slide_on')) $('filter_slide_on').show(); } if ($('filter_slide_on')){ $('filter_slide_on').addEvent('click', function(e){ e.stop(); $('filter_slide_off').setStyle('display',''); $('filter_slide_on').setStyle('display','none'); $('filter_slide_content').show(); Cookie.write('filter_slide','true',{duration:1}); }); } if ($('filter_slide_off')){ $('filter_slide_off').addEvent('click', function(e){ e.stop(); $('filter_slide_off').setStyle('display','none'); $('filter_slide_on').setStyle('display',''); $('filter_slide_content').hide(); Cookie.write('filter_slide','false',{duration:1}); }); } } } var periodicalHistory=0; function changeHistory() { //$clear(periodicalHistory); if(window.location.href!=this.url && this.url) { loading_start(); var self=this; this.url=window.location.href; var myRequest = new Request({ method: 'get', url: window.location.href, onComplete: function(data) { if(data.length>0) { sessionStorage.setItem('data'+this.options.url,data); StorageSet(); } onCompleted(data); if(history.state && !(history.state.filter==false && self.stateHistory==false)) { var boxstr=''; self.stateHistory=history.state.filter var loadCategories = new Request({ method: 'post', data:{'url':window.location.search}, url: '/ajax/categories_ajax/load/', onComplete: function(data) { loading_stop(); boxstr=window.location.search; cat=/\/c\/(\d+)\//gi.exec(window.location.href); if(cat && cat[1]>0) boxstr+='&c='+cat[1]; if(data.length>0) { sessionStorage.setItem('box'+boxstr,data); StorageSet(); } $('box_categories').set('html',data); cat_ajax_list2(); } }); boxstr=window.location.search; cat=/\/c\/(\d+)\//gi.exec(window.location.href); if(cat && cat[1]>0) boxstr+='&c='+cat[1]; StorageClear(); if(window.sessionStorage && sessionStorage.getItem('box'+boxstr)) { boxstr=window.location.search; cat=/\/c\/(\d+)\//gi.exec(window.location.href); if(cat && cat[1]>0) boxstr+='&c='+cat[1]; var data = sessionStorage.getItem('box'+boxstr); loadCategories.onSuccess(data, data); } else { loadCategories.send(); } }else { loading_stop(); } } }); StorageClear(); if(window.sessionStorage && sessionStorage.getItem('data'+myRequest.options.url)) { var data = sessionStorage.getItem('data'+myRequest.options.url); myRequest.onSuccess(data, data); } else { myRequest.send(); } } } var cat_ajax_list2 = function() { $$('[id^=catl_]','.box_list_data_lavel:not([id^=catl_])').removeProperty('onclick'); $$('[id^=catl_]','.box_list_data_lavel:not([id^=catl_])').removeEvents('click'); $$('[id^=catl_]','.box_list_data_lavel:not([id^=catl_])').each(function(el){ el.addEvent('click',function(){ var url = $(this).getElement('a').get('href'); $$('.box_list_active').each(function(el){ el.removeClass('box_list_active'); el.set('onmouseout','this.className=\''+el.get('class').replace('_active','')+'\''); }); $$('.box_list_level_active').each(function(el){ el.removeClass('box_list_level_active'); el.addClass('box_list_data_lavel'); el.set('onmouseout','this.className=\''+el.get('class').replace('_active','')+'\''); }); if($(this).get('class').indexOf("level") != -1) $(this).addClass('box_list_level_active'); else $(this).addClass('box_list_active'); $(this).set('onmouseout','this.className=\''+$(this).get('class').replace('_hover','')+'\''); //box_list_level_active if(url!=window.location.href) linkChanged(url); if(el.get('id')) { //$$('[id^=catls_]').each(function(el1){ //if(el.get('id').replace('catl_','')!=el1.get('id').replace('catls_','')) //el1.setStyles({'display':'none'}); //}); var id=el.get('id').replace('catl_',''); if($('catls_'+id)) { $('catls_'+id).toggle(); } else { if(!=5141) { loading_start(); } // loading_start(); var req = new Request({ method: 'post', url: '/ajax/categories_ajax/get_tree/', data: {"cid":id,'url':window.location.search}, onComplete: function(data) { if(==5141) { $$('[id^=catls_]').setStyle('display','none'); } if(data=="") { //window.location.href='/c/'+id+'/'+id+'.html'; } else { var nElement = new Element('div', { id: 'catls_'+id }); nElement.set('html',data); el.grab(nElement,'after'); cat_ajax_list2(); loading_stop(); } } }).send(); } } var cidh=/\/c\/(\d+)\//gi.exec(el.getElement('a').get('href')); var boxstr=''; StorageClear(); if(cidh==null) { boxstr=el.getElement('a').get('href'); } else { boxstr=cidh[1]; } if(window.sessionStorage && !sessionStorage.getItem('breadcrumbs'+boxstr)) { var req = new Request({ method: 'post', url: '/ajax/categories_ajax/breadcrumbs/', data: {"cid":boxstr}, onComplete: function(data) { loading_stop(); if(data.length>0) { sessionStorage.setItem('breadcrumbs'+boxstr,data); StorageSet(); } if($('box_breadcrumbs')) $('box_breadcrumbs').set('html',data); } }).send(); } else { loading_stop(); if($('box_breadcrumbs')) $('box_breadcrumbs').set('html',sessionStorage.getItem('breadcrumbs'+boxstr)); } }); }); } function StorageClear() { var n=new Date().getTime(); var n1=(60 * 60 * 1000); //var n1=(1 * 10 * 1000); if(window.sessionStorage) { if(n>parseInt(sessionStorage.getItem('StorageTime'))+n1) { sessionStorage.clear(); } } } function StorageSet() { var n=new Date().getTime(); if(window.sessionStorage) sessionStorage.setItem('StorageTime',n); } function quickView() { $$('.qv-button').addEvent('click', function(){ var pid = $(this).get('data-id'); var rc_w=new rc_windows({ id:'brief_'+pid, container: $(document.body), useOverlay: true, varAJAX: {"pid":pid}, contentAJAX:'https://serparmezan.pl/ajax.php?p=pinfo&f=get_brief&products_id=' + pid, width:900, head: true, onComplete: function(){ inventory(pid); $$('a.gallery-main.').addEvent('click', function(e) { e.stop(); $('img_main').set('src',$(this).get('href')); var datasrc = $(this).getElements('img')[0].get('data-src'); $('img_main').set('data-src',datasrc); $('link_img_main').set('href',datasrc); }) add_cart_pinfo_new(); rc3Event(); jQuery("a.slideHref").fancybox(); jQuery('#thumbs .thumb a').each(function(i) { jQuery(this).addClass( 'itm'+i ); }); jQuery('#thumbs a.itm0').addClass( 'selected' ); jQuery('#thumbs').carouFredSel({ direction: 'left', responsive: true, circular: false, infinite: false, items: 3, align: false, auto: false, prev: '#prev', next: '#next' }); } }); }) } // wywolanie w pliku box_filter_search function boxFilterSwitch(i) { $('filter_i_' + i).toggle(); icon = $('filter_icon_' + i); if(icon.hasClass('icon-chevron-sign-down')) { icon.removeClass('icon-chevron-sign-down'); icon.addClass('icon-chevron-sign-up'); } else { icon.removeClass('icon-chevron-sign-up'); icon.addClass('icon-chevron-sign-down'); } } window.addEvent('domready', function() { if(''=='true'){ var ajaxflag=false; var content; content=$$('.content_center_in'); if(content.length) ajaxflag=true; else { if($('content_x')) ajaxflag=true; else if($('content_2')) ajaxflag=true; } if (!history.pushState) ajaxflag = false; if(ajaxflag) { cat_ajax_list2(); changeHistory(); periodicalHistory=changeHistory.periodical(100,{url:window.location.href,stateHistory:false}); } } slideContent(); //window.addEventListener('popstate', function(event) { //console.log('popstate fired!'); //updateContent(event.state); //}); quickView(); });