﻿var imageRotator = function(list)
{
    var listItems = $('li',list);
    //list.css({position:'relative'});
    //list.height($('img', list).height()); // Firefox issue not set height correctly
    list.height('300px');
    //listItems.css({position:'absolute'});
    
    var current = 0;
    listItems.each(function(i)
    {
        if(i != current)
        {
            $(this).hide();
        }
        else
        {
            $(this).show();
        }
    });
    
    var moveNext = function()
    {
        $(listItems[current]).fadeOut(1000);
        current++;
        if(current >= listItems.length)
        {
            current = 0;
        }
        $(listItems[current]).fadeIn(1000);
    }
    
    setInterval(moveNext, 10000);
}

$(function()
{
    $('.rotator').each(function()
    {
       new imageRotator($(this)); 
    });
});