var activatedAreas = new Array();

function setTextareaToTinyMCE(sEditorID)
{
  var oEditor = document.getElementById(sEditorID);
    if(oEditor)
  {
    if(activatedAreas[sEditorID] == true)
      unsetTextareaToTinyMCE(sEditorID);
    try {
      activatedAreas[sEditorID] = true;
      tinyMCE.execCommand("mceAddControl", true, sEditorID);
    }
    catch(e)
    {
      //alert("Error activating element " + sEditorID + "\n" + e);
    }
  }
}

function unsetTextareaToTinyMCE(sEditorID)
{
  var oEditor = document.getElementById(sEditorID);
  if(oEditor && (activatedAreas[sEditorID] == true))
  {
    try
    {
      tinyMCE.execCommand("mceRemoveControl", true, sEditorID);
      activatedAreas[sEditorID] = false;
    }
    catch(e)
    {
      //alert("Error deactivating element " + sEditorID + "\n" + e);
    }
  }
}

function tinymceDeactivate()
{
  try {
    tinyMCE.triggerSave(true,true);
  }
  catch(e)
  {
    //alert("Error saving form\n" + e);
  }

  for(var i in activatedAreas)
  {
    if(activatedAreas[i] == true)
    {
      unsetTextareaToTinyMCE(i);
    }
  }
}


tinyMCE.init({

  mode: "exact",
  language: "es",
  theme : "advanced",
  //document_base_url : "../",
  theme_advanced_resize_horizontal : false,
  theme_advanced_resizing : true,
  auto_reset_designmode : true,
  plugins: "table,advlink,contextmenu,paste,noneditable,inlinepopups,autosave",
  noneditable_noneditable_class: "tagImagen",
  theme_advanced_toolbar_location: "top",
  theme_advanced_toolbar_align: "left",
  theme_advanced_path_location: "bottom",
  //theme_advanced_buttons1 : "table,bold,italic,underline,separator,justifyleft,justifycenter,justifyright, justifyfull,separator,bullist,numlist,separator,undo,redo,link,unlink,separator,pastetext,pasteword,selectall",
  theme_advanced_buttons1 : "formatselect,table,bold,italic,underline,separator,justifyleft,justifycenter,justifyright,justifyfull",
	theme_advanced_buttons2 : "bullist,numlist,separator,undo,redo,link,separator,pastetext,pasteword,code",
  theme_advanced_buttons3 : "",
  valid_elements : "*[*]",
  extended_valid_elements: "img[id|width|height|class|src|alt|title|onmouseover|onmouseout|name]",
  verify_html : true,
  relative_urls: false,
  height: "100%",
  width: "100%",
  // Esto es para que limpie lo que se pegue del word
  paste_auto_cleanup_on_paste : true,
  paste_convert_headers_to_strong : true,
	paste_create_paragraphs : false,
	paste_create_linebreaks : false,
	paste_use_dialog : true,
	paste_auto_cleanup_on_paste : true,
	paste_convert_middot_lists : false,
	paste_unindented_list_class : "unindentedList",
	paste_convert_headers_to_strong : true,
	//paste_insert_word_content_callback : "convertWord",
	debug: false
  });


