//<!--
//
// ident "$Id$ SMI"
//
// Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
// Use is subject to license terms.
//

var ORIG_VALUE = "";

function initValues() {
    ORIG_VALUE = "";
    var selectedList = document.getElementById("f1:p1:r1_selected");
    for (i = 0; i < selectedList.length; i++) {
        ORIG_VALUE += selectedList.options[i].value;
    }
}

function toggleOkButton() {
    var disableSubmits = false;
    var newSelected = "";
    var selectedList = document.getElementById("f1:p1:r1_selected");
    for (i = 0; i < selectedList.length; i++) {
        newSelected += selectedList.options[i].value;
    }
    if (newSelected == ORIG_VALUE) {
        disableSubmits = true;
    }
    document.getElementById("f1:p1:pageButtonsGroupBottom:ok").setDisabled(disableSubmits);
}

function resetOnClicks() {
    document.getElementById("f1:p1:r1_available").ondblclick=availableOnDblClick;
    document.getElementById("f1:p1:r1_selected").ondblclick=selectedOnDblClick;

    document.getElementById("f1:p1:r1:r1_addButton").onclick=addOnClick;
    document.getElementById("f1:p1:r1:r1_addAllButton").onclick=addAllOnClick;

    document.getElementById("f1:p1:r1:r1_removeButton").onclick=removeOnClick;
    document.getElementById("f1:p1:r1:r1_removeAllButton").onclick=removeAllOnClick;
    
    document.getElementById("f1:p1:r1:r1_moveUpButton").onclick=moveUpOnClick;
    document.getElementById("f1:p1:r1:r1_moveDownButton").onclick=moveDownOnClick;
}

function availableOnDblClick() {
    AddRemove_f1_p1_r1.add();
    toggleOkButton();
    return false;
}

function selectedOnDblClick() {
    AddRemove_f1_p1_r1.remove();
    toggleOkButton();
    return false;
}

function addOnClick() {
    AddRemove_f1_p1_r1.add();
    toggleOkButton();
    return false;
}

function addAllOnClick() {
    AddRemove_f1_p1_r1.addAll();
    toggleOkButton();
    return false;
}

function removeOnClick() {
    AddRemove_f1_p1_r1.remove();
    toggleOkButton();
    return false;
}

function removeAllOnClick() {
    AddRemove_f1_p1_r1.removeAll();
    toggleOkButton();
    return false;
}

function moveUpOnClick() {
    AddRemove_f1_p1_r1.moveUp();
    toggleOkButton();
    return false;
}

function moveDownOnClick() {
    AddRemove_f1_p1_r1.moveDown();
    toggleOkButton();
    return false;
}


//-->
