// Class cVaxDigitTone

function cVaxDigitTone()
{
    this.OnLoadPage = function ()
    {
        m_objVaxWebPhoneLib.SetEventMainSIP(OnInitialized, OnUnInitialized, null, null, null, null);
    }

    function OnInitialized()
    {
    }

    function OnUnInitialized()
    {
    }

    ///////////////////////////////////////////////////////////////////////////////////
    ///////////////////////////////////////////////////////////////////////////////////

    /*
    function PlayStartDigitTone(sDigitDTMF)
    {
        m_aDigitTone[nDigitDTMF].currentTime = 0;
        m_aDigitTone[nDigitDTMF].loop = false;

        m_aDigitTone[nDigitDTMF].play();
    }

    function PlayStopDigitTone(nDigitDTMF)
    {
        m_aDigitTone[nDigitDTMF].pause();
        m_aDigitTone[nDigitDTMF].currentTime = 0;
    }
    */

    function PlayToneDigitDTMF(sDigitDTMF)
    {
        if (sDigitDTMF == '*')
            sDigitDTMF = 'Star';
        else if (sDigitDTMF == '#')
            sDigitDTMF = 'Num';

        const sFileName = 'AudioWeb/Digit' + sDigitDTMF + '.wav';
                                
        m_objVaxWebPhoneLib.PlayMediaStartFile(sFileName, false);
    }

    this.PlayDigitTone = function (sDigitDTMF)
    {
        PlayToneDigitDTMF(sDigitDTMF);
    }

    /////////////////////////////////////////////////////////////////////////////////
    /////////////////////////////////////////////////////////////////////////////////

    this.BtnDialPad1_onclick = function () {
        EditPhoneNo.value += "1";
        m_objVaxWebPhoneLib.DigitDTMF("1");

        this.PlayDigitTone("1");
    }

    this.BtnDialPad2_onclick = function () {
        EditPhoneNo.value += "2";
        m_objVaxWebPhoneLib.DigitDTMF("2");

        this.PlayDigitTone("2");
    }

    this.BtnDialPad3_onclick = function () {
        EditPhoneNo.value += "3";
        m_objVaxWebPhoneLib.DigitDTMF("3");

        this.PlayDigitTone("3");
    }

    this.BtnDialPad4_onclick = function () {
        EditPhoneNo.value += "4";
        m_objVaxWebPhoneLib.DigitDTMF("4");

        this.PlayDigitTone("4");
    }

    this.BtnDialPad5_onclick = function () {
        EditPhoneNo.value += "5";
        m_objVaxWebPhoneLib.DigitDTMF("5");

        this.PlayDigitTone("5");
    }

    this.BtnDialPad6_onclick = function () {
        EditPhoneNo.value += "6";
        m_objVaxWebPhoneLib.DigitDTMF("6");

        this.PlayDigitTone("6");
    }

    this.BtnDialPad7_onclick = function () {
        EditPhoneNo.value += "7";
        m_objVaxWebPhoneLib.DigitDTMF("7");

        this.PlayDigitTone("7");
    }

    this.BtnDialPad8_onclick = function () {
        EditPhoneNo.value += "8";
        m_objVaxWebPhoneLib.DigitDTMF("8");

        this.PlayDigitTone("8");
    }

    this.BtnDialPad9_onclick = function () {
        EditPhoneNo.value += "9";
        m_objVaxWebPhoneLib.DigitDTMF("9");

        this.PlayDigitTone("9");
    }

    this.BtnDialPadStar_onclick = function () {
        EditPhoneNo.value += "*";
        m_objVaxWebPhoneLib.DigitDTMF("*");

        this.PlayDigitTone("*");
    }

    this.BtnDialPad0_onclick = function () {
        EditPhoneNo.value += "0";
        m_objVaxWebPhoneLib.DigitDTMF("0");

        this.PlayDigitTone("0");
    }

    this.BtnDialPadNo_onclick = function () {
        EditPhoneNo.value += "#";
        m_objVaxWebPhoneLib.DigitDTMF("#");

        this.PlayDigitTone("#");
    }

    /////////////////////////////////////////////////////////////////////////////////
    /////////////////////////////////////////////////////////////////////////////////
};