AC.ViewMaster.AudioSection = Class.create();
Object.extend(AC.ViewMaster.AudioSection.prototype, AC.ViewMaster.Section.prototype);
if (Event.Listener) {
    Object.extend(AC.ViewMaster.AudioSection.prototype, Event.Listener)
}
Object.extend(AC.ViewMaster.AudioSection.prototype, {
    isACMediaAvailable: function () {
        return false
    },
    mediaType: function () {
        var a = this.movieLink.getAttribute("href", 2).split("."),
        b;
        if (a.length === 2) {
            b = a[1]
        } else {
            b = "quicktime"
        }
        return this.movieLink ? "audio/" + b : "text/html"
    },
    _superInitialize: AC.ViewMaster.Section.prototype.initialize,
    initialize: function (a, b) {
        this._superInitialize(a, b);
        if (Event.Listener) {
            this.listenForEvent(AC.ViewMaster, "ViewMasterDidShowNotification", false, this.viewMasterDidShowNotificationCallback.bind(this))
        }
    },
    viewMasterDidShowNotificationCallback: function (b) {
        var c = b.event_data.data,
        a = c.incomingView;
        if (a === this && (a === this.viewMaster.currentSection)) {
            if (this._movieController && !this._movieController.isPlaying()) {
                if (this._movieController.movie) {
                    this._movieController.Play()
                } else {
                    Event.observe(document.getElementsByTagName("body")[0], "QuickTime:didAttach", this.controllerDidAttach.bind(this))
                }
            }
        }
    },
    controllerDidAttach: function (b) {
        var a = b.memo.controller;
        if (a === this._movieController && !this._movieController.isPlaying()) {
            this._movieController.Play()
        }
    },
    newMovieController: function () {
        return new AC.QuickTime.CircularController(null, {
            state: AC.QuickTime.States.Polling
        })
    },
    defaultMovieWidth: function () {
        return 1
    },
    defaultMovieHeight: function () {
        return 1
    },
    _isValidQTAvailable: undefined,
    isValidQTAvailable: function () {
        if (typeof this._isValidQTAvailable === "undefined") {
            this._isValidQTAvailable = AC.Detector.isValidQTAvailable("7");
        }
        return this._isValidQTAvailable
    },
    _super_playMovie: AC.ViewMaster.Section.prototype._playMovie,
    _playMovie: function () {
        if (AC.Detector.isIEStrict() && !this.isValidQTAvailable()) {
            if (this.movieLink && this.moviePanel) {
                this.moviePanel.innerHTML = "";
                if (this.posterLink && this.posterLink.href) {
                    var a = this.posterLink.href
                }
                this.moviePanel.appendChild(this._audioElement);
                this.movie = AC.HTMLPlusTimeSlideshow.create(this._audioElement, null, {
                    autoplay: true,
                    controller: this._movieController,
                    listenForViewMasterWillShowNotification: false
                })
            }
        } else {
            this._super_playMovie()
        }
    },
    firstControllerTrigger: function () {
        var a = this.triggers(),
        b,
        c;
        if (!a) {
            return null
        }
        for (b = 0;
        (c = a[b]); b++) {
            if (c.hasClassName("controller")) {
                return c
            }
        }
        return null
    },
    _super_loadMovie: AC.ViewMaster.Section.prototype._loadMovie,
    _loadMovie: function () {
        this._super_loadMovie();
        if (AC.Detector.isIEStrict() && !this.isValidQTAvailable()) {
            this._audioElement = document.createElement("t:AUDIO");
            this._audioElement.setAttribute("begin", "indefinite");
            var a = this.movieLink.getAttribute("href", 2).split(".");
            if (a.length === 2) {
                a = a[0] + ".mp3"
            }
            this._audioElement.setAttribute("src", a)
        }
    },
    _superWillClose: AC.ViewMaster.Section.prototype.willClose,
    willClose: function () {
        if (this.currentTriggerControllerElement) {
            this.currentTriggerControllerElement.style.visibility = "visible";
            this.controllerPanel.style.visibility = "hidden"
        }
        return this._superWillClose()
    },
    _superWillShow: AC.ViewMaster.Section.prototype.willShow,
    willShow: function () {
        this._superWillShow();
        if (this.hasShown && !this.moviePanel) {
            this.movieLink = this.content.getElementsByClassName("audioLink")[0];
            this.posterLink = this.content.getElementsByClassName("posterLink")[0];
            if (this.movieLink) {
                this._loadMovie()
            }
        }
        return this.content
    },
    _superDidShow: AC.ViewMaster.Section.prototype.didShow,
    didShow: function () {
        if (!this.isMobile) {
            var b = this.viewMaster.currentTrigger(),
            c = b.parentNode,
            a;
            this.currentTriggerControllerElement = this.firstControllerTrigger();
            this.currentTriggerControllerElement.parentNode.appendChild(this.controllerPanel);
            a = Element.positionedOffset(this.currentTriggerControllerElement);
            this.controllerPanel.style.left = (a.left) + "px";
            this.controllerPanel.style.top = (a.top) + "px";
            this.controllerPanel.style.width = this.currentTriggerControllerElement.clientWidth + "px";
            this.controllerPanel.style.height = this.currentTriggerControllerElement.clientHeight + "px";
            this.controllerPanel.style.position = "absolute";
            this.controllerPanel.style.visibility = "visible";
            this.currentTriggerControllerElement.style.visibility = "hidden"
        }
        return this._superDidShow()
    },
    _closeMovie: function () {
        if ((!AC.Detector.isIEStrict() || this.isValidQTAvailable()) && this.movie && this.moviePanel) {
            this.moviePanel.removeChild(this.movie);
            this.movie = null;
            this.moviePanel.innerHTML = ""
        }
    }
});
AC.ViewMaster.AudioGallery = Class.create();
if (Event.Listener) {
    Object.extend(AC.ViewMaster.AudioGallery.prototype, Event.Listener)
}
Object.extend(AC.ViewMaster.AudioGallery.prototype, AC.ViewMaster.Viewer.prototype);
Object.extend(AC.ViewMaster.AudioGallery.prototype, {
    viewMasterId: "AudioGallery",
    _superInitialize: AC.ViewMaster.Viewer.prototype.initialize,
    initialize: function (d, a, e, c, b) {
        if (!a) {
            a = document.createElement("div");
            document.body.appendChild(a)
        }
        a.style.left = "0px";
        a.style.top = "0px";
        a.style.width = "1px";
        a.style.height = "1px";
        a.style.position = "fixed";
        if (!b) {
            b = {}
        }
        if (b.shouldAnimateContentChange == null) {
            b.shouldAnimateContentChange = false
        }
        this._superInitialize(d, a, e, b);
        if (Event.Listener) {
            this.listenForEvent(AC.ViewMaster, "ViewMasterWillShowNotification", false, this.viewMasterWillShowNotificationCallback.bind(this))
        }
        this.slideshow = new AC.ViewMaster.Slideshow(this, c, b)
    },
    createSectionForContent: function (a) {
        return new AC.ViewMaster.AudioSection(a, this)
    },
    viewMasterWillShowNotificationCallback: function (c) {
        var d = c.event_data.data,
        b = d.sender,
        a = d.incomingView;
        if (b && b.viewMasterId != "AudioGallery" && this.currentSection) {
            if (a) {
                if (!a.content.down(this.currentSection.content) || !a.content.down(this.currentSection.movieLink)) {
                    this.show(null, true)
                }
            }
        }
    },
    _superTriggerClicked: AC.ViewMaster.Viewer.prototype.triggerClicked,
    triggerClicked: function (a, b) {
        if (!AC.Detector.isMobile()) {
            this._superTriggerClicked(a, b)
        }
    }
});