

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.transitionexeter.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.transitionexeter.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 News', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='News';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, "{cms_selflink page='news' text='"+sel+"'}");
					}});
					var mm = m.addMenu({title : '3 Activities'});

					mm.add({title : '3 Activities', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Activities';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, "{cms_selflink page='activities' text='"+sel+"'}");
					}});
					mm.addSeparator();
					var mmm = mm.addMenu({title : '3.1 Transport'});

					mmm.add({title : '3.1 Transport', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Transport';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, "{cms_selflink page='transport' text='"+sel+"'}");
					}});
					mmm.addSeparator();

					mmm.add({title : '3.1.1 Transport Group', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Transport Group';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, "{cms_selflink page='transport-group' text='"+sel+"'}");
					}});

					mmm.add({title : '3.1.3 Critical Mass', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Critical Mass';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, "{cms_selflink page='critical-mass' text='"+sel+"'}");
					}});
					var mmm = mm.addMenu({title : '3.2 Food'});

					mmm.add({title : '3.2 Food', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Food';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, "{cms_selflink page='food' text='"+sel+"'}");
					}});
					mmm.addSeparator();

					mmm.add({title : '3.2.1 Food Strategy Group', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Food Strategy Group';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, "{cms_selflink page='food-strategy-group' text='"+sel+"'}");
					}});

					mmm.add({title : '3.2.2 Local Food Co-op', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Local Food Co-op';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, "{cms_selflink page='local-food-co-op' text='"+sel+"'}");
					}});
					var mmm = mm.addMenu({title : '3.3 Energy'});

					mmm.add({title : '3.3 Energy', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Energy';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, "{cms_selflink page='energy' text='"+sel+"'}");
					}});
					mmm.addSeparator();

					mmm.add({title : '3.3.1 Low Carbon Exeter Projec &#133;', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Low Carbon Exeter Project';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, "{cms_selflink page='low-carbon-exeter-project' text='"+sel+"'}");
					}});

					mmm.add({title : '3.3.2 Green Homes Tour', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Green Homes Tour';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, "{cms_selflink page='green-homes-tour' text='"+sel+"'}");
					}});

					mmm.add({title : '3.3.3 Energy Saving in the Hom &#133;', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Energy Saving in the Home';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, "{cms_selflink page='energy-saving-home' text='"+sel+"'}");
					}});

					mmm.add({title : '3.3.4 Retailer Energy Efficien &#133;', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Retailer Energy Efficiency Award Scheme';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, "{cms_selflink page='reeas' text='"+sel+"'}");
					}});
					var mmm = mm.addMenu({title : '3.4 Inner Transition'});

					mmm.add({title : '3.4 Inner Transition', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Inner Transition';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, "{cms_selflink page='inner_transition' text='"+sel+"'}");
					}});
					mmm.addSeparator();

					mmm.add({title : '3.4.1 Inner Transition Group', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Inner Transition Group';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, "{cms_selflink page='inner_transition-group' text='"+sel+"'}");
					}});
					var mm = m.addMenu({title : '4 Get Involved'});

					mm.add({title : '4 Get Involved', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Get Involved';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, "{cms_selflink page='get-involved' text='"+sel+"'}");
					}});
					mm.addSeparator();

					mm.add({title : '4.1 Ways of Helping', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Ways of Helping';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, "{cms_selflink page='ways-of-helping' text='"+sel+"'}");
					}});

					mm.add({title : '4.2 Contact', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Contact';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, "{cms_selflink page='contact' text='"+sel+"'}");
					}});

					mm.add({title : '4.7 Borrow a DVD', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Borrow a DVD';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, "{cms_selflink page='borrow-a-dvd' text='"+sel+"'}");
					}});
					var mm = m.addMenu({title : '5 Events'});

					mm.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+"'}");
					}});
					mm.addSeparator();

					mm.add({title : '5.1 Full List of Upcoming Even &#133;', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Full List of Upcoming Events';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, "{cms_selflink page='upcoming-events' text='"+sel+"'}");
					}});

					mm.add({title : '5.2 Previous Events and Report &#133;', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Previous Events and Reports';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, "{cms_selflink page='previous-events' text='"+sel+"'}");
					}});
					var mm = m.addMenu({title : '6 About'});

					mm.add({title : '6 About', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='About';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, "{cms_selflink page='about' text='"+sel+"'}");
					}});
					mm.addSeparator();

					mm.add({title : '6.1 Transition', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Transition';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, "{cms_selflink page='transition' text='"+sel+"'}");
					}});
					var mmm = mm.addMenu({title : '6.2 Transition Exeter'});

					mmm.add({title : '6.2 Transition Exeter', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Transition Exeter';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, "{cms_selflink page='transition-exeter' text='"+sel+"'}");
					}});
					mmm.addSeparator();

					mmm.add({title : '6.2.1 Core Group', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Core Group';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, "{cms_selflink page='core-group' text='"+sel+"'}");
					}});

					mmm.add({title : '6.2.2 Constitution', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Constitution';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, "{cms_selflink page='constitution' text='"+sel+"'}");
					}});

					mm.add({title : '6.3 Videos', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Videos';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, "{cms_selflink page='videos' text='"+sel+"'}");
					}});
					var mm = m.addMenu({title : '7 Contact Us'});

					mm.add({title : '7 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+"'}");
					}});
					mm.addSeparator();

					mm.add({title : '7.1 Media', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Media';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, "{cms_selflink page='media' text='"+sel+"'}");
					}});
					var mm = m.addMenu({title : '8 Sandbox'});

					mm.add({title : '8 Sandbox', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Sandbox';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, "{cms_selflink page='sandbox' text='"+sel+"'}");
					}});
					mm.addSeparator();

					mm.add({title : '8.1 blogs', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='blogs';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, "{cms_selflink page='blogs' text='"+sel+"'}");
					}});

					mm.add({title : '8.2 rss feeds', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='rss feeds';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, "{cms_selflink page='rss-feeds' 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.transitionexeter.org.uk/modules/TinyMCE/stylesheet.php?templateid=26&amp;mediatype=screen&amp;bogus=1284036484",

    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.transitionexeter.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);
}
  

  