///////////////////////////////////////////////////////////////////////////////
//
//  Silverlight.logger.js   			version 4.0.50524.0
//
//  This file is provided by Microsoft as a helper file for websites that
//  incorporate Silverlight Objects. This file is provided under the Microsoft
//  Public License available at 
//  http://code.msdn.microsoft.com/silverlightjs/Project/License.aspx.  
//  You may not use or distribute this file or the code in this file except as 
//  expressly permitted under that license.
// 
//  Copyright (c) Microsoft Corporation. All rights reserved.
//
///////////////////////////////////////////////////////////////////////////////
if (!window.Silverlight)
{ 
    window.Silverlight = { };
    Silverlight.disableAutoStartup = true;
}

var PromptFinishInstall = "";
var PromptInstall = "";
var PromptUpgrade = "";
var PromptFinishUpgrade = "";
var PromptRestart = "";
var PromptNotSupported = "";
var RedirectNotSupported = "";

//////////////////////////////////////////////////////////////////
//
// _silverlightCount:
//
// Counter of globalized event handlers
//
//////////////////////////////////////////////////////////////////
Silverlight._silverlightCount = 0;

//////////////////////////////////////////////////////////////////
//
// __onSilverlightInstalledCalled:
//
// Prevents onSilverlightInstalled from being called multiple 
// times
//
//////////////////////////////////////////////////////////////////
Silverlight.__onSilverlightInstalledCalled = false;

//////////////////////////////////////////////////////////////////
//
// fwlinkRoot:
//
// Prefix for fwlink URL's
//
//////////////////////////////////////////////////////////////////
Silverlight.fwlinkRoot='http://go2.microsoft.com/fwlink/?LinkID=';

//////////////////////////////////////////////////////////////////
//
// __installationEventFired:
//
// Ensures that only one Installation State event is fired.
//
//////////////////////////////////////////////////////////////////
Silverlight.__installationEventFired = false;

//////////////////////////////////////////////////////////////////
//  
// onGetSilverlight:
//
// Called by Silverlight.GetSilverlight to notify the page that a user
// has requested the Silverlight installer
//
//////////////////////////////////////////////////////////////////
Silverlight.onGetSilverlight = null;

//////////////////////////////////////////////////////////////////
//
// onSilverlightInstalled:
//
// Called by Silverlight.WaitForInstallCompletion when the page detects
// that Silverlight has been installed. The event handler is not called
// in upgrade scenarios.
//
//////////////////////////////////////////////////////////////////
Silverlight.onSilverlightInstalled = function () {window.location.reload(false);};

//////////////////////////////////////////////////////////////////
//
// isInstalled:
//
// Checks to see if the correct version is installed
//
//////////////////////////////////////////////////////////////////
Silverlight.isInstalled = function(version)
{
    if (version == undefined)
        version = null;
        
    var isVersionSupported = false;
    var container = null;

    try
    {
        var control = null;
        var tryNS = false;

        if (window.ActiveXObject)
        {
            try
            {
                control = new ActiveXObject('AgControl.AgControl');
                if (version === null)
                {
                    isVersionSupported = true;
                }
                else if (control.IsVersionSupported(version))
                {
                    isVersionSupported = true;
                }
                control = null;
            }
            catch (e)
            {
                tryNS = true;
            }
        }
        else
        {
            tryNS = true;
        }
        if (tryNS)
        {
            var plugin = navigator.plugins["Silverlight Plug-In"];
            if (plugin)
            {
                if (version === null)
                {
                    isVersionSupported = true;
                }
                else
                {
                    var actualVer = plugin.description;
                    if (actualVer === "1.0.30226.2")
                        actualVer = "2.0.30226.2";
                    var actualVerArray = actualVer.split(".");
                    while (actualVerArray.length > 3)
                    {
                        actualVerArray.pop();
                    }
                    while (actualVerArray.length < 4)
                    {
                        actualVerArray.push(0);
                    }
                    var reqVerArray = version.split(".");
                    while (reqVerArray.length > 4)
                    {
                        reqVerArray.pop();
                    }

                    var requiredVersionPart;
                    var actualVersionPart;
                    var index = 0;

                    do
                    {
                        requiredVersionPart = parseInt(reqVerArray[index]);
                        actualVersionPart = parseInt(actualVerArray[index]);
                        index++;
                    }
                    while (index < reqVerArray.length && requiredVersionPart === actualVersionPart);

                    if (requiredVersionPart <= actualVersionPart && !isNaN(requiredVersionPart))
                    {
                        isVersionSupported = true;
                    }
                }
            }
        }
    }
    catch (e)
    {
        isVersionSupported = false;
    }
    
    return isVersionSupported;
};
//////////////////////////////////////////////////////////////////
//
// WaitForInstallCompletion:
//
// Occasionally checks for Silverlight installation status. If it
// detects that Silverlight has been installed then it calls
// Silverlight.onSilverlightInstalled();. This is only supported
// if Silverlight was not previously installed on this computer.
//
//////////////////////////////////////////////////////////////////
Silverlight.WaitForInstallCompletion = function()
{
	if ( ! Silverlight.isBrowserRestartRequired && Silverlight.onSilverlightInstalled )

    {
        try
        {
            navigator.plugins.refresh();
        }
        catch(e)
        {
        }
        if (Silverlight.isInstalled(null) && !Silverlight.__onSilverlightInstalledCalled)
        {
            Silverlight.onSilverlightInstalled();
            Silverlight.__onSilverlightInstalledCalled = true;
        }
        else
        {
              setTimeout(Silverlight.WaitForInstallCompletion, 3000);
        }    
    }
};
//////////////////////////////////////////////////////////////////
//
// __startup:
//
// Performs startup tasks. 
//////////////////////////////////////////////////////////////////
Silverlight.__startup = function()
{

	navigator.plugins.refresh();
    Silverlight.isBrowserRestartRequired = Silverlight.isInstalled(null);
    if (!Silverlight.isBrowserRestartRequired)
    {
        Silverlight.WaitForInstallCompletion();
        if (!Silverlight.__installationEventFired)
        {
            Silverlight.onInstallRequired();
            Silverlight.__installationEventFired = true;
        }
    }
    else if (window.navigator.mimeTypes)
    {
        var mimeSL2 =   navigator.mimeTypes["application/x-silverlight-2"];
        var mimeSL2b2 = navigator.mimeTypes["application/x-silverlight-2-b2"];
        var mimeSL2b1 = navigator.mimeTypes["application/x-silverlight-2-b1"];
        var mimeHighestBeta = mimeSL2b1;
        if (mimeSL2b2)
            mimeHighestBeta = mimeSL2b2;
            
        if (!mimeSL2 && (mimeSL2b1 || mimeSL2b2))
        {
            if (!Silverlight.__installationEventFired)
            {
                Silverlight.onUpgradeRequired();
                Silverlight.__installationEventFired = true;
            }
        }
        else if (mimeSL2 && mimeHighestBeta)
        {
            if (mimeSL2.enabledPlugin &&
                mimeHighestBeta.enabledPlugin)
            {
                if (mimeSL2.enabledPlugin.description !=
                    mimeHighestBeta.enabledPlugin.description)
                {
                    if (!Silverlight.__installationEventFired)
                    {
                        Silverlight.onRestartRequired();
                        Silverlight.__installationEventFired = true;
                    }
                }
            }
        }
    }
    if (!Silverlight.disableAutoStartup)
    {
        if (window.removeEventListener)
        {
            window.removeEventListener('load', Silverlight.__startup, false);
        }
        else
        {
            window.detachEvent('onload', Silverlight.__startup);
        }
    }
};

///////////////////////////////////////////////////////////////////////////////
//
// This block wires up Silverlight.__startup to be executed once the page
// loads. This is the desired behavior for most sites. If, however, a site
// prefers to control the timing of the Silverlight.__startup call then it should
// put the following block of javascript into the webpage before this file is
// included:
//
//    <script type="text/javascript">
//        if (!window.Silverlight)
//        {
//            window.Silverlight = {};
//        }
//        Silverlight.disableAutoStartup = true;
//    </script> 
//
/////////////////////////////////////////////////////////////////////////////////

if (!Silverlight.disableAutoStartup)
{
    if (window.addEventListener)
    {
        window.addEventListener('load', Silverlight.__startup, false);
    }
    else
    {
        window.attachEvent('onload', Silverlight.__startup);
    }
}

///////////////////////////////////////////////////////////////////////////////
// createObject:
//
// Inserts a Silverlight <object> tag or installation experience into the HTML
// DOM based on the current installed state of Silverlight. 
//
/////////////////////////////////////////////////////////////////////////////////

Silverlight.createObject = function(source, parentElement, id, properties, events, initParams, userContext)
{
    var slPluginHelper = new Object();
    var slProperties = properties;
    var slEvents = events;
    
    slPluginHelper.version = slProperties.version;
    slProperties.source = source;    
    slPluginHelper.alt = slProperties.alt;
    
    //rename properties to their tag property names. For backwards compatibility
    //with Silverlight.js version 1.0
    if ( initParams )
        slProperties.initParams = initParams;
    if ( slProperties.isWindowless && !slProperties.windowless)
        slProperties.windowless = slProperties.isWindowless;
    if ( slProperties.framerate && !slProperties.maxFramerate)
        slProperties.maxFramerate = slProperties.framerate;
    if ( id && !slProperties.id)
        slProperties.id = id;
    
    // remove elements which are not to be added to the instantiation tag
    delete slProperties.ignoreBrowserVer;
    delete slProperties.inplaceInstallPrompt;
    delete slProperties.version;
    delete slProperties.isWindowless;
    delete slProperties.framerate;
    delete slProperties.data;
    delete slProperties.src;
    delete slProperties.alt;

    // detect that the correct version of Silverlight is installed, else display install

    if (Silverlight.isInstalled(slPluginHelper.version))
    {
        //move unknown events to the slProperties array
        for (var name in slEvents)
        {
            if ( slEvents[name])
            {
                if ( name == "onLoad" && typeof slEvents[name] == "function" && slEvents[name].length != 1 )
                {
                    var onLoadHandler = slEvents[name];
                    slEvents[name]=function (sender){ return onLoadHandler(document.getElementById(id), userContext, sender)};
                }
                var handlerName = Silverlight.__getHandlerName(slEvents[name]);
                if ( handlerName != null )
                {
                    slProperties[name] = handlerName;
                    slEvents[name] = null;
                }
                else
                {
                    throw "typeof events."+name+" must be 'function' or 'string'";
                }
            }
        }
        slPluginHTML = Silverlight.buildHTML(slProperties);
    }
    //The control could not be instantiated. Show the installation prompt
    else 
    {
        slPluginHTML = Silverlight.buildPromptHTML(slPluginHelper);
    }

    // insert or return the HTML
    if(parentElement)
    {
        parentElement.innerHTML = slPluginHTML;
    }
    else
    {
        return slPluginHTML;
    }

};

///////////////////////////////////////////////////////////////////////////////
//
//  buildHTML:
//
//  create HTML that instantiates the control
//
///////////////////////////////////////////////////////////////////////////////
Silverlight.buildHTML = function( slProperties)
{
    var htmlBuilder = [];

    htmlBuilder.push('<object type=\"application/x-silverlight-2\" data="data:application/x-silverlight-2,"');
    if ( slProperties.id != null )
    {
        htmlBuilder.push(' id="' + Silverlight.HtmlAttributeEncode(slProperties.id) + '"');
    }
    if ( slProperties.width != null )
    {
        htmlBuilder.push(' width="' + slProperties.width+ '"');
    }
    if ( slProperties.height != null )
    {
        htmlBuilder.push(' height="' + slProperties.height + '"');
    }
    htmlBuilder.push(' >');
    
    delete slProperties.id;
    delete slProperties.width;
    delete slProperties.height;
    
    for (var name in slProperties)
    {
        if (slProperties[name])
        {
            htmlBuilder.push('<param name="'+Silverlight.HtmlAttributeEncode(name)+'" value="'+Silverlight.HtmlAttributeEncode(slProperties[name])+'" />');
        }
    }
    htmlBuilder.push('<\/object>');
    return htmlBuilder.join('');
};



//////////////////////////////////////////////////////////////////
//
// createObjectEx:
//
// takes a single parameter of all createObject 
// parameters enclosed in {}
//
//////////////////////////////////////////////////////////////////

Silverlight.createObjectEx = function(params)
{
    var parameters = params;
    var html = Silverlight.createObject(parameters.source, parameters.parentElement, parameters.id, parameters.properties, parameters.events, parameters.initParams, parameters.context);
    if (parameters.parentElement == null)
    {
        return html;
    }
};

///////////////////////////////////////////////////////////////////////////////////////////////
//
// buildPromptHTML
//
// Builds the HTML to prompt the user to download and install Silverlight
//
///////////////////////////////////////////////////////////////////////////////////////////////
Silverlight.buildPromptHTML = function(slPluginHelper)
{
    var slPluginHTML = "";
    var urlRoot = Silverlight.fwlinkRoot;
    var version = slPluginHelper.version ;
    if ( slPluginHelper.alt )
    {
        slPluginHTML = slPluginHelper.alt;
    }
    else
    {
        if (! version)
        {
            version="";
        }
        slPluginHTML = "<a href='javascript:Silverlight.getSilverlight(\"{1}\");' style='text-decoration: none;'><img src='{2}' alt='Get Microsoft Silverlight' style='border-style: none'/></a>";
        slPluginHTML = slPluginHTML.replace('{1}', version);
        slPluginHTML = slPluginHTML.replace('{2}', urlRoot + '108181');
    }
    
    return slPluginHTML;
};

///////////////////////////////////////////////////////////////////////////////////////////////
//
// getSilverlight:
//
// Navigates the browser to the appropriate Silverlight installer
//
///////////////////////////////////////////////////////////////////////////////////////////////
Silverlight.getSilverlight = function(version)
{
    if (Silverlight.onGetSilverlight )
    {
        Silverlight.onGetSilverlight();
    }
    
    var shortVer = "";
    var reqVerArray = String(version).split(".");
    if (reqVerArray.length > 1)
    {
        var majorNum = parseInt(reqVerArray[0] );
        if ( isNaN(majorNum) || majorNum < 2 )
        {
            shortVer = "1.0";
        }
        else
        {
            shortVer = reqVerArray[0]+'.'+reqVerArray[1];
        }
    }
    
    var verArg = "";
    
    if (shortVer.match(/^\d+\056\d+$/) )
    {
        verArg = "&v="+shortVer;
    }
    
    Silverlight.followFWLink("149156" + verArg);
};


///////////////////////////////////////////////////////////////////////////////////////////////
//
// followFWLink:
//
// Navigates to a url based on fwlinkid
//
///////////////////////////////////////////////////////////////////////////////////////////////
Silverlight.followFWLink = function(linkid)
{
    top.location=Silverlight.fwlinkRoot+String(linkid);
};

///////////////////////////////////////////////////////////////////////////////////////////////
//
// HtmlAttributeEncode:
//
// Encodes special characters in input strings as charcodes
//
///////////////////////////////////////////////////////////////////////////////////////////////
Silverlight.HtmlAttributeEncode = function( strInput )
{
      var c;
      var retVal = '';

    if(strInput == null)
      {
          return null;
    }
      
      for(var cnt = 0; cnt < strInput.length; cnt++)
      {
            c = strInput.charCodeAt(cnt);

            if (( ( c > 96 ) && ( c < 123 ) ) ||
                  ( ( c > 64 ) && ( c < 91 ) ) ||
                  ( ( c > 43 ) && ( c < 58 ) && (c!=47)) ||
                  ( c == 95 ))
            {
                  retVal = retVal + String.fromCharCode(c);
            }
            else
            {
                  retVal = retVal + '&#' + c + ';';
            }
      }
      
      return retVal;
};
///////////////////////////////////////////////////////////////////////////////
//
//  default_error_handler:
//
//  Default error handling function 
//
///////////////////////////////////////////////////////////////////////////////

Silverlight.default_error_handler = function (sender, args)
{
    var iErrorCode;
    var errorType = args.ErrorType;

    iErrorCode = args.ErrorCode;

    var errMsg = "\nSilverlight error message     \n" ;

    errMsg += "ErrorCode: "+ iErrorCode + "\n";


    errMsg += "ErrorType: " + errorType + "       \n";
    errMsg += "Message: " + args.ErrorMessage + "     \n";

    if (errorType == "ParserError")
    {
        errMsg += "XamlFile: " + args.xamlFile + "     \n";
        errMsg += "Line: " + args.lineNumber + "     \n";
        errMsg += "Position: " + args.charPosition + "     \n";
    }
    else if (errorType == "RuntimeError")
    {
        if (args.lineNumber != 0)
        {
            errMsg += "Line: " + args.lineNumber + "     \n";
            errMsg += "Position: " +  args.charPosition + "     \n";
        }
        errMsg += "MethodName: " + args.methodName + "     \n";
    }
    alert (errMsg);
};

///////////////////////////////////////////////////////////////////////////////////////////////
//
// __cleanup:
//
// Releases event handler resources when the page is unloaded
//
///////////////////////////////////////////////////////////////////////////////////////////////
Silverlight.__cleanup = function ()
{
    for (var i = Silverlight._silverlightCount - 1; i >= 0; i--) {
        window['__slEvent' + i] = null;
    }
    Silverlight._silverlightCount = 0;
    if (window.removeEventListener) { 
       window.removeEventListener('unload', Silverlight.__cleanup , false);
    }
    else { 
        window.detachEvent('onunload', Silverlight.__cleanup );
    }
};

///////////////////////////////////////////////////////////////////////////////////////////////
//
// __getHandlerName:
//
// Generates named event handlers for delegates.
//
///////////////////////////////////////////////////////////////////////////////////////////////
Silverlight.__getHandlerName = function (handler)
{
    var handlerName = "";
    if ( typeof handler == "string")
    {
        handlerName = handler;
    }
    else if ( typeof handler == "function" )
    {
        if (Silverlight._silverlightCount == 0)
        {
            if (window.addEventListener) 
            {
                window.addEventListener('unload', Silverlight.__cleanup , false);
            }
            else 
            {
                window.attachEvent('onunload', Silverlight.__cleanup );
            }
        }
        var count = Silverlight._silverlightCount++;
        handlerName = "__slEvent"+count;
        
        window[handlerName]=handler;
    }
    else
    {
        handlerName = null;
    }
    return handlerName;
};
//////////////////////////////////////////////////////////////////
//  
// onRequiredVersionAvailable:
//
// Called by version  verification control to notify the page that
// an appropriate build of Silverlight is available. The page 
// should respond by injecting the appropriate Silverlight control
//
//////////////////////////////////////////////////////////////////
Silverlight.onRequiredVersionAvailable = function() 
{
};
//////////////////////////////////////////////////////////////////
//  
// onRestartRequired:
//
// Called by version verification control to notify the page that
// an appropriate build of Silverlight is installed but not loaded. 
// The page should respond by injecting a clear and visible 
// "Thanks for installing. Please restart your browser and return
// to mysite.com" or equivalent into the browser DOM
//
//////////////////////////////////////////////////////////////////
//Silverlight.onRestartRequired = function() 
//{
//};
//////////////////////////////////////////////////////////////////
//  
// onUpgradeRequired:
//
// Called by version verification control to notify the page that
// Silverlight must be upgraded. The page should respond by 
// injecting a clear, visible, and actionable upgrade message into
// the DOM. The message must inform the user that they need to 
// upgrade Silverlight to use the page. They are already somewhat
// familiar with the Silverlight product when they encounter this.
// Silverlight should be mentioned so the user expects to see that
// string in the installer UI. However, the Silverlight-powered
// application should be the focus of the solicitation. The user
// wants the app. Silverlight is a means to the app.
// 
// The upgrade solicitation will have a button that directs 
// the user to the Silverlight installer. Upon click the button
// should both kick off a download of the installer URL and replace
// the Upgrade text with "Thanks for downloading. When the upgarde
// is complete please restart your browser and return to 
// mysite.com" or equivalent.
//
// Note: For a more interesting upgrade UX we can use Silverlight
// 1.0-style XAML for this upgrade experience. Contact PiotrP for
// details.
//
//////////////////////////////////////////////////////////////////
Silverlight.onUpgradeRequired = function() 
{
};
//////////////////////////////////////////////////////////////////
//  
// onInstallRequired:
//
// Called by Silverlight.checkInstallStatus to notify the page
// that Silverlight has not been installed by this user.
// The page should respond by 
// injecting a clear, visible, and actionable upgrade message into
// the DOM. The message must inform the user that they need to 
// download and install components needed to use the page. 
// Silverlight should be mentioned so the user expects to see that
// string in the installer UI. However, the Silverlight-powered
// application should be the focus of the solicitation. The user
// wants the app. Silverlight is a means to the app.
// 
// The installation solicitation will have a button that directs 
// the user to the Silverlight installer. Upon click the button
// should both kick off a download of the installer URL and replace
// the Upgrade text with "Thanks for downloading. When installation
// is complete you may need to refresh the page to view this 
// content" or equivalent.
//
//////////////////////////////////////////////////////////////////
Silverlight.onInstallRequired = function() 
{
};

//////////////////////////////////////////////////////////////////
//  
// IsVersionAvailableOnError:
//
// This function should be called at the beginning of a web page's
// Silverlight error handler. It will determine if the required 
// version of Silverlight is installed and available in the 
// current process.
//
// During its execution the function will trigger one of the 
// Silverlight installation state events, if appropriate.
//
// Sender and Args should be passed through from  the calling
// onError handler's parameters. 
//
// The associated Sivlerlight <object> tag must have
// minRuntimeVersion set and should have autoUpgrade set to false.
//
//////////////////////////////////////////////////////////////////
Silverlight.IsVersionAvailableOnError = function(sender, args)
{
    var retVal = false;
    try
    {
        if (args.ErrorCode == 8001 && !Silverlight.__installationEventFired)
        {
            Silverlight.onUpgradeRequired();
            Silverlight.__installationEventFired = true;
        }
        else if (args.ErrorCode == 8002 && !Silverlight.__installationEventFired)
        {
            Silverlight.onRestartRequired();
            Silverlight.__installationEventFired = true;
        }
        // this handles upgrades from 1.0. That control did not
        // understand the minRuntimeVerison parameter. It also
        // did not know how to parse XAP files, so would throw
        // Parse Error (5014). A Beta 2 control may throw 2106
        else if (args.ErrorCode == 5014 || args.ErrorCode == 2106)
        {
            if (Silverlight.__verifySilverlight2UpgradeSuccess(args.getHost()))
            {
                retVal = true;
            }
        }
        else
        {
            retVal = true;
        }
    }
    catch (e)
    {
    }
    return retVal;
};
//////////////////////////////////////////////////////////////////
//  
// IsVersionAvailableOnLoad:
//
// This function should be called at the beginning of a web page's
// Silverlight onLoad handler. It will determine if the required 
// version of Silverlight is installed and available in the 
// current process.
//
// During its execution the function will trigger one of the 
// Silverlight installation state events, if appropriate.
//
// Sender should be passed through from  the calling
// onError handler's parameters. 
//
// The associated Sivlerlight <object> tag must have
// minRuntimeVersion set and should have autoUpgrade set to false.
//
//////////////////////////////////////////////////////////////////
Silverlight.IsVersionAvailableOnLoad = function(sender)
{
    var retVal = false;
    try
    {
        if (Silverlight.__verifySilverlight2UpgradeSuccess(sender.getHost()))
        {
            retVal = true;
        }
    }
    catch (e)
    {
    }
    return retVal;
};
//////////////////////////////////////////////////////////////////
//
// __verifySilverlight2UpgradeSuccess:
//
// This internal function helps identify installation state by
// taking advantage of behavioral differences between the
// 1.0 and 2.0 releases of Silverlight. 
//
//////////////////////////////////////////////////////////////////
Silverlight.__verifySilverlight2UpgradeSuccess = function(host)
{
    var retVal = false;
    var version = SLS.minSlVersion.split(".")[0] + "." + SLS.minSlVersion.split(".")[1] + "." + SLS.minSlVersion.split(".")[2]; 
    var installationEvent = null;

    try
    {
        if (host.IsVersionSupported(version + ".99"))
        {
            installationEvent = Silverlight.onRequiredVersionAvailable;
            retVal = true;
        }
        else if (host.IsVersionSupported(version + ".0"))
        {
            installationEvent = Silverlight.onRestartRequired;
        }
        else
        {
            installationEvent = Silverlight.onUpgradeRequired;
        }

        if (installationEvent && !Silverlight.__installationEventFired)
        {
            installationEvent();
            Silverlight.__installationEventFired = true;
        }
    }
    catch (e)
    {
    }
    return retVal;
};

// Check Silverlight version
Silverlight.detectSilverlightVersion = function() {
	var container = null;
	var silverlightVersion;

	try {
		var control = null;

		try {
			control = new ActiveXObject('AgControl.AgControl');
		}
		catch (z) {
			if ( navigator.plugins["Silverlight Plug-In"] )
			{
				container = document.createElement('div');
				document.body.appendChild(container);
				container.innerHTML= '<embed type="application/x-silverlight" />';
				control = container.childNodes[0];
			}
		}		
		if (control.Settings) {
			try {
				silverlightVersion = control.Settings.version;
			}
			catch (z) {
			}
		}
// Use hard-coded version numbers to test installed version
// ToDo: make this a web lookup for latest version number list
		var slVers=new Array(
			"4.0.50524.0",  // 4 GDR0
			"4.0.50401.0",	// 4 RTW
			"4.0.50303.0",	// 4 RC
			"4.0.41108.0",  // 4 Beta 1 
			"3.0.50106.0",  // 3 GDR 3
			"3.0.40818.0",  // 3 GDR 2
			"3.0.40723.0",  // 3 GDR 1
			"3.0.40624.0",	// 3 RTW
			"3.0.40307.0",
			"2.0.40115.0",
			"2.0.31005.0",
			"2.0.30523.9",
			"2.0.30523.8",
			"2.0.30523.6",
			"2.0.30226.2",
			"1.0.30715.0",
			"1.0.30401.0",
			"1.0.30109.0",
			"1.0.21115.0",
			"1.1.20926.0",
			"1.0.20816"
			);
		if (!silverlightVersion) {
			for (i in slVers) {
				if (control.IsVersionSupported(slVers[i])) {
					silverlightVersion = slVers[i];
					break;
				} 
			}
		}
// If it falls through the hard-coded test then itterate through possible version numbers		
		if (!silverlightVersion)
		{
			var major = 0;
			var minor = 0;
			var revision = 0;
			var build = 0;
			
			var buildVersionString = function(versionNumbers) {
				var versionString = "";
				for (var l = 0; l < versionNumbers.length; ++l) {
					versionString += versionNumbers[l];
					if (l != versionNumbers.length - 1)
						versionString += ".";
				}
				return versionString;
			}
			
			var versionNumbers = [0,0,0,0];
			for(var i = 0; i < versionNumbers.length; ++i) {
				for (var incrementor = 0; incrementor < 100000; ++incrementor) {
					versionNumbers[i] = incrementor;

					if (!control.IsVersionSupported(buildVersionString(versionNumbers))) {
						versionNumbers[i] = incrementor - 1;
						break;
					} 
				}
			}
			
			silverlightVersion = buildVersionString(versionNumbers);
		}


		control = null; 
	}
	catch (e) {
	}
	if (container) {
		document.body.removeChild(container);
	}
	
	//if (!silverlightVersion)
	//	silverlightVersion = "Not installed!";
	return silverlightVersion;
}


// Logger code

if (!window.SLS)
	window.SLS = {};

SLS.logCount = 0;

SLS.statusShowInstall = "1"; // install screen shown to user
SLS.statusShowUpgrade = "2"; // upgrade screen show to user
SLS.statusShowUnsupported = "3"; // unsupported platform shown to user (eg PPC Mac)
SLS.statusShowRestart = "4"; // Show "restart required" after upgrade
SLS.statusChooseInstall = "5"; // user chose to install
SLS.statusChooseUpgrade = "6"; // user chose to upgrade
SLS.statusChooseReject = "7"; // user selected a "no thanks" option
SLS.statusChooseAbandon = "8"; // user abandoned (navigate away / close browser)

SLS.statusSuccessInstall = "10"; // successful installation
SLS.statusSuccessUpgrade = "11"; // successful upgrade

// deployment settings
SLS.hqPlayerMsLogDelay = 1250;
SLS.hqPlayerErrorHandler = function(source, error) { alert("Oops! An unexpected error occurred.\n\nSource: " + source + "\nDescription: " + error.description); };

SLS.entryFlowCookieName = function() {
	return SLS.appName + "entryFlow";
}

SLS.appIdCookieName = function() {
	return SLS.appName + "appId";
}

SLS.installFlowCookieName = function() {
	return SLS.appName + "installFlow";
}

// common functions
SLS.getClientState = function() {
	if (!SLS.clientState) {
		var o = {};
		o.uid = SLS.getUid();
		o.isLogEntryFlowCookieDefined = SLS.isCookieDefined(SLS.entryFlowCookieName(), "1");
		o.isLogInstallFlowCookieDefined = SLS.isCookieDefined(SLS.installFlowCookieName(), SLS.statusChooseInstall) | SLS.isCookieDefined(SLS.installFlowCookieName(), SLS.statusChooseUpgrade);
		o.isSlVersionInstalled = Silverlight.isInstalled(SLS.minSlVersion);
		o.isSlVersionSupported = Silverlight.supportedUserAgent(SLS.minSlVersion.substring(0, 1).concat(".0"));
		o.isSlUpgradeRequired = !o.isSlVersionInstalled && Silverlight.isInstalled(null);
		SLS.clientState = o;
	}

	return SLS.clientState;
};

SLS.onPlayerPageBeforeUnload = function() {
	// log abandoned install on badge
	if (SLS.installState == SLS.statusShowInstall || SLS.installState == SLS.statusShowUpgrade) {
		SLS.logInstallFlow(SLS.statusChooseAbandon);
	}

	// log app event
	if (SLS.hqAppSessionId)
		alert("logAppEvent");
		//SLS.logAppEvent();

	// force delay to allow logging to complete
	var date = new Date();
	while (new Date() - date < SLS.hqPlayerMsLogDelay) {}
};


SLS.isCookieDefined = function(name, value) {
	var cookieValue = SLS.getCookieValue(name);
	return SLS.equals(cookieValue, value);
};

SLS.getCookieValue = function(name, caseSensitive) {
	var cookie = document.cookie;

	if (cookie && cookie.length > 0) {
		var items = cookie.split(";");
		return SLS.getParamValue(items, name, caseSensitive);
	}
};

SLS.getParamValue = function(items, name, caseSensitive) {
	name = name.toString();
	for (i = 0; i < items.length; i++) {
		var item = items[i].split("=");

		if (SLS.equals(SLS.trim(unescape(item[0])), name, caseSensitive))
			return item[1] ? unescape(item[1]) : item[1];
	}
};

SLS.equals = function(s1, s2, caseSensitive) {
	if (s1 == s2)
		return true;
	else if (s1 == null || s2 == null || caseSensitive)
		return false;
	else
		return s1.toLowerCase() == s2.toLowerCase();
};

SLS.trim = function(s) {
	return s.replace(/^\s+|\s+$/g, "");
};

SLS.setCookie = function(name, value, hours) {
	if (hours) {
		var expDate = new Date(new Date().getTime() + hours * 60 * 60 * 1000);
		document.cookie = name + "=" + value + ";expires=" + expDate.toGMTString();
	}
	else {
		document.cookie = name + "=" + value;
	}
};

SLS.clearCookie = function(name) {
	document.cookie = name + "=;expires=Thu, 01-Jan-1970 00:00:01 GMT";
};

SLS.getUid = function() {
	var uid = SLS.getCookieValue(SLS.appIdCookieName());

	if (!uid) {
		uid = guid(); // Math.uuid();
		SLS.setCookie(SLS.appIdCookieName(), uid);
	}

	return uid;
};

SLS.getParamValue = function(items, name, caseSensitive) {
	for (i = 0; i < items.length; i++) {
		var item = items[i].split("=");

		if (SLS.equals(SLS.trim(unescape(item[0])), name, caseSensitive))
			return item[1] ? unescape(item[1]) : item[1];
	}
};

SLS.appendScript = function(index, src) {
	try {
		var script = document.createElement("script");
		script.id = "script" + index;
		script.src = src;
		script.type = "text/javascript";

		var head = document.getElementsByTagName("head")[0];
		head.appendChild(script);
	}
	catch (e) {
		SLS.hqPlayerErrorHandler("SLS.appendScript", e);
	}
};

SLS.removeScript = function(index) {
	try {
		var script = document.getElementById("script" + index);
		var head = document.getElementsByTagName("head")[0];
		head.removeChild(script);
	}
	catch (e) {
		SLS.hqPlayerErrorHandler("SLS.removeScript", e);
	}
};

SLS.setAppSessionId = function(id) {
	SLS.hqAppSessionId = id;
};

//SLS.logAppEvent = function() {
//	try {
//		// svc parameters
//		var u = SLS.hqAppSessionId;
//		var i = SLS.logCount++;
//		var t = new Date().getTime();
//
//		// append script tag
//		var src = SLS.hqPlayerMsLogUri + "/appevent.svc/parms?u=" + u + "&i=" + i + '&t=' + t + '&an=' + SLS.appName + '&av=' + SLS.appVersion;
//		SLS.appendScript(i, src);
//	}
//	catch (e) {
//		SLS.hqPlayerErrorHandler("SLS.logAppEvent", e);
//	}
//};

SLS.logEntryFlow = function() {
	try {
		var state = SLS.getClientState();

		if (!state.isLogEntryFlowCookieDefined) {
			// set the session cookie to avoid multiple calls
			SLS.setCookie(SLS.entryFlowCookieName(), "1");

			if (SLS.logEntryflow) {
				// svc parameters
				var sls, sle, p;
				var u = state.uid;
				var r = encodeURIComponent(document.referrer);
				var i = SLS.logCount++;
				var t = new Date().getTime();

				// Silverlight install state
				if (state.isSlVersionInstalled)
					sls = 2;
				else if (state.isSlUpgradeRequired)
					sls = 1;
				else
					sls = 0;

				// Silverlight support state
				if (state.isSlVersionSupported)
					sle = 1;
				else if (SLBrowser == "Chrome" && OperatingSystem == "Windows")
					sle = 1;	// treating this as a fully supported platform
				else
					sle = 0;
					
				// append script tag
				//var src = SLS.hqPlayerMsLogUri + "/entryflow.svc/parms?u=" + u + "&s=" + sls + "&o=" + sle + "&i=" + i + '&t=' + t + '&an=' + SLS.appName + '&av=' + SLS.appVersion + '&r=' +r;
				var src = "http://silf.cloudapp.net/silf.aspx?e=e&u=" + u + "&s=" + sls + "&o=" + sle + "&i=" + i + '&t=' + t + '&an=' + SLS.appName + '&av=' + SLS.appVersion + '&r=' +r;
				// agLog version
				//var src = SLS.hqPlayerMsLogUri + "/aglog.aspx?t=e&AppID=" + SLS.appName + "&AppVer=" + SLS.appVersion + "&sls=" + sls + "&sle=" + sle + "&u=" +u + "&seq=" + i + "&br=" + SLBrowser + "&os=" + OperatingSystem;
				
				SLS.appendScript(i, src);
			}
		}
	}
	catch (e) {
		SLS.hqPlayerErrorHandler("SLS.logEntryFlow", e);
	}
};

SLS.logInstallFlow = function(action) {
	SLS.installState = action;
	try {
		// attempting to run silverlight install
		if (action == SLS.statusChooseInstall || action == SLS.statusChooseUpgrade)
			SLS.setCookie(SLS.installFlowCookieName(), action, 1);
		// install success
		else if (action == SLS.statusSuccessInstall || action == SLS.statusSuccessUpgrade || action == SLS.statusChooseReject || action == SLS.statusChooseAbandon)
			SLS.clearCookie(SLS.installFlowCookieName());

		var state = SLS.getClientState();

		// make the uid stick around for up to 24 hours if we're in an install cycle
		if (action == SLS.statusChooseReject || action == SLS.statusChooseAbandon) {
		} else {
			SLS.setCookie(SLS.appIdCookieName(), state.uid,24);
		}
		if (SLS.logInstall) {
			// svc parameters
			var u = state.uid;
			var a = action;
			var i = SLS.logCount++;
			var t = new Date().getTime();

			// append script tag
			// var src = SLS.hqPlayerMsLogUri + "/install.svc/parms?u=" + u + "&a=" + a + "&i=" + i + '&t=' + t + '&an=' + SLS.appName + '&av=' + SLS.appVersion;
			var src = "http://silf.cloudapp.net/silf.aspx?e=i&u=" + u + "&a=" + a + "&i=" + i + '&t=' + t + '&an=' + SLS.appName + '&av=' + SLS.appVersion; 			
			// aglog version
			//var src = SLS.hqPlayerMsLogUri + "/aglog.aspx?t=i&AppID=" + SLS.appName + "&AppVer=" + SLS.appVersion + "&a=" + a + "&u=" +u + "&seq=" + i + "&br=" + SLBrowser + "&os=" + OperatingSystem;

			SLS.appendScript(i, src);
		}
	}
	catch (e) {
		SLS.hqPlayerErrorHandler("SLS.logInstallFlow", e);
	}
};

function onLauncherPageLoad() {
// if the object we're tracking exists on the page
// initialize the scripts
// otherwise just exit
	if (document.getElementById(SilverlightControlHost)) {

		// ensure that if browser is closed/page left it gets tracked
		window.onbeforeunload = SLS.onPlayerPageBeforeUnload;

		// would be good to track install version at this point but need to resolve perf issue
		SLS.logEntryFlow();
 
		Silverlight.__startup()
	}
} 

function onSilverlightError(sender, args) {
	// 8001 code for upgrade required
	// 8002 code for restart required
	// 5014 code for improper installation (also fires if sl1.0 is installed)
	if ((args.ErrorCode == 8001) || (args.ErrorCode == 5014)) {
	// ignore as should be captured via silverlight.js events
	} else if (args.ErrorCode == 8002) {
		Silverlight.onRestartRequired()
	} else {
		alert("Debug:  Error Code = " + args.ErrorCode);
	}
}

function onSilverlightLoad(sender) {

	Silverlight.IsVersionAvailableOnLoad(sender);

	var state = SLS.getClientState();

	if (state.isSlVersionInstalled) {
		// log successful install
		if (state.isLogInstallFlowCookieDefined) {
			if (SLS.getCookieValue(SLS.installFlowCookieName()) == SLS.statusChooseInstall) {
				SLS.logInstallFlow(SLS.statusSuccessInstall);
			}
			if (SLS.getCookieValue(SLS.installFlowCookieName()) == SLS.statusChooseUpgrade) {
				SLS.logInstallFlow(SLS.statusSuccessUpgrade);
			}
		}
	}
}

function showSlateImageLoaded(obj) {
// Slate image has reloaded (so we have it in cache) and force a re-render of the whole element
	obj.onLoad = "";
	p=document.getElementById("silfdiv")
	pclone = p.cloneNode(true)
	document.getElementById(SilverlightControlHost).replaceChild(pclone, p)
}
function showSlate(slate) {
	if (SLS.showSlates) {
		document.getElementById(SilverlightControlHost).innerHTML = "<div id='silfdiv'>"+slate+"</div>";
	
		// find all images in the slate, and attach an onload event so we can force a display		
		var images = document.getElementById(SilverlightControlHost).getElementsByTagName("img");
		for(var j=0; j<images.length; j++){
			var b = images[j];
			images[j].onLoad=setTimeout(function(){showSlateImageLoaded(b)}, 3000);
		}
		
	}
}

Silverlight.onRestartRequired = function() {
	SLS.logInstallFlow(SLS.statusShowRestart);
	showSlate(PromptRestart);
};

Silverlight.onUpgradeRequired = function() {
	SLS.logInstallFlow(SLS.statusShowUpgrade);
	if (CheckSupported(PromptUpgrade)) {
	}
};

Silverlight.onInstallRequired = function() {
	SLS.logInstallFlow(SLS.statusShowInstall);
	if (CheckSupported(PromptInstall)) {
	}
};

function UpgradeClicked() {
	SLS.logInstallFlow(SLS.statusChooseUpgrade);
	showSlate(PromptFinishUpgrade);
	// if user has Chrome on Windows link directly to exe (currently SL3 handler reports unknown platform but we handle the message via slate)
	if (SLBrowser == "Chrome" && OperatingSystem == "Windows" && SLS.minSlVersion.split(".")[0] == "3") {
		Silverlight.followFWLink("156091");
	} else {
		Silverlight.followFWLink("149156");	// only need the &v to force an earlier version, default to latest
	}
	//window.location = "http://go.microsoft.com/fwlink/?LinkID=149156&v=" + SLS.minSlVersion;

}

function InstallClicked() {
	SLS.logInstallFlow(SLS.statusChooseInstall);
	showSlate(PromptFinishInstall);
	// if user has Chrome on Windows link directly to exe (currently SL3 handler reports unknown platform but we handle the message via slate)
	if (SLBrowser == "Chrome" && OperatingSystem == "Windows" && SLS.minSlVersion.split(".")[0] == "3") {
		Silverlight.followFWLink("156091");
	} else {
		Silverlight.followFWLink("149156"); // only need the &v to force an earlier version, defaults to latest
	}
	//window.location = "http://go.microsoft.com/fwlink/?LinkID=149156&v=" + SLS.minSlVersion;
}

function CheckSupported(msg) {
// check to ensure current version is supported (tests the 3.0 for instance)

	if (Silverlight.supportedUserAgent(SLS.minSlVersion.split(".")[0] + "." + SLS.minSlVersion.split(".")[1])) {
	// Do nothing
		showSlate(msg);
		return(true);
	} else if (SLBrowser == "Chrome" && OperatingSystem == "Windows") {
		// alert that Chrome isn't fully tested, but allow install
		// SLS.logInstallFlow(6); <-- we track this from the entries table
		if ((typeof(PromptNotTested) != "undefined") && (PromptNotTested != "")) {
			msg = msg.replace(/<!--warn-->/i, PromptNotTested);
		}
		showSlate(msg);
		if ((typeof(WarningNotTested) != "undefined") && (WarningNotTested != "")) {
			alert(WarningNotTested);
		}
		return(true);
	} else {
		SLS.logInstallFlow(SLS.statusShowUnsupported);
		if (RedirectNotSupported != "") {
			window.location = RedirectNotSupported;
		} else {
			showSlate(PromptNotSupported);
		}
		return(false);
	}
}

///
//	 JG:  8/5/09
//   Exposing OS property
//	 EC:  8/24/09
//   Exposing Browser property
//   JC:  10/14/09
//   Adding Chrome to list of returned browsers (but not supported)
//   JC:  11/12/09
//   Added support for 3.0, 4.0 as supported versions
///
var OperatingSystem;
var SLBrowser;

///////////////////////////////////////////////////////////////////////////////
//
//  Silverlight.supportedUserAgent.js   	version 2.0.40211.0
//
//  This file is provided by Microsoft as a helper file for websites that
//  incorporate Silverlight Objects. This file is provided under the Microsoft
//  Public License available at 
//  http://code.msdn.microsoft.com/SLsupportedUA/Project/License.aspx.  
//  You may not use or distribute this file or the code in this file except as 
//  expressly permitted under that license.
// 
//  Copyright (c) Microsoft Corporation. All rights reserved.
//
///////////////////////////////////////////////////////////////////////////////


///////////////////////////////////////////////////////////////////////////////
//
// supportedUserAgent:
//
// NOTE: This function is strongly tied to current implementations of web 
// browsers. The implementation of this function will change over time to 
// account for new Web browser developments. Visit 
// http://code.msdn.microsoft.com/SLsupportedUA often to ensure that you have
// the latest version.
//
// Determines if the client browser is supported by Silverlight. 
//
//  params:
//   version [string] 
//         determines if a particular version of Silverlight supports
//         this browser. Acceptable values are "1.0" and "2.0" etc
//   userAgent [string]
//         optional. User Agent string to be analized. If null then the
//         current browsers user agent string will be used.
//
//  return value: boolean
//
///////////////////////////////////////////////////////////////////////////////
Silverlight.supportedUserAgent = function(version, userAgent) {
	try {
		var ua = null;

		if (userAgent) {
			ua = userAgent;
		}
		else {
			ua = window.navigator.userAgent;
		}

		var slua = { OS: 'Unsupported', Browser: 'Unsupported' };

		//Silverlight does not support pre-Windows NT platforms
		if (ua.indexOf('Windows NT') >= 0 || ua.indexOf('Mozilla/4.0 (compatible; MSIE 6.0)') >= 0) {
			slua.OS = 'Windows';
		}
		else if (ua.indexOf('PPC Mac OS X') >= 0) {
			slua.OS = 'MacPPC';
		}
		else if (ua.indexOf('Intel Mac OS X') >= 0) {
			slua.OS = 'MacIntel';
		}
		else if (ua.indexOf('Linux') >= 0) {
			slua.OS = 'Linux';
		}

		OperatingSystem = slua.OS;
		if (slua.OS != 'Unsupported') {
			if (ua.indexOf('MSIE') >= 0) {
				if (navigator.userAgent.indexOf('Win64') == -1) {
					if (parseInt(ua.split('MSIE')[1]) >= 6) {
						slua.Browser = 'MSIE';
					}
				}
			}
			else if (ua.indexOf('Firefox') >= 0) {
				var versionArr = ua.split('Firefox/')[1].split('.');
				var major = parseInt(versionArr[0]);
				if (major >= 2) {
					slua.Browser = 'Firefox';
				}
				else {
					var minor = parseInt(versionArr[1]);
					if ((major == 1) && (minor >= 5)) {
						slua.Browser = 'Firefox';
					}
				}
			}

			else if (ua.indexOf('Chrome') >= 0) {
				slua.Browser = 'Chrome';
			}

			else if (ua.indexOf('Safari') >= 0) {
				slua.Browser = 'Safari';
			}

		}
		
		SLBrowser = slua.Browser;
		
		//detect all unsupported platform combinations (IE on Mac, Safari on Win)
		var supUA = (!(slua.OS == 'Unsupported' ||                             //Unsupported OS
                            slua.Browser == 'Unsupported' ||                        //Unsupported Browser
                            (slua.OS == 'Windows' && slua.Browser == 'Safari') ||   //Safari is not supported on Windows
                            (slua.OS.indexOf('Mac') >= 0 && slua.Browser == 'MSIE') ||   //IE is not supported on Mac
							(slua.Browser == "Chrome")
                                ));

		if ((slua.OS == 'MacPPC') && ((version == '2.0') || (version == '3.0') || (version == '4.0'))) {
			//add PPC to unsupported list if version > 1.0
			return ((supUA && (slua.OS != 'MacPPC')));
		}

		if ((slua.OS != 'Linux') && ((version == '1.0') || (version == '2.0'))) {
			//add Linux to unsupported list if version < 3.0
			return ((supUA && (slua.OS != 'Linux')));
		}
		if (version == '1.0') {
			//add win2k to unsupported list
			return (supUA && (ua.indexOf('Windows NT 5.0') < 0));
		}
		// return what we have
		return (supUA);

	}
	catch (e) {
		return false;
	}
}

function guid() { // http://www.ietf.org/rfc/rfc4122.txt section 4.4
	return 'aaaaaaaa-aaaa-4aaa-baaa-aaaaaaaaaaaa'.replace(/[ab]/g, function(ch) { 
		var digit = Math.random()*16|0, newch = ch == 'a' ? digit : (digit&0x3|0x8); 
		return newch.toString(16); 
		}).toUpperCase();
}
