

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.charlesbryant.co.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}');
					}});

 				});
 				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.charlesbryant.co.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+'"}');
					}});
					var mm = m.addMenu({title : '2 Web Services'});

					mm.add({title : '2 Web Services', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Web Services';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, '{cms_selflink page="web-services" text="'+sel+'"}');
					}});
					mm.addSeparator();

					mm.add({title : '2.1 Web Design', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Web Design';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, '{cms_selflink page="web-design" text="'+sel+'"}');
					}});

					mm.add({title : '2.2 Web Development', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Web Development';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, '{cms_selflink page="web-development" text="'+sel+'"}');
					}});

					mm.add({title : '2.3 Front End Development', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Front End Development';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, '{cms_selflink page="front-end-development" text="'+sel+'"}');
					}});

					mm.add({title : '2.4 CMS', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='CMS';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, '{cms_selflink page="cms" text="'+sel+'"}');
					}});

					mm.add({title : '2.5 Ecommerce', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Ecommerce';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, '{cms_selflink page="ecommerce" text="'+sel+'"}');
					}});
					var mm = m.addMenu({title : '3 Web Marketing'});

					mm.add({title : '3 Web Marketing', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Web Marketing';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, '{cms_selflink page="web-marketing" text="'+sel+'"}');
					}});
					mm.addSeparator();

					mm.add({title : '3.1 SEO', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='SEO';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, '{cms_selflink page="seo" text="'+sel+'"}');
					}});

					mm.add({title : '3.2 Pay Per Click', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Pay Per Click';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, '{cms_selflink page="pay-per-click" text="'+sel+'"}');
					}});

					mm.add({title : '3.3 Traffic Analysis', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Traffic Analysis';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, '{cms_selflink page="traffic-analysis" text="'+sel+'"}');
					}});

					mm.add({title : '3.4 Email Marketing', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Email Marketing';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, '{cms_selflink page="email-marketing" text="'+sel+'"}');
					}});

					m.add({title : '4 Blog', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Blog';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, '{cms_selflink page="blog" text="'+sel+'"}');
					}});

					m.add({title : '5 Contact', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Contact';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, '{cms_selflink page="contact" text="'+sel+'"}');
					}});

					m.add({title : '6 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 : "m5fbrp__6",
  content_css : "http://www.charlesbryant.co.uk/modules/TinyMCE/stylesheet.php?templateid=20&mediatype=screen&bogus=1328483708",

    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,
  
  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.charlesbryant.co.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);
}
  

  
