﻿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)) {
            SetLinkButtonVisible(hlShowAllNotesID, true);
            isAllWindowVisible = false;
            break;
        }
    }
      
    TBWindowContentReset();
    SetBtnDisabled(true);
}
function PC_OnCloseUp() {
    
}
function PC_OnPopUp() {
    
}
function SetLinkButtonVisible(elementID, value) {
    var element = document.getElementById(elementID);
    if (element != null) {
        if (value && element.className != 'LinkButton ShowInline')
            element.className = 'LinkButton ShowInline';
        else if (!value && element.className != 'LinkButton Hide')
            element.className = 'LinkButton Hide';
    }
}
function ShowAllNotes() {
    var popupControl = GetPopupControl();
    for (var i = 0; i < popupControl.GetWindowCount(); i++) {
        var window = popupControl.GetWindow(i);
        if (!popupControl.IsWindowVisible(window))
            popupControl.ShowWindow(window);
    }
    SetLinkButtonVisible(hlShowAllNotesID, false);
}
function TBWindowContentFocus() {
    var tbWindowContent = GetTBWindowContent();
    var btnCreateNote = GetBtnCreateNote();
    if (btnCreateNote != null && tbWindowContent != null && btnCreateNote.GetEnabled() == false) {
        tbWindowContent.SetText('');
        SetMemoInactive(false);
    }
}
function TBWindowContentChange() {
    var tbWindowContent = GetTBWindowContent();
    if (tbWindowContent != null && tbWindowContent.GetText() != '')
        SetBtnDisabled(false);
}
function ImposeMaxLength(maxLength) {
    var tbWindowContent = GetTBWindowContent();
    if (tbWindowContent != null)
        return (tbWindowContent.GetText().length <= maxLength);
    else
        return false;
}
function TBWindowContentBlur() {
    var tbWindowContent = GetTBWindowContent();
    if (tbWindowContent != null && tbWindowContent.GetText() == '') {
        TBWindowContentReset();
        SetBtnDisabled(true);
    }
}
function TBWindowContentReset() {
    var tbWindowContent = GetTBWindowContent();
    if (tbWindowContent != null) {
        tbWindowContent.SetText('[Enter some text here and then press the Create Note button]');
        SetMemoInactive(true);
    }
}
function SetMemoInactive(value) {
    var tbWindowContent = GetTBWindowContent();
    if (value)
        tbWindowContent.inputElement.className += ' InactiveColor';
    else
        tbWindowContent.inputElement.className = tbWindowContent.inputElement.className.replace(' InactiveColor', '');
}
function SetBtnDisabled(value) {
    var btnCreateNote = GetBtnCreateNote();
    if (btnCreateNote != null)
        btnCreateNote.SetEnabled(!value);
}
function GetTBWindowContent() {
}
function GetBtnCreateNote() {
    
}
function GetPopupControl() {
    return ASPxPopupClientControl;
}
