/**
 * @name jQuery phZoom Plugin
 * @version 1.292 Final
 * @create 2011.7.10
 * @lastmodified 2012.1.6
 * @description Based on jQuery 1.4+
 * @author Phoetry (http://phoetry.me)
 * @url http://phoetry.me/archives/phzoom.html
 *
**/
~function(f){var c=f(window),g=f(document),b=f("<div id=ph_lay/>"),a=f("<div id=ph_zoom/>"),h=b.add(a),d=function(j,i,l,k){this.opt=i;this.idx=l;this.all=k;this.len=k.length;this.end=this.len>l+1;this.img=f("img:first",j);this.lnk=j.addClass("phzoom").unbind("click").bind(this.imgFn()).append(this.hov=f("<span class=ph_hover/>").hide())[0];this.cap=f("<div/>",{id:"ph_cap",html:f([f("<span/>",{id:"ph_txt",text:this.img[0].title||this.lnk.title||"No title"})[0],f("<span/>",{id:"ph_idx",text:l+1+" / "+this.len})[0]])}).add(this.nav=f("<div/>",{id:"ph_nav",html:(l?"<span id=ph_prev>"+i.prevText+"</span>":"")+(this.end?"<span id=ph_next>"+i.nextText+"</span>":"")}));h.click(f.proxy(this,"imgQuit"));window.XMLHttpRequest||j.height(this.img.height())};d.prototype={imgFn:function(){var j=this,i=function(){return j.hov.not(".loading").stop(0,1)};return{mouseover:function(){i().fadeIn()},mouseout:function(){i().fadeOut()},click:function(){j.imgLoad();return false}}},imgPos:function(k,m){var j=this.img,i=c.scrollLeft(),l=c.scrollTop(),n=[c.width(),c.height(),j.width(),j.height(),j.offset().left,j.offset().top];this.opt.limitWidth&&k>n[0]&&(m=m/k*(k=n[0]));return n.concat(k,m,(n[0]-k)/2+i,(n[1]-m)/2+l,(n[0]-n[2])/2+i,(n[1]-n[3])/2+l)},imgLoad:function(){b.fadeTo(this.opt.layDur,this.opt.layOpacity);var i=this,j=new Image;this.hov.addClass("loading");j.className="zoomed";j.onload=function(){j.onload=null;i.hov.hasClass("loading")&&(a.height(g.height()).append(j).show(),i.imgAnim(j),i.preLoad())};j.src=this.lnk.href},imgAnim:function(n){var k=this,j=f(n),m=this.imgPos(n.width||+j.attr("width"),n.height||+j.attr("height")),i=m[0]<m[6],l=this.evtMon(j,m[0],m[0]-m[6],!i);j.after(this.cap.hide()).css({left:m[4],top:m[5],width:m[2],height:m[3]}).animate({left:m[10],top:m[11]},this.opt.animDurA,function(){j.animate({left:m[8],top:m[9],width:m[6],height:m[7]},k.opt.animDurB,function(){k.hov.removeClass("loading");k.cap.css({top:m[7]+m[9],left:i?0:m[8],width:i?m[0]:m[6]}).fadeIn(300);k.nav.bind(l).css("top",m[7]/3+m[9]);k.keyBind()}).bind(l)});f("#ph_txt").text("Size:"+m[6]+"*"+m[7]+" px")},imgQuit:function(i){this.hov.hide().hasClass("loading")?this.hov.removeClass("loading"):g.unbind(".phzoom");i&&b.fadeOut();a.hide().empty();return false},imgChange:function(i){this.imgQuit();f(".ph_hover",f(this.all[this.idx+i]).click()).show();return false},preLoad:function(i,j){this.idx&&(i=new Image,i.src=this.all[this.idx-1].href,delete i);this.end&&(j=new Image,j.src=this.all[this.idx+1].href,delete j)},keyBind:function(){var i=this;g.bind("keydown.phzoom",function(j){j=j.which;return j==37&&i.idx?i.imgChange(-1):j==39&&i.end?i.imgChange(1):j^27||i.imgQuit(1)})},evtMon:function(k,j,i,n){var l=this,m=f("span",this.nav).hide();return{click:function(o){return l.len<2||(o=o.pageX>j/2,l.idx?l.end?l.imgChange(o||-1):o||l.imgChange(-1):!o||l.imgChange(1))},mouseout:function(){m.hide()},mousemove:function(p,o){p=p.pageX,o=p>j/2;l.idx?(m.eq(o).show(),m.eq(1-o).hide()):m[o?"show":"hide"]();n||(p=p<j/3?0:p>j*2/3?i:i/2)==k.position().left||k.not(":animated").animate({left:p},200)}}}};f.phzoom=function(j,i,k){i=f.extend({layOpacity:0.7,layDur:300,animDurA:300,animDurB:300,navColor:"#cf0",capColor:"#cf0",prevText:"Prev",nextText:"Next",limitWidth:true,returnOrigin:true},i),(k=j.has("img"))[0]&&(f("#ph_lay")[0]||f("body").append(h),k.each(function(m,l){f.data(l,"phzoom",new d(f(l),i,m,k))}));return i.returnOrigin?j:k};f.fn.phzoom=function(i){return f.phzoom(this,i)};function e(i){console.log({}.toString.call(i)+" | "+i)}}(jQuery);