var Domain=document.location.protocol+"//"+document.location.host;var Yauth=false;try{Yauth=Lego.isSessionValid()}catch(e){}var Retpath=document.location.href;var modules_handlers=[{reqs:["MyShopsBar","AjaxProcessor","AjaxRequest","toolbar_init"],handler:"toolbar_init"}];function srcloaded(){var C,D,B,A;for(D in modules_handlers){C=modules_handlers[D];A=true;for(B in C.reqs){A=A?C.reqs[B] in window:false}if(A){window[C.handler]()}}}function print_r(A){var C="";for(k in A){if(typeof A[k]!="function"){C+=k+"="+A[k]+", "}else{try{C+=k+"="+(A[k])()+", "}catch(B){}}}alert(C)}$(document).keyup(function(A){var B="";if(window.event){B=A.keyCode}else{if(A.which){B=A.which}}if(B==27){$.fn.popupClose()}});$(document).bind("click",popupClick);$(document).data("popup",{lastParent:0,modal:false,id:0});jQuery.fn.popupOpen=function(M){var F=$(document).data("popup");var C=$(this).attr("id")||"p007";var I=M.type||"success";var K=(I=="success"||I=="inform"||I=="warning"||I=="action_modal");if(!F.lastParent||(F.lastParent&&!F.modal&&"popup"+$(this).attr("id")!==F.id)){$('div[class~="b-popup"]').remove();var H="";$("body").append('<div id="popup'+C+'" class="b-popup"></div>');var A=$("#popup"+C);window._pp=A;$('<i class="b-popup-tl"></i><i class="b-popup-tr"></i><i class="b-popup-t"></i><i class="b-popup-l"></i><div class="b-popup-content"><div class="b-popup-close" title="Закрыть (Esc)"><i></i></div><div class="b-popup-body"></div></div><i class="b-popup-r"></i><i class="b-popup-b"></i><i class="b-popup-bl"></i><i class="b-popup-br"></i>').appendTo(A);if("title" in M){A.find("div.b-popup-content").prepend('<div class="b-popup-title">'+M.title+"</div>")}else{A.find("div.b-popup-body").css({"padding-top":"10px"})}if(M.url){$("div.b-popup-body").load(M.url,function(){})}else{if(M.node){H="<div>"+$(M.node).html()+"</div>"}else{if(M.html){H=M.html}}}A.find("div.b-popup-body").append(H);if(K){A.addClass("b-popup-modal");$("body").addClass("doNotFlicker")}if(I!="note"){A.addClass("b-popup-"+I)}else{A.addClass("b-popup-note");A.find("div.b-popup-content").prepend('<div class="b-popup-tail"></div>');A.css({position:"absolute"})}var E=parseInt(A.outerWidth());var L=(M.height)?((parseInt(M.height)%2==1)?parseInt(M.height)+1:parseInt(M.height)):false;if(L){A.find("div.b-popup-body").css({height:L+"px"})}var B=(M.width)?((parseInt(M.width)%2==1)?parseInt(M.width)+1:parseInt(M.width)):false;if(B){if(K){A.find("div.b-popup-body").css({width:B+"px"})}A.css({width:(B+30)+"px"})}if(K){(M.top)?A.css({top:parseInt(M.top)}):A.css({"margin-top":Math.floor(A.outerHeight()/2*(-1))});(M.left)?A.css({left:parseInt(M.left)}):A.css({"margin-left":Math.floor(A.outerWidth()/2*(-1))})}else{if(I=="note"){A.css({top:getAbsolutePosz($(this).get(0)).y+$(this).innerHeight(),left:getAbsolutePosz($(this).get(0)).x})}else{var J=Math.floor(($(window).height()/2)-(A.outerHeight()/2)+$(document).scrollTop());(J<$(document).scrollTop())?J=$(document).scrollTop():false;var D=Math.floor(($(window).width()/2)-(A.outerWidth()/2)+$(document).scrollLeft());(D<$(document).scrollLeft())?D=$(document).scrollLeft():false;A.css({top:J,left:D})}}if($(window).width()-$(this).offset().left<A.outerWidth()&&$(this).offset().left>A.outerWidth()&&!K){A.addClass("b-popup-note-right");var G=(-1)*(A.outerWidth()-(E+parseInt(A.css("margin-left"))));A.css({"margin-left":G})}else{if(!K&&I=="note"){A.addClass("b-popup-note-left")}}A.find(".b-popup-frame").load(function(){A.find(".b-popup-frame").css({height:A.find("div.b-popup-body").innerHeight()-18,width:A.find("div.b-popup-body").innerWidth()-47})});A.find("div.b-popup-close").bind("click",function(){$(this).popupClose(A)});$(document).data("popup").lastParent=this;$(document).data("popup").modal=K;$(document).data("popup").id="popup"+C;$(document).data("popup").onclose="onclose" in M?M.onclose:null;A.addClass("someFakeClassName");return false}};function getAbsolutePosz(B){var C={x:B.offsetLeft,y:B.offsetTop};if(B.offsetParent){var A=getAbsolutePosz(B.offsetParent);C.x+=A.x;C.y+=A.y}return C}jQuery.fn.popupClose=function(A){if(jQuery.support.opacity){$('div[class~="b-popup"]').fadeOut("fast",popupRemove)}else{popupRemove()}return true};function popupRemove(){$('div[class~="b-popup"]').remove();$("body").removeClass("doNotFlicker");$(document).data("popup").lastParent=0;$(document).data("popup").modal=false;$(document).data("popup").id=0;if(typeof $(document).data("popup").onclose=="function"){$(document).data("popup").onclose()}}function popupClick(B){var A=$(document).data("popup").modal;if(B.target==$(document).data("popup").lastParent||$(B.target).parents().is("div.b-popup")||$(B.target).is(".b-popup")||A){return true}else{if(!$(document).data("popup").modal&&$(document).data("popup").lastParent){$.fn.popupClose();return false}else{return true}}}function AjaxProcessor(A){this.HTTPCode=0;this.status=0;this.customer=A;this.result=null;this.ProgID=["MSXML2.XMLHTTP","Microsoft.XMLHTTP"]}AjaxProcessor.prototype._getConnector=function(){try{return new XMLHttpRequest()}catch(B){for(var A=0;A<this.ProgID.length;A++){try{return new ActiveXObject(this.ProgID[A])}catch(B){continue}}return false}};AjaxProcessor.prototype.stop=function(){if(this.request&&this.request.readyState!=4){this.request.abort()}};AjaxProcessor.prototype.start=function(){var C;this.request=C=this._getConnector();if(!C){return false}this.customer.sleep();var A=this.customer;var B=this;C.onreadystatechange=function(){if(C.readyState==4&&C.status){return A.wakeup(C.status,C.responseText)}return false};C.open(this.customer.getMethod(),this.customer.calculateUrl(),this.customer.async);C.send(this.customer.body);return true};function printr(o){s="";for(k in o){s+=k+"=["+eval("o[k]")+"], "}alert(s)}function validateUrl(A){return true}function Dispatcher(){this.collection=new Array();this.add=function(A){this.collection[this.collection.length]=A;return this.collection.length-1};this.get=function(A){return this.collection[A]};this.unset=function(A){return this.collection[A]=null}}var Globals=new Dispatcher;function isMethodBelongToObject(obj,method){return typeof (method)=="string"&&method.length!=0&&eval("obj."+method)!=undefined&&typeof (eval("obj."+method))=="function"}function isUrl(A){return typeof (A)=="string"&&A.length>0&&validateUrl(A)}function isObject(A){return typeof (A)=="object"}function CreateAjaxRequest(E,D,C,B,A){if(isObject(E)&&isMethodBelongToObject(E,C)&&isMethodBelongToObject(E,B)&&isUrl(D)){return new AjaxRequest(E,D,C,B,A)}else{return null}}function AjaxRequest(E,D,C,B,A){this.method="GET";this.url=D;this.traceArgs=A||null;this.successCode="200";this.timeout=3000;this.timer=null;this.body=null;this.customer=E;this.successMeth=C;this.unSuccessMeth=B;this.result=null;this.params=[];this.randurl=true;this.provider=new AjaxProcessor(this);this.dnum=Globals.add(this);this.async=true;this.can=false}AjaxRequest.prototype.setTimeout=function(A){this.timeout=A};AjaxRequest.prototype.getTimeout=function(A){return this.timeout};AjaxRequest.prototype.calculateUrl=function(){var A=this.url;A+=this.params.length||this.randurl?"?":"";for(var B=0;B<this.params.length;B++){A+="&"+this.params[B][0]+"="+encodeURIComponent(this.params[B][1])}A+=this.randurl?"&rnd="+Math.random():"";return A};AjaxRequest.prototype.setSuccessCode=function(A){this.successCode=A;return true};AjaxRequest.prototype.setParam=function(B,C,A){var D=isNaN(A)?this.params.length:A;this.params[D]=[B,C];return D};AjaxRequest.prototype.setMethod=function(A){if(A=="GET"||A=="POST"){this.method=A;return true}return false};AjaxRequest.prototype.getMethod=function(){return this.method};AjaxRequest.prototype.start=function(){this.can=true;return this.provider.start()};AjaxRequest.prototype.wakeup=function(httpCode,text){if(this.timer==false||this.can==false){return false}else{clearTimeout(this.timer)}var args=(this.traceArgs!=null?"this.traceArgs":"");return eval("this.customer."+(httpCode==this.successCode?this.successMeth+"(text"+(args?", "+args:"")+")":this.unSuccessMeth+"("+args+")"))};AjaxRequest.prototype.wakeupByTimeout=function(){clearTimeout(this.timer);this.can=false;this.timer=false;var args=(this.traceArgs!=null?"this.traceArgs":"");eval("this.customer."+this.unSuccessMeth+"("+args+")");return false};AjaxRequest.prototype.sleep=function(){this.timer=window.setTimeout("Globals.get("+this.dnum+").wakeupByTimeout();",this.timeout)};srcloaded();function printr_0(C){var A="";var B="";for(k in C){if(C[k]!==null){A+=k+"="+C[k]+", "}else{B+=k+", "}}alert(A+B)}function MyShop(name,shopid,rate,ordering,delivery,quality,text,context){this.shopid=shopid;this.name=name;this.context=context;this.buff={};this.offers={};this.gp_0=rate||null;this.text=text||"";this.ordering=ordering||null;this.delivery=delivery||null;this.quality=quality||null;this.gate=Domain+"/gate/";this.addOffer=function(offerid,abuseurl){if(!(offerid in this.offers)){this.offers[offerid]=abuseurl}};this.setRateOk=function(response,trace){var result;eval(response);if(result&&("processing" in result)&&(result.processing==true)){this.gp_0=result.gp_0-0;this.ordering=result.gp_1-0;this.delivery=result.gp_2-0;this.quality=result.gp_3-0;this.text=(result.text!="null"&&trim(result.text)!="")?trim(result.text):"";if(this.text==""){MyShopsBar.set_current(trace[0],trace[1]);MyShopsBar.deactivate();this.buff={};MyShopsBar.setValues()}else{var gradeLink=document.getElementById("toolbarplace"+trace[0]);window.open(gradeLink.href+"&r&sign","_self")}}else{}return true};this.setRateFailed=function(){return false};this.abuse=function(offerid){if(offerid in this.offers){document.location.href=this.offers[offerid]+"&abusetext="+trim(EncodeURI(MyShopsBar.elems.textarea.value))}return false};this.commit=function(rate){var gp_0=this.buff&&"gp_0" in this.buff?this.buff.gp_0:this.gp_0;if(gp_0==null){$("#MTB_no-rate-warning").css("display","inline");$("#textSpacerMainRate").addClass("errorAlert")}else{var ordering=this.buff&&"ordering" in this.buff?this.buff.ordering:this.ordering;var delivery=this.buff&&"delivery" in this.buff?this.buff.delivery:this.delivery;var quality=this.buff&&"quality" in this.buff?this.buff.quality:this.quality;var text=trim(MyShopsBar.elems.textarea.value);this.buff={};var oRequest=CreateAjaxRequest(this,this.gate,"setRateOk","setRateFailed",[MyShopsBar.current_place,MyShopsBar.current_shop]);oRequest.setParam("a","c");oRequest.setParam("shop_id",this.shopid);oRequest.setParam("anonymous",1);oRequest.setParam("sk",mvc.obj("user").prop("sk"));if(gp_0!=null){oRequest.setParam("gr_0",gp_0)}if(ordering!=null){oRequest.setParam("gr_1",ordering)}if(delivery!=null){oRequest.setParam("gr_2",delivery)}if(quality!=null){oRequest.setParam("gr_3",quality)}if(MyShopsBar.current_place in MyShopsOffers){oRequest.setParam("context",MyShopsOffers[MyShopsBar.current_place])}oRequest.setParam("comment",myenc(text));oRequest.start()}return false}}var MyShopsOffers={};var MyShopsCollection={shops:{},addOffer:function(B,I,F,H,D,E,J,K,C,G,A){if(!(B in this.shops)){this.shops[B]=new MyShop(B,I,H,D,E,J,K,C)}this.shops[B].addOffer(F,G);if(A){MyShopsOffers[F]=A}}};var browserName="";var ua=navigator.userAgent.toLowerCase();if(ua.indexOf("opera")!=-1){browserName="opera"}else{if(ua.indexOf("msie")!=-1){browserName="msie"}else{if(ua.indexOf("safari")!=-1){browserName="safari"}else{if(ua.indexOf("mozilla")!=-1){if(ua.indexOf("firefox")!=-1){browserName="firefox"}else{browserName="mozilla"}}}}}function getPlace(A){return{x:document.body.clientWidth/2+document.body.scrollLeft,y:document.body.clientHeight/2+document.body.scrollTop}}var MyShopsBar={agreement_action:false,current_place:false,current_shop:false,nailed:false,real_rate:null,real_rate_timer:false,elems:{},auth:Yauth,grades_smile:[":-((",":-(",":-|",":-)",":-))"],grades_text:[["ужасный&#160;магазин","Удобство&#160;заказа","Доставка","Качество&#160;товара"],["плохой магазин","Удобство&#160;заказа","Доставка","Качество&#160;товара"],["обычный магазин","Удобство&#160;заказа","Доставка","Качество&#160;товара"],["хороший магазин","Удобство&#160;заказа","Доставка","Качество&#160;товара"],["отличный&#160;магазин","Удобство&#160;заказа","Доставка","Качество&#160;товара"]],init:function(A){this.agreement=A||false;this.elems.shopheader=document.getElementById("marketMyShopsBarShopHeader");this.elems.shopsbar=document.getElementById("marketMyShopsBar");this.elems.textarea=document.getElementById("commentArea");this.elems.thermometer=document.getElementById("marketMyShopsBarThermometer");this.elems.thermometer_link=document.getElementById("MSBT_Link");this.elems.userAlert=document.getElementById("userOpinionAlert")},TTimer:null,killTTimer:function(){if(this.TTimer!=null){window.clearTimeout(this.TTimer)}},enable_thermometer:function(){this.killTTimer();this.TTimer=window.setTimeout(function(){MyShopsBar.hide_thermometer()},600);return false},hide_thermometer:function(){this.killTTimer();this.elems.thermometer.style.display="none";return false},activate_thermometer:function(A){if(this.elems.userAlert){this.elems.userAlert.style.display="none"}return this.set_current(this.thermometer_state[0],this.thermometer_state[1],this.thermometer_state[2])},set_thermometer:function(A,B,C){var D=MyShopsCollection.shops[B].gp_0;this.thermometer_state=[A,B,C];this.elems.thermometer_link.innerHTML=D!=null?"<span>моя оценка</span>":"<span>написать отзыв</span>";this.elems.thermometer_link.onmouseover=function(){return MyShopsBar.killTTimer()};this.elems.thermometer_link.onmouseout=function(){return MyShopsBar.enable_thermometer()};return false},thermometer:function(D,A,B,C){if(this.nailed){return false}this.elems.thermometer.onmouseover=function(){return false};this.set_thermometer(A,B,C);return false},getRC:function(C,A){var B=A===true?"offsetTop":"offsetLeft";var D=C[B];while(C.offsetParent!=null){C=C.offsetParent;D+=C[B];if(C.tagName=="BODY"){break}}return D},set_current:function(A,B,C){if(!this.nailed){this.current_place=A;this.current_shop=B}else{this.deactivate();this.set_current(A,B)}try{this.activate(C)}catch(D){alert(D)}return false},subrate:function(A){if(this.current_shop===undefined||!this.current_shop||!(this.current_shop in MyShopsCollection.shops)||!("shopid" in MyShopsCollection.shops[this.current_shop])){return false}for(rate in A){MyShopsCollection.shops[this.current_shop].buff[rate]=A[rate]}this.setValues(MyShopsCollection.shops[this.current_shop].buff);return false},rate:function(A){this.real_rate=null;return this.subrate(A)},rateAndHideWarn:function(A){this.hideWarning();return this.rate(A)},hideWarning:function(){var A=$("#MTB_no-rate-warning");if(A.css("display")!="none"){A.css("display","none");$("#textSpacerMainRate").removeClass("errorAlert")}},authcommit:function(){var E=MyShopsCollection.shops[this.thermometer_state[1]].gp_0;var G=MyShopsCollection.shops[this.thermometer_state[1]].buff;var A=G&&"gp_0" in G&&(G.gp_0!=null&&!isNaN(G.gp_0))?G.gp_0:E;var B=document.getElementById("toolbarplace"+this.current_place);var F=getPlace(B);var D=document.getElementById("login-form");D.style.position="absolute";D.style.top=F.y-100;var C="&place="+this.burl+(A!==null?"&pregrade="+A:"");document.forms.login.retpath.value=Retpath+C;showLogin(0);return false},commit:function(C){if(this.agreement_action){this.setAgreeTransaction(C);return false}var A=MyShopsCollection.shops[this.current_shop].commit();if(C){var B=this;window.setTimeout(function(){B.abuse()},500)}return false},abuse:function(){MyShopsCollection.shops[this.current_shop].abuse(this.current_place)},isValidGrade:function(A){return(",-2,-1,0,1,2,".indexOf(","+A+",")!=-1)},setValues:function(N,A){this.elems.shopheader.innerHTML="Оценить магазин "+this.current_shop;if(this.current_shop===undefined||!this.current_shop||!(this.current_shop in MyShopsCollection.shops)||!("shopid" in MyShopsCollection.shops[this.current_shop])){return false}var B=MyShopsCollection.shops[this.current_shop].gp_0;var P=MyShopsCollection.shops[this.current_shop].ordering;var O=MyShopsCollection.shops[this.current_shop].delivery;var L=MyShopsCollection.shops[this.current_shop].quality;var C=MyShopsCollection.shops[this.current_shop].text;B=(B!=null&&!isNaN(B))?B:null;P=(P!=null&&!isNaN(P))?P:null;O=(O!=null&&!isNaN(O))?O:null;L=(L!=null&&!isNaN(L))?L:null;var F=N&&"gp_0" in N&&(N.gp_0!=null&&!isNaN(N.gp_0))?N.gp_0:B;var K=C;var E=N&&"ordering" in N&&(N.ordering!=null&&!isNaN(N.ordering))?N.ordering:P;var D=N&&"delivery" in N&&(N.delivery!=null&&!isNaN(N.delivery))?N.delivery:O;var J=N&&"quality" in N&&(N.quality!=null&&!isNaN(N.quality))?N.quality:L;for(var I=0;I<5;I++){document.getElementById("smilesMainRate"+(I-2)).className=((F!=null&&(F>=(I-2)))?" b-rating__star-my":" b-rating__star");document.getElementById("textSpacerMainRate"+(I-2)).className=(F!=null&&(F==(I-2)))?"visible":"tip";document.getElementById("ordering"+(I-2)).className=((E!=null&&(E>=(I-2)))?" b-rating__star-my":" b-rating__star");document.getElementById("delivery"+(I-2)).className=((D!=null&&(D>=(I-2)))?" b-rating__star-my":" b-rating__star");document.getElementById("quality"+(I-2)).className=((J!=null&&(J>=(I-2)))?" b-rating__star-my":" b-rating__star")}document.getElementById("textSpacerMainRate").className=(F==null)?"visible":"tip";var M=document.getElementById("agreepub");if(document.getElementById("MTB_rate")){document.getElementById("MTB_rate").disabled=(M!=null&&!this.agreement)}if(M){M.checked=this.agreement}if(this.isValidGrade(B)&&A!==true){for(offerid in MyShopsCollection.shops[this.current_shop].offers){var G=$("#toolbarplace"+offerid);if(G.length>0){G.find("span").html("моя оценка");var H="";for(I=-2;I<=B;I++){H+='<span class="b-rating__star b-rating__star-my" title="моя оценка магазина"><img class="b-rating__icon" alt="*" src="block/b-rating/transparent.png"/></span>'}for(I=B+1;I<3;I++){H+='<span class="b-rating__star" title="моя оценка магазина"><img class="b-rating__icon" alt="*" src="block/b-rating/transparent.png"/></span>'}G.parent().find("span.b-rating__with_text").find("span.b-rating").html(H)}else{return false}}}return false},setAgreeTransaction:function(A){var B=document.getElementById("agreepub");var C=CreateAjaxRequest(this,Domain+"/shop-grade.xml","setAgreeOk","setAgreeFailed",A?[A]:null);C.setParam("a","u");if(B.checked){C.setParam("confirmed",true)}C.start();return false},setAgreeOk:function(A,B){document.getElementById("grades_confirm").style.display="none";this.agreement_action=false;this.commit(B)},setAgreeFailed:function(A){},setAgree:function(){this.agreement=document.getElementById("agreepub").checked;this.agreement_action=this.agreement;this.setValues(MyShopsCollection.shops[this.current_shop].buff);return true},move:function(B,A){document.body.scrollTop=B;document.body.scrollLeft=A},deactivate:function(){if(this.elems.shopsbar){this.elems.shopsbar.style.visibility="hidden";this.elems.shopsbar.style.display="none";this.nailed=false;MyShopsCollection.shops[this.current_shop].buff={}}return false},activate:function(B){if(this.current_shop===undefined||!this.current_shop||!(this.current_shop in MyShopsCollection.shops)||!("shopid" in MyShopsCollection.shops[this.current_shop])){return false}if(this.current_place&&this.elems.shopsbar.style.display!="block"){this.setValues(null,true);this.elems.textarea.value=MyShopsCollection.shops[this.current_shop].text;var A=document.getElementById("toolbarplace"+this.current_place);var C=getPlace(A);this.elems.shopsbar.style.left=C.x-200;this.elems.shopsbar.style.top=C.y-240>80?C.y-240:80;this.elems.shopsbar.style.visibility="visible";this.elems.shopsbar.style.display="block";this.nailed=true;this.burl=B}return false}};function myenc(A){return trim(A)}function trim(A){return A?A.replace(/^[\s\xA0]+/g,"").replace(/[\s\xA0]+$/g,""):""}function UnHideTree(B){var C="i/i-minus.gif";var A="i/i-plus.gif";if(B.firstChild.src.match(A)){B.firstChild.src=C;B.parentNode.parentNode.getElementsByTagName("ul")[0].style.display="block"}else{B.firstChild.src=A;B.parentNode.parentNode.getElementsByTagName("ul")[0].style.display="none"}return false}function hideLogin(){if(document.getElementById("login-form")){document.getElementById("login-form").style.display="none"}return false}function EncodeURI(A){try{return encodeURI(A)}catch(B){return escape(A)}}srcloaded();var ItemToMoveID=null;function checkCookie(){if(document.cookie.length>0){return true}else{alert("Для использования этой функции вам необходимо включить cookies в вашем браузере.");return false}}function showCode(){var A=document.getElementById("codeCont");if(A.className=="closed"){A.className="opened"}else{A.className="closed"}}function moveSelectedItem(B,E,C){var A=document.getElementById("memo-lists-layer-move-"+E);if(A){var D=getBoundsMarket(B);A.style.left=D.left+"px";A.style.top=D.top-(-2)+D.height+"px";switchElement(A);reloadCodeFrame();deleteIdent(C);deleteIdentGroups(E);deleteIdentOffers(E)}ItemToMoveID=E;return false}function moveItemToList(A,B){if(ItemToMoveID==null){return false}var C={BurnOk:function(){this.BurnFinish()},BurnFinish:function(){var D=document.getElementById("memo-lists-layer-move-"+ItemToMoveID);switchElement(D);if(!B){document.getElementById("item-id"+ItemToMoveID).parentNode.removeChild(document.getElementById("item-id"+ItemToMoveID))}if(B){window.location.href=window.location.href}ItemToMoveID=null;reloadCodeFrame();nothingShow()},BurnFailed:function(){alert("Ошибка перемешения. Попробуйте позже");this.BurnFinish()}};C.Request=CreateAjaxRequest(C,"/gate/move-items.xml","BurnOk","BurnFailed");C.Request.setParam("old_list_id",currentListId);C.Request.setParam("new_list_id",A);C.Request.setParam("id",ItemToMoveID);C.Request.start();return false}function clearList(C,A){if(confirm("Очистить список?")){var B={BurnOk:function(){this.BurnFinish()},BurnFinish:function(){var D=getElementsByClassName(document,"table","results")[0];D.style.display="none";C.style.display="none";document.getElementById("nothing-holder").style.display="block"},BurnFailed:function(){alert("Ошибка удаления. Попробуйте позже");this.BurnFinish()}};B.Request=CreateAjaxRequest(B,"/gate/clear-list.xml","BurnOk","BurnFailed");B.Request.setParam("list_id",A);B.Request.start()}return false}function reloadCodeFrame(){var A=document.getElementById("codeFrame");if(A){A.src=A.src}}function BurnComment(A,C){var B={BurnOk:function(){document.getElementById("note"+A).disabled=false;this.BurnFinish()},BurnFinish:function(){var E=document.getElementById("note"+A).value;document.getElementById("memo-note-"+A).innerHTML=E.replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\n/g,"<br>");reloadCodeFrame();setClass(document.getElementById("comment-place-"+A),"has-note",E=="");switchClass(document.getElementById("comment-place-"+A),"open");var D=document.getElementById("comment-swither-"+A);switchClass(D,"open");setClass(D,"has-note",E=="");D.firstChild.firstChild.data=(E=="")?"моя заметка":"моя заметка"},BurnFailed:function(){alert("Ошибка записи. Попробуйте позже")}};B.Request=CreateAjaxRequest(B,"/gate/add-ware.xml","BurnOk","BurnFailed");if(C=="2"){B.Request.setParam("offer_id",document.getElementById("offer_id"+A).value);B.Request.setParam("model_id",document.getElementById("model_id"+A).value);B.Request.setParam("display_name",document.getElementById("display_name"+A).value);B.Request.setParam("cat_name",document.getElementById("cat_name"+A).value);B.Request.setParam("hid",document.getElementById("hid"+A).value);B.Request.setParam("note",document.getElementById("note"+A).value);B.Request.setParam("type","o")}else{if(C=="1"){B.Request.setParam("group_id",document.getElementById("group_id"+A).value);B.Request.setParam("display_name",document.getElementById("display_name"+A).value);B.Request.setParam("cat_name",document.getElementById("cat_name"+A).value);B.Request.setParam("hid",document.getElementById("hid"+A).value);B.Request.setParam("note",document.getElementById("note"+A).value);B.Request.setParam("type","g")}else{B.Request.setParam("model_id",document.getElementById("model_id"+A).value);B.Request.setParam("display_name",document.getElementById("display_name"+A).value);B.Request.setParam("cat_name",document.getElementById("cat_name"+A).value);B.Request.setParam("hid",document.getElementById("hid"+A).value);B.Request.setParam("note",document.getElementById("note"+A).value);B.Request.setParam("type","m")}}document.getElementById("note"+A).disabled=true;B.Request.start();return false}function deleteIdent(E){var D=[];for(var C=0,B=0,A=idents.length;C<A;C++){if(idents[C]!=E){D[B++]=idents[C]}}idents=D;return idents}function deleteIdentGroups(E){var B=[];for(var D=0,C=0,A=identsGroups.length;D<A;D++){if(identsGroups[D]!=E){B[C++]=identsGroups[D]}}identsGroups=B;return identsGroups}function deleteIdentOffers(E){var D=[];for(var C=0,B=0,A=identsOffers.length;C<A;C++){if(identsOffers[C]!=E){D[B++]=identsOffers[C]}}identsOffers=D;return identsOffers}function deleteItem(D,C,A){conf_text="Удалить товар?";if(mvc.map("models").obj(C).prop("expected-price")>0){conf_text+="\nПри этом подписка на товар аннулируется."}if(confirm(conf_text)){var B={BurnOk:function(){this.BurnFinish()},BurnFinish:function(){document.getElementById("item-id"+D).parentNode.removeChild(document.getElementById("item-id"+D));reloadCodeFrame();deleteIdent(C);deleteIdentGroups(C);deleteIdentOffers(C);nothingShow()},BurnFailed:function(){alert("Ошибка удаления. Попробуйте позже");this.BurnFinish()}};B.Request=CreateAjaxRequest(B,"/gate/delete-item.xml","BurnOk","BurnFailed");B.Request.setParam("a","d");B.Request.setParam("id",D);B.Request.setParam("list_id",A);B.Request.start();return false}else{return false}}function compareSelectedItems_OPEN(B){var A=document.getElementById("memo-lists-layer-categories");if(A){var C=getBoundsMarket(B);A.style.left=C.left+"px";A.style.top=C.top-(-2)+C.height+"px";if(A.style.display=="none"){switchElement(A);return false}}return false}function compareSelectedItems(C,A){if(C.match(/bla/)){var B=C.replace(/bla/g,",").replace(/,$/,"")}else{var B=C}window.open("/compare.xml?CMD=-CMP="+B+"&hid="+A+"&list_id="+currentListId+"&from_memo","_self");return false}function searchSelectedItems(A){var B=currentListId.length>0?"&list_id="+currentListId:"";if(A){window.open("/search.xml?hyperid="+idents.join("&hyperid=")+B+"&mhid="+A+"&from_memo","_self")}else{window.open("/search.xml?hyperid="+idents.join("&hyperid=")+B+"&from_memo","_self")}return false}function searchSelectedItemsOneShop(C,A){if(idents.length>20){alert("Поиск в одном магазине ищет до 20 товаров");return false}else{var G=idents.join(",")?idents.join(","):"";var F=identsOffers.join(",o")?",o"+identsOffers.join(",o"):"";var E=identsGroups.join(",g")?",g"+identsGroups.join(",g"):"";if(idents.length==0){identsOffers[0]="o"+identsOffers[0];var F=identsOffers.join(",o")}if(idents.length==0&&identsOffers.length==0){identsGroups[0]="g"+identsGroups[0];var E=identsGroups.join(",g")}var B=G.concat(F);var D=B.concat(E);if(C&&A){window.open("/search-models.xml?model_ids="+D+"&list_id="+C+"&hid="+A,"_self")}else{if(C){window.open("/search-models.xml?model_ids="+D+"&list_id="+C,"_self")}else{if(A){window.open("/search-models.xml?model_ids="+D+"&hid="+A,"_self")}else{window.open("/search-models.xml?model_ids="+D,"_self")}}}return false}}function nothingShow(){if(idents.length==0&&identsGroups.length==0&&identsOffers.length==0){document.getElementById("nothing-holder").style.display="block"}}function switchListComment(){var B=document.getElementById("list-comment");var A=document.getElementById("list-comment-text");if(B&&A){switchElement(B);switchElement(A)}}function switchListName(){var A=document.getElementById("list-name");if(A){switchElement(A)}};