﻿function ListBox_Up(LBID, HFID) 
{ 
    try
    {
        //confirm("Text") Ok=>true, Cancel=>false
        var lb = document.getElementById(LBID);
        var hf = document.getElementById(HFID);
        var iSelIndex = lb.selectedIndex;

        if(iSelIndex < 1) 
        {
            return false;
        }

        var sVal = lb.options[iSelIndex].value;
        var sText = lb.options[iSelIndex].text;
        var sUpVal = lb.options[iSelIndex - 1].value;
        var sUpText = lb.options[iSelIndex - 1].text;

        lb.options[iSelIndex - 1].value = sVal;
        lb.options[iSelIndex - 1].text = sText;
        lb.options[iSelIndex].value = sUpVal;
        lb.options[iSelIndex].text = sUpText;
        lb.selectedIndex = iSelIndex - 1;
        hf.value = "";
        for (a = 0; a < lb.length; a++)
        {
            hf.value = hf.value + lb.options[a].value + ",";
        }
    }
    catch(err)
    {
        alert("Catch: " + err);
    }
    return false;
};
function ListBox_Down(LBID, HFID) 
{ 
    try
    {
        var lb = document.getElementById(LBID);
        var hf = document.getElementById(HFID);
        var iSelIndex = lb.selectedIndex;

        if(iSelIndex < 0 || iSelIndex >= lb.length - 1) 
        {
            return false;
        }

        var sVal = lb.options[iSelIndex].value;
        var sText = lb.options[iSelIndex].text;
        var sUpVal = lb.options[iSelIndex + 1].value;
        var sUpText = lb.options[iSelIndex + 1].text;

        lb.options[iSelIndex + 1].value = sVal;
        lb.options[iSelIndex + 1].text = sText;
        lb.options[iSelIndex].value = sUpVal;
        lb.options[iSelIndex].text = sUpText;
        lb.selectedIndex = iSelIndex + 1;
        
        hf.value = "";
        for (a = 0; a < lb.length; a++)
        {
            hf.value = hf.value + lb.options[a].value + ",";
        }
    }
    catch(err)
    {
        alert("Catch: " + err);
    }
    return false;
};