var LAYER_FADE_DURATION=200;var layer_working=false;function getNaturalHeight(a){if(typeof a.naturalHeight=="undefined"||a.naturalHeight==0){var b=new Image();b.src=a.src;return b.height}else{return a.naturalHeight}}function showLayer(b,a,c){b.css("filter","alpha(opacity=10)");a=typeof(a)!="undefined"?a:true;c=typeof(c)!="undefined"?c:true;if($(".layer:visible").length){$(".layer:visible").hide()}if($(".layer_mini:visible").length){$(".layer_mini:visible").hide()}var e=$(window).scrollTop()+($(window).height()/2-b.height()/2);if(e<0){e=0}var d=$(window).scrollLeft()+($(window).width()/2-b.width()/2);if(d<0){d=0}$("#shade").css("height",$(document).height()+"px");if(c){$("#shade").fadeIn(LAYER_FADE_DURATION)}$(".hide_when_layer_shown").fadeOut(LAYER_FADE_DURATION);layer_working=true;if($.browser.msie){b.css({display:"inline-block"})}b.fadeIn(LAYER_FADE_DURATION,function(){b.css("filter","none");layer_working=false});if(a){b.css("top",e+"px");b.css("left",d+"px")}}function showCallLayer(b,a,d){a=typeof(a)!="undefined"?a:true;d=typeof(d)!="undefined"?d:true;if($(".layer:visible").length){$(".layer:visible").hide()}if($(".layer_mini:visible").length){$(".layer_mini:visible").hide()}var f=$(window).scrollTop()+($(window).height()/2-b.height()/2);if(f<0){f=0}var c=$("body").width()-$("#content").width();var e=$(window).scrollLeft()+($(window).width()/2-b.width()/2);if(c>0){e-=c}if(e<0){e=0}if($.browser.msie){b.css("filter","alpha(opacity=10)")}$("#shade").css("height",$(document).height()+"px");if(d){$("#shade").fadeIn(LAYER_FADE_DURATION,function(){})}$(".hide_when_layer_shown").fadeOut(LAYER_FADE_DURATION);layer_working=true;if($.browser.msie){b.css({display:"inline-block"})}b.fadeIn(LAYER_FADE_DURATION,function(){b.css("filter","none");layer_working=false});if(a){b.css("top",f+"px");b.css("left",e+"px")}}function hideLayer(a){layer_working=true;$("#shade").fadeOut(LAYER_FADE_DURATION);$(".hide_when_layer_shown").fadeIn(LAYER_FADE_DURATION);if($.browser.msie){if($.browser.msie){a.css({display:"inline-block",filter:"alpha(opacity=10)"})}}if(a){a.fadeOut(LAYER_FADE_DURATION,function(){a.css("filter","none");layer_working=false})}else{$(".layer, .layer_mini").fadeOut(LAYER_FADE_DURATION,function(){layer_working=false})}}$(document).keydown(function(b){var a=b.keyCode||b.which;if(a==27){hideLayer()}});$(document).ready(function(){$("body").addClass("js");$(document).bind("rebind",function(){$(".arr_up, .arr_down").unbind("click");$(".arr_up, .arr_down").click(function(){if($(this).hasClass("arr_up")){if($("#global-filter-state-ajax").length>0){$.ajax({url:$("#global-filter-state-ajax").text(),data:{state:"off"},cache:false})}$(this).removeClass("arr_up").addClass("arr_down").attr("title","Развернуть");if($.browser.msie&&$.browser.version<=6){$("#"+$(this).attr("rel")).hide()}else{$("#"+$(this).attr("rel")).slideUp()}}else{if($("#global-filter-state-ajax").length>0){$.ajax({url:$("#global-filter-state-ajax").text(),data:{state:"on"},cache:false})}$(this).removeClass("arr_down").addClass("arr_up").attr("title","Свернуть");if($.browser.msie&&$.browser.version<=6){$("#"+$(this).attr("rel")).show()}else{$("#"+$(this).attr("rel")).slideDown()}}});$(".photo-link").mouseenter(function(b){$("#photo-image").attr("src","");coord=b.pageY;$("#photo-image").attr("alt",$(this).attr("rel"));$("#photo-image").attr("src",$(this).attr("href"));$("#photo-layer").css("left",$(this).offset().left+$(this).width());$("#photo-layer").css("top",$(this).offset().top+$(this).height());delta=$(this).height();h=getNaturalHeight($("#photo-image")[0]);if($.browser.msie){if((coord-$(window).scrollTop())>$(window).height()/2){$("#photo-layer").css("top",coord-h-2*delta)}else{$("#photo-layer").css("top",coord)}}else{$("#photo-image").load(function(){if(!h){h=this.height}if((coord-$(window).scrollTop())>$(window).height()/2){$("#photo-layer").css("top",coord-h-2*delta)}else{$("#photo-layer").css("top",coord)}})}showLayer($("#photo-layer"),false);return false});$(".photo-link").mouseleave(function(){hideLayer($("#photo-layer"));return false});$(".photo-link-cart").mouseenter(function(b){coord=b.pageY;$("#photo-image").attr("alt",$(this).attr("rel"));$("#photo-image").attr("src",$(this).attr("href"));$("#photo-layer").css("left",$(this).offset().left+$(this).width()-$("#content .container").offset().left);$("#photo-layer").css("top",$(this).offset().top);delta=$(this).height();h=getNaturalHeight($("#photo-image")[0]);if($.browser.msie){if((coord-$(window).scrollTop())>$(window).height()/2){$("#photo-layer").css("top",coord-h+delta-$("#god_mode").height()*3)}else{$("#photo-layer").css("top",coord-delta-$("#god_mode").height()*3)}}else{$("#photo-image").load(function(){h=this.height;if((coord-$(window).scrollTop())>$(window).height()/2){$("#photo-layer").css("top",coord-h-2*delta-$("#god_mode").height()*3)}else{$("#photo-layer").css("top",coord-delta-$("#god_mode").height()*3)}})}showLayer($("#photo-layer"),false);return false});$(".photo-link-cart").mouseleave(function(){hideLayer($("#photo-layer"));return false});$(".swap-currency-link").click(function(){$.ajax({url:$(this).attr("href"),cache:false,data:({rand:Math.random()}),success:function(b){if($("#auto-ajax-content").length){$content=$("#auto-ajax-content")}else{$content=$("#main-content")}if($.browser.msie){window.location.href.search("&")?rand="?rand="+Math.random():rand="&rand="+Math.random();$content.load(window.location.href+rand,function(){$(document).trigger("rebind");bindAutoAjaxLinks()})}else{$content.load(window.location.href,function(){$(document).trigger("rebind");bindAutoAjaxLinks()})}$(document).trigger("currency_change")}});return false})});bindLoginForm=function(){$("#login-form").submit(function(){$("#login-loader").show();$.post($(this).attr("action"),$(this).serialize(),function(c,b,d){if(d.status!=278){$("#login-form-container").html(c);$("#login-loader").hide();bindLoginForm()}else{location.reload(true)}});return false})};bindLoginForm();var a=null;$(".breadcrumb-link.dashed").click(function(){if(layer_working){return}$layer=$(".breadcrumb-layer[rel="+$(this).attr("rel")+"]");if(!$layer.is(":visible")){$layer.css("left",$(this).offset().left-5+"px");$layer.css("top",$(this).offset().top+$(this).height()+2+"px");if(a){a.fadeOut(LAYER_FADE_DURATION,function(){showLayer($layer,false)})}else{showLayer($layer,false)}a=$layer;return false}});$(document).click(function(b){if(layer_working){return}if(a&&!$(b.target).is(".breadcrumb-layer")&&!$(b.target).parents(".breadcrumb-layer").length){hideLayer(a);a=null}});bindAutoAjaxLinks=function(){$("a.auto-ajax").click(function(){if($("#auto-ajax-content").length){$content=$("#auto-ajax-content")}else{$content=$("#main-content")}$(this).attr("href").search("&")?rand="&rand="+Math.random():rand="?rand="+Math.random();$content.load($(this).attr("href")+rand,function(){bindAutoAjaxLinks();$(document).trigger("rebind")});return false})};bindAutoAjaxLinks();$(document).trigger("rebind")});
