﻿Type.registerNamespace('BL');

BL.ImageRotator = function (el) {

    BL.ImageRotator.initializeBase(this);

    var _$divSlideshow = null;
    var _container = el.parentNode;

    var _interval = 0;
    this.get_interval = function () {
        return _interval;
    };

    this.set_interval = function (ms) {
        _interval = ms;
    };

    var _transitionSpeed = 0;
    this.get_transitionSpeed = function () {
        return _transitionSpeed;
    };

    this.set_transitionSpeed = function (ms) {
        _transitionSpeed = ms;
    };

    function TitleImage(i) {
        $(this).attr('title', $(this).attr('alt'));
    }

    this.start = function () {
        _$divSlideshow.cycle({ timeout: _interval, speed: _transitionSpeed, random: true });
    };

    function _init() {
        _$divSlideshow = $('[id$="_divSlideshow"]', $(_container));
        $('img', _$divSlideshow).each(TitleImage);
    }

    _init();
};

BL.ImageRotator.registerClass('BL.ImageRotator', Sys.Component);
