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

//var SyncOption = window.getElementByName("Sync_Option");
//var BackOption = window.getElementByName("BackUp_Option");
var SyncList = window.getElementByName("SyncList");
var BackUpList = window.getElementByName("BackupList");

var Btn_StartSync = window.getElementByName("StartSync");
var Btn_StopSync = window.getElementByName("StopSync");
var Btn_ClearHistory = window.getElementByName("ClearHistory");
var BackupManager = new IBackupWndManager();

function WndNotify(a, b) {
    if (b == "windowinit") {
        if (SyncOption.getText() == "΄«ΚδΑΠ±ν") 
        {
            Btn_ClearHistory.setVisible(true);
            Btn_StartSync.setVisible(false);
            Btn_StopSync.setVisible(false);
        }
    }
    else if ("click" == b) {
    if (a == "view_button") {
        BackupManager.doAction(BackUpList, TransmissionAction_Open);
    }
    else if (a  == "paly_button") {
        BackupManager.doAction(BackUpList, TransmissionAction_Start);
    }
    else if (a == "stop_button") {
        BackupManager.doAction(BackUpList, TransmissionAction_Stop);
    }
    else if (a == "Cancel_button") {
        BackupManager.doAction(BackUpList, TransmissionAction_Delete);
    }
    else if (a == "Redo_button") {
        BackupManager.doAction(BackUpList, TransmissionAction_Start);
    }
//     else if (a == "Vip_link") {
//        window.shellExecute("open","http://epay.21cn.com/initOrder.do?productID=P20130116121717796", "", "", SW_SHOWNOACTIVATE);
//     }
    }
}

function OnClick(obj) {
    if (obj.getName() == "closebtn") {
        window.closeWnd();
    }
    else if (obj.getName() == "minbtn") {
         SyncList.needUpdate(false);
         BackUpList.needFreshData(false);
        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);
    }
    else if (obj.getName() == "ClearHistory") {
        BackupManager.clearComplete();
    }
}

function OnMenuClick(a) {
    if (a == "menu_backup_selectall") {
        BackUpList.selectAllItems();
    }
    else if (a == "menu_backup_fresh") {
        BackUpList.needFreshData(true);
    }
    else if (a == "menu_backup_view") {
            BackupManager.doMenuAction(BackUpList, TransmissionAction_Open);  
    }
    else if (a == "menu_backup_pause") {
            BackupManager.doMenuAction(BackUpList, TransmissionAction_Stop);  
    }
    else if (a == "menu_backup_play") {
            BackupManager.doMenuAction(BackUpList, TransmissionAction_Start);  
    }
    else if (a == "menu_backup_cancel") {
            BackupManager.doMenuAction(BackUpList, TransmissionAction_Delete);  
    }
    else if (a == "menu_backup_redo") {
            BackupManager.doMenuAction(BackUpList, TransmissionAction_Start);  
    }
    
}