var ZhViewer=Class.create({initialize:function(A){this.root=$(A);this.container=$("over_viewer");this.title=this.container.select("h2 span").first();this.preview_container=this.container.select("div.preview").first();this.preview=this.preview_container.select("div.last").first();this.prev_link=this.container.select("div.prev-link").first();this.next_link=this.container.select("div.next-link").first();this.big_image=this.container.select("img.big-image").first();this.current_ix=0;var B=this;this.prev_link.onclick=function(){if(!B.prev_link.hasClassName("disable")){B.showImage((B.preview.childElements())[B.current_ix-1]||null)}};this.next_link.onclick=function(){if(!B.next_link.hasClassName("disable")){B.showImage((B.preview.childElements())[B.current_ix+1]||null)}};(this.container.select("div.close").first()).onclick=function(){B.container.setStyle({display:"none"})}},assign:function(B,E,C){var D=this;if(B.size()){var A=E.size()>0?(E.first()).up():(B.first()).up();B.each(function(G,F){G.onclick=function(){D.create(A,F,C);return false}})}},remove:function(){(this.preview.childElements()).invoke("remove");this.current_ix=0;this.big_image.src="/i/css/px.gif"},create:function(E,A,C){this.remove();this.preview.insert(E.innerHTML);var G=C.title;if(C.title_postfix){G+=" "+C.title_postfix}this.title.update(G);this.prev_link.update('<span class="pseudo">&larr;</span>'+C.label_prev);this.next_link.update('<span class="pseudo">&rarr;</span>'+C.label_next);this.preview_container[(E.childElements()).size()>1?"show":"hide"]();var D=this.preview.childElements();var F=this;var B=C.src_attribute||null;D.each(function(I){var H=I.firstDescendant();if(B){H.src=H.readAttribute(B)}I.onclick=function(){F.showImage(I);return false}});this.container.setStyle({display:"block",height:this.root.clientHeight+"px"});this.showImage(D[A]);this.container.scrollTo()},showImage:function(A){if(A){var B=this;this.preview.childElements().each(function(D,C){D.removeClassName("selected");if(D.href==A.href){D.addClassName("selected");B.current_ix=C}B.prev_link[((A.previousSiblings()).size()==0)?"addClassName":"removeClassName"]("disable");B.next_link[((A.nextSiblings()).size()==0)?"addClassName":"removeClassName"]("disable");B.big_image.onload=function(){var E=(B.big_image.cumulativeOffset())[1]+B.big_image.clientHeight+60;if(B.container.clientHeight<E){B.container.style.height=E+"px"}};B.big_image.src=A.href})}}});