

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.thechuckwagongang.net/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.thechuckwagongang.net/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, '<a href="{cms_selflink href=\'home\'}">'+sel+'</a>');
					}});
					var mm = m.addMenu({title : '2 Bio'});

					mm.add({title : '2 Bio', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Bio';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, '<a href="{cms_selflink href=\'bio\'}">'+sel+'</a>');
					}});
					mm.addSeparator();

					mm.add({title : '2.1 History', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='History';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, '<a href="{cms_selflink href=\'history\'}">'+sel+'</a>');
					}});

					m.add({title : '3 Schedule', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Schedule';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, '<a href="{cms_selflink href=\'schedule\'}">'+sel+'</a>');
					}});
					var mm = m.addMenu({title : '4 Store'});

					mm.add({title : '4 Store', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Store';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, '<a href="{cms_selflink href=\'store\'}">'+sel+'</a>');
					}});
					mm.addSeparator();

					mm.add({title : '4.1 CDs', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='CDs';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, '<a href="{cms_selflink href=\'cds\'}">'+sel+'</a>');
					}});

					mm.add({title : '4.2 DVDs', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='DVDs';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, '<a href="{cms_selflink href=\'dvds\'}">'+sel+'</a>');
					}});

					mm.add({title : '4.3 Books &amp; Songbooks', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Books &amp; Songbooks';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, '<a href="{cms_selflink href=\'songbooks\'}">'+sel+'</a>');
					}});

					mm.add({title : '4.4 Downloads', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Downloads';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, '<a href="{cms_selflink href=\'downloads\'}">'+sel+'</a>');
					}});

					mm.add({title : '4.7 Misc', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Misc';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, '<a href="{cms_selflink href=\'misc\'}">'+sel+'</a>');
					}});

					m.add({title : '5 Blog', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Blog';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, '<a href="{cms_selflink href=\'blog\'}">'+sel+'</a>');
					}});

					m.add({title : '6 News', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='News';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, '<a href="{cms_selflink href=\'news\'}">'+sel+'</a>');
					}});

					m.add({title : '7 Media', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Media';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, '<a href="{cms_selflink href=\'media-press\'}">'+sel+'</a>');
					}});

					m.add({title : '8 Donations', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Donations';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, '<a href="{cms_selflink href=\'donate\'}">'+sel+'</a>');
					}});

					m.add({title : '9 Photos', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Photos';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, '<a href="{cms_selflink href=\'photos\'}">'+sel+'</a>');
					}});
					var mm = m.addMenu({title : '10 Contact Us'});

					mm.add({title : '10 Contact Us', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Contact Us';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, '<a href="{cms_selflink href=\'contact\'}">'+sel+'</a>');
					}});
					mm.addSeparator();

					mm.add({title : '10.1 Booking Form', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Booking Form';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, '<a href="{cms_selflink href=\'booking-form\'}">'+sel+'</a>');
					}});

					m.add({title : '11 Search', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Search';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, '<a href="{cms_selflink href=\'search\'}">'+sel+'</a>');
					}});

					m.add({title : '12 Singing By The Lake', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Singing By The Lake';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, '<a href="{cms_selflink href=\'singingbylake\'}">'+sel+'</a>');
					}});

					m.add({title : '13 test', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='test';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, '<a href="{cms_selflink href=\'test\'}">'+sel+'</a>');
					}});

					m.add({title : '14 Homecoming', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Homecoming';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, '<a href="{cms_selflink href=\'homecoming\'}">'+sel+'</a>');
					}});

				});

				// 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.thechuckwagongang.net/modules/TinyMCE/stylesheet.php?templateid=21&amp;mediatype=screen&amp;bogus=1284036889",

    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,spellchecker",
  
  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,spellchecker,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.thechuckwagongang.net/",

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

  