﻿headers = [
    "SYMBOL", "CEILING", "FLOOR", "PRIOR",
    "BPRICE3","BVOL3","BPRICE2","BVOL2", "BPRICE1","BVOL1",
    "PRICE", "VOL", "CHANGE",
    "SPRICE1", "SVOL1","SPRICE2", "SVOL2","SPRICE3", "SVOL3",
    "HIGHEST", "LOWEST", "TOTAL_VOL", "ROOM"
];

var MARKET_NAME = 'HO';

function mi_remove_stock(id)
{
}

function MarketAdd(result)
{
    var i = 2;
    // status
    mk_date.html(', ngày ' + result[i++]);
    mk_status.html(status_lang[result[i++]]);
    // index
    mk_index.removeClass().addClass(result[i].slice(0,1));
    mk_index.html(result[i++].slice(1));
    mk_advance.html(result[i++]);
    mk_nochange.html(result[i++]);
    mk_decline.html(result[i++]);
    mk_vol.html(result[i++]);
    mk_val.html(result[i++] + MARKET_VAL_UNIT);

    if(result[i] != '')
    {
        $('#call1').show();
        $('#index1').removeClass().addClass(result[i].slice(0,1));
        $('#change1').removeClass().addClass(result[i].slice(0,1));
        $('#index1').html(result[i++].slice(1));
        $('#change1').html(result[i++]);
        $('#vol1').html(result[i++]);
        $('#val1').html(result[i++] + MARKET_VAL_UNIT);
        $('#advance1').html(result[i++]);
        $('#nochange1').html(result[i++]);
        $('#decline1').html(result[i++]);
    }
    else
    {
        i = i + 7;
        $('#call1').hide();
    }

    if(result[i] != '')
    {    
        $('#call2').show();
        $('#index2').removeClass().addClass(result[i].slice(0,1));
        $('#change2').removeClass().addClass(result[i].slice(0,1));
        $('#index2').html(result[i++].slice(1));
        $('#change2').html(result[i++]);
        $('#vol2').html(result[i++]);
        $('#val2').html(result[i++] + MARKET_VAL_UNIT);
        $('#advance2').html(result[i++]);
        $('#nochange2').html(result[i++]);
        $('#decline2').html(result[i++]);
    }
    else
    {
        i = i + 7;
        $('#call2').hide();
    }

    if(result[i] != '')
    {    
        $('#call3').show();
        $('#index3').removeClass().addClass(result[i].slice(0,1));
        $('#change3').removeClass().addClass(result[i].slice(0,1));
        $('#index3').html(result[i++].slice(1));
        $('#change3').html(result[i++]);
        $('#vol3').html(result[i++]);
        $('#val3').html(result[i++] + MARKET_VAL_UNIT);
        $('#advance3').html(result[i++]);
        $('#nochange3').html(result[i++]);
        $('#decline3').html(result[i++]);
    }
    else
    {
        $('#call3').hide();
    }
}

function MarketUpdate(result)
{
    var i = 2;
    var c;
    // status
    mk_date.html(', ngày ' + result[i++]);
    mk_status.html2(status_lang[result[i++]], 'w');
    // index
    mk_index.html2(result[i].slice(1), result[i++].slice(0,1));
    mk_advance.html2(result[i++], 'w');
    mk_nochange.html2(result[i++], 'w');
    mk_decline.html2(result[i++], 'w');
    mk_vol.html2(result[i++], 'w');
    mk_val.html2(result[i++] + MARKET_VAL_UNIT, 'w');

    if(result[i] != '')
    {
        $('#call1').show();
        c = result[i].slice(0,1);
        $('#index1').html2(result[i++].slice(1), c);
        $('#change1').html2(result[i++], c);
        $('#vol1').html2(result[i++], 'w');
        $('#val1').html2(result[i++] + MARKET_VAL_UNIT, 'w');
        $('#advance1').html2(result[i++], 'w');
        $('#nochange1').html2(result[i++], 'w');
        $('#decline1').html2(result[i++], 'w');
    }
    else
    {
        i = i + 7;
        $('#call1').hide();
    }

    if(result[i] != '')
    {    
        $('#call2').show();
        c = result[i].slice(0,1);
        $('#index2').html2(result[i++].slice(1), c);
        $('#change2').html2(result[i++], c);
        $('#vol2').html2(result[i++], 'w');
        $('#val2').html2(result[i++] + MARKET_VAL_UNIT, 'w');
        $('#advance2').html2(result[i++], 'w');
        $('#nochange2').html2(result[i++], 'w');
        $('#decline2').html2(result[i++], 'w');
    }
    else
    {
        i = i + 7;
        $('#call2').hide();
    }

    if(result[i] != '')
    {    
        $('#call3').show();
        c = result[i].slice(0,1);
        $('#index3').html2(result[i++].slice(1), c);
        $('#change3').html2(result[i++], c);
        $('#vol3').html2(result[i++], 'w');
        $('#val3').html2(result[i++] + MARKET_VAL_UNIT, 'w');
        $('#advance3').html2(result[i++], 'w');
        $('#nochange3').html2(result[i++], 'w');
        $('#decline3').html2(result[i++], 'w');
    }
    else
    {
        $('#call3').hide();
    }
}
