jQuery.fn.slidey=function(a){a=jQuery.extend({cropper:".product-grid-wrap",slider:".product-grid-slide",items:"ul",prev:"a.btn-icn-prev",next:"a.btn-icn-next",pages:null,speed:500,initial:1,onClass:"on",init:function(){var b=this;this.offset=1;this.total=Math.ceil(this.wrapper.data("items_width")/this.wrapper.data("crop_width"));this.slide(this.initial)},slide:function(c){var b=this;c=parseInt(c);if(c>0&&c<=this.total){this.slider.animate({left:this.wrapper.data("crop_width")*(c-1)*-1},this.speed);this.offset=c;if(!this.has_prev()){this.prevButton.addClass("inactive")}else{this.prevButton.removeClass("inactive")}if(!this.has_next()){this.nextButton.addClass("inactive")}else{this.nextButton.removeClass("inactive")}}jQuery(this.wrapper).trigger("slide",[this.offset])},has_prev:function(){var b=this.offset-1;return(b>0)?b:false},slide_prev:function(){var b=this.has_prev();if(b!==false){this.slide(b)}jQuery(this.wrapper).trigger("prev")},has_next:function(){var b=this.offset+1;return(b<=this.total)?b:false},slide_next:function(){var b=this.has_next();if(b!==false){this.slide(b)}jQuery(this.wrapper).trigger("next")}},a);return this.each(function(e,l){l=jQuery(l);var b=jQuery(a.cropper,l);var c=jQuery(a.slider,l);var g=jQuery(a.items,l);var h=jQuery(a.prev,l);var k=jQuery(a.next,l);var d=jQuery(a.pages,l);var j=0;g.each(function(m,i){j=j+jQuery(i).outerWidth()});c.width(j);l.data("crop_width",b.width());l.data("items_width",j);var f=jQuery.extend(a,{wrapper:l,cropper:b,slider:c,prevButton:h,nextButton:k,pageButtons:d});h.click(function(i){i.preventDefault();a.slide_prev.apply(f);return false});k.click(function(i){i.preventDefault();a.slide_next.apply(f);return false});if(d){d.each(function(n,m){jQuery(m).click(function(i){i.preventDefault();a.slide.apply(f,[(n+1)]);return false})})}a.init.apply(f)})};var Zoomer=function(b,a){this.initialize.apply(this,arguments);return this};Zoomer.prototype={version:"1.8.1",initialize:function(d,c){var e={smooth:6,zoomWidth:null,zoomHeight:null};this.options=$.extend(e,c||{});this.small=$(d);var b=this;var f=this.options.big||this.small.attr("big")||this.small.parent().attr("href");if(!this.small[0].complete){this.small.bind("load",function(){b.prepareSmall()})}else{this.prepareSmall()}var a=new Image();a.src=f;this.big=$(a).css({position:"absolute",top:0,left:0}).hide();if(!this.big[0].complete){this.big.bind("load",function(){b.prepareBig()})}else{this.prepareBig()}},prepareSmall:function(){this.small.wrap('<div class="zoomer-wrapper"></div>');this.wrapper=this.small.parent();var a=this;function b(c,e){if(c.currentStyle){return c.currentStyle[e]}var d=document.defaultView.getComputedStyle(c,null);return(d)?d.getPropertyValue(e):null}$.each(["margin","left","top","bottom","right","float","clear","border","padding"],function(c,h){var d;if($.inArray(h,["left","top","bottom","right"])!=-1){d=b(a.small[0],h)}else{try{d=a.small.css(h)}catch(g){d="auto"}}if(h=="margin"&&d=="auto"){return}var f="auto";if($.inArray(h,["float","clear","border"])!=-1){f="none"}if(h=="padding"){f="0"}try{a.small.css(h,f);a.wrapper.css(h,d)}catch(g){}});this.wrapper.css({width:this.small[0].offsetWidth,height:this.small[0].offsetHeight,position:"relative",overflow:"hidden"});this.smallSize={width:(this.options.zoomWidth?this.options.zoomWidth:this.small[0].width),height:(this.options.zoomHeight?this.options.zoomHeight:this.small[0].height)};if(this.bigPrepared){this.ready()}else{this.smallPrepared=true}},prepareBig:function(){this.bigSize={width:this.big[0].width,height:this.big[0].height};if(this.smallPrepared){this.ready()}else{this.bigPrepared=true}},ready:function(){this.big.appendTo(this.wrapper);this.big.wrap('<div class="zoomer-wrapper-big"></div>');this.bigWrapper=this.big.parent();this.bigWrapper.css({position:"absolute",overflow:"hidden",top:this.small.offset().top-this.wrapper.offset().top-parseInt(this.wrapper.css("border-top-width"),10)||0,left:this.small.offset().left-this.wrapper.offset().left-parseInt(this.wrapper.css("border-left-width"),10)||0,width:this.small[0].offsetWidth,height:this.small[0].offsetHeight,background:"url(_)"}).mouseenter($.proxy(this.startZoom,this)).mouseleave($.proxy(this.stopZoom,this)).mousemove($.proxy(this.move,this))},move:function(a){this.dstPos={x:a.pageX,y:a.pageY}},startZoom:function(){this.position=this.small.offset();this.ratio={x:1-this.bigSize.width/this.smallSize.width,y:1-this.bigSize.height/this.smallSize.height};this.current={left:parseInt(this.big.css("left"),10),top:parseInt(this.big.css("top"),10)};this.timer=setInterval($.proxy(this.zoom,this),10);this.big.fadeIn()},stopZoom:function(){clearInterval(this.timer);this.big.fadeOut()},zoom:function(){if(!this.dstPos){return}var a=this.options.smooth;var b={left:parseInt((this.dstPos.x-this.position.left)*this.ratio.x,10),top:parseInt((this.dstPos.y-this.position.top)*this.ratio.y,10)};this.current.left-=(this.current.left-b.left)/a;this.current.top-=(this.current.top-b.top)/a;this.big.css(this.current)}};$.fn.zoomer=function(b){for(var c=0,a=this.length;c<a;c++){new Zoomer(this[c],b)}};$(document).ready(function(){$("#content-body .col-l").slidey({cropper:".slides-med-wrap",slider:".slides-med-slide",items:"ul.slides-med li",pages:".product-views-foot a"});$("#content-body .col-l").bind("slide",function(b,a){$(".product-views-foot a").each(function(c,d){if((c+1)==a){$(d).fadeTo(500,1)}else{$(d).fadeTo(500,0.35)}})});$(".product-views-foot a:not(:first)").fadeTo(0,0.35);$(".slides-med li a").click(function(a){a.preventDefault();return false})});$(window).load(function(){$(".slides-med li img.product-view-preview").zoomer({zoomHeight:$(".slides-med li:first").height(),zoomWidth:$(".slides-med li:first").width()})});
