var buttons = window.getElementsByClassName("ButtonUI");
for (var i = 0; i < buttons.length; i++) {
    buttons[i].OnClick = "OnClick";
}


function OnClick(obj) {
    if (obj.getName() == "closebtn") {
        window.closeWnd();
    }
    else if (obj.getName() == "minbtn") {
        window.sendWndMessage(WM_SYSCOMMAND, SC_MINIMIZE, 0);
    }
    else if (obj.getName() == "maxbtn") {
        window.sendWndMessage(WM_SYSCOMMAND, SC_MAXIMIZE, 0);//
    }
    else if (obj.getName() == "restorebtn") {
        window.sendWndMessage(WM_SYSCOMMAND, SC_RESTORE, 0);
    }

}