﻿AG.Stock.PriceUtils =
{
    //id: Cua bien thay doi
    //Value: Truong Hien thi
    //iCheck: Truong lam moc de so sanh
    //Ivariable:Truong so sanh
    //background_color:Ma mau hien thi khi chay
    Change: function (id, value, iCheck, ivariable, background_color) {
        var ivalue;
        if (ivariable == 0) {
            ivalue = value;
        }
        else {
            if (id == 'Ordersupport_Contentpane1_TotalShare' || id == 'SellAmount3' || id == 'SellAmount1' || id == 'SellAmount2' || id == 'BuyAmount1' || id == 'BuyAmount2' || id == 'BuyAmount3') {
                ivalue = formatNumber_input_decimal_format(value, 0);
            }
            else {
                if (id != 'Ordersupport_Contentpane1_Change') {
                    ivalue = formatNumber_input_decimal_format(value, 1);
                }
                else {
                    ivalue = value;
                }
            }
        }
        setTimeout(function () {
            var color = CheckColor(iCheck, ivariable);
            //alert( color);
            $('#' + id).css({ 'color': '' + color + '' });
            $('#' + id).css({ 'background-color': '#C3C3C3' });
            $('#' + id).html(ivalue);
            setTimeout(function () {
                $('#' + id).css({ 'background-color': '' + background_color + '' });
            }, 1500);
        }, 1500);
    },
    // iCheck: giá trị check
    // RefPrice: G
    GetColor: function (iCheck, RefPrice, CeilingPrice, FloorPrice, StockExchange, Diff) {
        iCheck = parseFloat(iCheck);
        RefPrice = parseFloat(RefPrice);
        CeilingPrice = parseFloat(CeilingPrice);
        FloorPrice = parseFloat(FloorPrice);
        var currentDate = getCurrentDate();
        if (StockExchange == '00000000-0000-0000-0000-000000000001' || StockExchange == '00000000-0000-0000-0000-000000000002') {
            if (currentDate > 830 && currentDate < 1100) {
                if (iCheck == RefPrice || iCheck == 0) {
                    return '#F8A800';
                }
                else {
                    if (iCheck == CeilingPrice) {
                        return '#FF00FF';
                    }
                    else {
                        if (iCheck == FloorPrice) {
                            return '#99CCFF';
                        }
                        else {
                            if (iCheck > RefPrice) {
                                return '#1CB920';
                            }
                            else {
                                return '#F80808';
                            }
                        }
                    }
                }
            }
            else {
                Diff = parseFloat(Diff);
                if (Diff < 0)
                    return '#F80808';
                if (Diff == 0)
                    return '#F8A800';
                if (Diff > 0)
                    return '#1CB920';
            }
        }
        if (StockExchange == '00000000-0000-0000-0000-000000000004') {
            if (currentDate > 830 && currentDate < 1100 || currentDate > 1300 && currentDate < 1530) {
                if (iCheck == RefPrice || iCheck == 0) {
                    return '#F8A800';
                }
                else {
                    if (iCheck == CeilingPrice) {
                        return '#FF00FF';
                    }
                    else {
                        if (iCheck == FloorPrice) {
                            return '#99CCFF';
                        }
                        else {
                            if (iCheck > RefPrice) {
                                return '#1CB920';
                            }
                            else {
                                return '#F80808';
                            }
                        }
                    }
                }
            }
            else {
                Diff = parseFloat(Diff);
                if (Diff < 0)
                    return '#F80808';
                if (Diff == 0)
                    return '#F8A800';
                if (Diff > 0)
                    return '#1CB920';
            }
        }
    },
    GetColor1: function (value) {
        value = parseFloat(value);
        if (value < 0)
            return '#F80808';
        if (value == 0)
            return '#F8A800';
        if (value > 0)
            return '#00FF00';
    },
    GetColor2: function (value) {
        value = parseFloat(value);
        if (value < 0)
            return '#F80808';
        if (value == 0)
            return '#F8A800';
        if (value > 0)
            return '#00FF00';
    },

    getSymbolDiff: function (value) {
        if (value < 0)
            return '▼';
        if (value == 0)
            return '■';
        if (value > 0)
            return '▲';
    },
    getSymbolDiff1: function (value) {
        if (value < 0)
            return 'Down.png';
        if (value == 0)
            return 'tb.jpg';
        if (value > 0)
            return 'Up.png';
    }
};
function getCurrentDate() {
    var currentDate, hour, min = "";
    var objDate = new Date();
    hour = objDate.getHours().toString();
    min = objDate.getMinutes().toString();
    currentDate = eval(hour + min);
    return parseInt(currentDate);
} 

