var IE6=navigator.userAgent.indexOf("MSIE 6")>=0?true:false,is_chrome=navigator.userAgent.toLowerCase().indexOf("chrome")>-1,tmbary=[],divarry=[],_tw,$$,index,_prew,_wrapper,_thumbs,_caption,_collection,_outer,_play,_pause,_cap,_infoary=[];(function(d){$$=d.fn.galleria=function(a){function c(f,h){f=g.find(f);f.attr("linked",g.children("li").size());var l=f.clone();l.attr("linked",h);g.append(l);if(f.hasClass("start")){f.removeClass("start");l.addClass("start")}}function b(){k=false;if(m){m=false;d.galleria.activate($$.getMid(_thumbs));if(!IE6){_outer.removeClass("tdragcur");_outer.addClass("thovercur")}}}for(var e in a)d.galleria[e]=a[e];d(a.insert);_wrapper=d("#main_image");var g=d(this).children("ul");_prew=g.children("li").size()*78;c("li:first-child",0);c("li:nth-child(2)",1);c("li:nth-child(3)",2);c("li:nth-child(4)",3);c("li:nth-child(5)",4);c("li:nth-child(6)",5);c("li:nth-child(7)",6);c("li:nth-child(8)",7);c("li:nth-child(9)",8);c("li:nth-child(10)",9);c("li:nth-child(11)",10);c("li:nth-child(12)",11);c("li:nth-child(13)",12);var q=g.children("li").size(),j,k=false,m=false;_tw=g.children("li").size()*78;g.width(_tw);_outer.mousedown(function(f){j=f.clientX;k=true;f.preventDefault&&f.preventDefault();return true});_outer.mousemove(function(f){if(k)if(m){nextpos=_thumbs.scrollLeft()+(j-f.clientX);if(nextpos<0)nextpos+=_prew;else if(nextpos>=_tw-703)nextpos-=_prew;_thumbs.scrollLeft(nextpos);j=f.clientX}else{f=j-f.clientX;if(f>5||f<-5){m=true;if(!IE6){_outer.removeClass("thovercur");_outer.addClass("tdragcur")}}}});IE6||_outer.addClass("thovercur");_outer.mouseup(function(){b()});_outer.bind("mouseleave",function(){b()});e=d(".buy");var v=d(".details");e.bind("mouseleave",function(){v.fadeOut(100)});e.bind("mouseenter",function(){v.css({display:"none",opacity:0.6}).fadeIn(100)});return g.each(function(){d(this).addClass("galleria");var f=0;d(this).children("li").each(function(){var h=d(this),l=h.hasClass("start");d.meta&&d.extend({},a,h.data());_infoary[f]=h.children("div");if(_infoary[f]){_infoary[f].remove();_infoary[f].css({display:"block"})}var i=d(new Image),n=d(new Image);i.addClass("thumb");n.addClass("image");var r="gallery/"+h.attr("gsrc")+".jpg",y="gallery/t"+h.attr("gsrc")+".jpg";i.attr("alt",h.attr("alt"));i.attr("collection",h.attr("collection"));i.attr("title",h.attr("title"));i.attr("linked",h.attr("linked"));n.attr("alt",h.attr("alt"));var o=f;i.load(function(){n.load(function(){tmbary[o]=i;var s=d(document.createElement("div")).addClass("outer_image");divarry[o]=s.append(n);s=(_wrapper.height()-this.height)/2+"px";var z=(_wrapper.width()-this.width)/2+"px";divarry[o].css({top:s,left:z});var p=o,w,x=false;if(p>q-5){p=parseInt(i.attr("linked"));w=true}if(p<4){p=parseInt(i.attr("linked"));x=true}i.mouseup(function(){if(!m){if(w){var u=_thumbs.scrollLeft()-_prew;_thumbs.scrollLeft(u)}if(x){u=_thumbs.scrollLeft()+_prew;_thumbs.scrollLeft(u)}$$.onPageLoad(p,200,false)}});h.prepend(i);i.css({display:"none",opacity:0.5}).fadeIn(1500);if(l){hideLoading();$$.onPageLoad(o,150,true)}}).error(function(){h.html('<span class="error" style="color:red">Error loading image: '+r+"</span>")});n.attr("src",r)}).error(function(){h.html('<span class="error" style="color:red">Error loading image: '+r+"</span>")});i.attr("src",y);f++})})};$$.getMid=function(a){return Math.round((a.scrollLeft()+320)/78)};$$.getMiddleThumb=function(a){return tmbary[$$.getMid(a)]};$$.onPageLoad=function(a,c,b){var e=tmbary[a];if(a!=index||b){if(!b)if(tmbary[index]){var g=index;tmbary[index].fadeTo(100,0.5);divarry[index].fadeOut(500,function(){divarry[g].remove()});if(b=tmbary[index].attr("linked")){b=parseInt(b);tmbary[b]&&tmbary[b].fadeTo(100,0.5)}_infoary[g]&&_infoary[g].remove()}index=a;if(e){b=divarry[a];b.css({display:"none"});_infoary[a]&&_galinfo.append(_infoary[a]);_wrapper.append(b);b.fadeIn(500);(a=e.attr("title"))&&_caption.html(a);(a=e.attr("collection"))&&_collection.html(a);e.fadeTo(100,1);if(b=e.attr("linked")){b=parseInt(b);tmbary[b]&&tmbary[b].fadeTo(100,1)}}else _wrapper.siblings().andSelf().empty()}if(e){e=e.position().left-326;e=_thumbs.scrollLeft()+e;_thumbs.stop();_thumbs.animate({scrollLeft:e},c)}};d.extend({galleria:{activate:function(a){$$.onPageLoad(a,150,false)},next:function(){tmbary[index+1].mouseup()},prev:function(){tmbary[index-1].mouseup()},play:function(){_play.css("display","none");_pause.css("display","inline");var a=function(){var c=index+1;tmbary[c]?tmbary[c].mouseup():tmbary[0].mouseup()};a(0);_thumbs.everyTime(4E3,"slideshow",a)},pause:function(){_pause.css("display","none");_play.css("display","inline");_thumbs.stopTime("slideshow")}}})})(jQuery);$(document).ready(function(){_outer=$("#thumbs");_thumbs=$("#inner");_caption=$("#caption");_cap=$("#cap");_collection=$("#collection");_play=$("#gcplay");_pause=$("#gcpause");_middle=$("#middle");_galinfo=$("#galinfo")});$(window).load(function(){_thumbs.galleria({insert:"#main_image"});t=document.body;if(typeof t.onselectstart!="undefined")t.onselectstart=function(){return false};else if(typeof t.style.MozUserSelect!="undefined")t.style.MozUserSelect="none";else t.onmousedown=function(){return false};t.style.cursor="default";document.ondragstart=function(){return false};_middle.mouseenter(function(){_outer.stop();_outer.animate({bottom:5},500);_galinfo.stop();_galinfo.animate({right:0},500);_cap.stop();_cap.animate({left:0},500)});_middle.mouseleave(function(){_outer.stop();_outer.animate({bottom:-60},500);_galinfo.stop();_galinfo.animate({right:-130},500);_cap.stop();_cap.animate({left:-250},500)})});jQuery.fn.extend({everyTime:function(d,a,c,b,e){return this.each(function(){jQuery.timer.add(this,d,a,c,b,e)})},oneTime:function(d,a,c){return this.each(function(){jQuery.timer.add(this,d,a,c,1)})},stopTime:function(d,a){return this.each(function(){jQuery.timer.remove(this,d,a)})}});jQuery.extend({timer:{global:[],guid:1,dataKey:"jQuery.timer",regex:/^([0-9]+(?:\.[0-9]*)?)\s*(.*s)?$/,powers:{ms:1,cs:10,ds:100,s:1E3,das:1E4,hs:1E5,ks:1E6},timeParse:function(d){if(d==undefined||d==null)return null;var a=this.regex.exec(jQuery.trim(d.toString()));return a[2]?parseFloat(a[1])*(this.powers[a[2]]||1):d},add:function(d,a,c,b,e,g){var q=0;if(jQuery.isFunction(c)){e||(e=b);b=c;c=a}a=jQuery.timer.timeParse(a);if(!(typeof a!="number"||isNaN(a)||a<=0)){if(e&&e.constructor!=Number){g=!!e;e=0}e=e||0;g=g||false;var j=jQuery.data(d,this.dataKey)||jQuery.data(d,this.dataKey,{});j[c]||(j[c]={});b.timerID=b.timerID||this.guid++;var k=function(){if(!(g&&this.inProgress)){this.inProgress=true;if(++q>e&&e!==0||b.call(d,q)===false)jQuery.timer.remove(d,c,b);this.inProgress=false}};k.timerID=b.timerID;j[c][b.timerID]||(j[c][b.timerID]=window.setInterval(k,a));this.global.push(d)}},remove:function(d,a,c){var b=jQuery.data(d,this.dataKey),e;if(b){if(a){if(b[a]){if(c){if(c.timerID){window.clearInterval(b[a][c.timerID]);delete b[a][c.timerID]}}else for(c in b[a]){window.clearInterval(b[a][c]);delete b[a][c]}for(e in b[a])break;if(!e){e=null;delete b[a]}}}else for(a in b)this.remove(d,a,c);for(e in b)break;e||jQuery.removeData(d,this.dataKey)}}}});jQuery(window).bind("unload",function(){jQuery.each(jQuery.timer.global,function(d,a){jQuery.timer.remove(a)})});