﻿function BindCounty(destControl, strCountyList, strSelectText) {
    var objDEST_DropDown;

    objDEST_DropDown = eval("document.getElementById('" + destControl + "')");

    var ReturnArray = new Array();
    ReturnArray = strCountyList.split("####");

    objDEST_DropDown.options.length = 0;

    if (strCountyList != '') {
        
        if (strSelectText != '') {
            temp_opt = document.createElement("option");
            temp_opt.text = strSelectText;
            temp_opt.value = "";
            objDEST_DropDown.options.add(temp_opt);
        }
    }
    


    for (var i = 0; i < ReturnArray.length - 1; i = i + 2) {
        temp_opt = document.createElement("option");
        temp_opt.text = ReturnArray[i + 1];
        temp_opt.value = ReturnArray[i];
        objDEST_DropDown.options.add(temp_opt);
    }

}

function BindCounty_WithSelectedValue(destControl, strCountyList, strSelectText, SelectedValue) {
    var objDEST_DropDown;

    objDEST_DropDown = eval("document.getElementById('" + destControl + "')");

    var ReturnArray = new Array();
    ReturnArray = strCountyList.split("####");

    objDEST_DropDown.options.length = 0;

    if (strCountyList != '') {

        if (strSelectText != '') {
            temp_opt = document.createElement("option");
            temp_opt.text = strSelectText;
            temp_opt.value = "";
            objDEST_DropDown.options.add(temp_opt);
        }
    }



    for (var i = 0; i < ReturnArray.length - 1; i = i + 2) {
        temp_opt = document.createElement("option");
        temp_opt.text = ReturnArray[i + 1];
        temp_opt.value = ReturnArray[i];
        objDEST_DropDown.options.add(temp_opt);
    }

    objDEST_DropDown.value = SelectedValue;
}
function CurrencyFormatted(amount) 
{
    var i = parseFloat(roundNumber(amount, 2));

    if (isNaN(i)) { i = 0.00; }

    var minus = '';

    if (i < 0) { minus = '-'; }

    i = Math.abs(i);

    i = parseInt((i + .005) * 100);

    i = i / 100;

    s = new String(i);

    if (s.indexOf('.') < 0) { s += '.00'; }

    if (s.indexOf('.') == (s.length - 2)) { s += '0'; }

    s = minus + s;

    return s;

}
function roundNumber(num, dec) 
{
    var result = Math.round(num * Math.pow(10, dec)) / Math.pow(10, dec);
    return result;
}

