/**
  i18n string used in the move to menu, text in the menu to indicate which
  list to move the bib/item to
*/
var MoveToMenuAddToText = "Move To:";

/**
 i18n string used to indicate when nothing is selected when it is required
*/
var myListNothingSelected = "Nothing is selected.";


/**
 i18n string used to confirmation if the user wants to move the titles
*/
var myListConstantsMoveConfirm = "Do you want to move the selected titles?";

MoveToMenu.prototype = new MyListMenu;
MoveToMenu.prototype.constructor = MoveToMenu;
 

/**
@class This js object is linked to the moveTo menu.  It is used to select a destination
list for a set of records.
@extends MyListMenu
*/
function MoveToMenu(){
    MyListMenu.prototype.constructor.call(this);
    this.AddToText = MoveToMenuAddToText;
}


function moveToList(menu, moveToListId)
{
    selectedBibIds = getSelectedInputsAsString("bibID");
    selectedItemIds = getSelectedInputsAsString("itemID");
    selectedItemIdsWithBibs = getSelectedItemsWithBibIds("itemIDbibID");

    if (selectedBibIds != "" || selectedItemIds != "")
    {
        document.formMoveTo.moveToListId.value = moveToListId;
        document.formMoveTo.bibIds.value = selectedBibIds;
        document.formMoveTo.itemIds.value = selectedItemIds;
        document.formMoveTo.itemIdsWithBibs.value = selectedItemIdsWithBibs;
        document.formMoveTo.submit();
    }
    else
    {
        alert(myListNothingSelected);
    }

}

/**
This function checks if nothing is selected and then calls superclass toggle()
which opens the menu if closed and closes if open.
*/
MoveToMenu.prototype.toggle = function () {
    if (!this.isOpen)
    {
        selectedBibIds = getSelectedInputsAsString("bibID");
        selectedItemIds = getSelectedInputsAsString("itemID");

        if (selectedBibIds.length == 0 && selectedItemIds.length == 0)
        {
           alert(ErrorNothingSelected);
           return true;
        }
    }

    //call the superclass function
    MyListMenu.prototype.toggle.call(this);
}
