﻿if (!window.WindowsLive)
    WindowsLive = {};

WindowsLive.Page = function() 
{ 
}

WindowsLive.Page.prototype =
{
    //Gestion du préchargement
    onSourceDownloadProgressChanged: function(sender, eventArgs) {
    },

    //gestion des erreurs
    handleLoadError: function(sender, args) {
        var errorDiv = document.getElementById("errorLocation");
        if (errorDiv != null) {
            var errorText = args.errorType + "- " + args.errorMessage;
            if (args.ErrorType == "ParserError") {
                errorText += "<br>File: " + args.xamlFile;
                errorText += ", line " + args.lineNumber;
                errorText += " character " + args.charPosition;
            }
            else if (args.ErrorType == "RuntimeError") {
                errorText += "<br>line " + args.lineNumber;
                errorText += " character " + args.charPosition;
            }
            errorDiv.innerHTML = errorText;
        }
    },

    //gestion du chargement
    handleLoad: function(control) {
        //on Stocke le control dans l'instance de la classe Page
        this.control = control;

        //on récupère le Canvas principal
        this.rootElement = control.Content.findName('LayoutRoot');

    }

}

WindowsLive.Page.prototype.createRelegate = function(instance, method)
{
    var _params = [];
    
    for(var n = 0; n < arguments.length; ++n)
    {
        _params.push(arguments[n]);
    }
    
    return function()
    {
        _params.splice(0,2)
         _params.unshift(arguments[0],arguments[1]);
        return method.apply(instance,_params);
    }
        
}