﻿// JScript File

function submitform(buttonname, e){
    var keycode = 0;
    if (window.event) keycode = window.event.keyCode;
    else if (e) keycode = e.which;
    if (keycode == 13){
        var thebutton = document.getElementById(buttonname);
        thebutton.click();
    }
    return true;
}

function stopsubmit(e){
    var targ;
    if (e.target) targ = e.target;
    else if (e.srcElement) targ = e.srcElement;
    if (targ.nodeType == 3) targ = targ.parentNode;
    var keycode = 0;
    if (window.event) keycode = window.event.keyCode;
    else if (e) keycode = e.which;
    if(keycode == 13 && targ.tagName == 'INPUT') return false;
    return true;
}


function moveItems(fromlistid, fromhdnid, tolistid, tohdnid){
    var fromlist = document.getElementById(fromlistid);
    var fromhdn = document.getElementById(fromhdnid);
    var tolist = document.getElementById(tolistid);
    var tohdn = document.getElementById(tohdnid);
    for(var i = fromlist.options.length-1; i>=0; i--){
        if(fromlist.options[i].selected){
            tolist.options[tolist.options.length] = new Option(fromlist.options[i].text, fromlist.options[i].value);
            fromlist.options[i] = null;
        }
    }
    fromhdn.value = "";
    for(var i = 0; i<fromlist.options.length; i++){
        if(i == 0){
            fromhdn.value = fromlist.options[i].value;
        }else{
            fromhdn.value += "|" + fromlist.options[i].value;
        }
    }
    tohdn.value = "";
    for(var i = 0; i<tolist.options.length; i++){
        if(i == 0){
            tohdn.value = tolist.options[i].value;
        }else{
            tohdn.value += "|" + tolist.options[i].value;
        }
    }
}