(function(a){iOffer.namespace("ItemDetail",function(d){this.methods({ready:function(){a("#sliding-actions .converted-price").html(function(a,c){return d.supprice(c)});var c=a("#top-section .image-gallery");c.length>0&&(c.itemgallery({target:".main-image img",images:"ul li",event:"mouseenter"}),c.outerHeight(a("#top-section .item-details").outerHeight()));a(".make-offer-form div.comment label").bind("click",function(){a(this).next("textarea").slideToggle()});a("#top-section .featured-payments .view-all").hover(function(){a("#all-payment-icons").show().position({my:"center bottom",
at:"center top",of:this,collision:"fit"})},function(){a("#all-payment-icons").hide()}).bind("click",function(){return!1});a("#top-section .main-image img").bind("click",function(){var b=a("#top-section .other-images li.active").index();d.showGalleria(b)});a("#top-section .other-images").delegate("li","click",function(){d.showGalleria(a(this).index())});a("input.price-field").each(function(){a(this).pricify();new iOffer.CurrencyConversionHelper(Element.extend(this))});this.offerContainer=a("#make-offer-top");
a("#top-section .make-offer").bind("click",function(b){b.preventDefault();d.offerContainer.slideDown("slow",function(){a(this).infold({offset:10}).css({filter:""}).find(".price-field").focus()})});this.offerContainer.find("a.close").bind("click",function(a){a.preventDefault();d.offerContainer.slideUp("slow")});a("#right-panel a.add-to-watchlist.ajax").bind("click",function(b){b.preventDefault();var c=a(this).loading(!0,"small");a.get(this.href,function(a){c.loading(!1).text(a.text)})});window.loaded?
d.loaded():a(window).bind("load",function(){d.loaded()})},loaded:function(){this.autoBalanceColumns();a.fn.stickify&&a("#sliding-actions").stickify({offset:20,container:"#right-panel .glossy-panel"});a(window).delayed("resize",150,function(){d.autoBalanceColumns()})},autoBalanceColumns:function(){a(".even-columns").each(function(){var c=a(this).children().find("> .glossy-panel").height(""),b=Math.max.apply(this,a.map(c,function(b){return a(b).height()}));c.height(b)})},supprice:function(a){if(currentCode==
"USD"){a=(a+"").split(".");var b=a.pop();return a.join(",")+"<sup>."+b+"</sup>"}},setupGalleria:function(c){var b=[];a("#top-section .other-images li").each(function(){b.push({image:a(this).data("src"),thumb:a(this).find("img").attr("src")})});this.galleria=a("<div/>").appendTo(document.body).galleria({height:600,width:750,maxScaleRatio:1,debug:!1,data_source:b,show:c});a('<div id="galleria-close"/>').appendTo(this.galleria.find(".galleria-container")).bind("click",function(){d.galleria.hide();d.galleria.data("galleria").detachKeyboard()});
return this.galleria.data("galleria")},showGalleria:function(a){if(a>=0){if(this.galleria)b=this.galleria.data("galleria"),this.galleria.show(),b.show(a);else var b=this.setupGalleria(a);b.attachKeyboard({left:b.prev,right:b.next})}}});this.namespace("RecentActivity",function(c){this.methods({ready:function(){this.container=a(".item-recent-activity");this.url=this.container.data("url");this.container.find(".sort select").val("default");this.container.find(".sort select").bind("change",function(){var b=
a(this);c.update({refresh:!0,sort:b.val()})});this.container.delegate(".pagination a","click",function(b){b.preventDefault();c.update(a.deparam(this.href.split("?")[1]))});this.container.delegate(".recent-activity-item","click",function(b){if(a(b.target).closest("a").length==0)window.location=a(this).find("a.action-taken:first").attr("href")});this.cleanComments()},update:function(b){var e=this.container.find("table").loading(!0);a.get(c.url,b||{},function(a){e.loading(!1).replaceWith(a);c.cleanComments();
d.autoBalanceColumns()})},cleanComments:function(){this.container.find("a.comment").text(function(a,c){return c.replace(/(\S{45})/g,"$1 ")})}})})})})(jQuery);

