

tinymce.create('tinymce.plugins.CustomDropDown', {
	createControl: function(n, cm) {
		switch (n) {
			case 'customdropdown': {
			  var c = cm.createMenuButton('customdropdown', {
					title : 'Custom dropdown-menu',
					image : 'http://www.soxoncamra.org.uk/modules/TinyMCE/images/customdropdown.gif',
					icons : false
				});
				c.onRenderMenu.add(function(c, m) {				
    					m.add({title : 'Start expand/collapse-area', onclick : function() {
	  					tinyMCE.activeEditor.execCommand('mceInsertContent', false, '{startExpandCollapse id=\'expand1\' title=\'This is my expandable area\'}');
					}});
    					m.add({title : 'End expand/collapse-area', onclick : function() {
	  					tinyMCE.activeEditor.execCommand('mceInsertContent', false, '{stopExpandCollapse}');
					}});
  					m.addSeparator();
    					m.add({title : 'Insert CMS version info', onclick : function() {
	  					tinyMCE.activeEditor.execCommand('mceInsertContent', false, '{cms_version} {cms_versionname}');
					}});
  					m.addSeparator();
  	  				m.add({title : 'Insert Smarty {literal} around selection', onclick : function() {
              var sel=tinyMCE.activeEditor.selection.getContent();
	  					tinyMCE.activeEditor.execCommand('mceInsertContent', false, '{literal}'+sel+'{/literal}');
					}});

 				});
 				return c;
			}			
		}
		return null;
		
	}
});
// Register plugin with a short name

tinymce.PluginManager.add('customdropdown', tinymce.plugins.CustomDropDown);

		
//Creates a new plugin class and a custom listbox
tinymce.create('tinymce.plugins.CMSLinkerPlugin', {
	createControl: function(n, cm) {	
		switch (n) {
			case 'cmslinker':			
				var c = cm.createMenuButton('cmslinker', {
					title : 'Insert link to cmsms-page',
					image : 'http://www.soxoncamra.org.uk/modules/TinyMCE/images/cmsmslink.gif',
					icons : false
				});

				c.onRenderMenu.add(function(c, m) {

					m.add({title : '1 Home', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Home';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, "{cms_selflink page='home' text='"+sel+"'}");
					}});

					m.add({title : '2 About us', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='About us';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, "{cms_selflink page='about-soxon-camra' text='"+sel+"'}");
					}});

					m.add({title : '2.1 Pub Map', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Pub Map';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, "{cms_selflink page='pub-map' text='"+sel+"'}");
					}});
					var mm = m.addMenu({title : '3 News'});

					mm.add({title : '3 News', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='News';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, "{cms_selflink page='news' text='"+sel+"'}");
					}});
					mm.addSeparator();

					mm.add({title : '3.1 Submit News &amp; Events', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Submit News &amp; Events';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, "{cms_selflink page='submit-news' text='"+sel+"'}");
					}});

					m.add({title : '4 Newsletter', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Newsletter';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, "{cms_selflink page='newsletter' text='"+sel+"'}");
					}});

					m.add({title : '5 Events', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Events';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, "{cms_selflink page='events' text='"+sel+"'}");
					}});

					m.add({title : '6 Contact us', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Contact us';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, "{cms_selflink page='contact-us' text='"+sel+"'}");
					}});

					m.add({title : '7 What we do', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='What we do';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, "{cms_selflink page='what-we-do' text='"+sel+"'}");
					}});

					m.add({title : '8 CAMRA UK', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='CAMRA UK';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, "{cms_selflink page='camra-uk' text='"+sel+"'}");
					}});

					m.add({title : '9 Privacy Policy', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Privacy Policy';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, "{cms_selflink page='privacy-policy' text='"+sel+"'}");
					}});

					m.add({title : '10 Site Map', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Site Map';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, "{cms_selflink page='site-map' text='"+sel+"'}");
					}});

				});

				// Return the new menu button instance
				return c;
		}

		return null;
	}
});

// Register plugin with a short name
tinymce.PluginManager.add('cmslinker', tinymce.plugins.CMSLinkerPlugin);
		 tinyMCE.init({ 
    mode : "exact",
  elements : "",
  body_class : "CMSMSBody",
  content_css : "http://www.soxoncamra.org.uk/modules/TinyMCE/stylesheet.php?templateid=26&amp;mediatype=screen&amp;bogus=1283621211",

    entity_encoding : "raw", 
  button_tile_map : true, //performance update

		
  theme : "advanced",
  skin : "default",
  skin_variant : "",
  theme_advanced_toolbar_location : "top",
  theme_advanced_toolbar_align : "left",
  visual : true,
	      
  accessibility_warnings : false,
      			
  fix_list_elements : true,
  verify_html : true,
  verify_css_classes : false,
  
  plugins : "-cmslinker,-customdropdown,paste,advimage,advlink,contextmenu,inlinepopups",
  
  paste_auto_cleanup_on_paste : true,
  paste_remove_spans : true,
  paste_remove_styles : true,

  theme_advanced_buttons1 : "cut,paste,pastetext,pasteword,copy,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,styleselect,formatselect,fontselect,fontsizeselect",
  theme_advanced_buttons2 : "bold,italic,underline,strikethrough,advhr,separator,bullist,numlist,separator,outdent,indent,separator,undo,redo,separator,cmslinker,link,unlink,anchor,image,charmap,cleanup,separator,forecolor,backcolor,separator,code,fullscreen,help",
  theme_advanced_buttons3 : "",
  theme_advanced_buttons4 : "",


  theme_advanced_blockformats : "p,div,h1,h2,h3,h4,h5,h6,div,blockquote,dt,dd,code,samp",
  document_base_url : "http://www.soxoncamra.org.uk/",

  relative_urls : true,
  remove_script_host : true,
  	
  language: "en",
  dialog_type: "modal",
  apply_source_formatting : true,

  theme_advanced_statusbar_location : 'bottom',
  theme_advanced_path : true,
			
		
	force_br_newlines : false,
  force_p_newlines : true,		
			 
  forced_root_block : false,		
		
  plugin_insertdate_dateFormat : "%Y-%m-%d",
  plugin_insertdate_timeFormat : "%H:%M:%S"



    
});
  
	
  
function toggleEditor(id) {
  if (!tinyMCE.getInstanceById(id))
    tinyMCE.execCommand('mceAddControl', false, id);
  else
    tinyMCE.execCommand('mceRemoveControl', false, id);
}
  

  