﻿function PC_OnInit() {
   var popupControl = GetPopupControl();
    var isAllWindowVisible = true;
    for(var i = 0; i < popupControl.GetWindowCount(); i++) {
        var window = popupControl.GetWindow(i);
        if(!popupControl.IsWindowVisible(window)) {
            isAllWindowVisible = false;
            break;
        }
    }    
    TBWindowContentReset();     
    SetBtnDisabled(true);
}
function PC_Close() {
    var popupControl = GetPopupControl();    
    popupControl.Hide();
}

function PC_OnInit1() {
    var popupControl = GetPopupControl();
    var isAllWindowVisible = true;
    for (var i = 0; i < popupControl.GetWindowCount(); i++) {
        var window = popupControl.GetWindow(i);
        if (!popupControl.IsWindowVisible(window)) {
            isAllWindowVisible = false;
            break;
        }
    }
    TBWindowContentReset1();
    SetBtnDisabled(true);
}

function TBWindowContentFocus1() {
    var tbWindowContent = GetTBWindowContent();   
}

function TBWindowContentFocus() {    
    var tbWindowContent = GetTBWindowContent();
    var tbWindowContent1 = GetTBWindowContent1();
    var tbWindowContent2 = GetTBWindowContent2();
    var tbWindowContent3 = GetTBWindowContent3();
    var btnCreateNote = GetBtnCreateNote();
    if (btnCreateNote != null && (tbWindowContent != null || tbWindowContent1 != null || tbWindowContent2 != null || tbWindowContent3 != null) && btnCreateNote.GetEnabled() == false) {
        
//        tbWindowContent.SetText('');
//        tbWindowContent1.SetText('');
//        tbWindowContent2.SetText('');
//        tbWindowContent3.SetText('');
        
    }
}
function TBWindowContentChange() {
   
    var tbWindowContent = GetTBWindowContent();
    var tbWindowContent1 = GetTBWindowContent1();
    var tbWindowContent2 = GetTBWindowContent2();
    var tbWindowContent3 = GetTBWindowContent3();

    if ((tbWindowContent != null && tbWindowContent.GetText() != '') && (tbWindowContent1 != null && tbWindowContent1.GetText() != '') && (tbWindowContent2 != null && tbWindowContent2.GetText() != '') && (tbWindowContent3 != null && tbWindowContent3.GetText() != '')) {
        SetBtnDisabled(false);
    }
}
function TBWindowContentChange1() {

    var tbWindowContent = GetTBWindowContent();
    if (tbWindowContent != null && tbWindowContent.GetText() != '')
    {
        SetBtnDisabled(false);
    }
}

function TBWindowContentBlur() {
    
    var tbWindowContent = GetTBWindowContent();
    var tbWindowContent1 = GetTBWindowContent1();
    var tbWindowContent2 = GetTBWindowContent2();
    var tbWindowContent3 = GetTBWindowContent3();
    if ((tbWindowContent != null && tbWindowContent.GetText() == '') && (tbWindowContent1 != null && tbWindowContent1.GetText() == '') && (tbWindowContent2 != null && tbWindowContent2.GetText() == '') && (tbWindowContent3 != null && tbWindowContent3.GetText() == '')) {
        TBWindowContentReset();
        SetBtnDisabled(true);
    }
}

function TBWindowContentBlur1() {

    var tbWindowContent = GetTBWindowContent();
    if (tbWindowContent != null && tbWindowContent.GetText() == '') {
        TBWindowContentReset1();
        SetBtnDisabled(true);
    }
}
function TBWindowContentReset() {
    
    var tbWindowContent = GetTBWindowContent();
    var tbWindowContent1 = GetTBWindowContent1();
    var tbWindowContent2 = GetTBWindowContent2();
    var tbWindowContent3 = GetTBWindowContent3();
    if (tbWindowContent != null) {
        tbWindowContent.SetText('');
        
    }
    if (tbWindowContent1 != null) {
        tbWindowContent1.SetText('');
       
    }
    if (tbWindowContent2 != null) {
        tbWindowContent2.SetText('');
       
    }
    if (tbWindowContent3 != null) {
        tbWindowContent3.SetText('');
        
    }
}

function TBWindowContentReset1() {
    var tbWindowContent = GetTBWindowContent();
       if (tbWindowContent != null) {
        tbWindowContent.SetText('');

    }
   
}

function SetBtnDisabled(value) {
    var btnCreateNote = GetBtnCreateNote();
    if (btnCreateNote != null)
        btnCreateNote.SetEnabled(!value);
}
function GetTBWindowContent() {
    return ASPxWindowContent;
}
function GetTBWindowContent1() {
    return ASPxWindowContent1;
}
function GetTBWindowContent2() {
    return ASPxWindowContent2;
}
function GetTBWindowContent3() {
    return ASPxWindowContent3;
}
function GetBtnCreateNote() {
    return ASPxBtnCreateNote;
}
function GetPopupControl() {
    return ASPxPopupClientControl;
} 
 
