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);
    }
  }
}

function submitForm(formId)
{
 if($(formId).onsubmit())
 {
    $(formId).submit();
 }
}
//MODIFICATO
tinyMCE.init({
  theme : "advanced",
  language : "it",
  mode : "exact",
  relative_urls : false,
  debug : false,
  valid_elements : "*[*]",
  height:"500",
  width:"100%",
  theme_advanced_resize_horizontal : false,
  //theme_advanced_resizing : true, ORIGINALE
  auto_reset_designmode : true,
  file_browser_callback : "myRichUrlManage.fileBrowserCallBack",
  plugins : "safari,spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,imagemanager,filemanager",
  theme_advanced_buttons1 :"save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect",
  theme_advanced_buttons2 :"cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
  theme_advanced_buttons3 :"tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
  theme_advanced_buttons4:"insertlayer,moveforward,movebackward,absolute,|,styleprops,spellchecker,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,blockquote,pagebreak,|,insertfile,insertimage",
  theme_advanced_toolbar_location : "top",
  theme_advanced_toolbar_align : "left",
  theme_advanced_statusbar_location : "bottom",
  theme_advanced_resizing : true,
  extended_valid_elements : "iframe[src|width|height|name|align]",
  content_css : "/css/stili.css"
});

