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="+encodeURI(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 findOffsetHeight(B){var A=0;while((A==0)&&B.parentNode){B=B.parentNode;A=B.offsetHeight}return A}function getOffsetHeight(A){return A.offsetHeight||A.style.pixelHeight||findOffsetHeight(A)}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)-360)+"px"}else{C.style.top=Math.round(myscrollY()+(windowHeight()/2)-220)+"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!=null){B.parentNode.removeChild(B)}A.style.display="none"}function addOption(F,E,B,D,A){var C=document.createElement("option");C.appendChild(document.createTextNode(E));C.setAttribute("value",B);if(D){C.defaultSelected=true}else{if(A){C.selected=true}}F.appendChild(C)}function clearSelect(B){for(var A=B.options.length-1;A>=0;A--){B.remove(A)}}function LoadCity(A,B){$.ajax({url:"/ajax/mylib.php",type:"POST",data:{action:"LoadCity",region:A},dataType:"json",success:function(C){if(C.result!=null&&C.result.length>0){var D=document.getElementById(B);clearSelect(D);var F=C.result.length;var H=C.result;var G;for(var E=0;E<F;E++){G=H[E];addOption(D,G.name,G.id,(E==0?true:false),false)}}else{if(C.error!=null){alert(C.error)}else{alert(C)}}}})}function LoadDiller(C,B){var A=document.getElementById(C);$.ajax({url:"/ajax/mylib.php",type:"POST",data:{action:"LoadDiller",city:A.options[A.selectedIndex].value},dataType:"json",success:function(D){if(D.dID.length>0){var F="/index.php?DILLER="+D.dID;location.replace(F);var E=document.getElementById(B);E.innerHTML=D.result}else{if(D.result.length>0){var E=document.getElementById(B);E.innerHTML=D.result}else{alert(D)}}}})}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 AddToBasket(D,B){var A=document.getElementById("orderCount_"+D);var C=0;if(B==2){C=A.value}else{C=A.options[A.selectedIndex].value}$.ajax({url:"/ajax/mylib.php",type:"POST",data:{action:"AddToBasket",item:D,count:C},dataType:"json",success:function(E){if(E.result.length>0){var F=document.getElementById("windowWrapper4");document.getElementById("textAlert").innerHTML=E.result;if(E.info!=undefined){document.getElementById("textInfo").innerHTML=E.info}ShowOverlay("windowWrapper4");if(E.basket.length>0){document.getElementById("basket").innerHTML=E.basket}}else{alert(E)}}})}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;$.ajax({url:"/ajax/mylib.php",type:"POST",data:A,dataType:"json",success:function(C){B.disabled=false;for(i=1;i<=12;i++){document.getElementById("code_"+i).value="";document.getElementById("q_"+i).value=""}if(C.result!=null&&C.result.length>0){var D=document.getElementById("windowWrapper4");document.getElementById("textAlert").innerHTML=C.result;if(C.info!=undefined){document.getElementById("textInfo").innerHTML=C.info}ShowOverlay("windowWrapper4");if(C.basket.length>0){document.getElementById("basket").innerHTML=C.basket}}else{alert(C.error)}}})}function compareItems(){document.formCompare.submit()}function sendInformation(){$.ajax({url:"/ajax/mylib.php",type:"POST",data:{action:"sendInformationForm",FORM_ID:6},dataType:"json",success:function(A){if(A.result.length>0){var B=document.getElementById("windowWrapper2");B.innerHTML=A.result;ShowOverlay("windowWrapper2")}else{if(A.error!=null){alert(A.error)}else{alert(A)}}}})}function sendInformationSubmit(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("windowWrapper2")}else{if(C.error!=null){alert(C.error)}else{alert(C)}}}})}function FeedbackForm(A){$.ajax({url:"/ajax/mylib.php",type:"POST",data:{action:"sendInformationForm",FORM_ID:7},dataType:"json",success:function(B){if(B.result.length>0){var D=document.getElementById("windowWrapper3");D.innerHTML=B.result;if(A==0){var E=document.getElementById("form_dropdown_type");var C=E.firstChild;E.removeChild(C)}ShowOverlay("windowWrapper3")}else{if(B.error!=null){alert(B.error)}else{alert(B)}}}})}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 AddToBasketOnEnter(C,B,A){if(C.keyCode==13){AddToBasket(B,A);return false}}function display_reason(A){var C=A.form;var B=document.getElementById("new_status");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 change_pass_form(){var B=document.getElementById("changePassBlock");var A=document.getElementById("changePassButton");if(B.style.display=="none"){B.style.display="block";A.value="Скрыть форму смены пароля";A.style.width="14.4em"}else{B.style.display="none";A.value="Поменять пароль";A.style.width="8.9em"}return false}function hideBlock(C,A){var D=document.getElementById("blockToHide");var B=document.getElementById("linkName");if(D.style.display=="none"||D.style.display==""){D.style.display="block";B.value=A}else{D.style.display="none";B.value=C}return false}function max_length(A,B){if(A.value.length>B){A.value=A.value.substring(0,B)}}function ChangedFormInfo(A){var B=new Object();$(A).find("input, textarea, select, button").each(function(D,C){if($(C).attr("type")!="radio"){B[$(C).attr("name")]=$(C).val()}else{if(C.checked){B[$(C).attr("name")]=$(C).val()}}});B.ajax=true;$.ajax({url:document.location.href,type:"POST",data:B,dataType:"json",success:function(C){if(C.result!=null&&C.result.length>0){$(A).parent().parent().parent().find(".comment").remove();if(C.comment.length>0){$(A).parent().parent().parent().parent().find("#download").find("img").attr("src","/img/popupIcon.gif");$(A).parent().parent().parent().find(".addcomment").before('<div class="comment">'+C.comment+"</div>")}else{$(A).parent().parent().parent().parent().find("#download").find("img").attr("src","/img/popupIconOff.gif")}$(A).parent().find("textarea").html(C.comment)}else{alert(C.error)}}});return false};