function app_submit_init(el, msg)
{
    if (el)
    {
        el.client_msg = msg;
        if (!el.aspnet_onclick)
        {
            el.aspnet_onclick = el.onclick;
            if (el.attachEvent)
                el.attachEvent("onclick",app_submit);
            else  
                el.setAttribute("onclick","app_submit(event, this)");
        }
    }
}

function app_submit(ev, el)
{
    if (!el) {
        el = ev.srcElement; }
    if (el)
    {
        el.disabled = true;
        try {
            if (el.aspnet_onclick)
                el.aspnet_onclick(); 
        }
        finally{
            var b = typeof(Page_IsValid) != "undefined";
            el.disabled = b ? Page_IsValid : true;
            if (el.client_msg && (b && Page_IsValid))
                alert(el.client_msg);                                        
        }
    }
}
