

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.matarikievents.co.nz/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.matarikievents.co.nz/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 About Matariki'});

					mm.add({title : '2.1 History of Matariki', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='History of Matariki';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, '{cms_selflink page="history-of-matariki" text="'+sel+'"}');
					}});

					mm.add({title : '2.2 Matariki Stories', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Matariki Stories';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, '{cms_selflink page="matariki-stories" text="'+sel+'"}');
					}});

					mm.add({title : '2.3 Matariki - Other Countries', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Matariki - Other Countries';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, '{cms_selflink page="other-countries-matariki" text="'+sel+'"}');
					}});
					var mm = m.addMenu({title : '4 2010 Matariki Events'});

					mm.add({title : '4.5 Nationwide', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Nationwide';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, '{cms_selflink page="nationwide" text="'+sel+'"}');
					}});

					mm.add({title : '4.6 Events Calendar', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Events Calendar';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, '{cms_selflink page="events-calendar" text="'+sel+'"}');
					}});

					mm.add({title : '4.8 Other Matariki Websites', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Other Matariki Websites';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, '{cms_selflink page="other-matariki-websites" text="'+sel+'"}');
					}});
					var mm = m.addMenu({title : '5 Events'});
					var mmm = mm.addMenu({title : '5.1 To add An Event'});

					mmm.add({title : '5.1 To add An Event', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='To add An Event';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, '{cms_selflink page="events-redirect" text="'+sel+'"}');
					}});
					mmm.addSeparator();

					mm.add({title : '5.2 Showcasing 2008 Matariki Events', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Showcasing 2008 Matariki Events';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, '{cms_selflink page="kahungunu-e" text="'+sel+'"}');
					}});
					var mmm = mm.addMenu({title : '5.3 Event Management'});

					mmm.add({title : '5.3.1 Event Management', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Event Management';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, '{cms_selflink page="events" text="'+sel+'"}');
					}});

					mmm.add({title : '5.3.2 Event Registration', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Event Registration';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, '{cms_selflink page="registration" text="'+sel+'"}');
					}});

					mmm.add({title : '5.3.3 Add Event', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Add Event';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, '{cms_selflink page="add-event" text="'+sel+'"}');
					}});

					mmm.add({title : '5.3.4 Update Event', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Update Event';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, '{cms_selflink page="update-event" text="'+sel+'"}');
					}});

					mmm.add({title : '5.3.5 Image instructions', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Image instructions';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, '{cms_selflink page="image-instructions" text="'+sel+'"}');
					}});

					mmm.add({title : '5.3.6 Delete Event', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Delete Event';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, '{cms_selflink page="delete-event" text="'+sel+'"}');
					}});
					var mm = m.addMenu({title : '6 Resources'});

					mm.add({title : '6.1 Help finding Matariki', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Help finding Matariki';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, '{cms_selflink page="help-to-find-matariki" text="'+sel+'"}');
					}});
					var mmm = mm.addMenu({title : '6.2 Matariki Event Training'});

					mmm.add({title : '6.2 Matariki Event Training', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Matariki Event Training';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, '{cms_selflink page="matariki-event-training" text="'+sel+'"}');
					}});
					mmm.addSeparator();

					mmm.add({title : '6.2.1 Event Training Overview', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Event Training Overview';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, '{cms_selflink page="event-training-overview" text="'+sel+'"}');
					}});

					mmm.add({title : '6.2.2 Qualification', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Qualification';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, '{cms_selflink page="qualification" text="'+sel+'"}');
					}});

					mm.add({title : '6.3 Ideas for your Event', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Ideas for your Event';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, '{cms_selflink page="ideas-for-producing-your-matariki-event" text="'+sel+'"}');
					}});

					mm.add({title : '6.4 Guardianship', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Guardianship';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, '{cms_selflink page="guardianship" text="'+sel+'"}');
					}});

					mm.add({title : '6.5 Downloads', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Downloads';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, '{cms_selflink page="matarik-for-the-computer" text="'+sel+'"}');
					}});

					mm.add({title : '6.6 Games', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Games';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, '{cms_selflink page="resources" text="'+sel+'"}');
					}});
					var mm = m.addMenu({title : '7 Media Releases'});
					var mmm = mm.addMenu({title : '7.1 Kaumatua Kapa Haka at Te Papa'});

					mmm.add({title : '7.1 Kaumatua Kapa Haka at Te Papa', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Kaumatua Kapa Haka at Te Papa';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, '{cms_selflink page="kaumatua-kapa-haka-2" text="'+sel+'"}');
					}});
					mmm.addSeparator();

					mmm.add({title : '7.1.1 Media Release', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Media Release';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, '{cms_selflink page="kaumatua-kapa-haka" text="'+sel+'"}');
					}});

					mm.add({title : '7.2 NZ Post Matarki Stamps', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='NZ Post Matarki Stamps';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, '{cms_selflink page="nz-post-matarki-stamps" text="'+sel+'"}');
					}});

					mm.add({title : '7.3 Wairoa Maori Film Festival', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Wairoa Maori Film Festival';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, '{cms_selflink page="wairoa-maori-film-festival" text="'+sel+'"}');
					}});
					var mm = m.addMenu({title : '8 Matariki Merchandise'});
					var mmm = mm.addMenu({title : '8.2 NZ Post'});

					mmm.add({title : '8.2 NZ Post', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='NZ Post';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, '{cms_selflink page="nz-post" text="'+sel+'"}');
					}});
					mmm.addSeparator();

					mmm.add({title : '8.2.1 NZ Post 2010 Matariki Stamps', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='NZ Post 2010 Matariki Stamps';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, '{cms_selflink page="nz-post-matariki-2010-stamps" text="'+sel+'"}');
					}});

					mmm.add({title : '8.2.2 NZ Post 2009 Matariki Stamps', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='NZ Post 2009 Matariki Stamps';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, '{cms_selflink page="nz-post-stamps" text="'+sel+'"}');
					}});
					var mmm = mm.addMenu({title : '8.3 Te Papa'});

					mmm.add({title : '8.3 Te Papa', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Te Papa';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, '{cms_selflink page="te-papa-matariki-merchandise" text="'+sel+'"}');
					}});
					mmm.addSeparator();

					mmm.add({title : '8.3.2 Matariki Maramataka Calendar 2010-2011', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Matariki Maramataka Calendar 2010-2011';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, '{cms_selflink page="matariki-maramataka-calendar-2010-2011" text="'+sel+'"}');
					}});

					mmm.add({title : '8.3.3 Matariki Maramataka Calendar 2009-2010', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Matariki Maramataka Calendar 2009-2010';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, '{cms_selflink page="items-for-sale" text="'+sel+'"}');
					}});

					mm.add({title : '8.4 Matakite Productions Ltd', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Matakite Productions Ltd';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, '{cms_selflink page="matakite-productions-ltd" text="'+sel+'"}');
					}});

					mm.add({title : '8.5 Add to our listings', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Add to our listings';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, '{cms_selflink page="add-to-our-listings" text="'+sel+'"}');
					}});
					var mm = m.addMenu({title : '9 NZ Maori Tourism Council'});

					m.add({title : '9 Links', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Links';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, '{cms_selflink page="website-links" text="'+sel+'"}');
					}});

					m.add({title : '9.1 A Brief History', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='A Brief History';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, '{cms_selflink page="a-brief-history" text="'+sel+'"}');
					}});

					m.add({title : '9.2 NZMTC Operating Values', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='NZMTC Operating Values';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, '{cms_selflink page="our-operating-values" text="'+sel+'"}');
					}});

					m.add({title : '9.3 Aotearoa National Matariki Project', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Aotearoa National Matariki Project';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, '{cms_selflink page="about-us" text="'+sel+'"}');
					}});

					m.add({title : '9.4 Other Key Initiatives', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='Other Key Initiatives';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, '{cms_selflink page="other-key-initiatives" text="'+sel+'"}');
					}});

					m.add({title : '10 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 : '11 test', onclick : function() {
						var sel=tinyMCE.activeEditor.selection.getContent();
						if (sel=='') sel='test';
						tinyMCE.activeEditor.execCommand('mceInsertContent', false, '{cms_selflink page="test" 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 : "",
  content_css : "http://www.matarikievents.co.nz/modules/TinyMCE/stylesheet.php?templateid=&mediatype=screen&bogus=1280569237",

    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,inlinepopups,advlink,paste,advimage,iespell,contextmenu",

  theme_advanced_buttons1 : "cut,paste,pastetext,pasteword,copy,separator,justifyleft,justifycenter,justifyright,justifyfull,bold,italic,underline,strikethrough,advhr,separator,bullist,numlist,separator,outdent,indent,separator,forecolor,backcolor",
  theme_advanced_buttons2 : "",  
  theme_advanced_buttons3 : "",

  theme_advanced_blockformats : "",
  document_base_url : "http://www.matarikievents.co.nz/",

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

  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",			

			

	
  file_browser_callback : 'CMSMSFilePicker'
  
});
  
	
  
function toggleEditor(id) {
  if (!tinyMCE.getInstanceById(id))
    tinyMCE.execCommand('mceAddControl', false, id);
  else
    tinyMCE.execCommand('mceRemoveControl', false, id);
}
  
	
  
function CMSMSFilePicker (field_name, url, type, win) {
     
  var cmsURL = "http://www.matarikievents.co.nz/modules/TinyMCE/filepicker.php?_s_=&type="+type;
  
  tinyMCE.activeEditor.windowManager.open({
  
    file : cmsURL,
    title : 'CMSMadeSimple File Selection',
    width : '700',
    height : '500',
    resizable : "yes",
    scrollbars : "yes",
    inline : "yes",      close_previous : "no"
  
  }, {
    window : win,
    input : field_name
  });
  return false;
}



	
