function myscrollX(){var A=document.documentElement;return self.pageXOffset||(A&&A.scrollLeft)||document.body.scrollLeft}function myscrollY(){var A=document.documentElement;return self.pageYOffset||(A&&A.scrollTop)||document.body.scrollTop}function windowHeight(){var A=document.documentElement;return self.innerHeight||(A&&A.clientHeight)||document.body.clientHeight}function windowWidth(){var A=document.documentElement;return self.innerWidth||(A&&A.clientWidth)||document.body.clientWidth}function ShowImg(D,C,B,G){var A="no";var F=0,E=0;if(C>screen.width-10||B>screen.height-28){A="yes"}if(B<screen.height-28){F=Math.floor((screen.height-B)/2-14)}if(C<screen.width-10){E=Math.floor((screen.width-C)/2)}C=Math.min(C,screen.width-10);B=Math.min(B,screen.height-28);window.open("/img_goods/imagepg.php?alt="+G+"&img="+D,"","scrollbars="+A+",resizable=no, width="+C+",height="+B+",left="+E+",top="+F)}$.fn.extend({getWidth:function(A){A=$(A);return A.offsetWidth},setWidth:function(B,A){B=$(B);B.style.width=A+"px"},setHeight:function(A,B){A=$(A);A.style.height=B+"px"},setTop:function(B,A){B=$(B);B.style.top=A+"px"},setLeft:function(B,A){B=$(B);B.style.left=A+"px"},setSrc:function(A,B){A=$(A);A.src=B},setHref:function(B,A){B=$(B);B.href=A},setInnerHTML:function(A,B){A=$(A);A.innerHTML=B}});function getPageSize(){var C,A;if(window.innerHeight&&window.scrollMaxY){C=window.innerWidth+window.scrollMaxX;A=window.innerHeight+window.scrollMaxY}else{if(document.body.scrollHeight>document.body.offsetHeight){C=document.body.scrollWidth;A=document.body.scrollHeight}else{C=document.body.offsetWidth;A=document.body.offsetHeight;if(navigator.userAgent.toLowerCase().indexOf("opera")>-1){A=document.getElementById("outerWrapper").offsetHeight}}}var B,D;if(self.innerHeight){if(document.documentElement.clientWidth){B=document.documentElement.clientWidth}else{B=self.innerWidth}D=self.innerHeight}else{if(document.documentElement&&document.documentElement.clientHeight){B=document.documentElement.clientWidth;D=document.documentElement.clientHeight}else{if(document.body){B=document.body.clientWidth;D=document.body.clientHeight}}}if(A<D){pageHeight=D}else{pageHeight=A}if(C<B){pageWidth=C}else{pageWidth=B}arrayPageSize=new Array(pageWidth,pageHeight,B,D);return arrayPageSize}function ShowOverlay(E){HideOverlay("windowWrapper");HideOverlay("windowWrapper2");HideOverlay("windowWrapper3");HideOverlay("windowWrapper4");var B=document.getElementsByTagName("body").item(0);var D=document.createElement("div");D.setAttribute("id","overlay");D.onclick=function(){HideOverlay(E)};B.appendChild(D);D.innerHTML="<!--[if lte IE 6]><iframe></iframe><![endif]-->";var A=getPageSize();D.style.width=A[0]+"px";D.style.height=A[1]+"px";var C=document.getElementById(E);if(E=="windowWrapper3"){C.style.top=Math.round(myscrollY()+(windowHeight()/2)-260)+"px";C.style.left=Math.round((A[0]-571)/2)+"px"}else{if(E=="windowWrapper"){C.style.top="70px";C.style.left=Math.round((A[0]-243)/2)+"px"}else{C.style.top=Math.round(myscrollY()+(windowHeight()/2)-120)+"px";C.style.left=Math.round((A[0]-571)/2)+"px"}}C.style.display="block";document.onkeyup=function(F){if(F==null){F=window.event}if(F.keyCode==27){HideOverlay(E)}}}function HideOverlay(C){var A=document.getElementById(C);var B=document.getElementById("overlay");if(B){B.parentNode.removeChild(B)}A.style.display="none"}function LoadDiller(B,A){$.ajax({url:"/ajax/mylib.php",type:"POST",data:{action:"LoadDiller",city:B},dataType:"json",success:function(C){if(C.dID.length>0){var D="/index.php?DILLER="+C.dID;location.replace(D)}else{alert(C)}}})}function AddToFavorite(A){$.ajax({url:"/ajax/mylib.php",type:"POST",data:{action:"AddToFavorite",item:A},dataType:"json",success:function(B){if(B.result.length>0){var C=document.getElementById("windowWrapper4");document.getElementById("textAlert").innerHTML=B.result;ShowOverlay("windowWrapper4")}else{alert(B)}}})}function AddToBasketAll(){$.ajax({url:"/ajax/mylib.php",type:"POST",data:{action:"AddToBasketAll"},dataType:"json",success:function(A){if(A.result.length>0){var B=document.getElementById("windowWrapper4");document.getElementById("textAlert").innerHTML=A.result;ShowOverlay("windowWrapper4")}else{alert(A)}}})}function checkMinPart(B,A){$.ajax({type:"POST",url:"/catalog/min_parts.php",data:{code:B,check:1},dataType:"json",success:function(C){if(document.getElementById("orderCount_"+B).value%C.min_part!=0){alert("Введите количество товара кратное минимальной партии "+C.min_part+" шт.")}else{AddToBasket(B,A)}}})}function checkMinPartOnEnter(C,B,A){if(C.keyCode==13){checkMinPart(B,A);return false}}function AddToBasketOnEnter(C,B,A){if(C.keyCode==13){AddToBasket(B,A);return false}}function AddToBasket(E,C,F){var A=document.getElementById("orderCount_"+E);var D=0;if(C==2){D=A.value}else{if(C=="n"){D=F}else{D=A.options[A.selectedIndex].value}}ShowOverlay("windowWrapper4");var B=document.getElementById("windowWrapper4");document.getElementById("textAlert").innerHTML='<div style="text-align:center;width:100%;">Товар добавляется в корзину, пожалуйста, ожидайте.<br><img style="margin: 10px auto" src="/img/ajaxload.gif"/></div>';$.ajax({url:"/ajax/mylib.php",type:"POST",data:{action:"AddToBasket",item:E,count:D},dataType:"json",success:function(G){if(G.result.length>0){var H=document.getElementById("windowWrapper4");if(H.style.display=="block"){HideOverlay("windowWrapper4")}document.getElementById("textAlert").innerHTML=G.result;if(G.info!=undefined){document.getElementById("textInfo").innerHTML=G.info}ShowOverlay("windowWrapper4");if(G.basket.length>0){document.getElementById("basket").innerHTML=G.basket;document.getElementById("in_basket_"+E).className="addedItem";document.getElementById("in_basket_"+E).style.display="block";document.getElementById("in_basket_"+E).innerHTML=G.quantity;if(G.replace_id>0){document.getElementById("in_basket_"+G.replace_id).innerHTML="";document.getElementById("in_basket_"+G.replace_id).style.display="none"}}}else{alert(G)}}})}function AddToBasketByCode(B){var A=new Object();B.disabled=true;for(i=1;i<=12;i++){if(document.getElementById("code_"+i).value==""){continue}A["codes["+document.getElementById("code_"+i).value+"]"]=document.getElementById("q_"+i).value}cur_date=new Date();cur_date=cur_date.getTime();A.action="AddToBasketByCode";A.rand=cur_date;ShowOverlay("windowWrapper4");var C=document.getElementById("windowWrapper4");document.getElementById("textAlert").innerHTML='<div style="text-align:center;width:100%;">Товар добавляется в корзину, пожалуйста, ожидайте.<br><img style="margin: 10px auto" src="/img/ajaxload.gif"/></div>';$.ajax({url:"/ajax/mylib.php",type:"POST",data:A,dataType:"json",success:function(D){B.disabled=false;for(i=1;i<=12;i++){document.getElementById("code_"+i).value="";document.getElementById("q_"+i).value=""}if(D.result!=null&&D.result.length>0){var E=document.getElementById("windowWrapper4");document.getElementById("textAlert").innerHTML=D.result;if(D.info!=undefined){document.getElementById("textInfo").innerHTML=D.info}ShowOverlay("windowWrapper4");if(D.basket.length>0){document.getElementById("basket").innerHTML=D.basket}}else{alert(D.error)}}})}function compareItems(){document.formCompare.submit()}function FeedbackForm(){$.ajax({url:"/ajax/mylib.php",type:"POST",data:{action:"sendInformationForm",FORM_ID:10},dataType:"json",success:function(A){if(A.result.length>0){var B=document.getElementById("windowWrapper3");B.innerHTML=A.result;ShowOverlay("windowWrapper3")}else{if(A.error!=null){alert(A.error)}else{alert(A)}}}})}function FeedbackSubmit(A){var B=new Object();for(i=0;i<A.elements.length;i++){B[A.elements[i].name]=A.elements[i].value}$.ajax({url:"/ajax/mylib.php",type:"POST",data:B,dataType:"json",success:function(C){if(C!=null&&C.result>0){HideOverlay("windowWrapper3");var D=document.getElementById("windowWrapper3");D.innerHTML='<div id="window"><div id="close"><a onclick="HideOverlay(\'windowWrapper3\');" href="javascript:void(0)">Закрыть</a> или нажмите Esc </div><h2>Обратная связь</h2><div id="notifInfo"><p>Спасибо за обращение. Ваше сообщение было отправлено.</p></div>';ShowOverlay("windowWrapper3")}else{if(C.error!=null){alert(C.error)}else{alert(C)}}}})}function ReviewForm(){$.ajax({url:"/ajax/mylib.php",type:"POST",data:{action:"sendReviewForm",FORM_ID:6},dataType:"json",success:function(A){if(A.result.length>0){var B=document.getElementById("windowWrapper3");B.innerHTML=A.result;ShowOverlay("windowWrapper3")}else{if(A.error!=null){alert(A.error)}else{alert(A)}}}})}function ReviewSubmit(A){var B=new Object();for(i=0;i<A.elements.length;i++){B[A.elements[i].name]=A.elements[i].value}B.url=window.location.href;$.ajax({url:"/ajax/mylib.php",type:"POST",data:B,dataType:"json",success:function(C){if(C!=null&&C.result>0){HideOverlay("windowWrapper3");var D=document.getElementById("windowWrapper3");D.innerHTML='<div id="window"><div id="close"><a onclick="HideOverlay(\'windowWrapper3\');" href="javascript:void(0)">Закрыть</a> или нажмите Esc </div><h2>Отзыв о результатах поиска</h2><div id="notifInfo"><p>Спасибо за отзыв. Ваше сообщение было отправлено.</p></div>';ShowOverlay("windowWrapper3")}else{if(C.error!=null){alert(C.error)}else{alert(C)}}}})}function display_reason(A){var C=A.form;var D=C.getElementsByTagName("div");var B=D[0];if(A.value=="D"){C.deny_reason.disabled=false;B.style.display="block"}else{C.deny_reason.disabled=true;B.style.display="none"}}function isCompareable(){var A=document.getElementsByName("compareItems[]");var B=0;for(i=0;i<A.length;i++){if(A[i].type=="checkbox"&&A[i].checked==true){B++}}if(B==0){alert("Не выделено ни одного товара для сравнения!");return false}return true}function hideBlock(E,C,B,A){var F=document.getElementById("blockToHide");var D=document.getElementById("linkName");if(F.style.display=="none"||F.style.display==""){F.style.display="block";D.value=C;D.style.width=A}else{F.style.display="none";D.value=E;D.style.width=B}return false}function max_length(A,B){if(A.value.length>B){A.value=A.value.substring(0,B)}}function VNCText(){document.getElementById("textAlert").innerHTML="Всегда Низкие Цены &#151; мы можем это гарантировать!";document.getElementById("textInfo").innerHTML='<div class="contentText"><p>ОфисМаг является частью холдинга &#151; крупного российского дистрибьютора товаров для офиса и школы &#151; Группы Компаний «Самсон», который имеет более <b>200 прямых контрактов</b> с производителями со всего мира и <b>значительные объемы</b> закупок. Наш годовой объем продаж превышает 3,5 миллиарда рублей!</p><p>Это обеспечивает нам наиболее выгодные цены от поставщиков и минимальное число посредников в цепи «Производитель &#151; конечный пользователь». </p><p>Мы действительно предоставляем нашим клиентам минимальные цены!</p><a href="/special/superprice/">Посмотреть «Суперцены»</a><br><a href="/help/about/">Узнать больше об ОфисМаге</a><br></div>';ShowOverlay("windowWrapper4")}function createStatLink(){$("#create_stat_link").html('<img src="/img/ajaxload_gray.gif">');$.ajax({type:"POST",url:"/stat/sale_stat.php",dataType:"json",success:function(B){if(B.error){$("#create_stat_link").html("");alert(B.error)}else{if(B.success){var A='<a href="/stat/'+B.success+'"><strong>Скачать файл в формате zip</strong></a>';$("#create_stat_link").html(A)}else{$("#create_stat_link").html("");alert("System error")}}},error:function(C,A,B){alert("Error status: "+A+"\nError message: "+C.responseText)}})};