Projector=function(b,a){proj=this;proj.thumbsElm=b;proj.viewElm=a;this.init=function(){proj.skipClickAction=false;proj.mouseIsDown=false;proj.isScrolling=false;proj.scrollInterval=Object;proj.leftOffset=0;proj.totalThumbsWidth=0;proj.thumbMarginRight=20;proj.scrollAmount=100;proj.itemsTotalWidth=0;proj.itemsViewWidth=0;proj.thumbnailIndex=0;proj.products=[];proj.backingElms={};proj.contentElms={};proj.closeWindowElms={};proj.windowHeights={};proj.windowHeights.thumbContainer=110;proj.windowHeights.collectionsWindow=150;proj.windowHeights.collectablesWindow=150;proj.windowHeights.publicationsWindow=150;proj.windowHeights.imageInfoWindow=164;proj.windowHeights.priceWindow=164;proj.backingOpacity=0.95;proj.collectionNavNormalOpacity=0.45;proj.collectionNavHighlightOpacity=0.75;proj.collectionNavActiveOpacity=0.9;proj.enlargeNavHighlightOpacity=1;proj.enlargeNavNormalOpacity=0.78;proj.isIE6=($.browser.msie==true&&$.browser.version==6);proj.backingNormalOpacity=0.87;proj.productMarginRight=20;proj.hasLightbox=(typeof $().lightBox=="function");proj.isFrameViewer=($("#mainImage").attr("class")=="frameviewer");$("body").addClass("dynamic");var c=Math.floor(Math.random()*10000);if(proj.isFrameViewer){proj.ajaxBaseURL="/partials/frame.php?r="+c+"&item="}else{proj.ajaxBaseURL="/partials/info.php?r="+c+"&item="}proj.build()};this.build=function(){proj.windowHeights.collectionsWindow=parseInt($("#collectionsWindowContent").height(),10)+20+"px";proj.windowHeights.collectablesWindow=parseInt($("#collectablesWindowContent").height(),10)+20+"px";proj.windowHeights.publicationsWindow=parseInt($("#publicationsWindowContent").height(),10)+20+"px";proj.canvasElm=$("#dynamiccontent");proj.thumbnailWindow=$("#thumbnailWindow");proj.thumbnailNav=$("#thumbnailNav");proj.collectionNav=$("#collectionNav");proj.itemsViewWidth=proj.thumbsElm.width();var f=$("#mainImage");proj.containerElm=$("#thumbContainer");var d=$(document.createElement("div")).attr("id","mainImageFrame");proj.imgFrame=$(document.createElement("a")).prependTo(d);proj.imgFrame.click(function(g){g.preventDefault()});proj.imgFrame.css("backgroundImage",f.css("backgroundImage"));f.css("backgroundImage","");f.addClass("dynamic");proj.enlargeElm=$("#enlargeImage");proj.containerElm.prepend($("#products"));proj.containerElm.prepend(proj.thumbnailNav);proj.containerElm.prepend(proj.thumbnailBackingElm);f.prepend(proj.enlargeElm);f.prepend(proj.collectionNav);f.prepend(d);proj.containerElm.prependTo(f);var e=$(".dynamicContentDivs");e.each(function(g,n){var n=$(n);var h=$(document.createElement("div")).addClass("backing");var m=$(document.createElement("div")).addClass("content");var k=$(document.createElement("div")).addClass("close");var j=n.children();k.text("X");h.css("opacity",0);m.css("opacity",0);k.css("opacity",0);h.height(n.height());k.prependTo(n);m.prependTo(n);h.prependTo(n);m.append(j);var l=n.attr("id");proj.backingElms[l]=h;proj.contentElms[l]=m;proj.closeWindowElms[l]=k});proj.descElm=proj.viewElm.find("#project-desc");proj.logoGalleryElm=proj.thumbsElm.find("ol");proj.mainImage=proj.viewElm.find("#project-display");proj.canvasElm.find("a").css("outline","none");proj.loadingElm=$(document.createElement("div")).attr("id","productLoading");proj.loadingElm.text("LOADING");proj.loadingElm.appendTo(proj.containerElm);this.buildTabs();proj.thumbsWrapperElm=$(document.createElement("div")).attr("class","wrapper");proj.products=proj.thumbsElm.find("ol");proj.productsElms=proj.products.find("li");proj.productCount=proj.productsElms.length-1;proj.thumbnailIndex=0;if($("#products img").length==0){return}proj.productsElms.each(function(k,l){var g=$(l).find("a");var j=($(this).find("strong").length>0);var h=$(document.createElement("div"));h.addClass("frame");if(j){proj.thumbnailIndex=k;h.addClass("selected");proj.originalSelection=l}else{}h.hover(function(){$(this).addClass("hover")},function(){$(this).removeClass("hover")});$(g).prependTo(h);h.prependTo(l);g.parent().click(proj.selectImage)});if(proj.productsElms.length>0){proj.loadImageInfo(proj.productsElms[proj.thumbnailIndex])}if(proj.hasLightbox){proj.imgFrame.lightBox()}proj.galleryNextElm=$("#nextThumb");proj.galleryPrevElm=$("#previousThumb");proj.collectionNextElm=$("#nextImage");proj.collectionPrevElm=$("#previousImage");var c=proj.collectionNav.find("li");proj.enlargeElmNav=proj.enlargeElm.find("a");proj.enlargeElmNav.css("opacity",proj.enlargeNavNormalOpacity);c.css("opacity",proj.collectionNavNormalOpacity);c.mouseover(function(){$(this).animate({opacity:proj.collectionNavHighlightOpacity},"fast")});c.mouseout(function(){$(this).animate({opacity:proj.collectionNavNormalOpacity},"fast")});c.mousedown(function(){$(this).css("opacity",proj.collectionNavActiveOpacity)});c.mouseup(function(){$(this).css("opacity",proj.collectionNavHighlightOpacity)});proj.enlargeElmNav.mouseover(function(){$(this).animate({opacity:proj.enlargeNavHighlightOpacity},"fast")});proj.enlargeElmNav.mouseout(function(){$(this).animate({opacity:proj.enlargeNavNormalOpacity},"fast")});proj.collectionNextElm.click(function(g){g.preventDefault();if(proj.hasNext()){proj.scrollRight();proj.setSelectedIndex(proj.thumbnailIndex+1)}});proj.collectionPrevElm.click(function(g){g.preventDefault();if(proj.hasPrevious()){proj.scrollLeft();proj.setSelectedIndex(proj.thumbnailIndex-1)}});proj.enlargeElmNav.click(function(g){g.preventDefault();$("#mainImageFrame a").click()});proj.galleryNextElm.click(function(g){g.preventDefault()});proj.galleryPrevElm.click(function(g){g.preventDefault()});proj.galleryNextElm.mousedown(function(g){proj.mouseIsDown=true;window.setTimeout(function(){if(proj.mouseIsDown){proj._beginRightScrolling(g)}},250)});proj.galleryNextElm.mouseup(function(g){proj.mouseIsDown=false;if(proj.isScrolling){proj._stopScrolling()}else{proj.scrollRight()}});proj.galleryPrevElm.mousedown(function(g){proj.mouseIsDown=true;window.setTimeout(function(){if(proj.mouseIsDown){proj._beginLeftScrolling(g)}},250)});proj.galleryPrevElm.mouseup(function(g){proj.mouseIsDown=false;if(proj.isScrolling){proj._stopScrolling()}else{proj.scrollLeft()}});proj.closeAllWindows();proj.logoGalleryElm.prependTo(proj.thumbsWrapperElm);proj.thumbsWrapperElm.prependTo(proj.thumbsElm);proj.updateControls()};this.buildTabs=function(){proj.tabElms=proj.canvasElm.find("div.right li");proj.tabElms.click(function(d){if($(this).attr("id")!="shoppingcart"){d.preventDefault()}});proj.canvasElm.find("#thumbnailsToggle").not(".disabled").click(function(){var d=$(this).parent();if(!d.hasClass("selected")){proj.showTabByID("thumbContainer",d);$("#products").fadeIn();$("#thumbnailNav").fadeIn();proj._scrollToItem(proj.originalSelection);proj._calcWidths(proj.originalSelection)}else{proj.closeAllWindows()}});proj.canvasElm.find("#imageinfoToggle").not(".disabled").click(function(){var d=$(this).parent();if(!d.hasClass("selected")){proj.showTabByID("imageInfoWindow",d)}else{proj.closeAllWindows()}});proj.canvasElm.find("#priceToggle").not(".disabled").click(function(){var d=$(this).parent();if(!d.hasClass("selected")){proj.showTabByID("priceWindow",d)}else{proj.closeAllWindows()}});proj.canvasElm.find("#collectionsToggle").not(".disabled").click(function(){var d=$(this).parent();if(!d.hasClass("selected")){proj.showTabByID("collectionsWindow",d)}else{proj.closeAllWindows()}});proj.canvasElm.find("#collectablesToggle").not(".disabled").click(function(){var d=$(this).parent();if(!d.hasClass("selected")){proj.showTabByID("collectablesWindow",d)}else{proj.closeAllWindows()}});proj.canvasElm.find("#publicationsToggle").not(".disabled").click(function(){var d=$(this).parent();if(!d.hasClass("selected")){proj.showTabByID("publicationsWindow",d)}else{proj.closeAllWindows()}});function c(e){var d="hover";if(e.type==="mouseover"){$(this).addClass(d)}else{$(this).removeClass(d)}}$("#dynamiccontent > div.right > ul li").hover(c,c)};this.closeAllWindows=function(){$(".right .selected").removeClass("selected");$("#thumbnailNav").fadeOut(100);var c={opacity:0,height:0};$(".content").hide();$(".content").css("opacity",0);$(".backing").animate(c,400);$("#products").fadeOut(300)};this.showTabByID=function(i,h){proj.closeAllWindows();h.addClass("active");var g=proj.backingElms[i];var f=proj.contentElms[i];var d=proj.closeWindowElms[i];var c=proj.windowHeights[i];var e=g.add(f);if(typeof g!="undefined"&&typeof f!="undefined"&&typeof d!="undefined"){f.show();g.animate({opacity:proj.backingNormalOpacity,height:c},400,function(){f.animate({opacity:1},100,function(){h.removeClass("active");proj.selectTab(h);d.animate({opacity:1});if(g.parent().attr("id")=="imageInfoWindow"){$(".scroll-pane").jScrollPane({showArrows:true})}if(g.parent().attr("id")=="priceWindow"){$(".scroll-pane2").jScrollPane({showArrows:true})}})})}};this.selectTab=function(c){var c=$(c);proj.tabElms.removeClass("selected");c.addClass("selected")};this.selectImage=function(c){c.preventDefault();var d=$(this).parent();proj.setSelectedIndex(proj.productsElms.index(d[0]))};this.setSelectedIndex=function(d,c){var e=proj.productsElms[d];if(typeof e!="undefined"){e=$(e);proj.thumbnailIndex=d;proj.closeAllWindows();proj.startLoading();proj.loadImageInfo(e,proj.finishLoading);proj.productsElms.find("div.selected").each(function(f,g){$(g).removeClass("selected")});e.find("div").addClass("selected");proj.updateControls()}};this.loadImageInfo=function(e,d){var c=$(e).find("a").attr("id").replace(/product/,"");$.getJSON(proj.ajaxBaseURL+c,function(g){var f=$(new Image);proj.product=g;if(typeof d!="undefined"){f.load(d)}f.attr("src",proj.product.imageWideSRC);if(!proj.isFrameViewer){$("#imageInfoWindow div.content").html($(proj.product.info))}$("#priceWindow div.content").html($(proj.product.price));var h=(parseInt(proj.thumbnailIndex+1)+" of "+proj.productsElms.length);$("a#thumbnailsToggle").attr("title",h).html(h);if(!proj.product.outOfStock){$("#shoppingcartToggle").attr("href","/add/"+c+"/");$("#shoppingcartToggle").parent("li").removeClass("disabled")}else{$("#shoppingcartToggle").parent("li").addClass("disabled")}if(proj.hasLightbox){proj.imgFrame.attr("href",proj.product.imageFullSRC);proj.imgFrame.click(function(){proj.closeAllWindows()})}})};this.startLoading=function(){proj.loadingElm.fadeIn()};this.finishLoading=function(c){proj.loadingElm.fadeOut();proj.imgFrame.fadeOut("fast",function(){proj.imgFrame.css("backgroundImage","url("+proj.product.imageWideSRC+")");proj.imgFrame.css("backgroundRepeat","repeat");proj.imgFrame.fadeIn("fast")})};this._beginRightScrolling=function(f){proj.isScrolling=true;var c=0;var d=0;proj.scrollInterval=window.setInterval(function(){if(proj._canScrollRight()){c=-4;d=proj._availableRightScroll();if(c>d){c=d}proj.leftOffset+=c;proj.products.css("left",proj.leftOffset);proj.updateControls()}else{proj._stopScrolling()}},10)};this._beginLeftScrolling=function(f){proj.isScrolling=true;var c=0;var d=0;proj.scrollInterval=window.setInterval(function(){if(proj._canScrollLeft()){c=4;d=proj._availableLeftScroll();if(c>d){c=d}proj.leftOffset+=c;proj.products.css("left",proj.leftOffset);proj.updateControls()}else{proj._stopScrolling()}},10)};this._stopScrolling=function(){window.clearInterval(proj.scrollInterval);proj.isScrolling=false};this.scrollRight=function(){var c=0;var d=0;if(proj._canScrollRight()){c=proj.scrollAmount;d=proj._availableRightScroll();if(c>d){c=d}}proj.leftOffset-=c;proj.products.stop().animate({left:proj.leftOffset},300);proj.updateControls()};this.scrollLeft=function(f){var c=0;var d=0;if(proj._canScrollLeft()){c=proj.scrollAmount;availableLeft=proj._availableLeftScroll();if(c>availableLeft){c=availableLeft}}proj.leftOffset+=c;proj.products.stop().animate({left:proj.leftOffset},300);proj.updateControls()};this._canScrollLeft=function(){return(-proj.leftOffset>0)};this._canScrollRight=function(){return(proj.itemsTotalWidth>(-proj.leftOffset+proj.itemsViewWidth))};this._availableRightScroll=function(){var c=-(proj.leftOffset-proj.scrollAmount)+proj.itemsViewWidth;var d=c-proj.itemsTotalWidth;return proj.scrollAmount-d};this._availableLeftScroll=function(){var c=0-proj.leftOffset;return(c>0?c:0)};this._calcWidths=function(){proj.itemsTotalWidth=0;proj.productsElms.each(function(c,d){proj.itemsTotalWidth+=$(d).width()+proj.productMarginRight});proj.itemsTotalWidth-=(proj.productMarginRight);proj.updateControls();return proj.itemsTotalWidth};this._scrollToItem=function(d){var c=0;proj.productsElms.each(function(e,f){if(d==f){proj.leftOffset=-c;proj.products.css("left",proj.leftOffset);return}c+=$(f).width()+proj.productMarginRight})};this.hasNext=function(){return proj.thumbnailIndex<proj.productCount};this.hasPrevious=function(){return proj.thumbnailIndex>0};this.updateControls=function(){if(!proj.hasPrevious()){proj.collectionPrevElm.addClass("disabled")}else{proj.collectionPrevElm.removeClass("disabled")}if(!proj.hasNext()){proj.collectionNextElm.addClass("disabled")}else{proj.collectionNextElm.removeClass("disabled")}if(!proj._canScrollRight()){proj.galleryNextElm.addClass("disabled");proj.galleryNextElm.css("opacity",0.3)}else{proj.galleryNextElm.removeClass("disabled");proj.galleryNextElm.css("opacity",0.9)}if(!proj._canScrollLeft()){proj.galleryPrevElm.addClass("disabled");proj.galleryPrevElm.css("opacity",0.3)}else{proj.galleryPrevElm.removeClass("disabled");proj.galleryPrevElm.css("opacity",0.9)}};this.init()};$(document).ready(function(){new Projector($("#products"),$("#mainImage"))});