/** ** Эта статья нужна для работы корзины в многостраничном режиме. Этот режим используется, если на вкладке "Цены" выбран пункт "ничего не делать при открытии страницы" и после этого выполнена нарезка static_site_new.bat . Если этот режим не используется, то содержимое данной статьи можно удалить. Саму статью удалять не следует ***/ var search_text="";if (document.querySelector('.swiper-wrapper')){var script = document.createElement('script');script.src = "https://heeg.ru/test/js/swiper.min.js";document.head.appendChild(script);script.onload = function() {var swiper=new Swiper(".swiper-container",{lazy:!0,pagination:{el:".swiper-pagination",clickable:!0},navigation:{nextEl:".swiper-button-next",prevEl:".swiper-button-prev"}});};};if (document.querySelector('.search_field')){var script = document.createElement('script');script.src = "search_base.html";document.head.appendChild(script);};if(document.querySelector(".simpleCart_shelfItem")){ var blocks = document.querySelectorAll( ".simpleCart_shelfItem" ); var arrObjects = [];for( let i = 0; i < blocks.length; i++){ ARR_items = blocks[i].querySelectorAll('[class^="item_"]');arrObjects[i] = {};var currclass =""; var curritem =""; var curritemval="";for (let t = 0; t < ARR_items.length; t++) {currclass=ARR_items[t].getAttribute('class'); curritemval=ARR_items[t].innerHTML;if(currclass!="item_Thumb" && currclass!="item_quantity" && currclass!="item_add"){if(currclass=="item_name"){search_text=search_text+"B='"+curritemval+"' OR "};if(isNaN(curritemval)){curritem =curritemval}else{curritem =parseFloat(curritemval)};arrObjects[i][currclass] = curritem;}; }; }; var arrObjectsGoogle = [];var google = { visualization: { Query: { setResponse:function setResponse(data){ var currGoog="";var currfind="";for (var ik=0, lenk=data.table.rows.length; ikb ? order : 0; }; }; };if(document.querySelector(".ContactFormSubmit")){document.querySelector(".ContactFormSubmit").onclick = function(event) {ContactFormSubmit();};};function ContactFormSubmit(){var re = /^[\w-\.]+@[\w-]+\.[a-z]{2,14}$/i; var myMail = document.querySelector('.userOO_form').value; var valid = re.test(myMail);document.querySelector('[aria-label^="name"]').value=document.querySelector('.userFF_form').value;document.querySelector('[aria-label^="telephone"]').value=document.querySelector('.userII_form').value;document.querySelector('[aria-label^="email"]').value=document.querySelector('.userOO_form').value;document.querySelector('[aria-label^="client_comments"]').value=document.querySelector('.userCC_form').value;document.querySelector('[aria-label^="order_number"]').value="Z_Запрос из контактной формы";document.querySelector('[aria-label^="link_for_your_order"]').value="https:\\\\heeg.ru";if (document.querySelector('.userFF_form').value === ""){ alert("Заполните, пожалуйста, Ваше Имя."); return;}if (document.querySelector('.userII_form').value === ""){alert("Заполните, пожалуйста, Ваш Телефон."); return;}if (document.querySelector('.userOO_form').value=="") {document.querySelector('[aria-label^="email"]').value="";}if (valid || document.querySelector('.userOO_form').value=="") {} else{ alert("Заполните, пожалуйста, Ваш e-mail ПРАВИЛЬНО или оставьте поле пустым."); return;}document.querySelector('[name="rsubmit"]').click();alert("Спасибо за ваш запрос. Мы обязательно свяжемся с вами.");document.querySelector('[target="my_iframe"]').reset();};document.querySelector('.selectDost').addEventListener('change', function () {simpleCart.initialize();}); var serchEl = document.querySelectorAll('.mysearch'); for (let i = 0; i< serchEl.length; i++) { serchEl[i].addEventListener('keydown', function(e) { if (e.keyCode === 13) { window.location="search.html?search="+ encodeURI(this.value);} }); }; var search_barEl = document.querySelectorAll('.start_search_bar'); for (let i = 0; i < search_barEl.length; i++) {search_barEl[i].onclick = function(event) {window.location="search.html?search="+ encodeURI(serchEl[i].value);}; }; var empty_sEl = document.querySelectorAll('.empty_search'); for (let i = 0; i < empty_sEl.length; i++) {empty_sEl[i].onclick = function(event) {serchEl[i].value="";}; };function getUrlVars() { var vars = {}; var parts = window.location.href.replace(/[?&|?#]+([^=&|^=#]+)=([^&|^#]*)/gi, function(m,key,value) { vars[key] = value; }); return vars;};var HEEGreadyState="onload";var corsmax=0;var corscurrent=0;function isLocalStorageAvailable() { var test2 = 'test2'; try { localStorage.setItem(test2, test2); return true; } catch(e) { return false; }}function a(i){var text="";for (var k = 0; k < i; k++){text=text+" ";}return text;}function stickmenu() {if (document.getElementById('aside1')){var a = document.querySelector('#aside1'), b = null; window.addEventListener('scroll', Ascroll, false);document.body.addEventListener('scroll', Ascroll, false); function Ascroll() { if (b == null) { var Sa = getComputedStyle(a, ""), s = ""; for (var i = 0; i < Sa.length; i++) { if (Sa[i].indexOf('box-sizing') == 0 || Sa[i].indexOf('overflow') == 0 || Sa[i].indexOf('padding') == 0 || Sa[i].indexOf('border') == 0 || Sa[i].indexOf('outline') == 0 || Sa[i].indexOf('box-shadow') == 0 || Sa[i].indexOf('background') == 0) { s += Sa[i] + ': ' +Sa.getPropertyValue(Sa[i]) + '; ' } } b = document.querySelector('#stick'); a.style.padding = '0'; a.style.border = '0'; } if (a.getBoundingClientRect().top <= 0) { b.className = 'sticky'; } else { b.className = 'sticky2'; }}}}function setAttr(prmName,val) { var res = ' '; var d = location.href.split("#")[0].split("?"); var base = d[0]; var query = d[1]; if(query) { var params = query.split("&"); for(var i = 0; i < params.length; i++) { var keyval = params[i].split("="); if(keyval[0] != prmName) { res += params[i] + '&'; } } } res += prmName + '=' + val;window.history.pushState(null, null, base + '?' + res); return false;}var disqus_developer = 1;var strlocat3 = window.location.toString();var pinframe=0;var currhash=window.location.hash; if (window.parent.frames.length >0) { pinframe=1; }setTimeout(function(){HEEGreadyState="isload"; stickmenu();var elements = document.querySelectorAll('.tw-table-of-contents-top>ul');document.querySelector(".tw-table-of-contents-top>ul").onclick = function(event) { for (var i = 0; i< elements.length; i++) {elements[i].className="hover"; }};document.querySelector(".tw-table-of-contents-top>ul").onmouseover = function(event) { for (var i = 0; i< elements.length; i++) {elements[i].className="hover"; }};},2000);function addSpaces(nStr){ nStr += ' '; x = nStr.split('.'); x1 = x[0]; x2 = x.length >1 ? '.' + x[1] : ' '; var rgx = /(\d+)(\d{3})/; while (rgx.test(x1)) { x1 = x1.replace(rgx, '$1' + ' ' + '$2'); } return x1 + x2;}var valuta = "сом";var noliq = "0" ;var noMail="";var quantityName = "шт." ;var refer= "["+ decodeURI(document.location).split('#')[0].split('?')[1]+"]";if(refer=="[undefined]"){refer=" ";}var userCook="";var noMailVal=0;var NextId=1,Custom="Custom",PayPal="PayPal",Email="Email",AustralianDollar=AUD="AUD",CanadianDollar=CAD="CAD",CzechKoruna=CZK="CZK",DanishKrone=DKK="DKK",Euro=EUR="EUR",HongKongDollar=HKD="HKD",HungarianForint=HUF="HUF",IsraeliNewSheqel=ILS="ILS",JapaneseYen=JPY="JPY",MexicanPeso=MXN="MXN",NorwegianKrone=NOK="NOK",NewZealandDollar=NZD="NZD",PolishZloty=PLN="PLN",PoundSterling=GBP="GBP",SingaporeDollar=SGD="SGD",SwedishKrona=SEK="SEK",SwissFranc=CHF="CHF",USDollar=USD="USD";RussianRUB=RUB="RUB";function Cart(){ var me = this; /* member variables */ me.Version = '2.0.1'; me.Shelf = new Shelf(); me.items = {}; me.isLoaded = false; me.pageIsReady = false; me.quantity = 0; me.total = 0; me.taxRate = 0; me.taxCost = 0; me.shippingFlatRate = 0; me.shippingTotalRate = 0; me.shippingQuantityRate = 0; me.shippingRate = 0; me.shippingCost = 0; me.currency ="RUB"; me.checkoutTo = PayPal; me.email = "info@heeg.ru"; me.merchantId = "";me.saleRate = "0.6"; me.cartHeaders = ['Name','Price','Quantity','Total']; /* cart headers: you can set these to which ever order you would like, and the cart will display the appropriate headers and item info. any field you have for the items in the cart can be used, and 'Total' will automatically be price*quantity. there are keywords that can be used: 1) "_input" - the field will be a text input with the value set to the given field. when the user changes the value, it will update the cart. this can be useful for quantity. (ie "Quantity_input") 2) "increment" - a link with "+" that will increase the item quantity by 1 3) "decrement" - a link with "-" that will decrease the item quantity by 1 4) "remove" - a link that will remove the item from the cart 5) "_image" or "Image" - the field will be an img tag with the src set to the value. You can simply use "Image" if you set a field in the items called "Image". If you have a field named something else, like "Thumb", you can add the "_image" to create the image tag (ie "Thumb_image"). 6) "_noHeader" - this will skip the header for that field (ie "increment_noHeader") */ /****************************************************** add/remove items to cart ******************************************************/ me.add = function () { var me=this; /* load cart values if not already loaded */ if( !me.pageIsReady ) { me.initializeView(); me.update(); } if( !me.isLoaded ) { me.load(); me.update(); } var newItem = new CartItem(); /* check to ensure arguments have been passed in */ if( !arguments || arguments.length === 0 ){ error( 'No values passed for item.'); return; } var argumentArray = arguments; if( arguments[0] && typeof( arguments[0] ) != 'string' && typeof( arguments[0] ) != 'number' ){ argumentArray = arguments[0]; } newItem.parseValuesFromArray( argumentArray ); newItem.checkQuantityAndPrice(); /* if the item already exists, update the quantity */ if( me.hasItem(newItem) ) { var id=me.hasItem(newItem); me.items[id].quantity= parseInt(me.items[id].quantity,10) + parseInt(newItem.quantity,10);ostatok=parseFloat(me.items[id].ostatok.replace(/\s/g, ).replace(",", "")); if(ostatok|➨/g, "")).replace(/\"|\'/gi, "”"); itemsStringTable=itemsStringTable + ""+ yacaption+"" +""+ item.quantity+""+ ShowVm3+ShowMkg+""+ addSpaces( currentPrice.toFixed(noliq)) +""+addSpaces(itogi.toFixed(noliq)) +""; Itogo=Itogo+itogi ; ordersTableArr[ordersTableArr.length]=[item.name,yacaption,item.quantity,currentPrice,itogi]; YaProducts =YaProducts+ '{'+ '"id":'+'"'+ item.name+'"' +','+ '"name":'+ '"'+yacaption+'"'+','+ '"price":' +currentPrice+','+ '"quantity":'+ item.quantity +'}'+','; YaProducts =YaProducts.replace(/\r?\n/g, ""); itemsString = itemsString + ";" + item.name + ";" + item.quantity + ";" + currentPrice.toFixed(noliq) ; counter++; } if (Itogo>tovDostavFreeFrom ){tovDostavSt=0}; itogoZakaz=Itogo+ tovDostavSt+ tip_oplatiSt; oplataSel=document.querySelector('.oplataSelect').options[document.querySelector('.oplataSelect').options.selectedIndex].text; dostavkaSel="Доставка"; dostvar="" +"" +oplataSel + "" + ""+ShowVm3All_+ShowMkgAll_+"" + " OK"+" "+"" +"" + dostavkaSel + "" + ""+ShowVm3All_+ShowMkgAll_+"" + addSpaces(tovDostavSt.toFixed(noliq))+" "+""+ShowVm3All +ShowMkgAll+" ИТОГО: "+"" + addSpaces((itogoZakaz).toFixed(noliq))+" "+valuta+ "" + ""; dostvarURL=";"+dostav1+";1;"+tovDostavSt+";"+tip_oplati1+";1;"+tip_oplatiSt; ordersTableArr[ordersTableArr.length]=[document.querySelector('.oplataSelect').value, oplataSel,"1","OK","OK"]; ordersTableArr[ordersTableArr.length]=[dostav1, dostavkaSel,"1","OK",tovDostavSt]; ordersTableArr[ordersTableArr.length]=["итог:", " "," "," ",itogoZakaz]; var max =[0,0,0,0,0]; var ordersTableArrLen =[]; for (var i = 0; i< ordersTableArr.length ; i++) { ordersTableArrLen[i] = []; for (var r = 0; r < ordersTableArr[i].length ; r++) { ordersTableArrLen[i][r] =ordersTableArr[i][r].toString().length; if(ordersTableArr[i][r].toString().length>max[r]){max[r]=ordersTableArr[i][r].toString().length} } } for (var i = 0; i< ordersTableArr.length ; i++) { strn4Google=strn4Google+"[ "; for (var r = 0; r < ordersTableArr[i].length ; r++) { if(r < ordersTableArr[i].length-1){stick=" | "}else{stick=""} strn4Google=strn4Google+ordersTableArr[i][r]+a(max[r]-ordersTableArr[i][r].toString().length) + stick; } strn4Google=strn4Google+" ]\r\n"; } strn3=strnTop + itemsStringTable+ dostvar + ""; strn = strn + itemsString ;var wlocation= encodeURI (strn +dostvarURL+";$" + userFF1+"$" +userII1+"$" +userOO1+"$" + fullOrder ); document.getElementById("hideCart").style.height = '0px'; document.getElementById("hideCart").style.overflow = 'hidden'; document.getElementById("cart_backdrop").style.display = 'none';document.getElementById("hideCart").style.padding = '0px';window.location="#!heeg#"+wlocation; MonetaAtt= "" ; if( tip_oplati1.indexOf("moneta") >-1) {window.open(MonetaAtt.getAttribute('url_zaprosa')+"?paymentSystem.unitId="+tip_oplati1.replace(/moneta/gi, "")+"&paymentSystem.limitIds="+tip_oplati1.replace(/moneta/gi, "")+"&MNT_ID="+MonetaAtt.getAttribute('id_magazina')+"&MNT_TEST_MODE="+MonetaAtt.getAttribute('test_1or0')+"&MNT_TRANSACTION_ID="+fullOrder+"&MNT_CURRENCY_CODE="+MonetaAtt.getAttribute('valuta_moneta')+"&MNT_AMOUNT="+itogoZakaz+"","_blank") }if( tip_oplati1=="all") {window.open(MonetaAtt.getAttribute('url_zaprosa')+"?"+"&MNT_ID="+MonetaAtt.getAttribute('id_magazina')+"&MNT_TEST_MODE="+MonetaAtt.getAttribute('test_1or0')+"&MNT_TRANSACTION_ID="+fullOrder+"&MNT_CURRENCY_CODE="+MonetaAtt.getAttribute('valuta_moneta')+"&MNT_AMOUNT="+itogoZakaz+"","_blank") }setTimeout(function(){if( tip_oplati1=="AC" || tip_oplati1=="PC" || tip_oplati1=="MC") {document.querySelector('[name="firstname"]').value=userFF1;document.querySelector('[name="phone"]').value=userII1;document.querySelector('[name="email"]').value=userOO1;document.querySelector('[name="street"]').value=tkV+" "+userAA1;document.querySelector('[name="comment"]').value=userCC1+" (не удаляйте ссылку на заказ) Ссылка на заказ "+ decodeURI (document.location); document.querySelector('[name="label"]').value=fullOrder;document.querySelector('[name="paymentType"]').value=tip_oplati1;document.querySelector('[name="sum"]').value=itogoZakaz;document.querySelector('[action="https://money.yandex.ru/quickpay/confirm.xml"]').submit();}if( tip_oplati1=="Paypal" ) {simpleCart.checkout2(); }document.querySelector('[aria-label^="name"]').value=userFF1;document.querySelector('[aria-label^="telephone"]').value=userII1;document.querySelector('[aria-label^="email"]').value=userOO1;document.querySelector('[aria-label^="delivery_adress"]').value=tkV+" "+userAA1;document.querySelector('[aria-label^="client_comments"]').value=userCC1+refer;document.querySelector('[aria-label^="order_number"]').value=fullOrder;/* document.querySelector('[aria-label^="random_number"]').value=randomNumber; *******************************/document.querySelector('[aria-label^="manager_comments"]').value=strn4Google;/* УБИРАЕМ document.querySelector('[aria-label^="link_for_your_order"]').value=decodeURI (document.location)+"heeg.html?"+wlocation+"#!heeg";*/document.querySelector('[aria-label^="link_for_your_order"]').value=decodeURI (document.location)+"heeg.html?"+wlocation+"&http#!heeg";document.querySelector('[name="rsubmit"]').click();if (noMailVal==1){userOO1="не указана";}var tablezakaz = ""+"Ваше имя   "+userFF1+"
"+"Ваш телефон:   "+userII1+"
"+"Ваша почта:   "+userOO1+"
"+"Адрес доставки:   "+tkV+userAA1 + "
" +"Точное время заказа:   "+fullOrder+"
"+ "Ваши комментарии к заказу:   "+userCC1+"
"+" "+"
" + strn3 +"

Ссылка на заказ<\/a>"; /*** document.getElementById('zakaz').innerHTML = tablezakaz; ***/ me.empty();alert("Спасибо за Ваш заказ! Мы свяжемся с Вами в ближайшее время.");document.querySelector('[target="my_iframe"]').reset();YaProducts=YaProducts.replace(/\(/g,"_");YaProducts=YaProducts.replace(/\)/g,"_");YaProducts=JSON.parse('['+YaProducts.slice(0, -1)+']');},100);return false; };me.paypal2 = function() {var strnPP ="";function toTranslit(text) { return text.replace(/([а-яё])|([\s_-])|([^a-z\d])/gi, function (all, ch, space, words, i) { if (space || words) { return space ? '+' : ""; } var code = ch.charCodeAt(0), index = code == 1025 || code == 1105 ? 0 : code > 1071 ? code - 1071 : code - 1039, t = ['yo', 'a', 'b', 'v', 'g', 'd', 'e', 'zh', 'z', 'i', 'y', 'k', 'l', 'm', 'n', 'o', 'p', 'r', 's', 't', 'u', 'f', 'h', 'c', 'ch', 'sh', 'shch', "", 'y', "", 'e', 'yu', 'ya' ]; return t[index]; });} var me = this; var winpar = "scrollbars,location,resizable,status", strnPP = "https://www.paypal.com/"+"ru"+"/cgi-bin/webscr?cmd=_cart" + "&upload=1" + "&business=" + "info@heeg.ru" + "¤cy_code=" + "RUB" , counter = 1, itemsString = "",itemsStringCh= "", me = this; if( me.taxRate ){ strnPP = strnPP + "&tax_cart=" + me.currencyStringForPaypalCheckout( me.taxCost ); } for( var current in me.items ){ var item = me.items[current]; var currentPrice=item.price; itemsString = itemsString + "&item_name_" + counter + "=" + toTranslit(item.name) + "&item_number_" + counter + "=" + counter + "&quantity_" + counter + "=" + item.quantity + "&amount_" + counter + "=" + me.currencyStringForPaypalCheckout( currentPrice ) + "&on0_" + counter + "=" + "Name" + "&os0_" + counter + "=" + toTranslit(item.name); counter++; } if( me.shipping() != 0){ itemsString = itemsString + "&item_name_" + counter + "=Shipping" + "&item_number_" + counter + "=" + counter + "&quantity_" + counter + "=1" + "&amount_" + counter + "=" + me.currencyStringForPaypalCheckout( me.shippingCost ); } strnPP = strnPP + itemsString ;window.location=strnPP; for( var current in me.items ){ var item = me.items[current]; itemsStringCh = itemsStringCh + "&" + item.name + "&" + item.quantity + "&" + currentPrice.toFixed(noliq) ; }var paypalLetter= "Проверка цен PayPal<\/a>"; }; /****************************************************** data storage and retrival ******************************************************/ /* load cart from cookie */ me.load = function () { var me = this; /* initialize variables and items array */ me.items = {}; me.total = 0.00; me.quantity = 0; if (isLocalStorageAvailable()) { var elements = document.querySelectorAll('.userFF, .userII, .userOO, .userAA '); for (var i = 0, length = elements.length; i< length; i++) { (function(element) { var name = element.getAttribute('class'); element.value = localStorage.getItem(name) || ""; element.addEventListener("input", function() { localStorage.setItem(name, element.value); }); })(elements[i]); }} /* retrieve item data from cookie */ if( isLocalStorageAvailable() ){var data= unescape(localStorage.getItem("userCookLS"+getUrlVars()["id"])).split('++');var dataStr=data.toString();} else if( readCookie('simpleCart'+getUrlVars()["id"]) ){ var data = unescape(readCookie('simpleCart'+getUrlVars()["id"])).split('++'); for(var x=0, xlen=data.length;x0 ){ me.updateCartView(); }}; me.updateViewButtons = function() { var matches = document.querySelectorAll('.simpleCart_shelfItem'); for(var i = 0; i< matches.length; i++) { matches[i].classList.remove("inCart") } for( var current in me.items ){ var nodes = document.querySelectorAll('.simpleCart_shelfItem');var item = me.items[current]; [].forEach.call( nodes, function(tw) { var a = tw.querySelector('[href="'+ encodeURIComponent(item.name)+'.html'+'"]'); if(a){ tw.classList.add("inCart") } });} }; me.updateViewTotals = function() {valuta="сом"; var outlets = [ ["quantity" , "none" ] , ["total" , "currency" ] , ["shippingCost" , "currency" ] , ["taxCost" , "currency" ] , ["taxRate" , "percentage" ] , ["finalTotal" , "currency" ] ]; for( var x=0,xlen=outlets.length; x";}else{ me[arrayName][element].innerHTML =me.quantity +""+quantityName+""+ "" + addSpaces(outputString) +" "+ valuta +"" ;dostav1= (document.querySelector('.dostav').value);tovDostavSt= parseFloat(document.querySelector('.selectDost').options[document.querySelector('.selectDost').options.selectedIndex].getAttribute('price')); tovDostavFreeFrom= parseFloat("") ;if(outputString>tovDostavFreeFrom){document.querySelector('#free_from_dost').innerHTML ="0 "+valuta;document.querySelector('#total_check').innerHTML=outputString +" "+valuta;}else{document.querySelector('#free_from_dost').innerHTML=tovDostavSt +" "+valuta;var total_check=parseFloat(outputString)+tovDostavSt;document.querySelector('#total_check').innerHTML=total_check +" "+valuta;}} } } }; me.updateCartView = function() { var newRows = [], x,newRow,item,current,header,newCell,info,outputValue,option,headerInfo; /* create headers row */ newRow = document.createElement('div'); for( header in me.cartHeaders ){ newCell = document.createElement('div'); headerInfo = me.cartHeaders[header].split("_"); newCell.innerHTML = headerInfo[0]; newCell.className = "item" + headerInfo[0]; for(x=1,xlen=headerInfo.length;x'; break; case "price": outputValue = me.valueToCurrencyString( item[ info[0].toLowerCase() ] ? item[info[0].toLowerCase()] : " " ); break; default: outputValue = item[ info[0].toLowerCase() ] ? item[info[0].toLowerCase()] : " "; break; } for( var y=1,ylen=info.length;y'; break; case "input": outputValue = me.valueToTextInput( outputValue , "onchange=\"simpleCart.items[\'" + item.id + "\'].set(\'" + outputValue + "\' , this.value);\"" ); break; case "div": case "span": case "h1": case "h2": case "h3": case "h4": case "p": outputValue = me.valueToElement( option , outputValue , "" ); break; case "noheader": break; default: error( "unkown header option: " + option ); break; } } newCell.innerHTML = outputValue; newCell.className = "item" + info[0]; newRow.appendChild( newCell ); } newRow.className = "itemContainer"; newRows[x] = newRow; x++; } for( current in me.cartDivs ){ /* delete current rows in div */ var div = me.cartDivs[current]; while( div.childNodes[0] ){ div.removeChild( div.childNodes[0] ); } for(var j=0, jLen = newRows.length; j"; } }; me.valueToTextInput = function( value , html ){ return ""; }; me.valueToLink = function( value, link, html){ return "" + value + ""; }; me.valueToElement = function( type , value , html ){ return "<" + type + " " + html + " >" + value + ""; }; /****************************************************** Duplicate management ******************************************************/ me.hasItem = function ( item ) { for( var current in me.items ) { var testItem = me.items[current]; var matches = true; for( var field in item ){ if( typeof( item[field] ) != "function" && field != "quantity" && field != "id" ){ if( item[field] != testItem[field] ){ matches = false; } } } if( matches ){ return current; } } return false; }; /****************************************************** Cart Update managment ******************************************************/ me.update = function() { if( !simpleCart.isLoaded ){ simpleCart.load(); } me.updateTotals(); me.updateView(); me.save(); me.updateViewButtons(); me.addEventToArray( getElementsByClassName('itemcaption') , simpleCart.hide , "click"); me.addEventToArray( getElementsByClassName('itemThumb') , simpleCart.hide , "click"); }; me.updateTotals = function() { me.total = 0 ; me.quantity = 0; for( var current in me.items ){ var item = me.items[current]; if( item.quantity< 1 ){ item.remove(); } else if( item.quantity !== null && item.quantity != "undefined" ){ me.quantity = parseInt(me.quantity,10) + parseInt(item.quantity,10); } if( item.price ){ me.total = parseFloat(me.total) + parseInt(item.quantity,10)*parseFloat(item.price); me.total = Math.floor(me.total * 100) / 100; } } me.shippingCost = me.shipping(); me.taxCost = parseFloat(me.total)*me.taxRate; me.finalTotal = me.shippingCost + me.taxCost + me.total; }; me.shipping = function(){ if( parseInt(me.quantity,10)===0 ) return 0; var shipping = parseFloat(me.shippingFlatRate) + parseFloat(me.shippingTotalRate)*parseFloat(me.total) + parseFloat(me.shippingQuantityRate)*parseInt(me.quantity,10), nextItem, next; for(next in me.items){ nextItem = me.items[next]; if( nextItem.shipping ){ if( typeof nextItem.shipping == 'function' ){ shipping += parseFloat(nextItem.shipping()); } else { shipping += parseFloat(nextItem.shipping); } } } return shipping; }; me.initialize = function() { simpleCart.initializeView(); simpleCart.load(); simpleCart.update(); }; } /******************************************************************************************************** * Cart Item Object ********************************************************************************************************/ var ostatok=0; function CartItem() { this.id = "c" + NextId++; } CartItem.prototype.set = function ( field , value ){ field = field.toLowerCase(); if( typeof( this[field] ) != "function" && field != "id" ){ if( field == "quantity" ){ value = value.replace( /[^(\d|\.)]*/gi , "" ); value = value.replace(/,*/gi, ""); value = parseInt(value,10); } else if( field == "price"){ value = value.replace( /[^(\d|\.)]*/gi, ""); value = value.replace( /\.$|[^\d.]/gi , "" ); value = value.replace(/,*/gi , ""); value = parseFloat( value ); } if( typeof(value) == "number" && isNaN( value ) ){ error( "Improperly formatted input."); } else { this[field] = value; this.checkQuantityAndPrice(); } } else { error( "Cannot change " + field + ", this is a reserved field."); } simpleCart.update(); }; CartItem.prototype.increment = function(){ this.quantity = parseInt(this.quantity,10) + 1; ostatok=parseFloat(this.ostatok.replace(/\s/g, ).replace(",", "")); if(ostatok0) { for(var x=0, xlen=array.length; x1 ){ if( value.length>2 ){ for(var j=2, jlen=value.length;jul'); document.querySelector(".tw-table-of-contents-top>ul").onclick = function(event) { for (var i = 0; i< elements.length; i++) { elements[i].className="hover"; } }; document.querySelector(".tw-table-of-contents-top>ul").onmouseover = function(event) { for (var i = 0; i< elements.length; i++) { elements[i].className="hover"; } }; var t; function up() { for (var i = 0; i < elements.length; i++) { elements[i].className = 'nohover'; } if ( pinframe==1){document.body.scrollIntoView(); }else{ var top = Math.max(document.body.scrollTop,document.documentElement.scrollTop); if(top > 0) { window.scrollBy(0,-100); t = setTimeout('up()',20); } else clearTimeout(t); return false; } }; function no_good( ost, cap){ simpleCart.initialize(); alert("К сожалению, на складе осталось только "+ost+" ед. "+cap); } if (document.querySelector('.personal')){ document.querySelector('.personal').addEventListener('click', function () { window.location="personal_data.html"; }); }; setTimeout(function(){ simpleCart.initialize(); if (typeof vkwidth == 'function') {vkwidth();} },700); /*Измените номер счетчика 27443453 на свой */ (function(m,e,t,r,i,k,a){m[i]=m[i]||function(){(m[i].a=m[i].a||[]).push(arguments)}; m[i].l=1*new Date();k=e.createElement(t),a=e.getElementsByTagName(t)[0],k.async=1,k.src=r,a.parentNode.insertBefore(k,a)}) (window, document, "script", "https://mc.yandex.ru/metrika/tag.js", "ym"); ym(27443453, "init", { clickmap:true, trackLinks:true, accurateTrackBounce:true, trackHash:true }); var div = document.createElement('div'); div.innerHTML = ''; document.body.appendChild(div);