/**
 * The PDFA Get Focused
 *
 * It loads the movie into the obtrusive overlay
 *
 * @author Miguel Julio (mjulio@mcdpartners.com)
 */
(function () {

    /**
     * The dei package
     *
     * @namespace pdfa
     * @package pdfa.dei.obtrusiveMovieLoader
     */
	pdfa.dei.movieLoader = {

	 	swf 		: '',		// flash movie
		flashVar	: '',		// xml file

		embedFlash: function() {
			swfobject.embedSWF(
				pdfa.dei.movieLoader.swf,
				'flash-content',
				'960',
				'406',
				'8.0.0',
				'expressInstall.swf',
				pdfa.dei.movieLoader.flashVar
			);
		},

        prepareOverlay: function() {
            mcd.ObtrusiveOverlay.manager.createBackdrop();
            mcd.ObtrusiveOverlay.manager.hideBackdrop();
            mcd.event.add("backdrop", "click", pdfa.dei.movieLoader.closeOverlay);
        },

        closeOverlay: function() {
            // When the overlay is closed, the video should stop playing.
            // Since the video should start from the beginning if the overlay is reopened,
            // we will remove the Flash file from the dom.
            var flash_container = document.getElementById("flash-content");

            if (typeof flash_container !== "undefined") {
                var flash_container_parent = flash_container.parentNode;
                flash_container_parent.removeChild(flash_container);

                // Once removed, the flash-content div must be replaced so that
                // swfobject can start from a clean slate if the overlay is redisplayed.
                var replacement = document.createElement("DIV");
                replacement.id = "flash-content";
                flash_container_parent.appendChild(replacement);
            }

            mcd.ObtrusiveOverlay.manager.exitObtrusive();
        }


	};
})();
