//  Animate on Attach
//  Created by Makaio Stygiann, modified by Water Rogers for IBM/Opensource
 
//  Purpose
//  --------------------------------------------------------------
//  This script shows you how you can order a list of buttons in a
//  dialog box to read from top to bottom, rather then bottom to top
//  like the default.
 
//  Requirements
//  --------------------------------------------------------------
//  A single prim is all that is necessary for this example.
 
//  Usage
//  --------------------------------------------------------------
//  Click on the object to bring up the dialog list.  Click on any of
//  the buttons to flip between ordered, or non-ordered formats.
 
//  GLOBALS
//  --------------------------------------------------------------
list button_list=["1","2","3","4","5","6","7","8","9","10"];    //  list of buttons and their labels
integer dialog_chan=-49324322;                                  //  the channel the dialog talks on
integer g_Rearranged = TRUE;                                    //  rearranger off or on switch
 
//  FUNCTIONS
//  --------------------------------------------------------------
list rearrange(list buttons)
{
    //  This function will return a list of the buttons in the list
    //  so they are in a "Top to Bottom" order, rather then the
    //  "Bottom to Top" order that SL defaults to.
    list reordered=buttons;
    list segment;
    integer total_buttons=llGetListLength(button_list);
    integer rows=total_buttons/3;
    integer remainder=total_buttons%3;
    if(remainder!=0)
    {
        segment=llList2List(reordered,0,remainder - 1);
        reordered=llDeleteSubList(reordered,0,remainder - 1);
        reordered+=segment;
    }
    integer x;
    for(x=0;x