function remove_from_mymacaroni(event_id) {
    $.post("/mymacaroni/remove/" + event_id + "/", {});
}



/*
 * Add click handler to events for my macaroni
 */
$(function() {
   $("a[id^='mym-event-']").each(function() {
      var $this = $(this);
      var event_id = $this.attr('id').split('-')[2];
      var mymClass = "mymacaroni-added";
      var mymClass_not = "mymacaroni-not-added";

      $this.click(function() {
          if ($this.hasClass(mymClass)) {
              remove_from_mymacaroni(event_id);
              $this.removeClass(mymClass);
              $this.addClass(mymClass_not);
              $this.html('<img src="/static/images/btn_my_mac_add.jpg" alt="" /> <span>Add to My Macaroni</span>');
          }
          else {
              $.post("/mymacaroni/add/" + event_id + "/", {});
              $this.addClass(mymClass);
              $this.removeClass(mymClass_not);
              $this.html('<img src="/static/images/btn_my_mac_remove.jpg" alt="" /> <span>Remove from My Macaroni</span>');
          }
          return false;
      });
   });
});



$(function() {
    $("textarea.richTextEditor").each(function() {
        var id = $(this).attr('id');
        var myEditor = new YAHOO.widget.Editor(id, {
            dompath: false, 
            width: '700px', 
            height: '300px', 
            handleSubmit : true, 

            toolbar: {
               buttonType: 'advanced', 
               buttons: [ 
                  { type: 'separator' }, 
                  { group: 'textstyle', label: 'Font Style', 
                      buttons: [ 
                          { type: 'push', label: 'Bold CTRL + SHIFT + B', value: 'bold' }, 
                          { type: 'push', label: 'Italic CTRL + SHIFT + I', value: 'italic' }, 
                          { type: 'push', label: 'Underline CTRL + SHIFT + U', value: 'underline' }, 
                          { type: 'separator' }, 
                          { type: 'push', label: 'Subscript', value: 'subscript', disabled: true }, 
                          { type: 'push', label: 'Superscript', value: 'superscript', disabled: true }, 
                          { type: 'separator' }, 
                          { type: 'color', label: 'Font Color', value: 'forecolor', disabled: true }, 
                          { type: 'color', label: 'Background Color', value: 'backcolor', disabled: true }, 
                          { type: 'separator' }, 
                          { type: 'push', label: 'Remove Formatting', value: 'removeformat', disabled: true }, 
                          { type: 'push', label: 'Show/Hide Hidden Elements', value: 'hiddenelements' } 
                      ] 
                  }, 
                  { type: 'separator' }, 
                  { group: 'alignment', label: 'Alignment', 
                      buttons: [ 
                          { type: 'push', label: 'Align Left CTRL + SHIFT + [', value: 'justifyleft' }, 
                          { type: 'push', label: 'Align Center CTRL + SHIFT + |', value: 'justifycenter' }, 
                          { type: 'push', label: 'Align Right CTRL + SHIFT + ]', value: 'justifyright' }, 
                          { type: 'push', label: 'Justify', value: 'justifyfull' } 
                      ] 
                  }, 
                  { type: 'separator' }, 
                  { group: 'parastyle', label: 'Paragraph Style', 
                      buttons: [ 
                      { type: 'select', label: 'Normal', value: 'heading', disabled: true, 
                          menu: [ 
                              { text: 'Normal', value: 'none', checked: true }, 
                              { text: 'Header 1', value: 'h1' }, 
                              { text: 'Header 2', value: 'h2' }, 
                              { text: 'Header 3', value: 'h3' }, 
                              { text: 'Header 4', value: 'h4' }, 
                              { text: 'Header 5', value: 'h5' }, 
                              { text: 'Header 6', value: 'h6' } 
                          ] 
                      } 
                      ] 
                  }, 
                  { type: 'separator' }, 
                  { group: 'indentlist', label: 'Indenting and Lists', 
                      buttons: [ 
                          { type: 'push', label: 'Indent', value: 'indent', disabled: true }, 
                          { type: 'push', label: 'Outdent', value: 'outdent', disabled: true }, 
                          { type: 'push', label: 'Create an Unordered List', value: 'insertunorderedlist' }, 
                          { type: 'push', label: 'Create an Ordered List', value: 'insertorderedlist' } 
                      ] 
                  }, 
                  { type: 'separator' }, 
                  { group: 'insertitem', label: 'Insert Item', 
                      buttons: [ 
                          { type: 'push', label: 'HTML Link CTRL + SHIFT + L', value: 'createlink', disabled: true }, 
                          { type: 'push', label: 'Insert Image', value: 'insertimage' } 
                      ] 
                  } 
              ] 
           }    

         });
       myEditor.render();

       var cleanPaste = new CleanPaste(myEditor);

    });
});

