// this is populated by each tinyMCE WYWISYG with their settings on page load
var cf_tinymce_settings = {};

$(function() {
  $('textarea.cf_tinymce').each(function() {
    var field_name = $(this).attr("name");
    var settings   = cf_tinymce_settings[field_name];
    settings.script_url = g.root_url + "/modules/field_type_tinymce/tinymce/tiny_mce.js";
    settings.theme = "advanced",
    $(this).tinymce(settings);
  });
});

cf_tinymce_settings.check_required = function() {
  var errors = [];
  for (var i=0; i<rsv_custom_func_errors.length; i++) {
    if (rsv_custom_func_errors[i].func != "cf_tinymce_settings.check_required") {
      continue;
    }
    var field_name = rsv_custom_func_errors[i].field;
    var val = $.trim(tinyMCE.get("cf_" + field_name + "_id").getContent());
    if (!val) {
      var el = document.edit_submission_form[field_name];
      errors.push([el, rsv_custom_func_errors[i].err]);
    }
  }
  if (errors.length) {
    return errors;
  }
  return true; 
}