(function($){var als=[],instance=0;var methods={init:function(options){this.each(function(){var defaults={visible_items:3,scrolling_items:1,orientation:"horizontal",circular:"no",autoscroll:"no",interval:4000,direction:"left",start_from:0},$obj=$(this),data=$obj.data('als'),$options=$(),$item=$(),$wrapper=$(),$viewport=$(),$prev=$(),$next=$(),num_items=0,viewport_width=0,wrapper_width=0,viewport_height=0,wrapper_height=0,initial_movement=0,i=0,j=0,current=0,timer=0;$options=$.extend(defaults,options);if($options.circular=="no"&&$options.autoscroll=="yes")
{$options.circular="yes";}
if(!$obj.attr("id")||$obj.attr("id")=="")
{$obj.attr("id","als-container_"+instance);}
$viewport=$obj.find(".als-viewport").attr("id","als-viewport_"+instance);$wrapper=$obj.find(".als-wrapper").attr("id","als-wrapper_"+instance);$item=$obj.find(".als-item");num_items=$item.size();if($options.visible_items>num_items)
{$options.visible_items=num_items-1;}
if($options.scrolling_items>$options.visible_items)
{$options.scrolling_items=$options.visible_items-1;}
if($options.start_from>num_items-$options.visible_items)
{$options.start_from=0;}
$prev=$obj.find(".als-prev").attr("data-id","als-prev_"+instance);$next=$obj.find(".als-next").attr("data-id","als-next_"+instance);switch($options.orientation)
{case"horizontal":default:$item.each(function(index)
{$(this).attr("id","als-item_"+instance+"_"+index);wrapper_width+=$(this).outerWidth(true);if(i<$options.visible_items)
{if($options.start_from==0)
{viewport_width+=$(this).outerWidth(true);i++;}
else
{if(index>=$options.start_from)
{viewport_width+=$(this).outerWidth(true);i++;}}}
if($options.start_from!=0)
{if(j<$options.start_from)
{initial_movement+=$(this).outerWidth(true);j++;}
current=$options.start_from;}});$wrapper.css("width",wrapper_width);$item.css("left",-initial_movement);$viewport.css("width",viewport_width);$wrapper.css("height",$item.outerHeight(true));$viewport.css("height",$item.outerHeight(true));if($options.circular=="yes"&&$options.start_from!=0)
{for(r=0;r<$options.start_from;r++)
{var position=$item.last().position(),riposizionamento_dx=position.left+$item.last().outerWidth(true);$item.eq(r).css("left",riposizionamento_dx);}}
break;case"vertical":$item.each(function(index)
{$(this).attr("id","als-item_"+instance+"_"+index);wrapper_height+=$(this).outerHeight(true);if(i<$options.visible_items)
{if($options.start_from==0)
{viewport_height+=$(this).outerHeight(true);i++;}
else
{if(index>=$options.start_from)
{viewport_height+=$(this).outerHeight(true);i++;}}}
if($options.start_from!=0)
{if(j<$options.start_from)
{initial_movement+=$(this).outerHeight(true);j++;}
current=$options.start_from;}});$wrapper.css("height",wrapper_height);$item.css("top",-initial_movement);$viewport.css("height",viewport_height);$wrapper.css("width",$item.outerWidth(true));$viewport.css("width",$item.outerWidth(true));if($options.circular=="yes"&&$options.start_from!=0)
{for(r=0;r<$options.start_from;r++)
{var position=$item.last().position(),riposizionamento_bottom=position.top+$item.last().outerHeight(true);$item.eq(r).css("top",riposizionamento_bottom);}}
break}
if($options.circular=="no")
{if($options.start_from==0)
{$prev.css("display","none");}
if($options.visible_items+$options.start_from==num_items)
{$next.css("display","none");}}
$obj.data('als',{container:$obj,instance:instance,options:$options,viewport:$viewport,wrapper:$wrapper,prev:$prev,next:$next,item:$item,num_items:num_items,wrapper_width:wrapper_width,viewport_width:viewport_width,wrapper_height:wrapper_height,viewport_height:viewport_height,current:current,timer:timer});data=$obj.data('als');als[instance]=data;$next.on("click",nextHandle);$prev.on("click",prevHandle);if($options.autoscroll=="yes")
{$.fn.als('start',instance);$wrapper.hover(function()
{$.fn.als('stop',$(this).attr("id"));},function()
{$.fn.als('start',$(this).attr("id"));});}
else if($options.autoscroll=="no"){$.fn.als('stop',instance);}
instance++;return als;});},next:function(id){id=find_instance(id);var data=als[id],k1=0,k2=0;switch(data.options.orientation)
{case"horizontal":default:var spostamento_sx=0,viewport_width=0;switch(data.options.circular)
{case"no":default:for(k1=data.current;k1<data.current+data.options.scrolling_items;k1++)
{spostamento_sx+=data.item.eq(k1).outerWidth(true);}
data.current+=data.options.scrolling_items;for(k2=data.current;k2<data.current+data.options.visible_items;k2++)
{viewport_width+=data.item.eq(k2).outerWidth(true);}
data.viewport.animate({"width":viewport_width},600);data.item.animate({"left":"-="+spostamento_sx},600);data.item.promise().done(function()
{data.next.on("click",nextHandle);data.prev.on("click",prevHandle);});if(data.current>0)
{data.prev.show();}
if(data.current+data.options.visible_items>=data.num_items)
{data.next.hide();}
break;case"yes":var memo=0,memo_index=[];for(k1=data.current;k1<data.current+data.options.scrolling_items;k1++)
{var k3=k1;if(k1>=data.num_items)
{k3=k1-data.num_items;}
spostamento_sx+=data.item.eq(k3).outerWidth(true);memo_index[memo]=k3;memo++;}
data.current+=data.options.scrolling_items;if(data.current>=data.num_items)
{data.current-=data.num_items;}
for(k2=data.current;k2<data.current+data.options.visible_items;k2++)
{var k4=k2;if(k2>=data.num_items)
{k4=k2-data.num_items;}
viewport_width+=data.item.eq(k4).outerWidth(true);}
data.viewport.animate({"width":viewport_width},600);data.item.animate({"left":"-="+spostamento_sx},600);data.item.promise().done(function()
{var position=data.item.last().position(),riposizionamento_dx=position.left+data.item.last().outerWidth(true);for(k5=0;k5<memo_index.length;k5++)
{if(memo_index[k5]==0)
{var position=data.item.last().position(),riposizionamento_dx=position.left+data.item.last().outerWidth(true);}
data.item.eq(memo_index[k5]).css("left",riposizionamento_dx);}
data.next.on("click",nextHandle);data.prev.on("click",prevHandle);});break;}
break;case"vertical":var spostamento_top=0,viewport_height=0;switch(data.options.circular)
{case"no":default:for(k1=data.current;k1<data.current+data.options.scrolling_items;k1++)
{spostamento_top+=data.item.eq(k1).outerHeight(true);}
data.current+=data.options.scrolling_items;for(k2=data.current;k2<data.current+data.options.visible_items;k2++){viewport_height+=data.item.eq(k2).outerHeight(true);}
data.viewport.animate({"height":viewport_height},600);data.item.animate({"top":"-="+spostamento_top},600);data.item.promise().done(function()
{data.next.on("click",nextHandle);data.prev.on("click",prevHandle);});if(data.current>0)
{data.prev.show();}
if(data.current+data.options.visible_items>=data.num_items)
{data.next.hide();}
break;case"yes":var memo=0,memo_index=[];for(k1=data.current;k1<data.current+data.options.scrolling_items;k1++)
{var k3=k1;if(k1>=data.num_items)
{k3=k1-data.num_items;}
spostamento_top+=data.item.eq(k3).outerHeight(true);memo_index[memo]=k3;memo++;}
data.current+=data.options.scrolling_items;if(data.current>=data.num_items)
{data.current-=data.num_items;}
for(k2=data.current;k2<data.current+data.options.visible_items;k2++)
{var k4=k2;if(k2>=data.num_items)
{k4=k2-data.num_items;}
viewport_height+=data.item.eq(k4).outerHeight(true);}
data.viewport.animate({"height":viewport_height});data.item.animate({"top":"-="+spostamento_top});data.item.promise().done(function()
{var position=data.item.last().position(),riposizionamento_bottom=position.top+data.item.last().outerHeight(true);for(k5=0;k5<memo_index.length;k5++)
{if(memo_index[k5]==0)
{var position=data.item.last().position(),riposizionamento_bottom=position.top+data.item.last().outerHeight(true);}
data.item.eq(memo_index[k5]).css("top",riposizionamento_bottom);}
data.next.on("click",nextHandle);data.prev.on("click",prevHandle);});break;}
break;}
als[id]=data;return als;},prev:function(id){id=find_instance(id);var data=als[id],k1=0,k2=0;switch(data.options.orientation)
{case"horizontal":default:var spostamento_dx=0,viewport_width=0;switch(data.options.circular)
{case"no":default:data.current-=data.options.scrolling_items;for(k1=data.current;k1<data.current+data.options.scrolling_items;k1++)
{spostamento_dx+=data.item.eq(k1).outerWidth(true);}
for(k2=data.current;k2<data.current+data.options.visible_items;k2++)
{viewport_width+=data.item.eq(k2).outerWidth(true);}
data.viewport.animate({"width":viewport_width});data.item.animate({"left":"+="+spostamento_dx},600);data.item.promise().done(function()
{data.prev.on("click",prevHandle);data.next.on("click",nextHandle);});if(data.current<=0)
{data.prev.hide();}
if(data.current+data.options.visible_items<data.num_items)
{data.next.show();}
break;case"yes":var memo=0,memo_index=[];data.current-=data.options.scrolling_items;if(data.current<0)
{data.current+=data.num_items;}
for(k1=data.current;k1<data.current+data.options.scrolling_items;k1++)
{var k3=k1;if(k1>=data.num_items)
{k3=k1-data.num_items;}
spostamento_dx+=data.item.eq(k3).outerWidth(true);memo_index[memo]=k3;memo++;}
for(k2=data.current;k2<data.current+data.options.visible_items;k2++)
{var k4=k2;if(k2>=data.num_items)
{k4=k2-data.num_items;}
viewport_width+=data.item.eq(k4).outerWidth(true);}
var position=data.item.first().position(),riposizionamento_sx=position.left-data.wrapper_width;for(k5=0;k5<memo_index.length;k5++)
{data.item.eq(memo_index[k5]).css("left",riposizionamento_sx);if(memo_index[k5]==0&&memo_index[k5-1]==data.num_items-1)
{var position=data.item.first().position(),riposizionamento_sx=position.left-data.wrapper_width;data.item.eq(memo_index[k5-1]).css("left",riposizionamento_sx);}}
setTimeout(function()
{data.viewport.animate({"width":viewport_width});data.item.animate({"left":"+="+spostamento_dx},600);data.item.promise().done(function()
{data.prev.on("click",prevHandle);data.next.on("click",nextHandle);});},200);break;}
break;case"vertical":var spostamento_bottom=0,viewport_height=0;switch(data.options.circular)
{case"no":default:data.current-=data.options.scrolling_items;for(k1=data.current;k1<data.current+data.options.scrolling_items;k1++)
{spostamento_bottom+=data.item.eq(k1).outerHeight(true);}
for(k2=data.current;k2<data.current+data.options.visible_items;k2++)
{viewport_height+=data.item.eq(k2).outerHeight(true);}
data.viewport.animate({"height":viewport_height});data.item.animate({"top":"+="+spostamento_bottom},600);data.item.promise().done(function()
{data.prev.on("click",prevHandle);data.next.on("click",nextHandle);});if(data.current<=0)
{data.prev.hide();}
if(data.current+data.options.visible_items<data.num_items)
{data.next.show();}
break;case"yes":var memo=0,memo_index=[];data.current-=data.options.scrolling_items;if(data.current<0)
{data.current+=data.num_items;}
for(k1=data.current;k1<data.current+data.options.scrolling_items;k1++)
{var k3=k1;if(k1>=data.num_items)
{k3=k1-data.num_items;}
spostamento_bottom+=data.item.eq(k3).outerHeight(true);memo_index[memo]=k3;memo++;}
for(k2=data.current;k2<data.current+data.options.visible_items;k2++)
{var k4=k2;if(k2>=data.num_items)
{k4=k2-data.num_items;}
viewport_height+=data.item.eq(k4).outerHeight(true);}
var position=data.item.first().position(),riposizionamento_top=position.top-data.wrapper_height;for(k5=0;k5<memo_index.length;k5++)
{data.item.eq(memo_index[k5]).css("top",riposizionamento_top);if(memo_index[k5]==0&&memo_index[k5-1]==data.num_items-1)
{var position=data.item.first().position(),riposizionamento_top=position.top-data.wrapper_height;data.item.eq(memo_index[k5-1]).css("top",riposizionamento_top);}}
setTimeout(function()
{data.viewport.animate({"height":viewport_height},600);data.item.animate({"top":"+="+spostamento_bottom},600);data.item.promise().done(function()
{data.prev.on("click",prevHandle);data.next.on("click",nextHandle);});},200);break;}
break;}
als[id]=data;return als;},start:function(id){id=find_instance(id);var data=als[id];if(data.timer!=0)
{clearInterval(data.timer);}
switch(data.options.direction)
{case"left":case"up":default:data.timer=setInterval(function(){data.next.off();data.prev.off();$.fn.als('next',id);},data.options.interval);break;case"right":case"down":data.timer=setInterval(function(){data.prev.off();data.next.off();$.fn.als('prev',id);},data.options.interval);break;}
als[id]=data;return als;},stop:function(id)
{id=find_instance(id);var data=als[id];clearInterval(data.timer);als[id]=data;return als;},destroy:function(id){id=find_instance(id);var data=als[id];data.prev.off();data.next.off();$.fn.als('stop',id);$.removeData(data,this.name);this.removeClass(this.name);this.unbind();this.element=null;}}
function find_instance(id)
{if(typeof(id)==="string")
{var position=id.indexOf("_");if(position!=-1)
{id=id.substr(position+1);}}
return id}
function nextHandle(e)
{e.preventDefault();var id=find_instance($(this).attr("data-id")),data=als[id];$(this).off();data.prev.off();$.fn.als('next',id);}
function prevHandle(e)
{e.preventDefault();var id=find_instance($(this).attr("data-id")),data=als[id];$(this).off();data.next.off();$.fn.als('prev',id);}
$.fn.als=function(method)
{if(methods[method])
{return methods[method].apply(this,Array.prototype.slice.call(arguments,1));}
else if(typeof method==='object'||!method)
{return methods.init.apply(this,arguments);}
else
{$.error('Method '+method+' does not exist on jQuery.als');}};})(jQuery);(function($){var trailing_whitespace=true;$.fn.truncate=function(options){var opts=$.extend({},$.fn.truncate.defaults,options);$(this).each(function(){var content_length=$.trim(squeeze($(this).text())).length;if(content_length<=opts.max_length){$(opts.more_node).remove();$(opts.less_node).remove();return;}
var actual_max_length=opts.max_length-opts.more.length-3;var truncated_node=recursivelyTruncate(this,actual_max_length);var full_node=$(this).hide();truncated_node.insertAfter(full_node);var lessNode;var moreNode;if(opts.more_node&&opts.less_node){findNodeForMore(truncated_node).append('...');lessNode=opts.less_node;moreNode=opts.more_node;moreNode.show();}else{findNodeForMore(truncated_node).append(' (<a href="#show more content">'+opts.more+'</a>)');findNodeForLess(full_node).append(' (<a href="#show less content">'+opts.less+'</a>)');lessNode=full_node.find('a:last');moreNode=truncated_node.find('a:last');}
moreNode.click(function(){truncated_node.hide();full_node.show();moreNode.hide();lessNode.show();return false;});lessNode.click(function(){truncated_node.show();full_node.hide();moreNode.show();lessNode.hide();return false;});});};$.fn.truncate.defaults={max_length:100,more:'…more',less:'less'};function recursivelyTruncate(node,max_length){return(node.nodeType==3)?truncateText(node,max_length):truncateNode(node,max_length);}
function truncateNode(node,max_length){var node=$(node);var new_node=node.clone().empty();var truncatedChild;node.contents().each(function(){var remaining_length=max_length-new_node.text().length;if(remaining_length==0)return;truncatedChild=recursivelyTruncate(this,remaining_length);if(truncatedChild)new_node.append(truncatedChild);});return new_node;}
function truncateText(node,max_length){var text=squeeze(node.data);if(trailing_whitespace)
text=text.replace(/^ /,'');trailing_whitespace=!!text.match(/ $/);var text=text.slice(0,max_length);text=$('<div/>').text(text).html();return text;}
function squeeze(string){return string.replace(/\s+/g,' ');}
function findNodeForMore(node){var $node=$(node);var last_child=$node.children(":last");if(!last_child)return node;var display=last_child.css('display');if(!display||display=='inline')return $node;return findNodeForMore(last_child);};function findNodeForLess(node){var $node=$(node);var last_child=$node.children(":last");if(last_child&&last_child.is('p'))return last_child;return node;};})(jQuery);if(typeof Object.create!=='function'){Object.create=function(obj){function F(){};F.prototype=obj;return new F();};}
(function($,window,document,undefined){var ElevateZoom={init:function(options,elem){var self=this;self.elem=elem;self.$elem=$(elem);self.imageSrc=self.$elem.data("zoom-image")?self.$elem.data("zoom-image"):self.$elem.attr("src");self.options=$.extend({},$.fn.elevateZoom.options,options);if(self.options.tint){self.options.lensColour="none",self.options.lensOpacity="1"}
if(self.options.zoomType=="inner"){self.options.showLens=false;}
self.$elem.parent().removeAttr('title').removeAttr('alt');self.zoomImage=self.imageSrc;self.refresh(1);$('#'+self.options.gallery+' a').click(function(e){if(self.options.galleryActiveClass){$('#'+self.options.gallery+' a').removeClass(self.options.galleryActiveClass);$(this).addClass(self.options.galleryActiveClass);}
e.preventDefault();if($(this).data("zoom-image")){self.zoomImagePre=$(this).data("zoom-image")}
else{self.zoomImagePre=$(this).data("image");}
self.swaptheimage($(this).data("image"),self.zoomImagePre);return false;});},refresh:function(length){var self=this;setTimeout(function(){self.fetch(self.imageSrc);},length||self.options.refresh);},fetch:function(imgsrc){var self=this;var newImg=new Image();newImg.onload=function(){self.largeWidth=newImg.width;self.largeHeight=newImg.height;self.startZoom();self.currentImage=self.imageSrc;self.options.onZoomedImageLoaded(self.$elem);}
newImg.src=imgsrc;return;},startZoom:function(){var self=this;self.nzWidth=self.$elem.width();self.nzHeight=self.$elem.height();self.isWindowActive=false;self.isLensActive=false;self.isTintActive=false;self.overWindow=false;if(self.options.imageCrossfade){self.zoomWrap=self.$elem.wrap('<div style="height:'+self.nzHeight+'px;width:'+self.nzWidth+'px;" class="zoomWrapper" />');self.$elem.css('position','absolute');}
self.zoomLock=1;self.scrollingLock=false;self.changeBgSize=false;self.currentZoomLevel=self.options.zoomLevel;self.nzOffset=self.$elem.offset();self.widthRatio=(self.largeWidth/self.currentZoomLevel)/self.nzWidth;self.heightRatio=(self.largeHeight/self.currentZoomLevel)/self.nzHeight;if(self.options.zoomType=="window"){self.zoomWindowStyle="overflow: hidden;"
+"background-position: 0px 0px;text-align:center;"
+"background-color: "+String(self.options.zoomWindowBgColour)
+";width: "+String(self.options.zoomWindowWidth)+"px;"
+"height: "+String(self.options.zoomWindowHeight)
+"px;float: left;"
+"background-size: "+self.largeWidth/self.currentZoomLevel+"px "+self.largeHeight/self.currentZoomLevel+"px;"
+"display: none;z-index:100;"
+"border: "+String(self.options.borderSize)
+"px solid "+self.options.borderColour
+";background-repeat: no-repeat;"
+"position: absolute;";}
if(self.options.zoomType=="inner"){var borderWidth=self.$elem.css("border-left-width");self.zoomWindowStyle="overflow: hidden;"
+"margin-left: "+String(borderWidth)+";"
+"margin-top: "+String(borderWidth)+";"
+"background-position: 0px 0px;"
+"width: "+String(self.nzWidth)+"px;"
+"height: "+String(self.nzHeight)
+"px;float: left;"
+"display: none;"
+"cursor:"+(self.options.cursor)+";"
+"px solid "+self.options.borderColour
+";background-repeat: no-repeat;"
+"position: absolute;";}
if(self.options.zoomType=="window"){if(self.nzHeight<self.options.zoomWindowWidth/self.widthRatio){lensHeight=self.nzHeight;}
else{lensHeight=String((self.options.zoomWindowHeight/self.heightRatio))}
if(self.largeWidth<self.options.zoomWindowWidth){lensWidth=self.nzWidth;}
else{lensWidth=(self.options.zoomWindowWidth/self.widthRatio);}
self.lensStyle="background-position: 0px 0px;width: "+String((self.options.zoomWindowWidth)/self.widthRatio)+"px;height: "+String((self.options.zoomWindowHeight)/self.heightRatio)
+"px;float: right;display: none;"
+"overflow: hidden;"
+"z-index: 999;"
+"-webkit-transform: translateZ(0);"
+"opacity:"+(self.options.lensOpacity)+";filter: alpha(opacity = "+(self.options.lensOpacity*100)+"); zoom:1;"
+"width:"+lensWidth+"px;"
+"height:"+lensHeight+"px;"
+"background-color:"+(self.options.lensColour)+";"
+"cursor:"+(self.options.cursor)+";"
+"border: "+(self.options.lensBorderSize)+"px"+" solid "+(self.options.lensBorderColour)+";background-repeat: no-repeat;position: absolute;";}
self.tintStyle="display: block;"
+"position: absolute;"
+"background-color: "+self.options.tintColour+";"
+"filter:alpha(opacity=0);"
+"opacity: 0;"
+"width: "+self.nzWidth+"px;"
+"height: "+self.nzHeight+"px;";self.lensRound='';if(self.options.zoomType=="lens"){self.lensStyle="background-position: 0px 0px;"
+"float: left;display: none;"
+"border: "+String(self.options.borderSize)+"px solid "+self.options.borderColour+";"
+"width:"+String(self.options.lensSize)+"px;"
+"height:"+String(self.options.lensSize)+"px;"
+"background-repeat: no-repeat;position: absolute;";}
if(self.options.lensShape=="round"){self.lensRound="border-top-left-radius: "+String(self.options.lensSize/2+self.options.borderSize)+"px;"
+"border-top-right-radius: "+String(self.options.lensSize/2+self.options.borderSize)+"px;"
+"border-bottom-left-radius: "+String(self.options.lensSize/2+self.options.borderSize)+"px;"
+"border-bottom-right-radius: "+String(self.options.lensSize/2+self.options.borderSize)+"px;";}
self.zoomContainer=$('<div class="zoomContainer" style="-webkit-transform: translateZ(0);position:absolute;left:'+self.nzOffset.left+'px;top:'+self.nzOffset.top+'px;height:'+self.nzHeight+'px;width:'+self.nzWidth+'px;"></div>');$('body').append(self.zoomContainer);if(self.options.containLensZoom&&self.options.zoomType=="lens"){self.zoomContainer.css("overflow","hidden");}
if(self.options.zoomType!="inner"){self.zoomLens=$("<div class='zoomLens' style='"+self.lensStyle+self.lensRound+"'>&nbsp;</div>").appendTo(self.zoomContainer).click(function(){self.$elem.trigger('click');});if(self.options.tint){self.tintContainer=$('<div/>').addClass('tintContainer');self.zoomTint=$("<div class='zoomTint' style='"+self.tintStyle+"'></div>");self.zoomLens.wrap(self.tintContainer);self.zoomTintcss=self.zoomLens.after(self.zoomTint);self.zoomTintImage=$('<img style="position: absolute; left: 0px; top: 0px; max-width: none; width: '+self.nzWidth+'px; height: '+self.nzHeight+'px;" src="'+self.imageSrc+'">').appendTo(self.zoomLens).click(function(){self.$elem.trigger('click');});}}
if(isNaN(self.options.zoomWindowPosition)){self.zoomWindow=$("<div style='z-index:999;left:"+(self.windowOffsetLeft)+"px;top:"+(self.windowOffsetTop)+"px;"+self.zoomWindowStyle+"' class='zoomWindow'>&nbsp;</div>").appendTo('body').click(function(){self.$elem.trigger('click');});}else{self.zoomWindow=$("<div style='z-index:999;left:"+(self.windowOffsetLeft)+"px;top:"+(self.windowOffsetTop)+"px;"+self.zoomWindowStyle+"' class='zoomWindow'>&nbsp;</div>").appendTo(self.zoomContainer).click(function(){self.$elem.trigger('click');});}
self.zoomWindowContainer=$('<div/>').addClass('zoomWindowContainer').css("width",self.options.zoomWindowWidth);self.zoomWindow.wrap(self.zoomWindowContainer);if(self.options.zoomType=="lens"){self.zoomLens.css({backgroundImage:"url('"+self.imageSrc+"')"});}
if(self.options.zoomType=="window"){self.zoomWindow.css({backgroundImage:"url('"+self.imageSrc+"')"});}
if(self.options.zoomType=="inner"){self.zoomWindow.css({backgroundImage:"url('"+self.imageSrc+"')"});}
self.$elem.bind('touchmove',function(e){e.preventDefault();var touch=e.originalEvent.touches[0]||e.originalEvent.changedTouches[0];self.setPosition(touch);});self.zoomContainer.bind('touchmove',function(e){if(self.options.zoomType=="inner"){self.showHideWindow("show");}
e.preventDefault();var touch=e.originalEvent.touches[0]||e.originalEvent.changedTouches[0];self.setPosition(touch);});self.zoomContainer.bind('touchend',function(e){self.showHideWindow("hide");if(self.options.showLens){self.showHideLens("hide");}
if(self.options.tint&&self.options.zoomType!="inner"){self.showHideTint("hide");}});self.$elem.bind('touchend',function(e){self.showHideWindow("hide");if(self.options.showLens){self.showHideLens("hide");}
if(self.options.tint&&self.options.zoomType!="inner"){self.showHideTint("hide");}});if(self.options.showLens){self.zoomLens.bind('touchmove',function(e){e.preventDefault();var touch=e.originalEvent.touches[0]||e.originalEvent.changedTouches[0];self.setPosition(touch);});self.zoomLens.bind('touchend',function(e){self.showHideWindow("hide");if(self.options.showLens){self.showHideLens("hide");}
if(self.options.tint&&self.options.zoomType!="inner"){self.showHideTint("hide");}});}
self.$elem.bind('mousemove',function(e){if(self.overWindow==false){self.setElements("show");}
if(self.lastX!==e.clientX||self.lastY!==e.clientY){self.setPosition(e);self.currentLoc=e;}
self.lastX=e.clientX;self.lastY=e.clientY;});self.zoomContainer.bind('mousemove',function(e){if(self.overWindow==false){self.setElements("show");}
if(self.lastX!==e.clientX||self.lastY!==e.clientY){self.setPosition(e);self.currentLoc=e;}
self.lastX=e.clientX;self.lastY=e.clientY;});if(self.options.zoomType!="inner"){self.zoomLens.bind('mousemove',function(e){if(self.lastX!==e.clientX||self.lastY!==e.clientY){self.setPosition(e);self.currentLoc=e;}
self.lastX=e.clientX;self.lastY=e.clientY;});}
if(self.options.tint&&self.options.zoomType!="inner"){self.zoomTint.bind('mousemove',function(e){if(self.lastX!==e.clientX||self.lastY!==e.clientY){self.setPosition(e);self.currentLoc=e;}
self.lastX=e.clientX;self.lastY=e.clientY;});}
if(self.options.zoomType=="inner"){self.zoomWindow.bind('mousemove',function(e){if(self.lastX!==e.clientX||self.lastY!==e.clientY){self.setPosition(e);self.currentLoc=e;}
self.lastX=e.clientX;self.lastY=e.clientY;});}
self.zoomContainer.add(self.$elem).mouseenter(function(){if(self.overWindow==false){self.setElements("show");}}).mouseleave(function(){if(!self.scrollLock){self.setElements("hide");}});if(self.options.zoomType!="inner"){self.zoomWindow.mouseenter(function(){self.overWindow=true;self.setElements("hide");}).mouseleave(function(){self.overWindow=false;});}
if(self.options.zoomLevel!=1){}
if(self.options.minZoomLevel){self.minZoomLevel=self.options.minZoomLevel;}
else{self.minZoomLevel=self.options.scrollZoomIncrement*2;}
if(self.options.scrollZoom){self.zoomContainer.add(self.$elem).bind('mousewheel DOMMouseScroll MozMousePixelScroll',function(e){self.scrollLock=true;clearTimeout($.data(this,'timer'));$.data(this,'timer',setTimeout(function(){self.scrollLock=false;},250));var theEvent=e.originalEvent.wheelDelta||e.originalEvent.detail*-1
e.stopImmediatePropagation();e.stopPropagation();e.preventDefault();if(theEvent/120>0){if(self.currentZoomLevel>=self.minZoomLevel){self.changeZoomLevel(self.currentZoomLevel-self.options.scrollZoomIncrement);}}
else{if(self.options.maxZoomLevel){if(self.currentZoomLevel<=self.options.maxZoomLevel){self.changeZoomLevel(parseFloat(self.currentZoomLevel)+self.options.scrollZoomIncrement);}}
else{self.changeZoomLevel(parseFloat(self.currentZoomLevel)+self.options.scrollZoomIncrement);}}
return false;});}},setElements:function(type){var self=this;if(!self.options.zoomEnabled){return false;}
if(type=="show"){if(self.isWindowSet){if(self.options.zoomType=="inner"){self.showHideWindow("show");}
if(self.options.zoomType=="window"){self.showHideWindow("show");}
if(self.options.showLens){self.showHideLens("show");}
if(self.options.tint&&self.options.zoomType!="inner"){self.showHideTint("show");}}}
if(type=="hide"){if(self.options.zoomType=="window"){self.showHideWindow("hide");}
if(!self.options.tint){self.showHideWindow("hide");}
if(self.options.showLens){self.showHideLens("hide");}
if(self.options.tint){self.showHideTint("hide");}}},setPosition:function(e){var self=this;if(!self.options.zoomEnabled){return false;}
self.nzHeight=self.$elem.height();self.nzWidth=self.$elem.width();self.nzOffset=self.$elem.offset();if(self.options.tint&&self.options.zoomType!="inner"){self.zoomTint.css({top:0});self.zoomTint.css({left:0});}
if(self.options.responsive&&!self.options.scrollZoom){if(self.options.showLens){if(self.nzHeight<self.options.zoomWindowWidth/self.widthRatio){lensHeight=self.nzHeight;}
else{lensHeight=String((self.options.zoomWindowHeight/self.heightRatio))}
if(self.largeWidth<self.options.zoomWindowWidth){lensWidth=self.nzWidth;}
else{lensWidth=(self.options.zoomWindowWidth/self.widthRatio);}
self.widthRatio=self.largeWidth/self.nzWidth;self.heightRatio=self.largeHeight/self.nzHeight;if(self.options.zoomType!="lens"){if(self.nzHeight<self.options.zoomWindowWidth/self.widthRatio){lensHeight=self.nzHeight;}
else{lensHeight=String((self.options.zoomWindowHeight/self.heightRatio))}
if(self.options.zoomWindowWidth<self.options.zoomWindowWidth){lensWidth=self.nzWidth;}
else{lensWidth=(self.options.zoomWindowWidth/self.widthRatio);}
self.zoomLens.css('width',lensWidth);self.zoomLens.css('height',lensHeight);if(self.options.tint){self.zoomTintImage.css('width',self.nzWidth);self.zoomTintImage.css('height',self.nzHeight);}}
if(self.options.zoomType=="lens"){self.zoomLens.css({width:String(self.options.lensSize)+'px',height:String(self.options.lensSize)+'px'})}}}
self.zoomContainer.css({top:self.nzOffset.top});self.zoomContainer.css({left:self.nzOffset.left});self.mouseLeft=parseInt(e.pageX-self.nzOffset.left);self.mouseTop=parseInt(e.pageY-self.nzOffset.top);if(self.options.zoomType=="window"){self.Etoppos=(self.mouseTop<(self.zoomLens.height()/2));self.Eboppos=(self.mouseTop>self.nzHeight-(self.zoomLens.height()/2)-(self.options.lensBorderSize*2));self.Eloppos=(self.mouseLeft<0+((self.zoomLens.width()/2)));self.Eroppos=(self.mouseLeft>(self.nzWidth-(self.zoomLens.width()/2)-(self.options.lensBorderSize*2)));}
if(self.options.zoomType=="inner"){self.Etoppos=(self.mouseTop<((self.nzHeight/2)/self.heightRatio));self.Eboppos=(self.mouseTop>(self.nzHeight-((self.nzHeight/2)/self.heightRatio)));self.Eloppos=(self.mouseLeft<0+(((self.nzWidth/2)/self.widthRatio)));self.Eroppos=(self.mouseLeft>(self.nzWidth-(self.nzWidth/2)/self.widthRatio-(self.options.lensBorderSize*2)));}
if(self.mouseLeft<=0||self.mouseTop<0||self.mouseLeft>self.nzWidth||self.mouseTop>self.nzHeight){self.setElements("hide");return;}
else{if(self.options.showLens){self.lensLeftPos=String(self.mouseLeft-self.zoomLens.width()/2);self.lensTopPos=String(self.mouseTop-self.zoomLens.height()/2);}
if(self.Etoppos){self.lensTopPos=0;}
if(self.Eloppos){self.windowLeftPos=0;self.lensLeftPos=0;self.tintpos=0;}
if(self.options.zoomType=="window"){if(self.Eboppos){self.lensTopPos=Math.max((self.nzHeight)-self.zoomLens.height()-(self.options.lensBorderSize*2),0);}
if(self.Eroppos){self.lensLeftPos=(self.nzWidth-(self.zoomLens.width())-(self.options.lensBorderSize*2));}}
if(self.options.zoomType=="inner"){if(self.Eboppos){self.lensTopPos=Math.max(((self.nzHeight)-(self.options.lensBorderSize*2)),0);}
if(self.Eroppos){self.lensLeftPos=(self.nzWidth-(self.nzWidth)-(self.options.lensBorderSize*2));}}
if(self.options.zoomType=="lens"){self.windowLeftPos=String(((e.pageX-self.nzOffset.left)*self.widthRatio-self.zoomLens.width()/2)*(-1));self.windowTopPos=String(((e.pageY-self.nzOffset.top)*self.heightRatio-self.zoomLens.height()/2)*(-1));self.zoomLens.css({backgroundPosition:self.windowLeftPos+'px '+self.windowTopPos+'px'});if(self.changeBgSize){if(self.nzHeight>self.nzWidth){if(self.options.zoomType=="lens"){self.zoomLens.css({"background-size":self.largeWidth/self.newvalueheight+'px '+self.largeHeight/self.newvalueheight+'px'});}
self.zoomWindow.css({"background-size":self.largeWidth/self.newvalueheight+'px '+self.largeHeight/self.newvalueheight+'px'});}
else{if(self.options.zoomType=="lens"){self.zoomLens.css({"background-size":self.largeWidth/self.newvaluewidth+'px '+self.largeHeight/self.newvaluewidth+'px'});}
self.zoomWindow.css({"background-size":self.largeWidth/self.newvaluewidth+'px '+self.largeHeight/self.newvaluewidth+'px'});}
self.changeBgSize=false;}
self.setWindowPostition(e);}
if(self.options.tint&&self.options.zoomType!="inner"){self.setTintPosition(e);}
if(self.options.zoomType=="window"){self.setWindowPostition(e);}
if(self.options.zoomType=="inner"){self.setWindowPostition(e);}
if(self.options.showLens){if(self.fullwidth&&self.options.zoomType!="lens"){self.lensLeftPos=0;}
self.zoomLens.css({left:self.lensLeftPos+'px',top:self.lensTopPos+'px'})}}},showHideWindow:function(change){var self=this;if(change=="show"){if(!self.isWindowActive){if(self.options.zoomWindowFadeIn){self.zoomWindow.stop(true,true,false).fadeIn(self.options.zoomWindowFadeIn);}
else{self.zoomWindow.show();}
self.isWindowActive=true;}}
if(change=="hide"){if(self.isWindowActive){if(self.options.zoomWindowFadeOut){self.zoomWindow.stop(true,true).fadeOut(self.options.zoomWindowFadeOut);}
else{self.zoomWindow.hide();}
self.isWindowActive=false;}}},showHideLens:function(change){var self=this;if(change=="show"){if(!self.isLensActive){if(self.options.lensFadeIn){self.zoomLens.stop(true,true,false).fadeIn(self.options.lensFadeIn);}
else{self.zoomLens.show();}
self.isLensActive=true;}}
if(change=="hide"){if(self.isLensActive){if(self.options.lensFadeOut){self.zoomLens.stop(true,true).fadeOut(self.options.lensFadeOut);}
else{self.zoomLens.hide();}
self.isLensActive=false;}}},showHideTint:function(change){var self=this;if(change=="show"){if(!self.isTintActive){if(self.options.zoomTintFadeIn){self.zoomTint.css({opacity:self.options.tintOpacity}).animate().stop(true,true).fadeIn("slow");}
else{self.zoomTint.css({opacity:self.options.tintOpacity}).animate();self.zoomTint.show();}
self.isTintActive=true;}}
if(change=="hide"){if(self.isTintActive){if(self.options.zoomTintFadeOut){self.zoomTint.stop(true,true).fadeOut(self.options.zoomTintFadeOut);}
else{self.zoomTint.hide();}
self.isTintActive=false;}}},setLensPostition:function(e){},setWindowPostition:function(e){var self=this;if(!isNaN(self.options.zoomWindowPosition)){switch(self.options.zoomWindowPosition){case 1:self.windowOffsetTop=(self.options.zoomWindowOffety);self.windowOffsetLeft=(+self.nzWidth);break;case 2:if(self.options.zoomWindowHeight>self.nzHeight){self.windowOffsetTop=((self.options.zoomWindowHeight/2)-(self.nzHeight/2))*(-1);self.windowOffsetLeft=(self.nzWidth);}
else{}
break;case 3:self.windowOffsetTop=(self.nzHeight-self.zoomWindow.height()-(self.options.borderSize*2));self.windowOffsetLeft=(self.nzWidth);break;case 4:self.windowOffsetTop=(self.nzHeight);self.windowOffsetLeft=(self.nzWidth);break;case 5:self.windowOffsetTop=(self.nzHeight);self.windowOffsetLeft=(self.nzWidth-self.zoomWindow.width()-(self.options.borderSize*2));break;case 6:if(self.options.zoomWindowHeight>self.nzHeight){self.windowOffsetTop=(self.nzHeight);self.windowOffsetLeft=((self.options.zoomWindowWidth/2)-(self.nzWidth/2)+(self.options.borderSize*2))*(-1);}
else{}
break;case 7:self.windowOffsetTop=(self.nzHeight);self.windowOffsetLeft=0;break;case 8:self.windowOffsetTop=(self.nzHeight);self.windowOffsetLeft=(self.zoomWindow.width()+(self.options.borderSize*2))*(-1);break;case 9:self.windowOffsetTop=(self.nzHeight-self.zoomWindow.height()-(self.options.borderSize*2));self.windowOffsetLeft=(self.zoomWindow.width()+(self.options.borderSize*2))*(-1);break;case 10:if(self.options.zoomWindowHeight>self.nzHeight){self.windowOffsetTop=((self.options.zoomWindowHeight/2)-(self.nzHeight/2))*(-1);self.windowOffsetLeft=(self.zoomWindow.width()+(self.options.borderSize*2))*(-1);}
else{}
break;case 11:self.windowOffsetTop=(self.options.zoomWindowOffety);self.windowOffsetLeft=(self.zoomWindow.width()+(self.options.borderSize*2))*(-1);break;case 12:self.windowOffsetTop=(self.zoomWindow.height()+(self.options.borderSize*2))*(-1);self.windowOffsetLeft=(self.zoomWindow.width()+(self.options.borderSize*2))*(-1);break;case 13:self.windowOffsetTop=(self.zoomWindow.height()+(self.options.borderSize*2))*(-1);self.windowOffsetLeft=(0);break;case 14:if(self.options.zoomWindowHeight>self.nzHeight){self.windowOffsetTop=(self.zoomWindow.height()+(self.options.borderSize*2))*(-1);self.windowOffsetLeft=((self.options.zoomWindowWidth/2)-(self.nzWidth/2)+(self.options.borderSize*2))*(-1);}
else{}
break;case 15:self.windowOffsetTop=(self.zoomWindow.height()+(self.options.borderSize*2))*(-1);self.windowOffsetLeft=(self.nzWidth-self.zoomWindow.width()-(self.options.borderSize*2));break;case 16:self.windowOffsetTop=(self.zoomWindow.height()+(self.options.borderSize*2))*(-1);self.windowOffsetLeft=(self.nzWidth);break;default:self.windowOffsetTop=(self.options.zoomWindowOffety);self.windowOffsetLeft=(self.nzWidth);}}
else{self.externalContainer=$('#'+self.options.zoomWindowPosition);self.externalContainerWidth=self.externalContainer.width();self.externalContainerHeight=self.externalContainer.height();self.externalContainerOffset=self.externalContainer.offset();self.windowOffsetTop=self.externalContainerOffset.top;self.windowOffsetLeft=self.externalContainerOffset.left;}
self.isWindowSet=true;self.windowOffsetTop=self.windowOffsetTop+self.options.zoomWindowOffety;self.windowOffsetLeft=self.windowOffsetLeft+self.options.zoomWindowOffetx;self.zoomWindow.css({top:self.windowOffsetTop});self.zoomWindow.css({left:self.windowOffsetLeft});if(self.options.zoomType=="inner"){self.zoomWindow.css({top:0});self.zoomWindow.css({left:0});}
self.windowLeftPos=String(((e.pageX-self.nzOffset.left)*self.widthRatio-self.zoomWindow.width()/2)*(-1));self.windowTopPos=String(((e.pageY-self.nzOffset.top)*self.heightRatio-self.zoomWindow.height()/2)*(-1));if(self.Etoppos){self.windowTopPos=0;}
if(self.Eloppos){self.windowLeftPos=0;}
if(self.Eboppos){self.windowTopPos=(self.largeHeight/self.currentZoomLevel-self.zoomWindow.height())*(-1);}
if(self.Eroppos){self.windowLeftPos=((self.largeWidth/self.currentZoomLevel-self.zoomWindow.width())*(-1));}
if(self.fullheight){self.windowTopPos=0;}
if(self.fullwidth){self.windowLeftPos=0;}
if(self.options.zoomType=="window"||self.options.zoomType=="inner"){if(self.zoomLock==1){if(self.widthRatio<=1){self.windowLeftPos=0;}
if(self.heightRatio<=1){self.windowTopPos=0;}}
if(self.largeHeight<self.options.zoomWindowHeight){self.windowTopPos=0;}
if(self.largeWidth<self.options.zoomWindowWidth){self.windowLeftPos=0;}
if(self.options.easing){if(!self.xp){self.xp=0;}
if(!self.yp){self.yp=0;}
if(!self.loop){self.loop=setInterval(function(){self.xp+=(self.windowLeftPos-self.xp)/self.options.easingAmount;self.yp+=(self.windowTopPos-self.yp)/self.options.easingAmount;if(self.scrollingLock){clearInterval(self.loop);self.xp=self.windowLeftPos;self.yp=self.windowTopPos
self.xp=((e.pageX-self.nzOffset.left)*self.widthRatio-self.zoomWindow.width()/2)*(-1);self.yp=(((e.pageY-self.nzOffset.top)*self.heightRatio-self.zoomWindow.height()/2)*(-1));if(self.changeBgSize){if(self.nzHeight>self.nzWidth){if(self.options.zoomType=="lens"){self.zoomLens.css({"background-size":self.largeWidth/self.newvalueheight+'px '+self.largeHeight/self.newvalueheight+'px'});}
self.zoomWindow.css({"background-size":self.largeWidth/self.newvalueheight+'px '+self.largeHeight/self.newvalueheight+'px'});}
else{if(self.options.zoomType!="lens"){self.zoomLens.css({"background-size":self.largeWidth/self.newvaluewidth+'px '+self.largeHeight/self.newvalueheight+'px'});}
self.zoomWindow.css({"background-size":self.largeWidth/self.newvaluewidth+'px '+self.largeHeight/self.newvaluewidth+'px'});}
self.changeBgSize=false;}
self.zoomWindow.css({backgroundPosition:self.windowLeftPos+'px '+self.windowTopPos+'px'});self.scrollingLock=false;self.loop=false;}
else{if(self.changeBgSize){if(self.nzHeight>self.nzWidth){if(self.options.zoomType=="lens"){self.zoomLens.css({"background-size":self.largeWidth/self.newvalueheight+'px '+self.largeHeight/self.newvalueheight+'px'});}
self.zoomWindow.css({"background-size":self.largeWidth/self.newvalueheight+'px '+self.largeHeight/self.newvalueheight+'px'});}
else{if(self.options.zoomType!="lens"){self.zoomLens.css({"background-size":self.largeWidth/self.newvaluewidth+'px '+self.largeHeight/self.newvaluewidth+'px'});}
self.zoomWindow.css({"background-size":self.largeWidth/self.newvaluewidth+'px '+self.largeHeight/self.newvaluewidth+'px'});}
self.changeBgSize=false;}
self.zoomWindow.css({backgroundPosition:self.xp+'px '+self.yp+'px'});}},16);}}
else{if(self.changeBgSize){if(self.nzHeight>self.nzWidth){if(self.options.zoomType=="lens"){self.zoomLens.css({"background-size":self.largeWidth/self.newvalueheight+'px '+self.largeHeight/self.newvalueheight+'px'});}
self.zoomWindow.css({"background-size":self.largeWidth/self.newvalueheight+'px '+self.largeHeight/self.newvalueheight+'px'});}
else{if(self.options.zoomType=="lens"){self.zoomLens.css({"background-size":self.largeWidth/self.newvaluewidth+'px '+self.largeHeight/self.newvaluewidth+'px'});}
if((self.largeHeight/self.newvaluewidth)<self.options.zoomWindowHeight){self.zoomWindow.css({"background-size":self.largeWidth/self.newvaluewidth+'px '+self.largeHeight/self.newvaluewidth+'px'});}
else{self.zoomWindow.css({"background-size":self.largeWidth/self.newvalueheight+'px '+self.largeHeight/self.newvalueheight+'px'});}}
self.changeBgSize=false;}
self.zoomWindow.css({backgroundPosition:self.windowLeftPos+'px '+self.windowTopPos+'px'});}}},setTintPosition:function(e){var self=this;self.nzOffset=self.$elem.offset();self.tintpos=String(((e.pageX-self.nzOffset.left)-(self.zoomLens.width()/2))*(-1));self.tintposy=String(((e.pageY-self.nzOffset.top)-self.zoomLens.height()/2)*(-1));if(self.Etoppos){self.tintposy=0;}
if(self.Eloppos){self.tintpos=0;}
if(self.Eboppos){self.tintposy=(self.nzHeight-self.zoomLens.height()-(self.options.lensBorderSize*2))*(-1);}
if(self.Eroppos){self.tintpos=((self.nzWidth-self.zoomLens.width()-(self.options.lensBorderSize*2))*(-1));}
if(self.options.tint){if(self.fullheight){self.tintposy=0;}
if(self.fullwidth){self.tintpos=0;}
self.zoomTintImage.css({'left':self.tintpos+'px'});self.zoomTintImage.css({'top':self.tintposy+'px'});}},swaptheimage:function(smallimage,largeimage){var self=this;var newImg=new Image();if(self.options.loadingIcon){self.spinner=$('<div style="background: url(\''+self.options.loadingIcon+'\') no-repeat center;height:'+self.nzHeight+'px;width:'+self.nzWidth+'px;z-index: 2000;position: absolute; background-position: center center;"></div>');self.$elem.after(self.spinner);}
self.options.onImageSwap(self.$elem);newImg.onload=function(){self.largeWidth=newImg.width;self.largeHeight=newImg.height;self.zoomImage=largeimage;self.zoomWindow.css({"background-size":self.largeWidth+'px '+self.largeHeight+'px'});self.zoomWindow.css({"background-size":self.largeWidth+'px '+self.largeHeight+'px'});self.swapAction(smallimage,largeimage);return;}
newImg.src=largeimage;},swapAction:function(smallimage,largeimage){var self=this;var newImg2=new Image();newImg2.onload=function(){self.nzHeight=newImg2.height;self.nzWidth=newImg2.width;self.options.onImageSwapComplete(self.$elem);self.doneCallback();return;}
newImg2.src=smallimage;self.currentZoomLevel=self.options.zoomLevel;self.options.maxZoomLevel=false;if(self.options.zoomType=="lens"){self.zoomLens.css({backgroundImage:"url('"+largeimage+"')"});}
if(self.options.zoomType=="window"){self.zoomWindow.css({backgroundImage:"url('"+largeimage+"')"});}
if(self.options.zoomType=="inner"){self.zoomWindow.css({backgroundImage:"url('"+largeimage+"')"});}
self.currentImage=largeimage;if(self.options.imageCrossfade){var oldImg=self.$elem;var newImg=oldImg.clone();self.$elem.attr("src",smallimage)
self.$elem.after(newImg);newImg.stop(true).fadeOut(self.options.imageCrossfade,function(){$(this).remove();});self.$elem.width("auto").removeAttr("width");self.$elem.height("auto").removeAttr("height");oldImg.fadeIn(self.options.imageCrossfade);if(self.options.tint&&self.options.zoomType!="inner"){var oldImgTint=self.zoomTintImage;var newImgTint=oldImgTint.clone();self.zoomTintImage.attr("src",largeimage)
self.zoomTintImage.after(newImgTint);newImgTint.stop(true).fadeOut(self.options.imageCrossfade,function(){$(this).remove();});oldImgTint.fadeIn(self.options.imageCrossfade);self.zoomTint.css({height:self.$elem.height()});self.zoomTint.css({width:self.$elem.width()});}
self.zoomContainer.css("height",self.$elem.height());self.zoomContainer.css("width",self.$elem.width());if(self.options.zoomType=="inner"){if(!self.options.constrainType){self.zoomWrap.parent().css("height",self.$elem.height());self.zoomWrap.parent().css("width",self.$elem.width());self.zoomWindow.css("height",self.$elem.height());self.zoomWindow.css("width",self.$elem.width());}}
if(self.options.imageCrossfade){self.zoomWrap.css("height",self.$elem.height());self.zoomWrap.css("width",self.$elem.width());}}
else{self.$elem.attr("src",smallimage);if(self.options.tint){self.zoomTintImage.attr("src",largeimage);self.zoomTintImage.attr("height",self.$elem.height());self.zoomTintImage.css({height:self.$elem.height()});self.zoomTint.css({height:self.$elem.height()});}
self.zoomContainer.css("height",self.$elem.height());self.zoomContainer.css("width",self.$elem.width());if(self.options.imageCrossfade){self.zoomWrap.css("height",self.$elem.height());self.zoomWrap.css("width",self.$elem.width());}}
if(self.options.constrainType){if(self.options.constrainType=="height"){self.zoomContainer.css("height",self.options.constrainSize);self.zoomContainer.css("width","auto");if(self.options.imageCrossfade){self.zoomWrap.css("height",self.options.constrainSize);self.zoomWrap.css("width","auto");self.constwidth=self.zoomWrap.width();}
else{self.$elem.css("height",self.options.constrainSize);self.$elem.css("width","auto");self.constwidth=self.$elem.width();}
if(self.options.zoomType=="inner"){self.zoomWrap.parent().css("height",self.options.constrainSize);self.zoomWrap.parent().css("width",self.constwidth);self.zoomWindow.css("height",self.options.constrainSize);self.zoomWindow.css("width",self.constwidth);}
if(self.options.tint){self.tintContainer.css("height",self.options.constrainSize);self.tintContainer.css("width",self.constwidth);self.zoomTint.css("height",self.options.constrainSize);self.zoomTint.css("width",self.constwidth);self.zoomTintImage.css("height",self.options.constrainSize);self.zoomTintImage.css("width",self.constwidth);}}
if(self.options.constrainType=="width"){self.zoomContainer.css("height","auto");self.zoomContainer.css("width",self.options.constrainSize);if(self.options.imageCrossfade){self.zoomWrap.css("height","auto");self.zoomWrap.css("width",self.options.constrainSize);self.constheight=self.zoomWrap.height();}
else{self.$elem.css("height","auto");self.$elem.css("width",self.options.constrainSize);self.constheight=self.$elem.height();}
if(self.options.zoomType=="inner"){self.zoomWrap.parent().css("height",self.constheight);self.zoomWrap.parent().css("width",self.options.constrainSize);self.zoomWindow.css("height",self.constheight);self.zoomWindow.css("width",self.options.constrainSize);}
if(self.options.tint){self.tintContainer.css("height",self.constheight);self.tintContainer.css("width",self.options.constrainSize);self.zoomTint.css("height",self.constheight);self.zoomTint.css("width",self.options.constrainSize);self.zoomTintImage.css("height",self.constheight);self.zoomTintImage.css("width",self.options.constrainSize);}}}},doneCallback:function(){var self=this;if(self.options.loadingIcon){self.spinner.hide();}
self.nzOffset=self.$elem.offset();self.nzWidth=self.$elem.width();self.nzHeight=self.$elem.height();self.currentZoomLevel=self.options.zoomLevel;self.widthRatio=self.largeWidth/self.nzWidth;self.heightRatio=self.largeHeight/self.nzHeight;if(self.options.zoomType=="window"){if(self.nzHeight<self.options.zoomWindowWidth/self.widthRatio){lensHeight=self.nzHeight;}
else{lensHeight=String((self.options.zoomWindowHeight/self.heightRatio))}
if(self.options.zoomWindowWidth<self.options.zoomWindowWidth){lensWidth=self.nzWidth;}
else{lensWidth=(self.options.zoomWindowWidth/self.widthRatio);}
if(self.zoomLens){self.zoomLens.css('width',lensWidth);self.zoomLens.css('height',lensHeight);}}},getCurrentImage:function(){var self=this;return self.zoomImage;},getGalleryList:function(){var self=this;self.gallerylist=[];if(self.options.gallery){$('#'+self.options.gallery+' a').each(function(){var img_src='';if($(this).data("zoom-image")){img_src=$(this).data("zoom-image");}
else if($(this).data("image")){img_src=$(this).data("image");}
if(img_src==self.zoomImage){self.gallerylist.unshift({href:''+img_src+'',title:$(this).find('img').attr("title")});}
else{self.gallerylist.push({href:''+img_src+'',title:$(this).find('img').attr("title")});}});}
else{self.gallerylist.push({href:''+self.zoomImage+'',title:$(this).find('img').attr("title")});}
return self.gallerylist;},changeZoomLevel:function(value){var self=this;self.scrollingLock=true;self.newvalue=parseFloat(value).toFixed(2);newvalue=parseFloat(value).toFixed(2);maxheightnewvalue=self.largeHeight/((self.options.zoomWindowHeight/self.nzHeight)*self.nzHeight);maxwidthtnewvalue=self.largeWidth/((self.options.zoomWindowWidth/self.nzWidth)*self.nzWidth);if(self.options.zoomType!="inner")
{if(maxheightnewvalue<=newvalue){self.heightRatio=(self.largeHeight/maxheightnewvalue)/self.nzHeight;self.newvalueheight=maxheightnewvalue;self.fullheight=true;}
else{self.heightRatio=(self.largeHeight/newvalue)/self.nzHeight;self.newvalueheight=newvalue;self.fullheight=false;}
if(maxwidthtnewvalue<=newvalue){self.widthRatio=(self.largeWidth/maxwidthtnewvalue)/self.nzWidth;self.newvaluewidth=maxwidthtnewvalue;self.fullwidth=true;}
else{self.widthRatio=(self.largeWidth/newvalue)/self.nzWidth;self.newvaluewidth=newvalue;self.fullwidth=false;}
if(self.options.zoomType=="lens"){if(maxheightnewvalue<=newvalue){self.fullwidth=true;self.newvaluewidth=maxheightnewvalue;}else{self.widthRatio=(self.largeWidth/newvalue)/self.nzWidth;self.newvaluewidth=newvalue;self.fullwidth=false;}}}
if(self.options.zoomType=="inner")
{maxheightnewvalue=parseFloat(self.largeHeight/self.nzHeight).toFixed(2);maxwidthtnewvalue=parseFloat(self.largeWidth/self.nzWidth).toFixed(2);if(newvalue>maxheightnewvalue){newvalue=maxheightnewvalue;}
if(newvalue>maxwidthtnewvalue){newvalue=maxwidthtnewvalue;}
if(maxheightnewvalue<=newvalue){self.heightRatio=(self.largeHeight/newvalue)/self.nzHeight;if(newvalue>maxheightnewvalue){self.newvalueheight=maxheightnewvalue;}else{self.newvalueheight=newvalue;}
self.fullheight=true;}
else{self.heightRatio=(self.largeHeight/newvalue)/self.nzHeight;if(newvalue>maxheightnewvalue){self.newvalueheight=maxheightnewvalue;}else{self.newvalueheight=newvalue;}
self.fullheight=false;}
if(maxwidthtnewvalue<=newvalue){self.widthRatio=(self.largeWidth/newvalue)/self.nzWidth;if(newvalue>maxwidthtnewvalue){self.newvaluewidth=maxwidthtnewvalue;}else{self.newvaluewidth=newvalue;}
self.fullwidth=true;}
else{self.widthRatio=(self.largeWidth/newvalue)/self.nzWidth;self.newvaluewidth=newvalue;self.fullwidth=false;}}
scrcontinue=false;if(self.options.zoomType=="inner"){if(self.nzWidth>=self.nzHeight){if(self.newvaluewidth<=maxwidthtnewvalue){scrcontinue=true;}
else{scrcontinue=false;self.fullheight=true;self.fullwidth=true;}}
if(self.nzHeight>self.nzWidth){if(self.newvaluewidth<=maxwidthtnewvalue){scrcontinue=true;}
else{scrcontinue=false;self.fullheight=true;self.fullwidth=true;}}}
if(self.options.zoomType!="inner"){scrcontinue=true;}
if(scrcontinue){self.zoomLock=0;self.changeZoom=true;if(((self.options.zoomWindowHeight)/self.heightRatio)<=self.nzHeight){self.currentZoomLevel=self.newvalueheight;if(self.options.zoomType!="lens"&&self.options.zoomType!="inner"){self.changeBgSize=true;self.zoomLens.css({height:String((self.options.zoomWindowHeight)/self.heightRatio)+'px'})}
if(self.options.zoomType=="lens"||self.options.zoomType=="inner"){self.changeBgSize=true;}}
if((self.options.zoomWindowWidth/self.widthRatio)<=self.nzWidth){if(self.options.zoomType!="inner"){if(self.newvaluewidth>self.newvalueheight){self.currentZoomLevel=self.newvaluewidth;}}
if(self.options.zoomType!="lens"&&self.options.zoomType!="inner"){self.changeBgSize=true;self.zoomLens.css({width:String((self.options.zoomWindowWidth)/self.widthRatio)+'px'})}
if(self.options.zoomType=="lens"||self.options.zoomType=="inner"){self.changeBgSize=true;}}
if(self.options.zoomType=="inner"){self.changeBgSize=true;if(self.nzWidth>self.nzHeight){self.currentZoomLevel=self.newvaluewidth;}
if(self.nzHeight>self.nzWidth){self.currentZoomLevel=self.newvaluewidth;}}}
self.setPosition(self.currentLoc);},closeAll:function(){if(self.zoomWindow){self.zoomWindow.hide();}
if(self.zoomLens){self.zoomLens.hide();}
if(self.zoomTint){self.zoomTint.hide();}},changeState:function(value){var self=this;if(value=='enable'){self.options.zoomEnabled=true;}
if(value=='disable'){self.options.zoomEnabled=false;}}};$.fn.elevateZoom=function(options){return this.each(function(){var elevate=Object.create(ElevateZoom);elevate.init(options,this);$.data(this,'elevateZoom',elevate);});};$.fn.elevateZoom.options={zoomActivation:"hover",zoomEnabled:true,preloading:1,zoomLevel:1,scrollZoom:false,scrollZoomIncrement:0.1,minZoomLevel:false,maxZoomLevel:false,easing:false,easingAmount:12,lensSize:200,zoomWindowWidth:400,zoomWindowHeight:400,zoomWindowOffetx:0,zoomWindowOffety:0,zoomWindowPosition:1,zoomWindowBgColour:"#fff",lensFadeIn:false,lensFadeOut:false,debug:false,zoomWindowFadeIn:false,zoomWindowFadeOut:false,zoomWindowAlwaysShow:false,zoomTintFadeIn:false,zoomTintFadeOut:false,borderSize:4,showLens:true,borderColour:"#888",lensBorderSize:1,lensBorderColour:"#000",lensShape:"square",zoomType:"window",containLensZoom:false,lensColour:"white",lensOpacity:0.4,lenszoom:false,tint:false,tintColour:"#333",tintOpacity:0.4,gallery:false,galleryActiveClass:"zoomGalleryActive",imageCrossfade:false,constrainType:false,constrainSize:false,loadingIcon:false,cursor:"default",responsive:true,onComplete:$.noop,onZoomedImageLoaded:function(){},onImageSwap:$.noop,onImageSwapComplete:$.noop};})(jQuery,window,document);(function(factory){if(typeof define==='function'&&define.amd){define(['jquery'],factory);}else if(typeof exports==='object'){module.exports=factory;}else{factory(jQuery);}}(function($){var toFix=['wheel','mousewheel','DOMMouseScroll','MozMousePixelScroll'],toBind=('onwheel'in document||document.documentMode>=9)?['wheel']:['mousewheel','DomMouseScroll','MozMousePixelScroll'],slice=Array.prototype.slice,nullLowestDeltaTimeout,lowestDelta;if($.event.fixHooks){for(var i=toFix.length;i;){$.event.fixHooks[toFix[--i]]=$.event.mouseHooks;}}
var special=$.event.special.mousewheel={version:'3.1.12',setup:function(){if(this.addEventListener){for(var i=toBind.length;i;){this.addEventListener(toBind[--i],handler,false);}}else{this.onmousewheel=handler;}
$.data(this,'mousewheel-line-height',special.getLineHeight(this));$.data(this,'mousewheel-page-height',special.getPageHeight(this));},teardown:function(){if(this.removeEventListener){for(var i=toBind.length;i;){this.removeEventListener(toBind[--i],handler,false);}}else{this.onmousewheel=null;}
$.removeData(this,'mousewheel-line-height');$.removeData(this,'mousewheel-page-height');},getLineHeight:function(elem){var $elem=$(elem),$parent=$elem['offsetParent'in $.fn?'offsetParent':'parent']();if(!$parent.length){$parent=$('body');}
return parseInt($parent.css('fontSize'),10)||parseInt($elem.css('fontSize'),10)||16;},getPageHeight:function(elem){return $(elem).height();},settings:{adjustOldDeltas:true,normalizeOffset:true}};$.fn.extend({mousewheel:function(fn){return fn?this.bind('mousewheel',fn):this.trigger('mousewheel');},unmousewheel:function(fn){return this.unbind('mousewheel',fn);}});function handler(event){var orgEvent=event||window.event,args=slice.call(arguments,1),delta=0,deltaX=0,deltaY=0,absDelta=0,offsetX=0,offsetY=0;event=$.event.fix(orgEvent);event.type='mousewheel';if('detail'in orgEvent){deltaY=orgEvent.detail*-1;}
if('wheelDelta'in orgEvent){deltaY=orgEvent.wheelDelta;}
if('wheelDeltaY'in orgEvent){deltaY=orgEvent.wheelDeltaY;}
if('wheelDeltaX'in orgEvent){deltaX=orgEvent.wheelDeltaX*-1;}
if('axis'in orgEvent&&orgEvent.axis===orgEvent.HORIZONTAL_AXIS){deltaX=deltaY*-1;deltaY=0;}
delta=deltaY===0?deltaX:deltaY;if('deltaY'in orgEvent){deltaY=orgEvent.deltaY*-1;delta=deltaY;}
if('deltaX'in orgEvent){deltaX=orgEvent.deltaX;if(deltaY===0){delta=deltaX*-1;}}
if(deltaY===0&&deltaX===0){return;}
if(orgEvent.deltaMode===1){var lineHeight=$.data(this,'mousewheel-line-height');delta*=lineHeight;deltaY*=lineHeight;deltaX*=lineHeight;}else if(orgEvent.deltaMode===2){var pageHeight=$.data(this,'mousewheel-page-height');delta*=pageHeight;deltaY*=pageHeight;deltaX*=pageHeight;}
absDelta=Math.max(Math.abs(deltaY),Math.abs(deltaX));if(!lowestDelta||absDelta<lowestDelta){lowestDelta=absDelta;if(shouldAdjustOldDeltas(orgEvent,absDelta)){lowestDelta/=40;}}
if(shouldAdjustOldDeltas(orgEvent,absDelta)){delta/=40;deltaX/=40;deltaY/=40;}
delta=Math[delta>=1?'floor':'ceil'](delta/lowestDelta);deltaX=Math[deltaX>=1?'floor':'ceil'](deltaX/lowestDelta);deltaY=Math[deltaY>=1?'floor':'ceil'](deltaY/lowestDelta);if(special.settings.normalizeOffset&&this.getBoundingClientRect){var boundingRect=this.getBoundingClientRect();offsetX=event.clientX-boundingRect.left;offsetY=event.clientY-boundingRect.top;}
event.deltaX=deltaX;event.deltaY=deltaY;event.deltaFactor=lowestDelta;event.offsetX=offsetX;event.offsetY=offsetY;event.deltaMode=0;args.unshift(event,delta,deltaX,deltaY);if(nullLowestDeltaTimeout){clearTimeout(nullLowestDeltaTimeout);}
nullLowestDeltaTimeout=setTimeout(nullLowestDelta,200);return($.event.dispatch||$.event.handle).apply(this,args);}
function nullLowestDelta(){lowestDelta=null;}
function shouldAdjustOldDeltas(orgEvent,absDelta){return special.settings.adjustOldDeltas&&orgEvent.type==='mousewheel'&&absDelta%120===0;}}));(function($){$.fn.imageZoomer=function(suppliedOptions){var options=$.extend(true,{zoomable:false,scrollZoom:true},suppliedOptions);var mouseClickLoadEvent;var maxZoom;var minZoom=40;var ImageZoomer=function(a){this.init(a);};ImageZoomer.prototype={zooming:false,init:function(a){var self=this;self.$a=$(a);self.$img=$(self.$a).find('img')[0];$(self.$img).click(function(e){var elevateZoom=$(self.$img).data('elevateZoom');if(!$(self.$img).data("zoomLoading")){if(elevateZoom===undefined&&options.zoomable===true){$(self.$img).data("zoomLoading",true);var zoomUrl=options.urlFactory(options);$(self.$img).data("zoom-image",zoomUrl);$(self.$img).elevateZoom({zoomType:"inner",containsLensZoom:true,onZoomedImageLoaded:onElevateZoomLoaded});mouseClickLoadEvent=e;}else if(elevateZoom!==undefined){$(self.$img).removeData('elevateZoom');$('.zoomContainer').remove();}
else{$('.zoomContainer').remove();}}});}};var onElevateZoomLoaded=function(a){$(this).remove();var elevateZoom=$(a).data('elevateZoom');if(elevateZoom===undefined){return;}
maxZoom=$(a).height()>$(a).width()?$(a).width():$(a).height();elevateZoom.options.lensSize=maxZoom/4;elevateZoom.setPosition(mouseClickLoadEvent);elevateZoom.showHideWindow("show");$(a).removeData("zoomLoading");elevateZoom.zoomContainer.on("mouseleave touchleave click",function(e){if(isZooming()){closeZoom();}});$(window).on('orientationchange',function(event){if(isZooming()){closeZoom();}});function isZooming(){return elevateZoom!==undefined&&elevateZoom.options.zoomEnabled===true;}
function closeZoom(){$(this).remove();elevateZoom.changeState('disable');$(a).removeData('elevateZoom');$('.zoomContainer').remove();}};return this.each(function(i,elem){var zoomer=new ImageZoomer(elem);});};})(jQuery);(function($){var instance=new Class();instance.init=function(args){try{options=$.extend(true,defaults,args);imageDescriptor=options.imageDescriptor;defaultSize=options.defaultSize;secured=options.secured;if(imageDescriptor!==undefined){serverUrl=imageDescriptor.serverUrl;path=imageDescriptor.path;serverSecureUrl=imageDescriptor.serverSecureUrl;}}catch(e){instance.logError(e);}};instance.createMediaUrl=function(imageName,size){var imageUrl=getServerUrl()+getPath()+getSize(size)+"/"+imageName;return imageUrl;};instance.createMedia360Url=function(pathName){var imageUrl=getServerUrl()+getPath()+"threeSixty/"+pathName;return imageUrl;};instance.addOverlay=function(selector,type,size){var overlay=$('<span class="overlay-'+size+' '+type+'"><img src="'+options.overlays[type][size]+'" /></span>');overlay.clone().appendTo(selector);};var imageDescriptor={};var defaultSize;var secured;var serverUrl;var serverSecureUrl;var path;var defaults={debug:false,defaultSize:"230x238",secured:false,overlays:{threeSixty:{small:"/GamesWorkshopStatic/static/img/gallery-overlays.png",large:"/GamesWorkshopStatic/static/img/threesixty-icons-singlerow.png",multirow:"/GamesWorkshopStatic/static/img/threesixty-icons.png"},zoomable:{small:"/GamesWorkshopStatic/static/img/gallery-overlays.png",large:""},threeSixtyMultiRow:{small:"/GamesWorkshopStatic/static/img/gallery-overlays.png",}}};function getPath(){try{var normalisedPath=path;if(!path.match(/^\//)||!path.match(/$\//)){if(!path.match(/^\//)){normalisedPath='/'+path;}
if(!path.match(/$\//)){normalisedPath=normalisedPath+'/';}}
return normalisedPath;}catch(e){instance.logError(e);}}
function getSize(size){if(!size){return defaultSize;}
for(var i=0;i<imageDescriptor.sizes.length;i++){if(imageDescriptor.sizes[i].directory==size){return size;}}
return defaultSize;}
function getServerUrl(){return secured?serverSecureUrl:serverUrl;}
gw.imaging=instance;}(jQuery));Magic360Options={"autospin-speed":900,"hint":"false","fullscreen":"false","right-click":"true","magnifier-shape":"inner","autospin-direction":"anticlockwise"};Magic360Lang={"loading-text":""};(function($){var instance=new Class();var options={};instance.init=function(args){try{options=$.extend(true,options,args);}catch(e){instance.logError(e);}};$.fn.threeSixty=function(args){var elem=$(this);var isTablet=args.isTablet||false;elem.click(function(e){e.preventDefault();if(elem.isThreeSixty()){e.stopImmediatePropagation();var dialogClass="threeSixty"+elem.data().dialogIndex;var width=(""===elem.data().threeSixtyWidth?"873":elem.data().threeSixtyWidth);var height=(""===elem.data().threeSixtyHeight?"627":elem.data().threeSixtyHeight);var isZoomable=!isTablet&&elem.data().threeSixtyZoomable;var columns=elem.data().threeSixtyFrames;var rows=elem.data().threeSixtyRows;var img,format;if(rows>1){img="/01-01.jpg";format="{row}-{col}";}else{img="/01.jpg";format="{col}";}
var html=gw.templates["gw.threeSixty.dialog"]({"index":elem.data().dialogIndex,"img":elem.data().threeSixtyFramesPath+img,"width":width+"px","height":height+"px","format":format,"columns":columns,"rows":rows,"zoomable":isZoomable,"filepath":elem.data().threeSixtyFramesPath,"large-filepath":elem.data().threeSixtyFramesPath+"/large/"});dialog=gw.core.global.dialog.createDialog(html,{onOpenCallback:function(){Magic360.start();},persisted:true,dialogClass:dialogClass,hasCloseButton:true});if(rows>1){$('.dialog-main').removeClass('singleRow');$('.dialog-main').addClass('multiRow');}else{$('.dialog-main').removeClass('multiRow');$('.dialog-main').addClass('singleRow');}
$('.dialog-main').addClass('lightbox360');dialog.center();dialog.open();}});};$.fn.isThreeSixty=function(){return $(this).data().threeSixtyFramesPath!==undefined;};$.fn.isMultiRow=function(){return $(this).data().threeSixtyRows>1;};gw.threeSixty=instance;}(jQuery));gw.classes.product=AJAXClass.extend({defaults:function(){return{productTypeMap:'{}',sourceMap:'{}',readMoreContentSize:undefined};},init:function(args){var instance=this;instance.options=$.extend({},instance.defaults(),args);instance.options.productTypeMap=JSON.parse(instance.options.productTypeMap);instance.options.sourceMap=JSON.parse(instance.options.sourceMap);instance.initReadMore();},initReadMore:function(){var instance=this;$('.description .content').truncate({max_length:instance.options.readMoreContentSize,more_node:$('.description .more'),less_node:$('.description .less')});}});gw.classes.product=gw.classes.product.extend({defaults:function(){return $.extend({},this._super(),{readMoreContentSize:750});},init:function(args){var instance=this;instance._super(args);instance.initBackButton();instance.initialiseTabs();},initialiseTabs:function(){$.tools.tabs.addEffect("prodTabs",function(tabIndex,done){this.getTabs().parent().removeClass("current");this.getTabs().eq(tabIndex).parent().addClass("current");this.getPanes().hide().eq(tabIndex).show();done.call();});$("#product-detail-tabs > ul").tabs("#product-detail-tabs > .panes > div",{effect:'prodTabs'});},initBackButton:function(){var instance=this;if(!instance.isSiteBrowseHistoryAvailable()){$('#btn-back').hide();}else{$('#btn-back').click(function(e){e.preventDefault();if(history.length<=1){window.location.href=document.referrer;}else{history.back();}});}},isSiteBrowseHistoryAvailable:function(){return document.referrer.indexOf(window.location.hostname)!=-1;}});gw.classes.singleProduct=gw.classes.product.extend({defaults:function(){return $.extend({},this._super(),{paintSwatchJsonPath:"/GamesWorkshopStatic/static/js/tests/mocks/paint-swatches-multibundle.json",media:[],templates:undefined,i18n:{addToCartText:"Add to cart",backInStockText:"Email me",noLongerAvailableText:"No longer available",preOrderText:"Pre-Order",paintSelectorTitle:"Recommended Paints",paintSelectorLabel:"Paints for:",selectAllLabel:"Select all"},readMoreContentSize:undefined});},init:function(args){var instance=this;instance._super(args);instance.paintSelector=new gw.classes.paintSelector(instance.options);instance.initGallery();bindQuantityChangeToSetValueForGiftlistAndDangerousProducts();function bindQuantityChangeToSetValueForGiftlistAndDangerousProducts(){$("#product-quantity").change(function(o){$("#confirm-add-product").attr('href',function(i,a){return a.replace(/(quantity=)[0-9]+/,'$1'+o.target.value);});$("#gift-item-quantity").val(o.target.value);});$("#btn-giftlist").click(function(o){this.href=this.href+'&quantity='+$("#gift-item-quantity").val();});}},incrementThumb:function(){var instance=this;var maxPages=instance.getMaxPages();var currentPage=$('.currentThumbPage').data('page');currentPage++;if(currentPage>maxPages){currentPage=1;}
instance.changeThumbnailPage(currentPage);},decrementThumb:function(){var instance=this;var maxPages=instance.getMaxPages();var currentPage=$('.currentThumbPage').data('page');currentPage--;if(currentPage<1){currentPage=maxPages;}
instance.changeThumbnailPage(currentPage);},getMaxPages:function(){var instance=this;var maxPages=Math.ceil(instance.options.media.length/instance.options.gallerySize);return maxPages;},changeThumbnailPage:function(currentPage){var instance=this;var completeCalled=false;var fadeInFunction=function(){if(!completeCalled){completeCalled=true;$('.gallery-inner li').hide();$('.visibleThumb').removeClass('visibleThumb');$('.currentThumbPage').removeClass('currentThumbPage');$('.pagination li:eq('+(currentPage-1)+') a').addClass('currentThumbPage');var startingIndex=(currentPage-1)*instance.options.gallerySize;for(var x=startingIndex;x<startingIndex+instance.options.gallerySize;x++){$('.gallery-inner ul li:eq('+x+')').addClass('visibleThumb');}
$('.visibleThumb').show();$('.visibleThumb').animate({opacity:1},500);}};if($('.visibleThumb').length>0){if(currentPage!==$('.currentThumbPage').data('page')){$('.visibleThumb').animate({opacity:0},300,fadeInFunction);}}else{fadeInFunction();}},initThumbnails:function(){var instance=this;var options=instance.options;var media=instance.filterMedia(options.media);var $box=$('.gallery-inner ul').empty();options.media=media;for(var i=0;i<media.length;i++){var thumb=$('<li><a><img/></a></li>');var path=media[i].imgPath;$('a',thumb).attr("href",gw.imaging.createMediaUrl(path,'600x620'));$('img',thumb).attr("src",gw.imaging.createMediaUrl(path,'70x70'));$('a',thumb).data("isZoomable",media[i].isZoomable);var data={};var overlay='';if(media[i].is360){data={"threeSixtyFramesPath":gw.imaging.createMedia360Url(media[i].framesPath),"threeSixtyFrames":media[i].frames,"threeSixtyRows":media[i].rows,"threeSixtyWidth":media[i].width,"threeSixtyHeight":media[i].height,"threeSixtyZoomable":media[i].isZoomable,"dialogIndex":i};if(media[i].rows!==undefined&&media[i].rows>1){gw.imaging.addOverlay(($('a',thumb)),'threeSixtyMultiRow',"small");}
else{gw.imaging.addOverlay(($('a',thumb)),'threeSixty',"small");}}else{data={"giantUrl":gw.imaging.createMediaUrl(path,'920x950'),"isZoomable":instance.mediaIsZoomable(media[i])};if(data.isZoomable==="true"){gw.imaging.addOverlay(($('a',thumb)),"zoomable","small");}}
data.index=i;$('a',thumb).data(data);$(thumb).appendTo($box);}
var controls=$('.pagination').empty();if(media.length>options.gallerySize){for(var x=1;x<=instance.getMaxPages();x++){var extraClasses=x===1?' currentThumbPage':'';var radio=instance.options.templates["products.mediaGalleryThumb"]({"extraClasses":extraClasses,"pageId":x});$(radio).appendTo(controls);}
$('.gallery-controls').show();$('.btn-back').click(function(event){event.preventDefault();instance.decrementThumb();});$('.btn-forward').click(function(event){event.preventDefault();instance.incrementThumb();});$('.mediaThumb').click(function(event){event.preventDefault();instance.changeThumbnailPage($(this).data('page'));});}else{$('.gallery-controls').hide();}
$('.gallery-inner a').click(function(event){event.preventDefault();options.imageHolder.find('img').attr('src',$(this).attr('href'));options.imageHolder.removeData().data($(this).data());$('.gallery-inner ul li').removeClass('selectedThumbnail');$(this).parent().addClass('selectedThumbnail');$('.overlay-large.threeSixty, .overlay-multirow.threeSixty').remove();if(instance.isThreeSixty()){if(options.imageHolder.isMultiRow()){gw.imaging.addOverlay((options.imageHolder),"threeSixty","multirow");}
else{gw.imaging.addOverlay((options.imageHolder),"threeSixty","large");}}
instance.setUpImageZoom();});$('.gallery-inner a:first').click();},initGallery:function(){}});gw.classes.singleProduct=gw.classes.singleProduct.extend({defaults:function(){return $.extend({},this._super(),{imageHolder:$('.img-holder'),gallerySize:12,tablet:false,displayName:undefined,});},init:function(args){var instance=this;instance._super(args);gw.core.global.dialog.confirmDialogModalListener("#confirm-add-product",rr.currentLocale+"/catalog/fragments/confirmAddProduct.jsp");},initGallery:function(){var instance=this;$(instance.options.imageHolder).click(function(e){e.preventDefault();});instance.options.imageHolder.threeSixty({isTablet:instance.options.tablet});instance.initThumbnails();instance.changeThumbnailPage(1);},initThumbnails:function(){var instance=this;var options=instance.options;instance._super();$('.overlay-large.threeSixty, .overlay-multirow.threeSixty').remove();$('.gallery-inner a').click(function(event){var action="thumbnail";if(options.imageHolder.isThreeSixty()){options.imageHolder.click();action="360";}
gw.classes.gtm.bindProductImageClickEvents(action,options.displayName,options.media[$(this).parent().index()].displayName);});instance.setUpImageZoom();},setUpImageZoom:function(){var instance=this;var options=instance.options;options.imageHolder.find('img').unbind();var config;if(options.imageHolder.data('isZoomable')==="true"&&!options.imageHolder.isThreeSixty()){config={urlFactory:function(){return options.imageHolder.data('giantUrl');},zoomable:true};options.imageHolder.addClass("zoomable");}else{config={zoomable:false};options.imageHolder.removeClass("zoomable");}
options.imageHolder.imageZoomer(config);},filterMedia:function(media){return media;},mediaIsZoomable:function(media){return media.isZoomable;},isThreeSixty:function(){var instance=this;return instance.options.imageHolder.isThreeSixty();}});gw.classes.paintSelector=AJAXClass.extend({defaults:function(){return{productTypeMap:'{}',sourceMap:'{}',webexclusive:false,i18n:{addToCartText:"Add to cart",backInStockText:"Email me",noLongerAvailableText:"No longer available",preOrderText:"Pre-Order",giftListText:"Gift List",selectColourLabel:"Select colour",qtyLabel:"Qty:"}};},init:function(args){var instance=this;var currentBundleIndex,currentSwatchIndex;instance.options=$.extend({},instance.defaults(),args);instance.registerHelpers();instance.ajax({url:instance.options.paintSwatchJsonPath,success:function(data){instance.handleResults(data);},error:instance.logAJAXError,dataType:"JSON"});},handleResults:function(data){var instance=this;instance.options.bundles=data[0].bundles;if(instance.options.bundles.length){var metadata={isMultipleBundles:instance.options.bundles.length>1};var container=instance.options.templates["products.paintSelector/container"]({"bundles":instance.options.bundles,"i18n":instance.options.i18n,"metadata":metadata});instance.insertContainer(container);selectBundle(0);bindSelectAllCheckbox();bindBundleSelector();}
instance.removeEmptyWrapper();function bindSelectAllCheckbox(){var selectAllCheckbox=$('#select-all-checkbox input');selectAllCheckbox.change(function(event){if($(event.target).attr('checked')=='checked'){selectAllSwatches();}else{selectSwatch(0);}});}
function bindBundleSelector(){var selectBox=$('#select-bundle select');selectBox.change(function(event){selectBundle(event.target.selectedIndex);$('#select-all-checkbox input').prop('checked',false);});}
function bindSwatchSelector(){$('#paints .swatch').each(function(swatchIndex,swatchElement){$(swatchElement).click(function(){selectSwatch(swatchIndex);});$(swatchElement).hover(function(){var swatchData=instance.options.bundles[currentBundleIndex].paints[swatchIndex];$('#paints .actions h4').text(swatchData.productTitle);$('#paints .actions p').text(swatchData.title);},function(){if(currentSwatchIndex>=0){selectSwatch(currentSwatchIndex);}else{selectAllSwatches();}});});}
function selectBundle(bundleIndex){currentBundleIndex=bundleIndex;var bundle=instance.options.bundles[bundleIndex];var swatches=instance.options.templates["products.paintSelector/swatches"]({"paints":bundle.paints});$('#paints .swatches').html(swatches);bindSwatchSelector();$('#select-all-checkbox').toggle(isBundleAvailable(bundle));selectSwatch(0);}
function isBundleAvailable(bundle){var available=true;$.each(bundle.paints,function(i,element){if(element.availabilityStatus!=="inStock"){available=false;return false;}});return available;}
function selectSwatch(swatchIndex){currentSwatchIndex=swatchIndex;$('#paints .swatches li input').prop('checked',false);$('#paints .swatches li input#swatch'+swatchIndex).prop('checked',true);$('#select-all-checkbox input').prop('checked',false);var swatch=instance.options.bundles[currentBundleIndex].paints[swatchIndex];var metadata={productType:instance.options.productTypeMap[swatch.productType],source:instance.options.sourceMap.relatedProduct,isAvailable:swatch.availabilityStatus!=="noLongerAvailable"};var actions=instance.options.templates["products.paintSelector/actions"]({"paint":swatch,"i18n":instance.options.i18n,"metadata":metadata});$('#paints .actions').html(actions);gw.core.global.formatPrices();}
function selectAllSwatches(){currentSwatchIndex=-1;$('#paints .swatches li input').prop('checked',true);var bundle=instance.options.bundles[currentBundleIndex];var metadata={productType:instance.options.productTypeMap[bundle.productType],source:instance.options.sourceMap.relatedProduct,};var actions=instance.options.templates["products.paintSelector/bundleActions"]({"bundle":bundle,"i18n":instance.options.i18n,"metadata":metadata});$('#paints .actions').html(actions);gw.core.global.formatPrices();}},insertContainer:function(container){},removeEmptyWrapper:function(){},registerHelpers:function(){var instance=this;Handlebars.registerHelper('cart-button',function(product){var metadata={source:instance.options.sourceMap.relatedProduct,type:instance.options.productTypeMap[product.productType],webExclusive:instance.options.webexclusive||false};if(product.availabilityStatus==='outOfStock'){metadata.classes="emailWhenBackInStock btn-style-b test-email-me-back-in-stock";metadata.buttonText=instance.options.i18n.backInStockText;}else{metadata.classes="addtocart test-add-paint-";if(isBundle(product)){metadata.classes+="bundle";product.id=product.skuId;}else{metadata.classes+=product.id;}
if(product.availabilityStatus==='advance'){metadata.buttonText=instance.options.i18n.preOrderText;}else{metadata.buttonText=instance.options.i18n.addToCartText;}}
return instance.options.templates["products.paintSelector/addToCart"]({"product":product,"metadata":metadata});function isBundle(product){return product.paints;}});Handlebars.registerHelper('image',function(swatch){var url="";if(swatch!==null&&swatch!==undefined){url=swatch.replace(/^(https?):\/\//,'//');}
return url;});}});gw.classes.paintSelector=gw.classes.paintSelector.extend({insertContainer:function(container){var position=$('#accessories').data().paintSelectorPosition||"before";if(position==="before"){$('#accessories').prepend(container);}else{$('#accessories').append(container);}},removeEmptyWrapper:function(){if($('#accessories').children().length===0){$('#accessories').remove();}}});