$(function(){var b=cookie("scroll");if(b){window.scrollTo(0,b);cookie("scroll",0);}$(".storepos").click(function(){cookie("scroll",(window.scrollY)?window.scrollY:document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop,{expires:10000});});$("#debug").ajaxError(function(e,d,c){$(this).append("<li>Error requesting page "+c.url+"<"+"/li>");});$(".ajaxform").each(function(){var c=this;$(this).find("a.submit").click(function(){var d=[];$(c).find("select").each(function(){d.push(this.name.replace(/_\d*/,"")+"="+encodeURIComponent(this.options[this.selectedIndex].value));});$(c).find("input").each(function(){d.push(this.name.replace(/_\d*/,"")+"="+encodeURIComponent(this.value));if(this.name.match(/^item_?/)){this.value="";}});$(this).parent().css({position:"relative"});var e=$("<div></div>").css({backgroundColor:"white",width:"70px",border:"1px solid gray",padding:"10px 20px",position:"absolute",top:"1.5em",left:0}).insertAfter($(this)).html("Товар<br>добавляется");$.post(this.href.replace("ajax=1","").replace(/(do=\w*)/,"do=add&ajax=1"),d.join("&"),function(g){if(g.error){alert(g.error);}if(g.debug){alert(g.debug);}if(g.session){if(!cookie(g.session.name)){var f=new RegExp("&"+g.session.name+"=\\w*|"+g.session.name+"=\\w*&","ig");document.location=document.location.href.replace(f,"")+"&"+g.session.name+"="+g.session.value;}}if(g.result){for(a in g.result){$("#"+a).html(g.result[a]);}e.html("Товар<br>добавлен");}else{alert(g.data);e.html("Ашипка :-( ");}setTimeout(function(){e.remove();e=null;},1000);},"json");return false;});});$(".galleryX a").eq(0).each(function(){if(this.onclick){this.onclick();}});$("a.url_page").click(function(){if(this.href&&!this.href.match(/javascript/i)){var c=this,d=$(this).parents(".para")[0];function e(f){if(f&&c){return false;}$(this).find(".back").toggleClass("hidden");$(this.container).toggle("normal");return false;}$.getJSON(this.href.replace("ajax=1","").replace(/(do=\w*)/,"$1&ajax=1"),function(f){if(f.error){alert(f.error);}if(f.debug){alert(f.debug);}if(f.data){c.container=$('<div class="ainfo"></div>').insertAfter($(d)).hide().html(f.data)[0];e.apply(c);c=null;}});this.href="javascript:;";$(this).click(e);}return false;});});function cookie(e,g,f){if(typeof g!="undefined"){f=f||{};if(g===null){g="";f.expires=-1;}var c="";if(f.expires&&(typeof(f.expires)=="number"||f.expires.toUTCString)){var d;if(typeof f.expires=="number"){d=new Date();d.setTime(d.getTime()+Math.round(f.expires*24*60*60*1000));}else{d=f.expires;}c="; expires="+d.toUTCString();}document.cookie=e+"="+encodeURIComponent(g)+c+(f.path?"; path="+f.path:"")+(f.domain?"; domain="+f.domain:"")+(f.secure?"; secure":"");}else{if(document.cookie&&document.cookie!=""){var b=(new RegExp(";\\s*"+e+"\\s*=([^;]+)")).exec(";"+document.cookie);return b&&decodeURIComponent(b[1]);}return null;}}function checkImg(e,d,b){if(!e||!e.src){return;}var f=new Image();f.src=e.src;if(f.width&&f.height){if(!d){if(e.style.width){d=parseInt(e.style.width);}}if(!b){if(e.style.height){b=parseInt(e.style.height);}}var c=1;if(d){c=Math.max(c,f.width/d);}else{d=f.width;}if(b){c=Math.max(c,f.height/b);}else{b=f.height;}if(!c){c=1;}e.style.width=Math.round(f.width/c)+"px";e.style.height=Math.round(f.height/c)+"px";}}function WindowO(i,f,b,d){var g=$(i).attr("href");if(g&&(g.length>2)){return true;}if(f.match(/\/$/)){return false;}try{var c="location=no,toolbar=no,resizable=yes";if((b+100>window.screen.width)||(d+100>window.screen.height)){c+=",scrollbars=yes";}if(b){c+=",width="+b;}if(d){c+=",height="+d;}wind=open("","win",c);wind.document.writeln("<html>"+"<head><title><"+"/title><style>body,html{width:100%;height:100%;padding:0;margin:0;}\n"+"body{overflow:auto;}\n</"+"style>\n<"+"script>function fitPic(){"+"iWidth = window.innerWidth||document.body.clientWidth;"+"iHeight = window.innerHeight||document.body.clientHeight;"+"iWidth = document.images[0].width - iWidth;"+"iHeight = document.images[0].height - iHeight;"+"if(iWidth && iHeight)window.resizeBy(iWidth,iHeight);self.focus();"+"};</"+"script>"+"<"+"/head><"+'body onload="fitPic()">'+'<img src="'+f+'"><button style="position:absolute;right:10px;bottom:10px;" '+'onclick="self.close();">close</button><'+"/body><"+"/html>");wind.document.close();}catch(i){alert("Всплывающие окна заблокированы! Разрешите всплывающие окна для нормального функционирования.");}return false;}function Throw_Up(e,f,b,d){var c=$(e).parents(".galleryX").find("img")[0];c.src=f;return false;}function menu(b,e){if(!e){e={};}else{if(typeof(e)=="function"){e={show:e};}}b=$(b)[0];function c(h){var g=h.target;while(true){if(g==b){return true;}else{if(g==document){d();return false;}else{g=g.parentNode;}}}}function f(){if(e.show){e.show.apply(b);}else{$(b).show();}b.shown=true;$(document).bind("mousedown",c);return false;}function d(){$(document).unbind("mousedown",c);if(e.hide){e.hide.apply(b);}else{$(b).hide();}b.shown=false;return false;}b.show_menu=f;b.hide_menu=d;$(window).bind("unload",function(){b=null;
});}