// JS-AppControl
// LastModified: 2009-04-16 09:20:19
//


// ----------------
//  Helper methods
// ----------------

// Method, to change the central ASP.NET-form tag
// found by http://www.keithelder.net/blog/archive/2008/01/26/Two-Form-Tags-in-Asp.Net-and-My-Work-Around.aspx
function changeActionOnFormAndSubmit(newAction, newMethod)
{
    var theForm = document.forms['appcontrol'];
    if (!theForm) {
        theForm = document.appcontrol;
    }
    theForm.action = newAction;
    theForm.method = newMethod;
    theForm.submit();
}

// Method, to patch the .NET-Bug in FireFox if hit the return key in muliline textboxes
// found by http://stackoverflow.com/questions/30230/enter-key-to-insert-newline-in-asp-net-multiline-textbox-control
function WebForm_FireDefaultButton(event, target) {
    var element = event.target || event.srcElement;
    if (event.keyCode == 13 &&
    !(element &&
    element.tagName.toLowerCase() == "textarea"))
    {
        var defaultButton;
        if (__nonMSDOMBrowser)
        {
            defaultButton = document.getElementById(target);
        }
        else
        {
            defaultButton = document.all[target];
        }
        if (defaultButton && typeof defaultButton.click != "undefined")
        {
            defaultButton.click();
            event.cancelBubble = true;
            if (event.stopPropagation)
            {
                event.stopPropagation();
            }
            return false;
        }
    }
    return true;
}

