﻿//! 
//!  PreviewXaml.debug.js                                            for Silverlight version 1.0
//!
//!  This file is provided by Microsoft as a helper file for websites that
//!  incorporate Silverlight Objects. This file is provided under the ASP.NET Futures 
//!  license available at http://go.microsoft.com/fwlink/?LinkId=95072.  
//!  You may not use or distribute this file or the code in this file except as 
//!  expressly permitted under that license.
//! 
//!  Copyright (c) 2007 Microsoft Corporation. All rights reserved.
//! 
Type.registerNamespace('Sys.Preview.UI.Xaml');

Sys.Preview.UI.Xaml.scriptVersion = "1.0.070716.0";

Sys.Preview.UI.Xaml.ScaleMode = function Sys$Preview$UI$Xaml$ScaleMode() {
    /// <field name="none" type="Number" integer="true" static="true"></field>
    /// <field name="zoom" type="Number" integer="true" static="true"></field>
    /// <field name="stretch" type="Number" integer="true" static="true"></field>
    if (arguments.length !== 0) throw Error.parameterCount();
    throw Error.notImplemented();
}




Sys.Preview.UI.Xaml.ScaleMode.prototype = {
    none: 0,
    zoom: 1,
    stretch: 2
}
Sys.Preview.UI.Xaml.ScaleMode.registerEnum('Sys.Preview.UI.Xaml.ScaleMode');
Sys.Preview.UI.Xaml.ErrorEventArgs = function Sys$Preview$UI$Xaml$ErrorEventArgs(xamlError) {
    /// <param name="xamlError"></param>
    var e = Function._validateParams(arguments, [
        {name: "xamlError"}
    ]);
    if (e) throw e;

    this._xamlError = xamlError;
    Sys.Preview.UI.Xaml.ErrorEventArgs.initializeBase(this);
}



    function Sys$Preview$UI$Xaml$ErrorEventArgs$get_error() {
        /// <value></value>
        if (arguments.length !== 0) throw Error.parameterCount();
        return this._xamlError;
    }
Sys.Preview.UI.Xaml.ErrorEventArgs.prototype = {
    _xamlError: null,
    
    get_error: Sys$Preview$UI$Xaml$ErrorEventArgs$get_error
}
Sys.Preview.UI.Xaml.ErrorEventArgs.registerClass("Sys.Preview.UI.Xaml.ErrorEventArgs", Sys.CancelEventArgs);
Sys.Preview.UI.Xaml.Control = function Sys$Preview$UI$Xaml$Control(domElement) {
    /// <param name="domElement" domElement="true"></param>
    var e = Function._validateParams(arguments, [
        {name: "domElement", domElement: true}
    ]);
    if (e) throw e;

    Sys.Preview.UI.Xaml.Control.initializeBase(this, [domElement]);
}







    function Sys$Preview$UI$Xaml$Control$add_xamlError(handler) {
    var e = Function._validateParams(arguments, [{name: "handler", type: Function}]);
    if (e) throw e;

        this.get_events().addHandler('xamlError', handler);
    }
    function Sys$Preview$UI$Xaml$Control$remove_xamlError(handler) {
    var e = Function._validateParams(arguments, [{name: "handler", type: Function}]);
    if (e) throw e;

        this.get_events().removeHandler('xamlError', handler);
    }

    function Sys$Preview$UI$Xaml$Control$add_resize(handler) {
    var e = Function._validateParams(arguments, [{name: "handler", type: Function}]);
    if (e) throw e;

        this.get_events().addHandler("resize", handler);
    }
    function Sys$Preview$UI$Xaml$Control$remove_resize(handler) {
    var e = Function._validateParams(arguments, [{name: "handler", type: Function}]);
    if (e) throw e;

        this.get_events().removeHandler("resize", handler);
    }

    function Sys$Preview$UI$Xaml$Control$add_xamlInitialized(handler) {
    var e = Function._validateParams(arguments, [{name: "handler", type: Function}]);
    if (e) throw e;

        this.get_events().addHandler('xamlInitialized', handler);
    }
    function Sys$Preview$UI$Xaml$Control$remove_xamlInitialized(handler) {
    var e = Function._validateParams(arguments, [{name: "handler", type: Function}]);
    if (e) throw e;

        this.get_events().removeHandler('xamlInitialized', handler);
    }

    function Sys$Preview$UI$Xaml$Control$get_scaleMode() {
        /// <value type="Sys.Preview.UI.Xaml.ScaleMode"></value>
        if (arguments.length !== 0) throw Error.parameterCount();
        return this._scaleMode;
    }
    function Sys$Preview$UI$Xaml$Control$set_scaleMode(value) {
        var e = Function._validateParams(arguments, [{name: "value", type: Sys.Preview.UI.Xaml.ScaleMode}]);
        if (e) throw e;

        this._scaleMode = value;
        if (this._xamlInitialized && value !== Sys.Preview.UI.Xaml.ScaleMode.none) {
            this._ensureTransform();
        }
    }

    function Sys$Preview$UI$Xaml$Control$get_xamlSource() {
        /// <value type="String"></value>
        if (arguments.length !== 0) throw Error.parameterCount();
        return this._xamlSource || "";
    }
    function Sys$Preview$UI$Xaml$Control$set_xamlSource(value) {
        var e = Function._validateParams(arguments, [{name: "value", type: String}]);
        if (e) throw e;

        if (this.get_isInitialized()) {
            throw Error.invalidOperation(Sys.Preview.UI.Xaml.Res.cannotChangeXamlSource);
        }
        this._xamlSource = value;
    }

    function Sys$Preview$UI$Xaml$Control$addEventListener(element, eventName, handler) {
        /// <param name="element"></param>
        /// <param name="eventName" type="String"></param>
        /// <param name="handler" type="Function"></param>
        /// <returns></returns>
        var e = Function._validateParams(arguments, [
            {name: "element"},
            {name: "eventName", type: String},
            {name: "handler", type: Function}
        ]);
        if (e) throw e;

        if (!this._boundEvents) {
            this._boundEvents = [];
        }

        var token = element.addEventListener(eventName, handler);
        this._boundEvents[this._boundEvents.length] = { element: element, eventName: eventName, token: token };
        return token;
    }

    function Sys$Preview$UI$Xaml$Control$addEventListeners(element, events, handlerOwner) {
        /// <param name="element"></param>
        /// <param name="events" type="Object"></param>
        /// <param name="handlerOwner" optional="true"></param>
        /// <returns></returns>
        var e = Function._validateParams(arguments, [
            {name: "element"},
            {name: "events", type: Object},
            {name: "handlerOwner", optional: true}
        ]);
        if (e) throw e;

        var tokens = { };
        for (var name in events) {
            var handler = events[name];
            if (typeof(handler) !== 'function') throw Error.invalidOperation(Sys.Res.cantAddNonFunctionhandler);
            if (handlerOwner) {
                handler = Function.createDelegate(handlerOwner, handler);
            }
            tokens[name] = this.addEventListener(element, name, handler);
        }
        return tokens;
    }

    function Sys$Preview$UI$Xaml$Control$dispose() {
        var host = this.get_element();
        if (host) {
            if (this._resizeDelegate) {
                host.content.onResize = null;
                this._resizeDelegate = null;
            }
            host.OnLoad = null;
            host.OnError = null;
        }

        if (this._xamlInitialized) {
            this.xamlDispose();
            this._xamlInitialized = false;
        }
        
        if (this._boundEvents) {
            for (var i = 0, l = this._boundEvents.length; i < l; i++) {
                var e = this._boundEvents[i];
                e.element.removeEventListener(e.eventName, e.token);
            }
            this._boundEvents = null;
        }

        Sys.Preview.UI.Xaml.Control.callBaseMethod(this, "dispose");
    }

    function Sys$Preview$UI$Xaml$Control$initialize() {
        Sys.Preview.UI.Xaml.Control.callBaseMethod(this, "initialize");

        var host = this.get_element();
        // host may be the installation medallion
        if ((host.tagName === "OBJECT") || (host.tagName === "EMBED")) {
            host.OnError = Function.createDelegate(this, this._xamlError);
            
            // set the xaml source
            var src = this.get_xamlSource();
            if (src && !host.Source) {
                host.OnLoad = Function.createDelegate(this, this._xamlLoaded);
                host.Source = src;
            }
            else {
                // if we are not setting the source we assume its already been loaded by some other means
                // or it will be maintained by the developer.
                this._raiseXamlInitialize();
            }
        }
    }

    function Sys$Preview$UI$Xaml$Control$onResize(args) {
        /// <param name="args" type="Sys.EventArgs"></param>
        var e = Function._validateParams(arguments, [
            {name: "args", type: Sys.EventArgs}
        ]);
        if (e) throw e;

    }

    function Sys$Preview$UI$Xaml$Control$onXamlError(errorEventArgs) {
        /// <param name="errorEventArgs" type="Sys.Preview.UI.Xaml.ErrorEventArgs"></param>
        var e = Function._validateParams(arguments, [
            {name: "errorEventArgs", type: Sys.Preview.UI.Xaml.ErrorEventArgs}
        ]);
        if (e) throw e;

    }

    function Sys$Preview$UI$Xaml$Control$xamlDispose() {
        if (arguments.length !== 0) throw Error.parameterCount();
    }

    function Sys$Preview$UI$Xaml$Control$xamlInitialize() {
        if (arguments.length !== 0) throw Error.parameterCount();
    }

    function Sys$Preview$UI$Xaml$Control$_ensureTransform() {

        var root = this.get_element().content.root;
        var scalePlayer = Sys.Preview.UI.Xaml.Control._computeScale(root);
        var x, y;
        if (this.get_scaleMode() === Sys.Preview.UI.Xaml.ScaleMode.zoom) {
            // zoom
            x = y = Math.min(scalePlayer.horizontal, scalePlayer.vertical);
        }
        else {
            // fit
            x = scalePlayer.horizontal;
            y = scalePlayer.vertical;
        }
        Sys.Preview.UI.Xaml.Control._ensureScale(root, x, y);
        
        // ensure we are watching the resize event
        if (!this._resizeDelegate) {
            this._resizeDelegate = Function.createDelegate(this, this._onResize);
            root.getHost().content.onResize = this._resizeDelegate;
        }
    }

    function Sys$Preview$UI$Xaml$Control$_onResize() {
        var element = this.get_element();
        // DevDiv Bugs 125915: may have been disposed by now. SL calls us even though we unhook.
        if (element && (this.get_scaleMode() !== Sys.Preview.UI.Xaml.ScaleMode.none)) {
            this._ensureTransform();

            var args = Sys.EventArgs.Empty;
            this.onResize(args);
            var handler = this.get_events().getHandler("resize");
            if (handler) {
                handler(this, args);
            }
        }
    }

    function Sys$Preview$UI$Xaml$Control$_raiseXamlError(sender, errorEventArgs) {
        this.onXamlError(errorEventArgs);
        
        if (!errorEventArgs.get_cancel()) {
            var handler = this.get_events().getHandler("xamlError");
            if (handler) {
                handler(this, errorEventArgs);
            }
            // in debug mode, when error goes unhandled, throw exception
            // The silverlight error object is particular about what fields you can access depending on the type of the error.
            // Accessing an inappropriate field will cause an error.
            else {
                var xamlError = errorEventArgs.get_error(),
                    errorType = xamlError.errorType,
                    errorCode = xamlError.errorCode,
                    errorMessage = xamlError.errorMessage,
                    id = this.get_id(),
                    lineNumber = "", charPosition = "", xamlFile = "", methodName = "",
                    errorFormat = Sys.Preview.UI.Xaml.Res.otherError;
                // not all the elements are available for all error types (you get an exception if you try)
                if (errorType === "ParserError") {
                    errorFormat = Sys.Preview.UI.Xaml.Res.parserError;
                    lineNumber = xamlError.lineNumber;
                    charPosition = xamlError.charPosition;
                    xamlFile = xamlError.xamlFile;
                }
                else if ((errorType === "ImageError" || errorType === "MediaError") && errorMessage === "AG_E_NOT_FOUND") {
                        errorFormat = Sys.Preview.UI.Xaml.Res.mediaError_NotFound;
                        errorMessage = sender.Source;
                }
                else if (errorType === "RuntimeError") {
                    if (xamlError.lineNumber) {
                        errorFormat = Sys.Preview.UI.Xaml.Res.runtimeErrorWithPosition;
                        lineNumber = xamlError.lineNumber;
                        charPosition = xamlError.charPosition;
                        methodName = xamlError.methodName;
                    }
                    else {
                        errorFormat = Sys.Preview.UI.Xaml.Res.runtimeErrorWithoutPosition;
                        methodName = xamlError.methodName;
                    }
                }
                throw Error.invalidOperation(
                    String.format(errorFormat, id, errorType, errorCode, errorMessage, lineNumber, charPosition, methodName, xamlFile));
            }
        }
    }

    function Sys$Preview$UI$Xaml$Control$_raiseXamlInitialize() {
        if (this.get_scaleMode() !== Sys.Preview.UI.Xaml.ScaleMode.none) {
            this._ensureTransform();
        }
        this._xamlInitialized = true;
        this.xamlInitialize();
        var handler = this.get_events().getHandler('xamlInitialized');
        if (handler) {
            handler(this, Sys.EventArgs.Empty);
        }
    }

    function Sys$Preview$UI$Xaml$Control$_xamlError(sender, args) {
        var element = this.get_element();
        if (element) {
            // DevDiv Bugs 125915: may have been disposed by now. SL calls us even though we unhook.
            this._raiseXamlError(sender, new Sys.Preview.UI.Xaml.ErrorEventArgs(args));
        }
    }

    function Sys$Preview$UI$Xaml$Control$_xamlLoaded() {
        var element = this.get_element();
        if (element) {
            // DevDiv Bugs 125915: may have been disposed by now. SL calls us even though we unhook.
            element.OnLoad = null;
            this._raiseXamlInitialize();
        }
    }
Sys.Preview.UI.Xaml.Control.prototype = {
    _xamlSource: null,
    _xamlInitialized: false,
    _scaleMode: Sys.Preview.UI.Xaml.ScaleMode.none,
    _resizeDelegate: null,
    _boundEvents: null,
    
    add_xamlError: Sys$Preview$UI$Xaml$Control$add_xamlError,
    remove_xamlError: Sys$Preview$UI$Xaml$Control$remove_xamlError,

    add_resize: Sys$Preview$UI$Xaml$Control$add_resize,
    remove_resize: Sys$Preview$UI$Xaml$Control$remove_resize,

    add_xamlInitialized: Sys$Preview$UI$Xaml$Control$add_xamlInitialized,
    remove_xamlInitialized: Sys$Preview$UI$Xaml$Control$remove_xamlInitialized,

    get_scaleMode: Sys$Preview$UI$Xaml$Control$get_scaleMode,
    set_scaleMode: Sys$Preview$UI$Xaml$Control$set_scaleMode,
    
    get_xamlSource: Sys$Preview$UI$Xaml$Control$get_xamlSource,
    set_xamlSource: Sys$Preview$UI$Xaml$Control$set_xamlSource,
    
    addEventListener: Sys$Preview$UI$Xaml$Control$addEventListener,
    
    addEventListeners: Sys$Preview$UI$Xaml$Control$addEventListeners,
    
    dispose: Sys$Preview$UI$Xaml$Control$dispose,    
    
    initialize: Sys$Preview$UI$Xaml$Control$initialize,

    onResize: Sys$Preview$UI$Xaml$Control$onResize,
    
    onXamlError: Sys$Preview$UI$Xaml$Control$onXamlError,
    
    xamlDispose: Sys$Preview$UI$Xaml$Control$xamlDispose,

    xamlInitialize: Sys$Preview$UI$Xaml$Control$xamlInitialize,
    
    _ensureTransform: Sys$Preview$UI$Xaml$Control$_ensureTransform,

    _onResize: Sys$Preview$UI$Xaml$Control$_onResize,
    
    _raiseXamlError: Sys$Preview$UI$Xaml$Control$_raiseXamlError,
    
    _raiseXamlInitialize: Sys$Preview$UI$Xaml$Control$_raiseXamlInitialize,

    _xamlError: Sys$Preview$UI$Xaml$Control$_xamlError,
    
    _xamlLoaded: Sys$Preview$UI$Xaml$Control$_xamlLoaded
}

Sys.Preview.UI.Xaml.Control._computeScale = function Sys$Preview$UI$Xaml$Control$_computeScale(element) {
    // Calculates the scale of a xamlElement in relation to the Silverlight host.
    // used by scaleMode !== none
    var width = element.width;
    var height = element.height;
    var host = element.getHost();
    var x = width ? (host.content.ActualWidth / width) : 0;
    var y = height ? (host.content.ActualHeight / height) : 0;
    return { horizontal: x, vertical: y };
}
Sys.Preview.UI.Xaml.Control._ensureScale = function Sys$Preview$UI$Xaml$Control$_ensureScale(el, x, y) {
    var transform = el.RenderTransform;
    if (!transform) {
        el.RenderTransform = transform = el.getHost().content.createFromXaml('<ScaleTransform ScaleX="1" ScaleY="1"/>');
    }
    else if (transform.toString() !== "ScaleTransform") {
        throw Error.invalidOperation(Sys.Preview.UI.Xaml.Res.scaleModeRequiresScaleTransform);
    }
    transform.ScaleX = x;
    transform.ScaleY = y;
}
Sys.Preview.UI.Xaml.Control._ensureMatrix = function Sys$Preview$UI$Xaml$Control$_ensureMatrix(el, xScale, yScale, xOffset, yOffset) {
    var transform = el.RenderTransform;
    if (!transform) {
        el.RenderTransform = transform = el.getHost().content.createFromXaml('<MatrixTransform Matrix="1.0,0.0, 0.0,1.0, 0.0,0.0"/>');
    }
    else if (transform.toString() !== "MatrixTransform") {
        // they have their own transform so its up to them
        return;
    }
    transform.Matrix.M11 = xScale;
    transform.Matrix.M22 = yScale;
    transform.Matrix.OffsetX = xOffset;
    transform.Matrix.OffsetY = yOffset;
}
Sys.Preview.UI.Xaml.Control.registerClass("Sys.Preview.UI.Xaml.Control", Sys.UI.Control);
// stores what silverlight versions are supported by this client,
// as determined by calling sl.IsVersionSupported()
Sys.Preview.UI.Xaml.Control._supportedVersionsCache = {};

Sys.Preview.UI.Xaml.Control._followFWLink = function Sys$Preview$UI$Xaml$Control$_followFWLink(fwLink) {
    // TODO: support HTTPS when there are fwlinks in place that work with it
    // detect https via: ((document.location.toString().toLowerCase().indexOf('https:') === 0) ? "https" : "http")
    window.top.location = "http://go.microsoft.com/fwlink/?LinkID=" + fwLink;
}

Sys.Preview.UI.Xaml.Control._getFWLinks = function Sys$Preview$UI$Xaml$Control$_getFWLinks(forVersion) {
    // Determine if silverlight is supported...
    var supported =
        // IE 6 or greater supported but not on Mac or the 64 bit version
        (   (Sys.Browser.agent === Sys.Browser.InternetExplorer) &&
            (Sys.Browser.version >= 6) &&
            (navigator.userAgent.indexOf('Win64') === -1) &&
            (navigator.userAgent.indexOf('Mac OS X') === -1)) ||
        // FF 1.5 or greater supported
        ((Sys.Browser.agent === Sys.Browser.Firefox) && (Sys.Browser.version >= 1.5)) ||
        // Safari supported but not for Windows
        ((Sys.Browser.agent === Sys.Browser.Safari) && (navigator.userAgent.indexOf("Windows NT") === -1));

    var v = 0;
    try { v = parseFloat(forVersion); }
    catch (e) { }
    if (v >= 1.1) {
        return Sys.Preview.UI.Xaml.Control._getFWLinksAlpha(supported);
    }
    
    // defaults for unsupported 
    var fwLinks = { install: "92822", eula: "93481", privacy: "93483" };
    // image2 always the same
    fwLinks.image2 = "104745";

    if (Sys.Preview.UI.Xaml.Control._installed) {
        // upgrade
        fwLinks.image1 = "104746";
    }
    else {
        fwLinks.image1 = "104747";
    }
    
    if (supported) {
        if (navigator.userAgent.indexOf('Windows NT') !== -1) {
            fwLinks.install = "92799";
            fwLinks.eula = "92803";
            fwLinks.privacy = "92805";
        }
        else if (navigator.userAgent.indexOf('PPC Mac OS X') !== -1) {
            fwLinks.install = "92807";
            fwLinks.eula = "92815";
            fwLinks.privacy = "92816";
        }
        else if (navigator.userAgent.indexOf('Intel Mac OS X') !== -1) {
            fwLinks.install = "92808";
            fwLinks.eula = "92804";
            fwLinks.privacy = "92806";
        }
        // else -- may be a supported browser but on an unsupported platform
    }

    fwLinks.installHtml = Sys.Preview.UI.Xaml.Res.inlineInstallHtml;
    return fwLinks;
}

Sys.Preview.UI.Xaml.Control._getFWLinksAlpha = function Sys$Preview$UI$Xaml$Control$_getFWLinksAlpha(supported) {
    // 1.1 does not support Mac PPC
    supported = supported && navigator.userAgent.indexOf('PPC Mac OS X') === -1;
    
    var fwLinks = { image2: null, privacy: null, eula: null };
    fwLinks.image1 = Sys.Preview.UI.Xaml.Control._installed ? "94378" : "92810";
   
    if (supported) {
        if (navigator.userAgent.indexOf('Windows NT') !== -1) {
            fwLinks.install = '92809';
        }
        else if (navigator.userAgent.indexOf('Mac OS X') !== -1) {
            fwLinks.install = '92813';
        }
    }
    else {
        fwLinks.install = '92821';
    }
    
    fwLinks.installHtml = Sys.Preview.UI.Xaml.Res.linkedInstallHtml;
    return fwLinks;
}

Sys.Preview.UI.Xaml.Control._getInstallPrompt = function Sys$Preview$UI$Xaml$Control$_getInstallPrompt(version, template) {
    var container = document.createElement("div");
    // when template is specified, apply certain attributes to the install prompt div
    if (template) {
        container.id = template.id;
        container.width = template.width;
        container.height = template.height;
        container.className = template.className;
        container.style.cssText = template.style.cssText;
    }
    
    var fwLinks = Sys.Preview.UI.Xaml.Control._getFWLinks(version);
    container.innerHTML = String.format(fwLinks.installHtml,
        fwLinks.install,
        fwLinks.image1,
        fwLinks.eula,
        fwLinks.privacy,
        fwLinks.image2);
        
    return container;
}

Sys.Preview.UI.Xaml.Control._supportsVersion = function Sys$Preview$UI$Xaml$Control$_supportsVersion(version) {
    // null or empty version means dev does not care what version is installed or if it is installed
    if (!version) return true;
    
    var supported = Sys.Preview.UI.Xaml.Control._supportedVersionsCache[version];
    if (typeof(supported) === "undefined") {
        // must dynamically create a plugin and query it
        var plugin = null;
        var tempContainer;
        
        if (Sys.Browser.agent === Sys.Browser.InternetExplorer) {
            try {
                plugin = new ActiveXObject('AgControl.AgControl');
            }
            catch(ex) {
            }
        }
        else if (navigator.plugins["Silverlight Plug-In"]) {
            tempContainer = document.createElement('div');
            tempContainer.style.width = "0px";
            tempContainer.style.height = "0px";
            
            if (Sys.Browser.agent === Sys.Browser.Safari) {
                tempContainer.innerHTML = '<embed type="application/x-silverlight" />';
            }
            else {
                // data:"data," attribute is a workaround for an issue in FF that causes it to make
                // a webrequest to the server when instantiating a new plugin
                tempContainer.innerHTML = '<object type="application/x-silverlight" data="data:," />';                    
            }    
            // note: this line will cause "Operation Aborted" in IE, but for IE we use ActiveXObject
            document.body.appendChild(tempContainer);
            plugin = tempContainer.childNodes[0];
        }
        
        if (plugin && typeof(plugin.IsVersionSupported) !== "undefined") {
            // don't compare with "function", it shows up "unknown" in IE since not a javascript function.
            Sys.Preview.UI.Xaml.Control._installed = true;
            supported = plugin.IsVersionSupported(version);
        }
        else {
            Sys.Preview.UI.Xaml.Control._installed = false;
            supported = false;
        }
        
        if (tempContainer) {
            tempContainer.parentNode.removeChild(tempContainer);
        }
    }
    
    Sys.Preview.UI.Xaml.Control._supportedVersionsCache[version] = supported;
    return supported;
}

Sys.Preview.UI.Xaml.Control._writeObject = function Sys$Preview$UI$Xaml$Control$_writeObject(placeHolderId, version, html) {
    var placeHolder = document.getElementById(placeHolderId);
    if (!placeHolder) {
        throw Error.invalidOperation(String.format(Sys.Preview.UI.Xaml.Res.placeHolderNotFound, placeHolderId));
    }
    
    if (Sys.Preview.UI.Xaml.Control._supportsVersion(version)) {
        placeHolder.innerHTML = html;
    }
    else {
        var container = document.createElement("div");
        container.innerHTML = html;
        var nodes = container.childNodes;
        var template = null;
        for (var i=0, l=nodes.length; i < l; i++) {
            var node = nodes[i];
            if ((node.tagName === "OBJECT") || (node.tagName === "EMBED")) {
                template = node;
                break;
            }
        }
        placeHolder.innerHTML = "";
        placeHolder.appendChild(Sys.Preview.UI.Xaml.Control._getInstallPrompt(version, template));
    }
}

Type.registerNamespace('Sys.Preview.UI.Xaml');
Sys.Preview.UI.Xaml.Res={
"runtimeErrorWithoutPosition":"Runtime error {2} in control \u0027{0}\u0027, method {6}: {3}",
"scaleModeRequiresScaleTransform":"When ScaleMode is set to zoom or stretch, only ScaleTransforms are permitted on the root Canvas.",
"mediaError_NotFound":"Media \"{3}\" in control \"{0}\" could not be found.",
"runtimeErrorWithPosition":"Runtime error {2} in control \u0027{0}\u0027, method {6} (line {4}, col {5}): {3}",
"silverlightVersionFormat":"Must be in the format \"MajorVersion.MinorVersion\".",
"otherError":"{1} error #{2} in control \u0027{0}\u0027: {3}",
"cannotChangeXamlSource":"The xaml source cannot be changed after initialization.",
"placeHolderNotFound":"A placeholder element with id \"{0}\" could not be found.",
"parserError":"Invalid XAML for control \u0027{0}\u0027. [{7}] (line {4}, col {5}): {3}",
"inlineInstallHtml":"\u003ctable border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"width:206px; font-size: 55%; font-family: Verdana;  color: #5E5D5D;\"\u003e\u003ctr\u003e\u003ctd\u003e\u003cimg style=\"display: block; cursor: pointer; border= 0;\" title=\"Get Microsoft Silverlight\" alt=\"Get Microsoft Silverlight\" onclick=\"javascript:Sys.Preview.UI.Xaml.Control._followFWLink({0})\" src=\"http://go.microsoft.com/fwlink/?LinkID={1}&amp;clcid=0x409\" /\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd style=\"width: 206px; margin: 0px; background: #FFFFFF; text-align: left; border-left-style: solid; border-right-style: solid; border-color: #c7c7bd;padding-left: 6px; padding-right: 6px; padding-top: 3px; padding-bottom: 10px; border-width: 2px; \"\u003eBy clicking \u003cb\u003e\"Get Microsoft Silverlight\"\u003c/b\u003e you accept the\u003cbr /\u003e\u003ca title=\"Silverlight License Agreement\" href=\"http://go.microsoft.com/fwlink/?LinkID={2}\" target=\"_blank\" style=\"text-decoration: underline; color: #0000CC\"\u003e\u003cb\u003eSilverlight license agreement\u003c/b\u003e\u003c/a\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd style=\"width: 206px; margin: 0px; background: #FFFFFF; text-align: left; border-left-style: solid; border-right-style: solid; padding-left: 6px; padding-right: 6px; border-color: #c7c7bd;padding-top: 0px; padding-bottom: 2px; border-width: 2px; \"\u003eSilverlight updates automatically, \u003ca title=\"Silverlight Privacy Statement\" href=\"http://go.microsoft.com/fwlink/?LinkID={3}\" target=\"_blank\" style=\"text-decoration: underline; color: #0000CC\"\u003e\u003cb\u003elearn more\u003c/b\u003e\u003c/a\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003cimg alt=\"\" src=\"http://go.microsoft.com/fwlink/?LinkID={4}\" style=\"display:block\" /\u003e\u003c/td\u003e\u003c/tr\u003e\u003c/table\u003e",
"linkedInstallHtml":"\u003cdiv style=\"display:block; width: 205px; height: 67px;\"\u003e\u003cimg onclick=\"javascript:Sys.Preview.UI.Xaml.Control._followFWLink({0})\" style=\"border:0; cursor:pointer; display:block\" src=\"http://go.microsoft.com/fwlink/?LinkID={1}&amp;clcid=0x409\" title=\"Get Microsoft Silverlight\" alt=\"Get Microsoft Silverlight\"/\u003e\u003c/div\u003e"
};

if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();