$.fn.imageMorph=(function(src,width,height,callback,SPEED){var SPEED=SPEED||300;return this.each(function(){var img=$(this),newImg=$('<img>'),throbber=img.parent().find('.throbber');if(img.hasClass('morpher')){img.remove();return;}
if(!throbber.length){throbber=$('<span class="throbber"></span>');img.parent().append(throbber);throbber.hide();}
var throbberTimeout=setTimeout(function(){throbber.show();},60);newImg.css({position:'absolute',top:0,left:0,width:img.width()+'px',height:img.height()+'px',opacity:0,cursor:'pointer'}).addClass('morpher');img.parent().append(newImg).css({width:img.width()+'px',height:img.height()+'px'});newImg.load(function(){var css={width:width+'px',height:height+'px',opacity:1};img.parent().stop().animate(css,SPEED);img.stop().animate(css,SPEED);clearTimeout(throbberTimeout);throbber.hide();newImg.animate(css,SPEED,function(){img.remove();newImg.removeClass('morpher');(callback||function(){})();});});newImg.attr('src',src);});});(function($){var image_index=1,change_image_index=0,CHANGE_TIMER=5000,MORPH_TIMER=1000;function nextImage(changeImage){image_index+=1;if(image_index>=home_image_list.length){image_index=0;}
if(!changeImage){changeImage=$('.home-gallery a.image').eq(change_image_index).find('img');change_image_index=change_image_index?0:1;}
changeImage.imageMorph(home_image_list[image_index][0],380,285,function(){},MORPH_TIMER);};$(function(){var interval=setInterval(function(){nextImage();},CHANGE_TIMER);$('.home-gallery a.image').click(function(){nextImage($(this).find('img').eq(0));clearInterval(interval);interval=setInterval(nextImage,CHANGE_TIMER);return false;});});})($);
