﻿Type.registerNamespace('Hbm.PresentationInterface.WebControls');

Hbm.PresentationInterface.WebControls.FlashPlayerVersion = function(arrVersion)
{
    this.major = arrVersion[0] != null ? parseInt(arrVersion[0]) : 0;
    this.minor = arrVersion[1] != null ? parseInt(arrVersion[1]) : 0;
    this.rev = arrVersion[2] != null ? parseInt(arrVersion[2]) : 0;
}

Hbm.PresentationInterface.WebControls.FlashPlayerVersion.prototype =
{
    isValid : function(fv)
    {
        if (this.major < fv.major)
        {
            return false;
        }
        else if (this.minor < fv.minor)
        {
            return false;
        }
        else if (this.rev < fv.rev)
        {
            return false;
        }
        else
        {
            return true;
        }
    }
}

Hbm.PresentationInterface.WebControls.FlashPlayerVersion.registerClass('Hbm.PresentationInterface.WebControls.FlashPlayerVersion');

Hbm.PresentationInterface.WebControls.FlashPlayer = function (element)
{
    Hbm.PresentationInterface.WebControls.FlashPlayer.initializeBase(this, [element]);

    this._minRequiredPlayerVersion = null;
    this._playerSrc = null;
    this._flashVars = null;
    this._allowScriptAccess = null;
    this._width = null;
    this._height = null;
    this._playbackQuality = null;
}

Hbm.PresentationInterface.WebControls.FlashPlayer.prototype = 
{
    initialize : function()
    {
        Hbm.PresentationInterface.WebControls.FlashPlayer.callBaseMethod(this, 'initialize');

        if (!this.getPlayerVersion().isValid(this._minRequiredPlayerVersion))
        {
            this.get_element().innerHTML = FlashPlayer.Resources.NoFlashPlayer;
            return;
        }

        var playerHtml = '<object width="';
        playerHtml += this._width;
        playerHtml += '" height="'
        playerHtml += this._height;
        playerHtml += '"';
        
        if (window.navigator.appVersion.indexOf('MSIE') == -1)
        {
            playerHtml += ' type="application/x-shockwave-flash" data="';
            playerHtml += this._playerSrc;
            playerHtml += '">';
        }
        else
        {
            playerHtml += ' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"><param name="movie" value="';
            playerHtml += this._playerSrc;
            playerHtml += '" />';
        }

        playerHtml += '<param name="flashvars" value="';
        playerHtml += this._flashVars;
        playerHtml += '" />';
        playerHtml += '<param name="allowscriptaccess" value="';
        playerHtml += this._allowScriptAccess;
        playerHtml += '" />';
        playerHtml += '<param name="quality" value="';
        playerHtml += this._playbackQuality;
        playerHtml += '" /><param name="bgcolor" value="#FFFFFF" /><param name="pluginspace" value="http://www.macromedia.com/go/getflashplayer" /></object>';

        this.get_element().innerHTML = playerHtml;
    },

    dispose : function()
    {
         Hbm.PresentationInterface.WebControls.FlashPlayer.callBaseMethod(this, 'dispose');
    },
    
    getPlayerVersion : function ()
    {
	    var playerVersion = new Hbm.PresentationInterface.WebControls.FlashPlayerVersion([0,0,0]);
	    if (navigator.plugins && navigator.mimeTypes.length)
	    {
		    var x = navigator.plugins["Shockwave Flash"];
		    if (x && x.description)
		    {
			    playerVersion = new Hbm.PresentationInterface.WebControls.FlashPlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split("."));
		    }
	    }
	    else
	    {
		    // do minor version lookup in IE, but avoid fp6 crashing issues
		    // see http://blog.deconcept.com/2006/01/11/getvariable-setvariable-crash-internet-explorer-flash-6/
		    try
		    {
			    var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		    }
		    catch (e)
		    {
			    try
			    {
				    var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
				    playerVersion = new Hbm.PresentationInterface.WebControls.FlashPlayerVersion([6,0,21]);
				    axo.AllowScriptAccess = "always"; // throws if player version < 6.0.47 (thanks to Michael Williams @ Adobe for this code)
			    }
			    catch(e)
			    {
				    if (playerVersion.major == 6)
				    {
					    return playerVersion;
				    }
			    }
			    try
			    {
				    axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			    }
			    catch(e) {}
		    }
		    if (axo != null)
		    {
			    playerVersion = new Hbm.PresentationInterface.WebControls.FlashPlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));
		    }
	    }
	    return playerVersion;
    },

    get_minRequiredPlayerVersion: function()
    {
        return this._minRequiredPlayerVersion;
    },

    set_minRequiredPlayerVersion : function(value)
    {
        this._minRequiredPlayerVersion = value;
    },

    get_playerSrc : function()
    {
        return this._playerSrc;
    },

    set_playerSrc : function(value)
    {
        this._playerSrc = value;
    },

    get_flashVars : function()
    {
        return this._flashVars;
    },

    set_flashVars : function(value)
    {
        this._flashVars = value;
    },

    get_allowScriptAccess : function()
    {
        return this._allowScriptAccess;
    },

    set_allowScriptAccess : function(value)
    {
        this._allowScriptAccess = value;
    },
    
    get_width : function()
    {
        return this._width;
    },

    set_width : function(value)
    {
        this._width = value;
    },

    get_height : function()
    {
        return this._height;
    },

    set_height : function(value)
    {
        this._height = value;
    },

    get_playbackQuality : function()
    {
        return this._playbackQuality;
    },

    set_playbackQuality : function(value)
    {
        this._playbackQuality = value;
    }
}

Hbm.PresentationInterface.WebControls.FlashPlayer.registerClass('Hbm.PresentationInterface.WebControls.FlashPlayer', Sys.UI.Behavior);

Type.registerNamespace('FlashPlayer');
FlashPlayer.Resources={
"NoFlashPlayer":"This video requires Macromedia Flash Player version 8 or newer. Please click the button below to find out how to get the latest version of Flash."
};

if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();