/*
 * @name:     ImgSwitch
 * @version:  0.1 
 * @release:  2008-10-15
 * @type:     jQuery plugin
 * @author:   David Sklar
--------------------------------------- */
(function($){var ImgSwitch=function(box,opts){var $this=box;var master;var slave;var css;var duration;var options=opts;var express=[];express['small']=options.small;express['medium']=options.medium;express['full']=options.full;master=$(options.master);duration=options.duration;css=options.css;$this.find('img:first').addClass(css);$this.bind('click',function(e){var target=$(e.target);if(target.is('img')){reset();target.addClass(css);load(target);}
e.preventDefault();});var show=function(img){var newImg=$(img);var x=master.position().left;var y=master.position().top;master.after(newImg);newImg.css({position:'absolute',top:y+'px',left:x+'px',opacity:0}).animate({opacity:1.0},duration,'swing',function(){newImg.remove();master.attr({src:newImg.attr('src'),title:newImg.attr('title'),alt:newImg.attr('alt')});});};var load=function(img){var newImg=$(new Image());newImg.bind('load',function(){show(this);}).attr({src:img.attr('src').replace(new RegExp(express['small'],'i'),express['medium']),title:img.attr('title'),alt:img.attr('alt')});master.parent('a').attr({href:img.attr('src').replace(new RegExp(express['small'],'i'),express['full'])});};var reset=function(){$this.find('img').removeClass(css);};};$.fn.imgSwitch=function(options){var opts=$.extend({},{master:'#master img',small:'50x50',medium:'190x160',full:'FULL',duration:300,css:'set'},options);return this.each(function(){return new ImgSwitch($(this),opts);});};})(jQuery);
