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

var FilesOpt = window.getElementByName("filesmanageropt");
var RecycleOpt = window.getElementByName("recyclemanageropt");
var VolumeProg = window.getElementByName("volumeprog");
var VolumeText = window.getElementByName("volumetext");
var MenuBtn = window.getElementByName("menubtn");
var UploadText = window.getElementByName("uploadtext");
var DownloadText = window.getElementByName("downloadtext");
var TransferBtn = window.getElementByName("transfermanagertext");
//var IconListUI = window.getElementByName("filemanagerconlistui");
//var ListUI = window.getElementByName("filemanagerlistui");
var RecycleList = window.getElementByName("recyclemanagerlistui");
var SearchEdit = window.getElementByName("searchedit");
var SearchCloseBtn = window.getElementByName("SearchCloseBtn");
var SearchBtn = window.getElementByName("SearchBtn");
var SearchWaitingLayout = window.getElementByName("SearchWaitingLayout");
var SearchPauseBtn = window.getElementByName("SearchPauseBtn");

function OnClick(obj) 
{
    if (obj.getName() == "closebtn") 
    {
        window.showWindow(false);
    }
    else if (obj.getName() == "minbtn") 
    {
        window.sendWndMessage(WM_SYSCOMMAND, SC_MINIMIZE, 0);
    }
    else if (obj.getName() == "maxbtn") 
    {
        window.sendWndMessage(WM_SYSCOMMAND, SC_MAXIMIZE, 0);//
        //var index = 0;
        // if (IconListUI.isVisible()) 
        // {
        //      IconListUI.needFreshData(true);
        // }
        // else if (ListUI.isVisible()) 
        // {
        //     ListUI.needFreshData(true);
        // }
    }
    else if (obj.getName() == "restorebtn") 
    {
       window.sendWndMessage(WM_SYSCOMMAND, SC_RESTORE, 0);
    }
    else if (obj.getName() == "iosbtn") 
    {
        var str = "http://cloud.189.cn/download_client.jsp?sel=iphone";
        window.shellExecute("open", str, "", "", SW_SHOWNOACTIVATE);
    }
    else if (obj.getName() == "wpbtn") 
    {
        var str = "http://cloud.189.cn/download_client.jsp?sel=wp";
        window.shellExecute("open", str, "", "", SW_SHOWNOACTIVATE);
    }
    else if (obj.getName() == "androidbtn") 
    {
        var str = "http://cloud.189.cn/download_client.jsp?sel=android";
        window.shellExecute("open", str, "", "", SW_SHOWNOACTIVATE);
    }
    else if (obj.getName() == "ipadbtn") 
    {
        var str = "http://cloud.189.cn/download_client.jsp?sel=ipad";
        window.shellExecute("open", str, "", "", SW_SHOWNOACTIVATE);
    }
    else if (obj.getName() == "SearchCloseBtn") 
    {
        SearchCloseBtn.setVisible(false);
        SearchBtn.setVisible(true);
        SearchEdit.setText("");//www 2014.06.30
    }
    else if (obj.getName() == "SearchPauseBtn") 
    {
//         SearchWaitingLayout.setVisible(false);        
//         SearchPauseBtn.setVisible(false);
//         SearchCloseBtn.setVisible(true);
    }
    else if (obj.getName() == "emailbtn" || obj.getName() == "pointbtn" || obj.getName() == "emailtextbtn") 
    {
        //var str = "http://webmail27.189.cn/webmail/";
        //window.shellExecute("open", str, "", "", SW_SHOWNOACTIVATE);
    }
}

