jQuery(document).ready(function($){
	$('#CommentBoxController').hide();

	var config = {
		width: '99%'
		,language:'fr'
		,height: '500'
		,autoUpdateElement : true
		,extraPlugins : 'uicolor'
		,uiColor: '#eaeaea'
		,fontSize_defaultLabel:'11pt'
/*		,toolbar:
		[
			['Source'],
			['Bold', 'Italic','Underline','Strike'],
			['Format'],
			['NumberedList', 'BulletedList'],
			['Link', 'Unlink','Anchor'],
			['Scayt','Undo','Redo'],
			'/',
			['Find','Replace','-','SelectAll','RemoveFormat'],
			['Image','MediaEmbed','Flash','Table','HorizontalRule','Smiley','SpecialChar'],
			['Outdent','Indent','Blockquote'],
			['Maximize','About'],
			['SelectAll','RemoveFormat']
		]*/
	};

// Initialize the editor.
// Callback function can be passed and executed after full instance creation.
ir_type = $('input[name="FormatType"]');
ir_type.change(function(){
	if( $(this).attr('value') == 'Html' )
		$('#CommentBox').eq(0).data( '_ckeditorInstance_', CKEDITOR.replace($('#CommentBox').get(0),config));
	else if ($('#CommentBox').eq(0).data('_ckeditorInstance_') != null ) {
		$('#CommentBox').eq(0).data('_ckeditorInstance_').destroy();
		$('#CommentBox').eq(0).data('_ckeditorInstance_', null);
	}
});
ir_type = $('input[name="FormatType"][checked]');
ir_type.change();

/*
$('input[type="submit"][name="btnSave"]').click(function(){
//$('#frmPostComment').submit(function(){
  cbox = $('#CommentBox');
  content = cbox.val();
  cbox.ckeditorGet().destroy();
//  $('textarea[name="Body"]'	).val( content	);
  $('#CommentBox').text( content	);

  alert(content					);
  alert($('textarea[name="Body"]').text()	);
  alert($('textarea[name="Body"]').val()	);
  alert($('#CommentBox').val()			);
  alert($('textarea[name="Body"]').get(0).value );

  return false;
});
*/



	/*	2010-02-19 11:50:30 LS
	 *	Stop CKEditor from butchering the sourcecode with random carriage returns.
	 *	http://cksource.com/forums/viewtopic.php?f=6&t=14493&p=38352&hilit=ckeditor#p38352
	 */
	CKEDITOR.on('instanceReady', function(ev)
	{	var TagsBlock = ['br','caption','div','h1','h2','h3','h4','h5','h6','li','ol','p','ul','table','tbody','td','th','thead','tr']; // etc.

		for (var key in TagsBlock) {
		ev.editor.dataProcessor.writer.setRules(TagsBlock[key],
			{	indent : true,
				breakBeforeOpen : true,
				breakAfterOpen : false,
				breakBeforeClose : false,
				breakAfterClose : true
			});
		}

		/*	2010-02-24 17:10:34 LS
		 *	Slightly over the top since this is the same as default, but hey :D
		 */
		var TagsInline = ['a','span']; // etc.

		for (var key in TagsInline) {
		ev.editor.dataProcessor.writer.setRules(TagsInline[key],
			{	indent : false,
				breakBeforeOpen : false,
				breakAfterOpen : false,
				breakBeforeClose : false,
				breakAfterClose : false
			});
		}
	});

	/*	2010-02-19 11:51:53 LS
	 *	Enable the MediaEmbed plugin for CKEditor 3
	 *	http://www.fluidbyte.net/index.php?view=embed-youtube-vimeo-etc-into-ckeditor
	 *	http://jesox.com/posts/how-add-youtube-vimeo-or-any-other-embed-content-ckeditor
	 */
	config.extraPlugins = 'MediaEmbed';
	CKEDITOR.plugins.addExternal('mediaembed','extensions/JQuery/plugins/ckeditor/plugins/MediaEmbed/');

});
// allows compatibility with prototype and other libraries

