﻿function CheckDeleted(name, msgNotFound, msgConfirm) {
    var count = 0;
    for (i = 0; i < document.all.length; i++) {
        var x = document.all.item(i);
        if (x != null && x.name != null && x.name != "" && x.name.indexOf(name) != -1 && x.checked == true)
            count++;
    }
    if (count == 0) {
        alert(msgNotFound);
        return false;
    }
    else
        return confirm(msgConfirm);
}

function SetCheckValue(name, value) {
  for(i = 0; i < document.all.length; i++) {
    var x = document.all.item(i);
    if(x != null && x.name != null && x.name != "" && x.name.indexOf(name) != -1 && x.disabled != true){
      x.checked = value;
    }
  }
}

// Попап окна для поиска ОПФ
function FindOPF(CtrlID, CtrlParentID, CtrlBtn, Level, Type, evarg) {
    tChildWindow = window.open('../Controls/OPFSearchDialog.aspx?ctrlID=' + CtrlID + '&ctrlParentID=' + CtrlParentID + '&ctrlBtn=' + CtrlBtn + '&level=' + Level + '&type=' + Type, 'PopUpObjectData', 'width=710,height=430,top=300px,left=300px,toolbars=no,scrollbars=yes,status=no,resizable=yes');
    tChildWindow.focus();
}

// Попап окна для добавления географии
function RegionAdd(CtrlBtn, evarg) {
    tChildWindow = window.open('../Controls/RegionAddDialog.aspx?ctrlBtn=' + CtrlBtn, 'PopUpObjectData', 'width=540,height=430,top=300px,left=300px,toolbars=no,scrollbars=yes,status=no,resizable=no');
    tChildWindow.focus();
}

// Попап окна для отображения цепочки
function ShowChain(ChainID, ChainSize, CtrlBtn, evarg) {
    tChildWindow = window.open('../Controls/Chain'+ChainSize+'.aspx?ChainID=' + ChainID + '&CtrlBtn=' + CtrlBtn, 'PopUpObjectData', 'width=750,height=650,top=100,left=100,toolbars=no,scrollbars=yes,status=no,resizable=yes');
    tChildWindow.focus();
}

// Попап окна для вывода текстовой информации о цепочке
function ShowTextChain(ChainID, evarg) {
    tChildWindow = window.open('../Controls/ChainText.aspx?ChainID=' + ChainID, 'PopUpObjectData', 'width=550,height=550,top=100,left=100,toolbars=no,scrollbars=yes,status=no,resizable=yes');
    tChildWindow.focus();
}

// Попап окна для загрузки файла
function GetFileUpload(CtrlName, id, FileSize, evarg) {
    tChildWindow = window.open('../Controls/FileUpload.aspx?CtrlName=' + CtrlName + '&id=' + id + '&FileSize=' + FileSize, 'PopUpFileUpload', 'width=450,height=200,left=300px,top=300px,toolbars=no,scrollbars=no,status=no,resizable=no');
    tChildWindow.focus();
}

//function ShowLotDetail(id, evarg) {
//    posX = evarg.screenX - 300;
//        tChildWindow = window.open('../Lots/LotDetail.aspx?L=' + id, 'PopUpObjectData', 'width=840,height=550,top=100,left=100,toolbars=no,scrollbars=yes,status=no,resizable=yes');
//    tChildWindow.focus();
//}

//function ShowOrgDetail(id, code, evarg) {
//    posX = evarg.screenX - 300;
//        if (code == 3) 
//            tChildWindow = window.open('../Catalog/OrgDetail.aspx?L=' + id, 'PopUpObjectData', 'width=840,height=550,top=100,left=100,toolbars=no,scrollbars=yes,status=no,resizable=yes');
//        else tChildWindow = window.open('../Catalog/IPDetail.aspx?L=' + id, 'PopUpObjectData', 'width=840,height=550,top=100,left=100,toolbars=no,scrollbars=yes,status=no,resizable=yes');
//    tChildWindow.focus();
//}


