function gotoWEB(link) {
    window.open(link, "_blank");
}
function deleteBlankRowIfNotEmpty(list)
{
    var idx = -1;
    var val = "";
    // find a blank row in table
    for (i = 0; i < list.length; i++) {
        val = list.options[i].value;
        if (val == "") {
            idx = i;
            break;
        }
    }
    if (idx >= 0 && (list.length > 1))
        list.options[idx] = null;
}

function selectAll(list)
{
    for (i = 0; i <= list.length - 1; i++)
        list.options[i].selected = true;
    return true;
}
function unSelectAll(list)
{
    for (i = 0; i <= list.length - 1; i++)
        list.options[i].selected = false;
    return true;
}
function clearList(list)
{
    list.length = 0;
}

function copyToList(fromList, toList, direction) {
    for (i = 0; i <= fromList.length - 1;) {
        if (fromList.options[i].selected) {
            txt = fromList.options[i].text;
            val = fromList.options[i].value;
            if (val != "") {
                // check if value is a spacer
                if (val == "spacer") {
                    if (direction == "left") {
                        // remove from right and do not add on left
                        fromList.options[i] = null;
                    }
                    else {
                        // add to right but do not remove from left
                        fromList.options[i].selected = false;
                        toList.options[toList.length] = new Option(txt, val, false, true);
                        toList.options[toList.selectedIndex].selected = false;
                    }
                }
                else {  //only increment when not moving and deleting
                    // create a new row
                    toList.options[toList.length] = new Option(txt, val, false, true);
                    // added these lines
                    // removes from fromList and unselects item in toList
                    fromList.options[i] = null;
                    toList.options[toList.selectedIndex].selected = false;
                }  //only increment when not moving and deleting
            } else {
                i++; // increment when selected element is empty
            }
        }
        else i++;  //only increment when not moving and deleting
    }
    deleteBlankRowIfNotEmpty(fromList);
    deleteBlankRowIfNotEmpty(toList);
    // Set the order
    // newOrder(toList, eval("document." + toList.form.name + "." + toList.name.substr(0, toList.name.lastIndexOf("select"))));
    // newOrder(fromList, eval("document." + fromList.form.name + "." + fromList.name.substr(0, fromList.name.lastIndexOf("select"))));
}
function copyAll(fromList, toList, direction) {
    indexofspacer = -1;
    spacerval = "";
    spacertxt = "";
    indexofitem = toList.length;
    for (i = 0; i <= fromList.length - 1; i++) {
        txt = fromList.options[i].text;
        val = fromList.options[i].value;
        if (val != "") {
            // check if we need to copy the spacer too
            if (val != "spacer") {
                toList.options[indexofitem] = new Option(txt, val, false, true);
                toList.options[indexofitem].selected = false;
                indexofitem++;
            }
            else { // found a spacer
                indexofspacer = i;
                spacerval = val;
                spacertxt = txt;
            }
        }
    }
    if (indexofspacer != -1 && direction == "right") // let the spacer be on the from list
        fromList.length = 1;
    else
        clearList(fromList);
    deleteBlankRowIfNotEmpty(toList);
    unSelectAll(toList);

    // Set the order
    //    newOrder(toList, eval("document." + toList.form.name + "." + toList.name.substr(0, toList.name.lastIndexOf("select"))));
    //   newOrder(fromList, eval("document." + fromList.form.name + "." + fromList.name.substr(0, fromList.name.lastIndexOf("select"))));
}