$(function() {
	/* By default ckeditor load related resources with a timestamp to avoid cache problem when upgrading itself
	 * load_plugin_file.php does not allow other param that file to load (pf param), so remove timestamp
	 */

	CKEDITOR.timestamp = '';
	CKEDITOR.config.skin = 'dotclear,'+dotclear.dcckeditor_plugin_url+'/js/ckeditor-skins/dotclear/';
	
	CKEDITOR.plugins.addExternal('entrylink',dotclear.dcckeditor_plugin_url+'/js/ckeditor-plugins/entrylink/');	
	CKEDITOR.plugins.addExternal('dclink',dotclear.dcckeditor_plugin_url+'/js/ckeditor-plugins/dclink/');
	CKEDITOR.plugins.addExternal('media',dotclear.dcckeditor_plugin_url+'/js/ckeditor-plugins/media/');


	$('textarea#post_excerpt,textarea#post_content').ckeditor({
		extraPlugins: 'entrylink,dclink,media',
		entities: false,
		allowedContent: true,
		toolbar: [{ 
			name: 'basicstyles',
			items: ['Bold','Italic','Underline','Strike','Blockquote',
				'NumberedList', 'BulletedList','RemoveFormat', 'EntryLink','dcLink','Media',
				'-','Source', 'Maximize'] 
		}]
	});

	CKEDITOR.on('instanceReady', function(e) {
		if ($('#post_excerpt').is(':hidden')) {
			$('#cke_post_excerpt').toggleClass('hide');
		} else {
			$('#cke_post_excerpt').removeClass('hide');
		}
		
		$('#excerpt-area label').click(function() {
			$('#cke_post_excerpt').toggleClass('hide',$('#post_excerpt').hasClass('hide'));
		});
	});


});
