function addConfirmer() {
    myform = document.userform;
    for (i = 0; i < myform.selectableIDList.options.length; i++) {
        if (myform.selectableIDList.options(i).selected == true) {
	    j = myform.selectedIDList.options.length - 1;
	    for (; j >= 0; j--) {
	 	if (myform.selectableIDList.item(i).value == myform.selectedIDList.item(j).value) {
	 	    break;
	 	}
	    }
	    if (j < 0) {
	        newOpt = new Option(myform.selectableIDList.item(i).text, myform.selectableIDList.item(i).value);
                myform.selectedIDList.add(newOpt);
	    }
	}
    }
}

function removeConfirmer() {
    myform = document.userform;

    myindex = 0;
    for (; myindex < myform.selectedIDList.options.length; myindex++) {
        if (myform.selectedIDList.options(myindex).value == myform.operatorID.value) {
            break;
	}
    }
    if (myindex == myform.selectedIDList.options.length) {
        myindex = -1;
    }

    for (i = myform.selectedIDList.options.length - 1; i > myindex; i--) {
        if (myform.selectedIDList.options(i).selected == true) {
            myform.selectedIDList.remove(i);
	}
    }
}

function moveUpDn(direction) {
    myform = document.userform;

    myindex = 0;
    for (; myindex < myform.selectedIDList.options.length; myindex++) {
    	var text = myform.selectedIDList.options(myindex).text;
    	if ( text.charAt(0) != '*'){
    		myindex--;
        //if (myform.selectedIDList.options(myindex).value == myform.operatorID.value) {
            break;
	}
    }
    
    if (myindex == myform.selectedIDList.options.length) {
        myindex = -1;
    }

    index = myform.selectedIDList.options.length;
    count = 0;
    for (i = myform.selectedIDList.options.length - 1; i > myindex; i--) {
        if (myform.selectedIDList.options(i).selected == true) {
	    count++;
	    index = i;
	}
    }
    if (count == 1) {	// Select One only
        if (direction < 0 && index > myindex + 1) {		// Up
	    newOpt = new Option(myform.selectedIDList.item(index).text, myform.selectedIDList.item(index).value);
	    newOpt.selected = true;
            myform.selectedIDList.remove(index);
            myform.selectedIDList.add(newOpt, index + direction);
        }
        if (direction > 0 && index < myform.selectedIDList.options.length - 1) { // Down
	    newOpt = new Option(myform.selectedIDList.item(index).text, myform.selectedIDList.item(index).value);
	    newOpt.selected = true;
            myform.selectedIDList.remove(index);
            myform.selectedIDList.add(newOpt, index + direction);
        }
    }
}


function GetUsers()
{
		myform = document.userform;
		myindex=0;
		for (i = myform.selectedIDList.options.length -1; i >= myindex; i--) {
        myform.selectedIDList.options(i).selected = true;
		myform.SelectedUsers.value=myform.SelectedUsers.value +','+ myform.selectedIDList.item(i).value
		}
		myform.StepIDs.value=myform.StepID[myform.StepID.selectedIndex].value
}

function closewindow(selectusers,strSelectUsers,StepID,StepName){
	self.opener.document.DocForm.CheckIDList.value=selectusers;
	self.opener.document.DocForm.CheckNameList.value=strSelectUsers;
	self.opener.document.DocForm.StepID.value=StepID;
	self.opener.document.DocForm.StepName.value=StepName;
	//self.opener.document.DocForm.submit();
	self.close();
}
