﻿function WidgetLibrary_SetDefaultInput_bootstrap(widgetId)
{
    var initFunc = new Function("WidgetLibrary_SetDefaultInput_init('" + widgetId + "')");
        
    if (window.addEventListener)
    {
        window.addEventListener('load', initFunc, false);        
    }
    else if (window.attachEvent)
    {
        window.attachEvent('onload', initFunc);
    }        
}

function WidgetLibrary_SetDefaultInput_init(widgetId)
{
    var widget = document.getElementById(widgetId);
    if (widget == null)
    {
        var errorElement = document.createElement("p");
        errorElement.innerText = "Invalid use of WidgetLibrary\\SetDefaultInput: Please specify the runtime Id property of an Input or Input Password widget.";
        errorElement.style.color = "red";
        document.body.appendChild(errorElement);
        return;
    }
    if (widget.tagName != "INPUT" && widget.tagName != "TEXTAREA")
    {
        var errorElement = document.createElement("p");
        errorElement.innerText = "Invalid use of WidgetLibrary\\SetDefaultInput: Only Input and Input Password widgets are supported.";
        errorElement.style.color = "red";
        document.body.appendChild(errorElement);
        return;
    }
    widget.focus();
}