﻿


function startRotator(length, fileName) {
    var intervalIndex = setInterval('rotateImg(' + "'" +length + "', '" + fileName + "')", 5000);
}

var curRotatorImgIndex = 0;
function rotateImg(length, fileName) {
    
    curRotatorImgIndex = (curRotatorImgIndex+1)%length;
    
    // back should remain as is until front is opacity 0, then front should become = to back, then back should be changed
    $('#rotated_imgFore').fadeOut('slow', function() {
        $('#rotated_imgFore').attr('src', $(this).attr('dst'));    
    });

    $('#rotated_imgFore').fadeIn('fast', function() {
        $('#rotated_imgBack').css("background-image","url('" + $(this).attr('dst') + "')");
        $('#rotated_imgFore').attr('dst', '' + fileName + curRotatorImgIndex + '.jpg');
    });
}



