$(document).ready(function(){$('.b-action-tabs-link').live('click',function(){if($(".b-action-tabs-link.active"))
$(".b-action-tabs-link.active").removeClass('active');$(this).addClass('active');});if($('.b-action-tabs-link.active').size()==0)
{$('.b-action-tabs-link').first().addClass('active');}
var bannerX=$('.b-action-list-item').size();var bannerW=$('.b-action-list-item').width();$('.b-action-list').css('width',bannerW*bannerX);});function getSelText(){var txt='';if(window.getSelection){txt=window.getSelection();}else if(document.getSelection){txt=document.getSelection();}else if(document.selection){txt=document.selection.createRange().text;}
return txt;}
jQuery.cookie=function(name,value,options){if(typeof value!='undefined'){options=options||{};if(value===null){value='';options.expires=-1;}
var expires='';if(options.expires&&(typeof options.expires=='number'||options.expires.toUTCString)){var date;if(typeof options.expires=='number'){date=new Date();date.setTime(date.getTime()+(options.expires*24*60*60*1000));}else{date=options.expires;}
expires='; expires='+date.toUTCString();}
var path=options.path?'; path='+(options.path):'';var domain=options.domain?'; domain='+(options.domain):'';var secure=options.secure?'; secure':'';document.cookie=[name,'=',encodeURIComponent(value),expires,path,domain,secure].join('');}else{var cookieValue=null;if(document.cookie&&document.cookie!=''){var cookies=document.cookie.split(';');for(var i=0;i<cookies.length;i++){var cookie=jQuery.trim(cookies[i]);if(cookie.substring(0,name.length+1)==(name+'=')){cookieValue=decodeURIComponent(cookie.substring(name.length+1));break;}}}
return cookieValue;}};function refreshBasketStats(){$.getJSON("/basket/getBasketStats",{},function(data){$("#basketAmount").html(data.amount);$("#basketSumm").html(data.summ);$('.b-total-summ span.total-price').html(data.summ);});}
function getTransferSumm()
{if($("#transfer").size()>0)
{$.get("/basket/transfersumm",{},function(data)
{if(data.length>0)
$("#transfer td").html(data);});}}
function addToCart(itemId,credit){if(!itemId)
return false;if(!credit)
var getvars={itemId:itemId};else
var getvars={itemId:itemId,credit:1};$.get("/basket/addtocart",getvars,function(data){$(".b-shadow").toggle();$(".b-minicart").css("top",$(window).scrollTop()+100);$('.b-minicart').show();$(".b-minicart").html(data);$(".input-count").keyfilter(/[\d\-]/);$(".b-shadow").height($(document).height()).width($(window).width());refreshBasketStats();});}
function appendFilter(filter){window.location=filter.options[filter.selectedIndex].value;}
function selectBrand(brand){if(brand.selectedIndex==0){window.location="/catalog/";}else{window.location="/catalog/brand/"
+brand.options[brand.selectedIndex].value;}
return true;}
function filter(id){var arr=window.location.toString().split('/');if(id!='price')
var id=id.substr(7);if(id!='price')
{for(var i in arr){if(arr[i]=='filter'+id+'_from'){arr[parseInt(i)+1]=$('#amount_from_'+id).val()!=''?$('#amount_from_'+id).val():0;var found=true;}
if(arr[i]=='filter'+id+'_to'){arr[parseInt(i)+1]=$('#amount_to_'+id).val()!=''?$('#amount_to_'+id).val():0;var found=true;}}}
else
{for(var i in arr){if(arr[i]=='price_from'){if($('#price_from').val()!='')
arr[parseInt(i)+1]=$('#price_from').val();else
arr.splice(i,2);var found=true;}
if(arr[i]=='price_to'){if($('#price_to').val()!='')
arr[parseInt(i)+1]=$('#price_to').val();else
arr.splice(i,2);var found=true;}}}
if(!found){if(id!='price')
{arr.push('filter'+id+'_from');var val=$('#amount_from_'+id).val()!=''?$('#amount_from_'+id).val():0;arr.push(val);arr.push('filter'+id+'_to');var val=$('#amount_to_'+id).val()!=''?$('#amount_to_'+id).val():0;arr.push(val);}
else
{if($('#price_from').val()!='')
{arr.push('price_from');arr.push($('#price_from').val());}
if($('#price_to').val())
{arr.push('price_to');arr.push($('#price_to').val());}}}
window.location=arr.join('/').replace("#",'');}
function StopDrag(){filter(window.id);}
function showMessage(text,time){if(!time)
var time=5600;if(text)
$("#messageText").html(text);$('#messages').slideDown(function(){setTimeout(function(){jQuery('#messages').slideUp();},time);});}
function getCompareItems()
{$.get("/catalog/getcompareitem",{},function(data){if(data.length>1)
{$("#compareItems").show();$("#compareItems").html(data);}
else
$("#compareItems").hide();});}
function addToCompare(itemId)
{$.get("/catalog/addcompareitem",{id:itemId},function(data){getCompareItems();showMessage('Товар успешно добавлен в список сравнения');});}
function delCompareitem(itemId,cat)
{$.get("/catalog/delcompareitem",{id:itemId,cat:cat},function(data){getCompareItems();});}
function FilerOnEnter(id)
{var testTextBox=$(id);var code=null;testTextBox.keypress(function(e)
{code=(e.keyCode?e.keyCode:e.which);if(code==13)
filter('price');});}
function rotateBanner()
{var el=$("#banner");if($(el).size()>0)
{var rawId=$(el).find('a').attr('id');var id=rawId.substring(2,rawId.length);$.getJSON('/banners/getbanner',{id:id},function(data){var aEl=$(el).find('a');$(aEl).attr('title',data.name);$(aEl).attr('href',data.href);$(aEl).attr('id','id'+data.id);$(el).find('img').attr('src','/public/uploads/'+data.filename);});setTimeout('rotateBanner()',4500)}}
$(document).ready(function(){$('.cart-currency').hover(function(){$('.b-currency-list').toggle();});$('.select-region').hover(function(){$('.b-city-box').toggle();});$('.b-brand').click(function(e){e.stopPropagation();$('.b-brand-list').show();});$('.b-layout').click(function(){$('.b-brand-list').hide();});$('.b-search-cat').live('click',function(e){$('.b-search-list').show();});$('.b-layout').click(function(){$('.b-search-list').hide();});$('.b-left-col .navigation > li > a').live('click',function(e)
{e.preventDefault();$('ul.navigation>li.active').toggleClass('active')
$(this).parent().toggleClass('active');$(this).parent().children('ul').each(function(index){$(this).toggleClass('active');});});if(window.location.href.match('search.+catid'))
{var catId=parseInt(window.location.href.substr(window.location.href.indexOf('catid')+6,window.location.href.length));$("#menu-"+catId).parent().addClass('active');$("#menu-"+catId).parent().parent().parent().addClass('active');}
if($('.navigation li.active').size()==0)
{$('.navigation').children('li').first().addClass('active');}
var b_seo_text=$('.b-seo-text').height();$('.b-right-col').css({'padding-bottom':b_seo_text})
var shadow=$('.b-shadow');doc_w=$(document).width();doc_h=$(document).height();shadow.css({'width':doc_w,'height':doc_h});var minicart=$('.b-minicart');minicart.css('left',(doc_w/2-minicart.width()/2));$('.b-minicart-close, .b-link-next').live('click',function(){minicart.hide();shadow.hide();});var popup=$('.b-popup');$('.open-auth').live('click',function(){popup.css("top",$(window).scrollTop()+150);popup.css({'left':(doc_w/2-popup.width()/2)})
shadow.show();popup.show();});$('.b-popup-close').live('click',function(){shadow.hide();popup.hide();});});(function($){var strImgDir='/public/js/jquery/jquery.fancyzoom.resources/';var oImgZoomBox=$('<div>');var oImgClose=$('<img>').css({position:'absolute',top:0,left:0,cursor:'pointer',zIndex:102});$.fn.fancyzoom=function(userOptions){var oOverlay=$('<div>').css({height:'100%',width:'100%',position:'fixed',left:0,top:0,cursor:"wait"});function openZoomBox(elLink,o){if(o.showoverlay){oOverlay.appendTo('body').click(function(){closeZoomBox(o)})}pos=$('img',elLink).offset();o=$.extend(o,{dimOri:{width:$('img',elLink).outerWidth(),height:$('img',elLink).outerHeight(),left:pos.left,top:pos.top,'opacity':0}});oImgZoomBox.css({'opacity':0}).appendTo('body');var iWidth=oImgZoomBox.outerWidth();var iHeight=oImgZoomBox.outerHeight();dimBoxTarget=$.extend({},{width:iWidth,height:iHeight,'opacity':1},__posCenter((iWidth+15),(iHeight+30)));oImgClose.css({left:(iWidth-30+dimBoxTarget.left),top:dimBoxTarget.top});var $fctEnd=function(){if($.fn.shadow&&!$.browser.msie){$('img:first',oImgZoomBox).shadow(o.shadowOpts)}if(o.Speed>0&&!$.browser.msie){oImgClose.fadeIn('slow');$('div',oImgZoomBox).fadeIn('slow')}else{oImgClose.show();$('div',oImgZoomBox).show()}};$('div',oImgZoomBox).hide();if(o.Speed>0){oImgZoomBox.css(o.dimOri).animate(dimBoxTarget,o.Speed,$fctEnd)}else{oImgZoomBox.css(dimBoxTarget);$fctEnd()}}function closeZoomBox(o){oImgClose.remove();if(o.Speed>0){oImgZoomBox.animate(o.dimOri,o.Speed,function(){$(this).empty().remove()});if(o.showoverlay){oOverlay.animate({'opacity':0},o.Speed,function(){$(this).empty().remove()})}}else{oImgZoomBox.empty().remove();if(o.showoverlay){oOverlay.empty().remove()}}}return this.each(function(){var $this=$(this);var opts=$.extend($.fn.fancyzoom.defaultsOptions,userOptions||{},{dimOri:{},oImgZoomBoxProp:{position:'absolute',left:0,top:0}});oOverlay.css({opacity:opts.overlay,background:opts.overlayColor});if(!/\.jpg|.jpeg|\.png|.gif/i.test($this.attr('href'))||$('img',$this).size()===0){return}$this.click(function(){if(oLoading&&oLoading.is(':visible')||timerLoadingImg){if(oImgZoomBox&&$('img:first',oImgZoomBox).attr('src')!=$(this).attr('href')){__cancelLoading()}else{return false}}var o=$.extend({},opts,userOptions);if(oImgZoomBox&&oImgZoomBox.parent().size()>0){var imCurrent=$('img:first',oImgZoomBox);if($this.attr('href')==imCurrent.attr('src')){var imgTarget=$('img',$this);pos=imgTarget.offset();o=$.extend(o,{dimOri:{width:imgTarget.outerWidth(),height:imgTarget.outerHeight(),left:pos.left,top:pos.top,'opacity':0}});closeZoomBox(o);return false}else{oImgClose.remove();oImgZoomBox.empty().remove()}}if(o.showoverlay&&oOverlay){oOverlay.empty().remove().css({'opacity':o.overlay})}oImgClose.attr('src',o.imgDir+'closebox.png').appendTo('body').hide();if($.fn.ifixpng){$.ifixpng(o.imgDir+'blank.gif');oImgClose.ifixpng(o.imgDir+'blank.gif')}oImgClose.unbind('click').click(function(){closeZoomBox(o)});oImgZoomBox=$('<div>').empty().css(o.oImgZoomBoxProp).css('z-index',101);var strTitle=$('img',$this).attr('alt');if(strTitle){var oTitle=$('<div><center><table height=0 border="0" cellspacing=0 cellpadding=0><tr><td></td><td class="fancyTitle">'+strTitle+'</td><td></td></table></center></div>').css({marginTop:10,marginRight:15});var tdL=oTitle.find('td:first').css({'background':'url('+o.imgDir+'zoom-caption-l.png)',width:'13px',height:'26px'});var tdR=oTitle.find('td:last').css({'background':'url('+o.imgDir+'zoom-caption-r.png)',width:'13px',height:'26px'});var tdC=$('.fancyTitle',oTitle).css({'background':'url('+o.imgDir+'zoom-caption-fill.png)','padding':'0px 20px',color:'#FFF','font-size':'14px'});if($.fn.ifixpng){tdL.ifixpng(o.imgDir+'blank.gif');tdR.ifixpng(o.imgDir+'blank.gif');tdC.ifixpng(o.imgDir+'blank.gif')}oTitle.appendTo(oImgZoomBox)}var oImgZoom=$('<img />').attr('src',$(this).attr('href')).css({zIndex:100,marginTop:15,marginRight:15}).click(function(){closeZoomBox(o)}).prependTo(oImgZoomBox);var imgPreload=new Image();imgPreload.src=$(this).attr('href');var $fctEndLoading=function(){if(bCancelLoading){bCancelLoading=false}else{if(__getFileName(imgPreload.src)==__getFileName($('img:first',oImgZoomBox).attr('src'))){openZoomBox($this,o);__stoploading()}}};if(imgPreload.complete){openZoomBox($this,o)}else{__displayLoading();imgPreload.onload=function(){$fctEndLoading()}}return false})})};$.fn.fancyzoom.defaultsOptions={overlayColor:'#000',overlay:0.6,showoverlay:false,Speed:400,shadowOpts:{color:"#000",offset:4,opacity:0.2},imgDir:strImgDir};function __posCenter(iWidth,iHeight){var iLeft=($(window).width()-iWidth)/2+$(window).scrollLeft();var iTop=($(window).height()-iHeight)/2+$(window).scrollTop();iLeft=(iLeft<0)?0:iLeft;iTop=(iTop<0)?0:iTop;return{left:iLeft,top:iTop}}var oLoading=null;var bCancelLoading=false;var timerLoadingImg=null;function __displayLoading(){if(!oLoading){oLoading=$('<div></div>').css({width:50,height:50,position:'absolute','background':'transparent',opacity:8/10,color:'#FFF',padding:'5px','font-size':'10px'})}oLoading.appendTo('body').css(__posCenter(50,50)).html('<img src="'+$.fn.fancyzoom.defaultsOptions.imgDir+'blank.gif" />').click(function(){__cancelLoading()}).show();timerLoadingImg=setTimeout(__changeimageLoading,400)}function __cancelLoading(){bCancelLoading=true;__stoploading()}function __stoploading(){oLoading.hide().remove();if(timerLoadingImg){clearTimeout(timerLoadingImg);timerLoadingImg=null}}function __changeimageLoading(){if(!oLoading.is(':visible')){timerLoadingImg=null;return}var $im=$('img',oLoading);if(!$im.attr('src')||/blank\.gif/.test($im.attr('src'))){strImgSrc=$.fn.fancyzoom.defaultsOptions.imgDir+"zoom-spin-1.png"}else{tab=$im.attr('src').split(/[- .]+/);iImg=parseInt(tab[2]);iImg=(iImg<12)?(iImg+1):1;strImgSrc=tab[0]+"-"+tab[1]+"-"+iImg+"."+tab[3]}var pLoad=new Image();pLoad.src=strImgSrc;var $fct=function(){oLoading.css(__posCenter(50,50));$im.attr('src',strImgSrc);timerLoadingImg=setTimeout(__changeimageLoading,100)};if(pLoad.complete){$fct()}else{pLoad.onload=$fct}}function __getFileName(strPath){if(!strPath){return false}var tabPath=strPath.split('/');return((tabPath.length<1)?strPath:tabPath[(tabPath.length-1)])}})(jQuery);(function($){$.fn.shadowEnable=function(){return $(this).find("+ .fx-shadow").show().end();};$.fn.shadowDisable=function(){return $(this).find("+ .fx-shadow").hide().end();};$.fn.shadowDestroy=function(){return $(this).find("+ .fx-shadow").remove().end();};$.fn.shadow=function(options){options=$.extend({offset:1,opacity:0.2,color:"#000",monitor:false},options||{});options.offset-=1;return this.each(function(){var $element=$(this).shadowDestroy(),$shadow=$("<div class='fx-shadow' style='position: relative;'></div>").hide().insertAfter($element);baseWidth=$element.outerWidth(),baseHeight=$element.outerHeight(),position=$element.position(),zIndex=parseInt($element.css("zIndex"))||0;$('<div class="fx-shadow-color fx-shadow-layer-1"></div>').css({position:'absolute',opacity:options.opacity-0.05,left:options.offset,top:options.offset,width:baseWidth+1,height:baseHeight+1}).appendTo($shadow);$('<div class="fx-shadow-color fx-shadow-layer-2"></div>').css({position:'absolute',opacity:options.opacity-0.10,left:options.offset+2,top:options.offset+2,width:baseWidth,height:baseHeight-3}).appendTo($shadow);$('<div class="fx-shadow-color fx-shadow-layer-3"></div>').css({position:'absolute',opacity:options.opacity-0.10,left:options.offset+2,top:options.offset+2,width:baseWidth-3,height:baseHeight}).appendTo($shadow);$('<div class="fx-shadow-color fx-shadow-layer-4"></div>').css({position:'absolute',opacity:options.opacity,left:options.offset+1,top:options.offset+1,width:baseWidth-1,height:baseHeight-1}).appendTo($shadow);$("div.fx-shadow-color",$shadow).css("background-color",options.color);$element.css({zIndex:zIndex+1,position:($element.css("position")=="static"?"relative":"")});$shadow.css({position:"absolute",zIndex:zIndex,top:position.top+"px",left:position.left+"px",width:baseWidth,height:baseHeight,marginLeft:$element.css("marginLeft"),marginRight:$element.css("marginRight"),marginBottom:$element.css("marginBottom"),marginTop:$element.css("marginTop")}).fadeIn();if(options.monitor){function rearrangeShadow(){var $element=$(this),$shadow=$element.next();$shadow.css({top:parseInt($element.css("top"))+"px",left:parseInt($element.css("left"))+"px"})
$(">*",$shadow).css({height:this.offsetHeight+"px",width:this.offsetWidth+"px"});}
$element.bind("DOMAttrModified",rearrangeShadow);if($shadow[0].style.setExpression){$shadow[0].style.setExpression("top","parseInt(this.previousSibling.currentStyle.top ) + 'px'");$shadow[0].style.setExpression("left","parseInt(this.previousSibling.currentStyle.left) + 'px'");}}});};})(jQuery);
