/* окошко купить еще (с) 2016-2019 */ function get(name){ if(name=(new RegExp('[?&]'+encodeURIComponent(name)+'=([^&]*)')).exec(location.search)) return decodeURIComponent(name[1]); } function _vrc(k){return(document.cookie.match('(^|; )'+k+'=([^;]*)')||0)[2]} function _vwc(name,value){var date=new Date();date.setTime(date.getTime()+(3600000*24*3));document.cookie = name+"="+value+"; expires="+date.toGMTString()+"; path=/";} function msg(a){ document.getElementById('msgCover').style.display='none'; if(a!=0)window.document.location.href=a; } function declOfNum(number, titles) { cases = [2, 0, 1, 1, 1, 2]; return titles[(number%100>4 && number%100<20)? 2 :cases[(number%10<5)?number%10:5]]; } function inc_up(v,to){ } function byuThis(f){ var mul=1; if(f.mul!==undefined) mul=parseInt(f.mul.value); if(mul<=0)mul=1; var count=1; if(f.count!==undefined) count=parseInt(f.count.value); if(count<=0) count=1; var add_text=''; var new_count=count; if( count % mul !=0){ new_count=Math.floor(count/mul)*mul+mul; add_text="

Эту позицию можно купить кратно "+mul+" шт.
Вам нужно "+count+" шт. Количество будет увеличено до "+new_count+" шт."+"

"+"

Позднее вы сможете откорректировать количество позиций в корзине кратно минимальному.

"; count=new_count; } var pokupki=_vrc('pokupki'); if(pokupki===undefined){var a_pokupki=Array();}else{a_pokupki=decodeURIComponent(pokupki).split(',');} //console.log( typeof(a_pokupki) ); var found=false; var cnt_pokupok=0; for(var key in a_pokupki) { var p=a_pokupki[key].split(':'); // ID:COUNT:mag_type //console.log(')))'+p[0]+ ' | '+p[1]+' | '+p[2] ); if( (p[0]==f.add.value) && (p[2]==f.mag_type.value) ) { p[1]=parseInt(p[1])+count; found=true; } a_pokupki[key]=p.join(':'); cnt_pokupok++; } if(!found){ a_pokupki.push( f.add.value+':'+count+':'+f.mag_type.value); cnt_pokupok++; } //console.log( 'cnt_pokupok:'+cnt_pokupok ); _vwc('pokupki',encodeURIComponent(a_pokupki)); document.getElementById("pokupki_div").style.display="block"; document.getElementById("byu_cnt").innerHTML='У меня'+cnt_pokupok+' покуп'+declOfNum(cnt_pokupok,['ка', 'ки', 'ок']); document.getElementById("byu_price").innerHTML='уточнить цену'; document.getElementById("msgAddText").innerHTML=add_text; document.getElementById("msgCover").style.display="block"; } /* компактный логин и админка (с) 2017 */ function hidlog(){ document.getElementById('hidlog').style.display='inline'; document.getElementById('btnlog').style.display='none'; return false; } function toggle_apf(){ var apf=_vrc('apf'); apf=(typeof(apf)=="undefined"?"0":apf) if(apf=="0"){apf="1";}else{apf="0";} _vwc("apf",apf); location.reload(true); } function contentLoaded(win, fn) { var done = false, top = true, doc = win.document, root = doc.documentElement, modern = doc.addEventListener, add = modern ? 'addEventListener' : 'attachEvent', rem = modern ? 'removeEventListener' : 'detachEvent', pre = modern ? '' : 'on', init = function(e) { if (e.type == 'readystatechange' && doc.readyState != 'complete') return; (e.type == 'load' ? win : doc)[rem](pre + e.type, init, false); if (!done && (done = true)) fn.call(win, e.type || e); }, poll = function() { try { root.doScroll('left'); } catch(e) { setTimeout(poll, 50); return; } init('poll'); }; if (doc.readyState == 'complete') fn.call(win, 'lazy'); else { if (!modern && root.doScroll) { try { top = !win.frameElement; } catch(e) { } if (top) poll(); } doc[add](pre + 'DOMContentLoaded', init, false); doc[add](pre + 'readystatechange', init, false); win[add](pre + 'load', init, false); } } /* void main(); */ contentLoaded(window, function () { var pageYLabel = 0; if(document.getElementsByClassName){ var x=document.getElementsByClassName("hiddenByu"); } else { var x=document.querySelectorAll(".hiddenByu"); } for (var i=0;i0)hidlog(); }else{ if(window.location.href.search('#auth_')>0)window.document.location.href='/magazin/manager/'; } var div = document.getElementById('bb'); div.onclick = function (e) { var e = e || window.event; var target = e.target || e.srcElement; if (this == target) { var pageY = window.pageYOffset || document.documentElement.scrollTop; if(pageY==0){window.scrollTo(0, pageYLabel);}else{ pageYLabel = pageY; window.scrollTo(0, 0); } } } }); var isAlt = false; document.onkeyup=function(e) { if(e.which == 18) isAlt=false; } window.onblur=function(e) { isAlt=false; } window.onfocus=function(e) { isAlt=false; } document.onkeydown=function(e){ if(e.which == 18) { isAlt=true; } if(e.which == 49 && isAlt ) { if(!logged_in){ document.getElementsByName('login')[0].focus(); hidlog(); } window.scrollTo(0,document.body.scrollHeight); return false; } } /* reload failed images (c) 2018 */ var addTimer=1000; function img_hosting_error(img){ setTimeout( function(){ cnt=img.getAttribute('error_cnt'); if(cnt>4)img.onerror=function(){}; var url=img.src.split('#')[0]; console.log( ' Reloading failed image :'+url+ ' @ '+addTimer+'sec e:'+cnt ); img.src=url+'#'+Math.random(); img.setAttribute('error_cnt',++cnt); addTimer+=5; }, addTimer); } var myVar = setTimeout( // 1 раз function(){ console.log('checking images'); var images = document.getElementsByTagName('img'); for (var i in images) { if( images[i].naturalWidth==0 && images[i].naturalHeight==0 ){ images[i].setAttribute('error_cnt',1); images[i].onerror=function(){img_hosting_error(this);} img_hosting_error(images[i]); } } }, 1000);