if (typeof thissection != "undefined") {
    var images = new Array();
    var imageObj = new Array();
    var n = 1;
    var i = 0;
    $(document).ready(function () {
        $.ajax({
            type: "GET",
            url: "/sections.xml",
            dataType: "xml",
            success: function (xml) {
                $(xml).find('section').each(function () {
                    var id = $(this).attr('id');
                    if (id == thissection) {
                        $(this).find('img').each(function () {
                            images.push($(this).attr('src'));
                            imageObj[i] = new Image();
                            $(imageObj[i]).attr('src', '/images/' + images[i]);
                            i++;
                        });
                    }
                });
                setInterval("rotateImage()", 5000);
            }
        });
    });

    function rotateImage() {
        $('.rotate').removeAttr('src');
        $('.rotate').attr('src', '/images/' + images[n]);
        n++;
        if (n >= images.length) {
            n = 0;
        }
    }
}
