
/* put in 'DOM READY' handler */
function show_CS_menu()
{ 
   //this.src = '/img/gear_picked.png'; 
   gear_menu.current_row = this.row_number;
   gear_menu.gear_button_id = this.id;
   // don't let the user add this track to a bin if
   //  he isn't supposed to see it
   if (this.cue_key && this.avail)
   {
      bins = new Array();

      for (var b in bin_data)
      {
         this_bin = bin_data[b];
         o = new Object();
         o.onclick = new Object();
         o.onclick.fn = add_to_bin_shim;
         o.onclick.obj = new Object();
         o.onclick.obj.bin_id = b;
         o.onclick.obj.cue_id = this.cue_key;
         o.text = this_bin.bin_name;
         bins.push(o);
      }
   }

   gear_menu.clearContent();
   gear_menu.addItems([
      { text: "Edit", onclick: {fn: edit_CS_shim}   }]);
   gear_menu.addItems([
      { text: "Duplicate", onclick: {fn: duplicate_CS_shim}   }]);
   gear_menu.addItems([
      { text: "Insert Blank", onclick: {fn: insert_blank_CS_shim}   }]);
   gear_menu.addItems([
      { text: "Delete", onclick: {fn: delete_CS_shim}   }]);
 
   // don't let the user add this track to a bin if
   //  he isn't supposed to see it
   if (this.cue_key && this.avail)
   {
      gear_menu.addItems([
         { text: "Add to bin", 
            submenu: { id: 'submenu1',
            itemdata: bins
            }
         }]);
   }
   
   gear_menu.render(document.body);
// this is NOT optional!
   gear_menu.cfg.setProperty('context', [this.id, 'tr','br']); 
   gear_menu.show();
}

function edit_CS_shim()
{  redraw_cue_sheet(gear_menu.current_row);
}
function delete_CS_shim()
{  delete_CS_row(gear_menu.current_row);
}
function duplicate_CS_shim()
{  duplicate_CS_row(gear_menu.current_row, true);
}
function insert_blank_CS_shim()
{  duplicate_CS_row(gear_menu.current_row, false);
}


