function Presentations(objectName, stopButtonId, stopButtonImageUrl, stopButtonPressedImageUrl, stopButtonDisabledImageUrl) {
    this._objectName = objectName;
    this._stopButtonId = stopButtonId;
    this._stopButtonImageUrl = stopButtonImageUrl;
    this._stopButtonPressedImageUrl = stopButtonPressedImageUrl;
    this._stopButtonDisabledImageUrl = stopButtonDisabledImageUrl;
}

Presentations.prototype =
{
    _objectName: null,
    _bios: null,
    _stopButtonId: null,
    _stopButtonImageUrl: null,
    _stopButtonPressedImageUrl: null,
    _stopButtonDisabledImageUrl: null,
    _currentPresentationIndex: null,
    _isStopButtonDisabled: false,

    initialize: function(bios) {
        this._currentPresentationIndex = 0;
        this._bios = bios;
        var count = this._bios.length;
        var divPresentations = $("#list");
        for (var k = 0; k < count; k++) {
            var div = $("<div></div>")
                           .text((k + 1) + ". ")
                           .appendTo(divPresentations);
            var lnk = $("<a></a>")
		            .attr("href", "#" + k)
		            .text(this._bios[k]._name)
		            .appendTo(div);
            lnk.click(this.onShowPresentationClick.createDelegate(this, [k, lnk]));
        }

        this.registerEventHandlers();
        player._playCallback = this.onPlayButtonClick.createDelegate(this);
    },

    registerEventHandlers: function() {
        this.getStopControl().click(this.onStopButtonClick.createDelegate(this));
        this.getStopControl().mousedown(this.onStopButtonMouseDown.createDelegate(this));
        this.getStopControl().mouseup(this.onStopButtonMouseUp.createDelegate(this));
        this.getStopControl().mouseout(this.onStopButtonMouseUp.createDelegate(this));
    },

    onShowPresentationClick: function(index, source, stopPlaying) {
        if (!player._disableButtons) {
            this._currentPresentationIndex = index;
            if ($("#bio" + index).length == 0) {
                player.addBio(player._bios[index], 2, false, true);
            }

            player._timeoutValue = window.clearTimeout(player._timeoutValue);
            player.hideCurrentBio(true, stopPlaying);
            player._currentBioIndex = index - 1;
            player.onPlayButtonClick();
        }
    },

    onStopButtonClick: function() {
        if (!this._isStopButtonDisabled) {
            if (player._currentPhotoIndex != 0 || player._photoShowingTimeoutValue != 0) {
                player._photoShowingTimeoutValue = window.clearTimeout(player._photoShowingTimeoutValue);
                player._disableButtons = false;
                this.onShowPresentationClick(this._currentPresentationIndex, null, true);
            }
            else {
                player.getCurrentPhoto().show();
                player._timeoutValue = window.clearTimeout(player._timeoutValue);
                player._isPlaying = false;
            }
            player.getPausePlayControl().attr("src", player._playButtonImageUrl);
            this._isStopButtonDisabled = true;
            this.getStopControl().attr("src", this._stopButtonDisabledImageUrl);
        }
    },

    onPlayButtonClick: function() {
        this._isStopButtonDisabled = false;
        this.getStopControl().attr("src", this._stopButtonImageUrl);
    },

    onStopButtonMouseDown: function() {
        if (!this._isStopButtonDisabled) {
            this.getStopControl().attr("src", this._stopButtonPressedImageUrl);
        }
    },
    onStopButtonMouseUp: function() {
        if (!this._isStopButtonDisabled) {
            this.getStopControl().attr("src", this._stopButtonImageUrl);
        }
    },

    getStopControl: function() {
        return $("#" + this._stopButtonId);
    }
};