﻿
function DisplaySelectedPrice(vnd, usd, gold, selectedIndex, priceLabel) {
    var labelObj = document.getElementById(priceLabel);
    if (labelObj != null) {
        switch (selectedIndex) {
            case '1': labelObj.innerHTML = vnd; break;
            case '2': labelObj.innerHTML = usd; break;
            case '3': labelObj.innerHTML = gold; break;
        }
    }
}

//function convertCurrency(currentUnit, targetUnit, amount, priceLabel) {
//    //alert('currentUnit=' + currentUnit + ', targetUnit=' + targetUnit + ',amount=' + amount + ', priceID=' + priceID.innerHTML);
//    //Unit = 1 -->VND
//    //Unit = 2 -->USD
//    //Unit = 3 -->Gold
//    var goldRate = 22000000;    // Gold/VND
//    var usdRate = 17800;        // USD/VND
//    var result = 0;
//    if (currentUnit == targetUnit)
//        result = amount;
//    else if (currentUnit == 1 && targetUnit == 2) //VND to USD
//    {
//        result = amount / usdRate;
//    }
//    else if (currentUnit == 1 && targetUnit == 3) //VND to Gold
//    {
//        result = amount / goldRate;
//    }
//    else if (currentUnit == 2 && targetUnit == 1) //USD to VND
//    {
//        result = amount * usdRate;
//    }
//    else if (currentUnit == 2 && targetUnit == 3) //USD to Gold
//    {
//        result = (amount * usdRate) / goldRate;
//    }
//    else if (currentUnit == 3 && targetUnit == 1) //Gold to VND
//    {
//        result = amount * goldRate;
//    }
//    else if (currentUnit == 3 && targetUnit == 2) //Gold to USD
//    {
//        result = (amount * goldRate) / usdRate;
//    }

//    priceLabel.innerHTML = format(String(result));
//}

//function format(str) {
//    index = str.indexOf(".");
//    if (index > 0)
//    {
//        str = str.substring(0, index + 3);
//        if (str.length < (index + 3)) str += "0";
//    }
//    return str;
//}
