(function($){$.imagezoom={};$.imagezoom._close_handler=false;$.imagezoom._all_images=[];$.imagezoom._ctl_count=0;$.imagezoom._defaults={defaultWidth:300,defaultHeight:300,dimSpeed:100,zoomAnimSpeed:100,padding:20,dimOpacity:0.5,removeScroll:false};$.imagezoom.settings={};$.fn.extend({imagezoom:function(settings){$.imagezoom.settings=$.extend({},$.imagezoom._defaults,settings);return this.each(function(){var t=$(this);if(this.tagName=='IMG'){var lnk=t.attr('longdesc');t.wrap('');t=t.parent();} $.imagezoom._all_images.push(t);if(!t.attr('id')){t.attr('id','__imagezoom-'+($.imagezoom._ctl_count++));} t.click(function(){$.imagezoom.openImagezoom(t);return false;});});}});function dimScreenOn(callback) {if($('#__dimScreen').length>0){if(typeof callback=='function'){callback();} return;} if($.imagezoom.settings.removeScroll){$('BODY').css('overflow','hidden');} $('
').attr({id:'__dimScreen'}).css({background:'#000',height:$(document).height(),left:'0px',opacity:0,position:'absolute',top:'0px',width:$(window).width(),zIndex:1999}).appendTo(document.body).fadeTo($.imagezoom.settings.dimSpeed,$.imagezoom.settings.dimOpacity,callback);$(window).resize(function(){$('#__dimScreen').css({height:$(document).height(),width:$(window).width()});});} function dimScreenOff(callback) {$('#__dimScreen').fadeOut($.imagezoom.settings.dimSpeed,function(){$(this).remove();if($.imagezoom.settings.removeScroll){$('BODY').css('overflow','auto');} if(typeof callback=='function'){callback();}});} $.imagezoom.openImagezoom=function(t){var tc=null;var n=null;var p=null;for(tc in $.imagezoom._all_images){if($.imagezoom._all_images[tc].attr('id')==t.attr('id')){tc=parseInt(tc,0);if($.imagezoom._all_images[tc+1]){n=$.imagezoom._all_images[tc+1];} if($.imagezoom._all_images[tc-1]){p=$.imagezoom._all_images[tc-1];}}} dimScreenOn(function(){var w_w=$(window).width();var w_h=$(window).height();var i_w=$.imagezoom.settings.defaultWidth-$.imagezoom.settings.padding*2;var i_h=$.imagezoom.settings.defaultHeight-$.imagezoom.settings.padding*2;var description=t.find('IMG').attr('alt');description=description.replace(/\n/g,'
');var toolbar_h=0;var imgc=$('#imagezoom-c');if(imgc.length==0){imgc=$('
').appendTo(document.body);imgc.css({width:i_w+'px',height:i_h+'px',left:(Math.round(w_w/2)-Math.round(i_w/2))+'px',top:($(window).scrollTop()+Math.round((w_h-i_h)/2))+'px'});} else{imgc.addClass('loading');} $('#imagezoom-description').css({marginLeft:p?$('#imagezoom-prev').width()+20:0,marginRight:n?$('#imagezoom-next').width()+20:0}).html(description);toolbar_h=Math.max($('#imagezoom-description').outerHeight(true),$('#imagezoom-next').outerHeight(true));$('#imagezoom-img').remove();$('#imagezoom-toolbar').hide();var img_obj=new Image();$(img_obj).load(function(){var iw=img_obj.width;var ih=img_obj.height;var w=iw;var h=ih+toolbar_h+$.imagezoom.settings.padding;imgc.animate({left:Math.round((w_w-w)/2)+'px',top:($(window).scrollTop()+Math.round((w_h-h)/2))+'px',width:w+'px',height:h+'px'},$.imagezoom.settings.zoomAnimSpeed,'swing',function(){imgc.removeClass('loading');var img_el=$('').prependTo(imgc);img_el.fadeIn($.imagezoom.settings.zoomAnimSpeed*3).bind('click',function(){$.imagezoom.closeImagezoom();});if(n){$('#imagezoom-next A').unbind('click').click(function(){$.imagezoom.openImagezoom(n);});$('#imagezoom-next').show();} else{$('#imagezoom-next').hide();} if(p){$('#imagezoom-prev A').unbind('click').click(function(){$.imagezoom.openImagezoom(p);});$('#imagezoom-prev').show();} else{$('#imagezoom-prev').hide();} if(description){$('#imagezoom-description').show();} else{$('#imagezoom-description').empty();} if(toolbar_h>0){$('#imagezoom-toolbar').show();}});});img_obj.onerror=function(){$.imagezoom.closeImagezoom();};img_obj.src=t.attr('href');});if(!$.imagezoom._close_handler){$('#__dimScreen').click(function(){$.imagezoom.closeImagezoom();});$(document).keydown(function(e){var key=(window.event)?event.keyCode:e.keyCode;var esc_code=27;if(key==esc_code&&$('#imagezoom-c').length>0){$.imagezoom.closeImagezoom();} $.imagezoom._close_handler=true;});}};$.imagezoom.closeImagezoom=function(callback){$('#imagezoom-c').remove();dimScreenOff(callback);};})(jQuery);