function mpInitTinyMCE() {
  tinyMCE.init({
    mode : "none",
    elements: "textContent",
    plugins:"visualchars",
    themes : 'advanced',
    theme_advanced_blockformats : "p,pre,h1,h2,h3,h4,h5,h6",
    theme_advanced_buttons1 : "bold,italic,underline,link,unlink,visualchars,bullist,numlist,formatselect",
    theme_advanced_buttons2 : "",
    theme_advanced_buttons3 : "",
    theme_advanced_toolbar_align : "left",
    theme_advanced_toolbar_location : "top",
    languages : 'en',
    disk_cache : true,
    debug : false
  });
}

function mpFormArticleOnDemand(urlPrefix, url, contentDivId) {
  //calls to jQuery.ajax occur on a user action, like a click on a link.
    jQuery.ajax({
      url:    urlPrefix + url + "&targetid=" + contentDivId,
      success:   function (data, textStatus) {
        // jQuery.getScript fixes safari 4 issues
        jQuery.getScript("http://sites-01.matchpoint.net/mp/10230/js/jquery.jSuggest.1.0.js");
        jQuery.getScript("http://sites-01.matchpoint.net/mp/10230/js/jquery.form.js", function(){	
          $('#' + contentDivId).html(data);
          if (document.getElementById('textContent') != null) {
            tinyMCE.execCommand('mceAddControl', false, 'textContent');
          }
        });	
      }	
    });
}

function mpJQueryDialogAdCenterAjaxInit(dialogBox, dialogBoxOpener, dialogBoxCloser, target, url, urlProxyPrefix) {
  $(document).ready(function() {
    $('#' + dialogBoxOpener).click(function(){
	    $('#' + dialogBox).show();
		  mpFormArticleOnDemand(urlProxyPrefix, url, target);
    });
    $('#' + dialogBoxCloser).click(function(){
      tinyMCE.execCommand('mceRemoveControl', false, 'textContent');		
      $('#' + target).children().remove();
	    $('#' + dialogBox).hide();											
    });
  });
}
