// *****************************************************************************
// Copyright (C) 2001 Empire Software, Inc. All rights reserved.
// *****************************************************************************
// function to move an entry in a list up one position
// *****************************************************************************
function ifListMoveUp (theList)
{
    var i;
    var j;
    var optGoDown;
    var optGoUp;

    for ( i = 1; i < theList.length; i++ )
    {
	if ( theList.options[i].selected )
	{
            optGoDown = new Option (theList.options[i-1].text, theList.options[i-1].value);
            optGoUp = new Option (theList.options[i].text, theList.options[i].value);
            theList.options[i-1] = optGoUp;
            theList.options[i] = optGoDown;
            theList.options[i-1].selected = true;
	}
    }
}

// *****************************************************************************
// function to move an entry in a list down one position
// *****************************************************************************
function ifListMoveDown (theList)
{
    var i;
    var j;
    var optGoUp;
    var optGoDown;

    for ( i = theList.length - 2; i >= 0; i-- )
    {
	if ( theList.options[i].selected )
	{
            optGoUp = new Option (theList.options[i+1].text, theList.options[i+1].value);
            optGoDown = new Option (theList.options[i].text, theList.options[i].value);
            theList.options[i+1] = optGoDown;
            theList.options[i] = optGoUp;
            theList.options[i+1].selected = true;
	}
    }
}

// *****************************************************************************
// function to select all items in the passed list before submitting the form
// *****************************************************************************
function ifListSelectAll (theList)
{
    var i;
    for ( i = theList.length - 1; i >= 0; i-- )
    {
	theList.options[i].selected = true;
    }
}

// *****************************************************************************
// function to submit a form for the PageMap editor. These page-specific
// functions are stored here to simplify the HTML coding.
// *****************************************************************************
function ifListSelectAndSubmit (theForm, theList)
{
    ifListSelectAll (theList);
    theForm.submit();
}

