(function(k){k.fn.sideswap=function(g){var h={navigation:false,previous:'prev',next:'next',display_time:5000,transition_speed:200,auto_run:true,selector:'img',delete_other_html:false,hover_stop:true,images:[]};if(g)k.extend(h,g);var j=false;return this.each(function(){var c=h.images.length;if(c>0){var d=k(h.selector,this).get(0).src;var e=d.substr(0,d.lastIndexOf('/')+1);for(var i=0;i<c;i++){k('<img src="'+e+h.images[i]+'" />').appendTo(this)}}var f=k(this),$parent=f.parent(),timer=false,$images,count;if(h.delete_other_html){$images=k(h.selector,this).clone();f.empty()}else{$images=k(h.selector,this)}if(h.delete_other_html){$images.appendTo(this)}count=$images.size();setup();function setup(){f.css('position','relative');$images.css({"display":"block","position":"absolute","top":"0px","left":"0px"}).removeClass('hide').hide();f.children(h.selector+':first').show();if(h.navigation&&count>1){createNavigation()}if(h.auto_run&&count>1){initiateInterval();if(h.hover_stop){$parent.hover(function(){clearInterval(timer)},function(){initiateInterval()})}}}function rotate(a){var b=f.children(':visible:first')=='undefined'?f.children(':first'):f.children(':visible:first'),$previous_image=b.prev()=='undefined'||b.prev().html()==null?f.children(':last'):b.prev(),$next_image=b.next()=='undefined'||b.next().html()==null?f.children(':first'):b.next();if(count>1){b.fadeOut(h.transition_speed);switch(a){case-1:$previous_image.fadeIn(h.transition_speed,function(){j=false});break;default:$next_image.fadeIn(h.transition_speed,function(){j=false});break}}}function createNavigation(){var a=k('<DIV></DIV>'),$next=a.clone().addClass('sideswap_nav sideswap_next').html(h.next).appendTo($parent).hide(),$previous=a.clone().addClass('sideswap_nav sideswap_previous').html(h.previous).appendTo($parent).hide();$next.click(function(){if(!j){j=true;rotate(1)}});$previous.click(function(){if(!j){j=true;rotate(-1)}});$parent.hover(function(){$next.fadeIn(h.transition_speed);$previous.fadeIn(h.transition_speed)},function(){$next.fadeOut(h.transition_speed);$previous.fadeOut(h.transition_speed)})}function initiateInterval(){timer=setInterval(function(){rotate()},h.display_time)}})}})(jQuery);