(function($){$.fn.imagerotator=function(options)
{var id=$(this).attr('id');settings=jQuery.extend({activeClass:'imagerotator-active',passiveClass:'imagerotator',interval:5000,speed:1000},options);var obj=new Object();obj.id=id;obj.interval=0;obj.settings=settings;obj.imagerotates=$('#'+id+' div[rel^=imagerotate-]');obj.navigation=$('#'+id+'-nav a[rel^=imagerotate-]');obj.active_id=0;obj.interval=setTimeout(function(){$(this).imagerotate_reload(obj);},obj.settings.interval);obj.navigation.each(function()
{$(this).click(function(){$(this).imagerotate_click($(this).attr('rel'),obj);});});}
$.fn.imagerotate_click=function(id,obj)
{clearTimeout(obj.interval)
var c=obj.imagerotates[obj.active_id];id=id.replace(obj.id+'-','');var num=parseInt(id.split('-')[0]);if((num-1)!=obj.active_id)
{var n=obj.imagerotates[0];if(num>0)
{if(obj.imagerotates[num-1])
{n=obj.imagerotates[num-1];obj.active_id=0;}}
for(var i=0;i<obj.imagerotates.length;i++)
{if($(obj.imagerotates[i]).attr('rel')==obj.id+'-'+num)
{n=obj.imagerotates[i];obj.active_id=i;break;}}
$(this).imagerotate_exec(c,n,obj);}
else
{obj.interval=setTimeout(function(){$(this).imagerotate_reload(obj);},obj.settings.interval);}}
$.fn.imagerotate_reload=function(obj)
{var c=obj.imagerotates[obj.active_id];var n=$(this).imagerotate_get_next_imagerotate(obj);$(this).imagerotate_exec(c,n,obj);}
$.fn.imagerotate_exec=function(c,n,obj)
{$(c).fadeOut(obj.speed);$(n).fadeIn(obj.speed);$(this).imagerotate_get_nav(obj,$(c).attr('rel')+'-nav').attr('class',obj.settings.passiveClass);$(this).imagerotate_get_nav(obj,$(n).attr('rel')+'-nav').attr('class',obj.settings.activeClass);obj.interval=setTimeout(function(){$(this).imagerotate_reload(obj);},obj.settings.interval);}
$.fn.imagerotate_get_nav=function(obj,id)
{for(var i=0;i<obj.navigation.length;i++)
{if($(obj.navigation[i]).attr('rel')==id)
{return $(obj.navigation[i]);}}
return null;}
$.fn.imagerotate_get_next_imagerotate=function(obj)
{var n=obj.imagerotates[0];if(obj.imagerotates.length>(obj.active_id+1))
{n=obj.imagerotates[obj.active_id+1];obj.active_id=obj.active_id+1;}
else
obj.active_id=0;return n;}})(jQuery);
