tinyMCE.init({
  mode                            : "textareas",
  theme                           : "advanced",
  editor_selector                 : "mceEditor",
  plugins                         : "table",
  theme_advanced_toolbar_location : "top",
  theme_advanced_buttons1         : "undo,redo,separator,bold,italic,underline,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,bullist,numlist,outdent,indent,separator,formatselect",
  theme_advanced_buttons2         : "link,unlink,anchor,hr,charmap,separator,tablecontrols,image,code",
  theme_advanced_buttons3         : "",
  theme_advanced_layout_manager   : "SimpleLayout",
  remove_script_host              : false,
  relative_urls                   : false,
  apply_source_formatting         : true,
  theme_advanced_image_image_browser_callback           : 'imagePicker',
  file_browser_callback           : 'imagePicker',
  extended_valid_elements         : 'map[class|dir<ltr?rtl|id|lang|name|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],'
                                  + 'area[accesskey|alt|class|coords|dir<ltr?rtl|href|id|lang|nohref<nohref|onblur|onclick|ondblclick|onfocus|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|shape<circle?default?poly?rect|style|tabindex|title|target]'
});

var imceBrowserURL = "/imgList.php";
var imceRefererWin, imceRefererField, imceRefererType, imceRefererURL;
function imagePicker(field_name, url, type, win) {
  //if (type!='image') return;//work for only images

  var imcePopup = window.open(imceBrowserURL, '', 'width=640, height=560, resize=1, scrollbars=1');
  imcePopup.focus();
  imceRefererWin = win;
  imceRefererField = win.document.forms[0].elements[field_name];
  imceRefererType = type;
  imceRefererURL = url;
}

