﻿/*
Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/

/*
 * 31/05/2012	Tony Payne	(1.0.1)
 *		Max Window Height Reduced. 
 *		Image icon removed.
 *		Built in Spell Checker replaced by ieSpell.
 * 14/06/2012	Tony Payne	(1.0.2)
 *		Add Browse Server to Link.
*/

/* Default all Links to "_blank" */
CKEDITOR.on('dialogDefinition', function ( ev ){
   if(ev.data.name == 'link'){
      ev.data.definition.getContents('target').get('linkTargetType')['default']='_blank';
   }
});  

CKEDITOR.on( 'instanceReady', function( ev )
   {
      var editor = ev.editor,
      dataProcessor = editor.dataProcessor,
      htmlFilter = dataProcessor && dataProcessor.htmlFilter;
      htmlFilter.addRules({
         a : function ( element ){
            element.attributes['target']="_blank";
         }
      });
   });

/*	14/06/2012 Tony Payne
		Function to read cookies 
*/
function getCookie(c_name)
{
var i,x,y,ARRcookies=document.cookie.split(";");
for (i=0;i<ARRcookies.length;i++)
{
  x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
  y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
  x=x.replace(/^\s+|\s+$/g,"");
  if (x==c_name)
    {
    return unescape(y);
    }
  }
}

var programLocation = getCookie('ProgramLocation');		


CKEDITOR.editorConfig = function( config )
{
config.extraPlugins = 'autogrow,confighelper,tableresize,iespell';
config.autoGrow_onStartup = true;
config.autoGrow_maxHeight = 300;
config.autoGrow_minHeight = 50;
config.toolbarCanCollapse = true;
config.toolbarStartupExpanded = false;
config.width = 800;
config.height = 50;
config.ResizeEnabled = true;
config.resize_maxWidth = 800;
config.resize_minHeight = 50;
config.contentsCss = '../Stylesheets/QA.css';
config.enterMode = CKEDITOR.ENTER_BR;
config.disableNativeSpellChecker = false;

// Configure url for FileBrowser plugin
var baseHref = 'http://www.drapertools.co.uk/';
//var fullPath = baseHref + 'qatest/php/';
var fullPath = baseHref + programLocation + '/php/';
config.filebrowserBrowseUrl      = fullPath + 'ckeditor/filemanager/browser/default/browser.html?Connector=' + fullPath + 'ckeditor/filemanager/connectors/php/connector.php';
config.filebrowserImageBrowseUrl = fullPath + 'ckeditor/filemanager/browser/default/browser.html?Type=Image&Connector=' + fullPath + 'ckeditor/filemanager/connectors/php/connector.php';
config.filebrowserFlashBrowseUrl = fullPath + 'ckeditor/filemanager/browser/default/browser.html?Type=Flash&Connector=' + fullPath + 'ckeditor/filemanager/connectors/php/connector.php';
            
config.dialogFieldsDefaultValues = 
	{
		table:
			{
				info:
					{
						txtWidth : '100%',
						txtCellSpace : '0',
						txtCellPad : '3'
					}
			},
		cellProperties:
			{
				info:
					{
						vAlign : 'top'
					}
			}
	};

// Cut Down Version Of Special Characters	
config.specialChars =
	[
		'!','&quot;','#','$','%','&amp;',"'",'(',')','*','+','-','.','/',
		':',';',
		'&lt;','=','&gt;','?','@',
		'[',']','^','_','`',
		'{','}','~',
		"&euro;", "&lsquo;", "&rsquo;", "&ldquo;", "&rdquo;", "&ndash;", "&mdash;", "&cent;", "&pound;", "&uml;", "&copy;", "&ordf;", "&reg;", "&macr;", "&deg;", "&sup2;", "&sup3;", "&acute;", "&para;", "&middot;", "&cedil;", "&sup1;", "&ordm;", "&raquo;", "&times;", "&Oslash;", "&divide;", "&OElig;", "&sbquo;", "&#8219;", "&bdquo;", "&hellip;", "&trade;", "&#9658;", "&bull;", "&rarr;", "&rArr;", "&hArr;", "&diams;", "&asymp;"
	];
// Additional Draper Special Characters
config.specialChars = config.specialChars.concat( [ "&#10003;","&#181;","&Omega;","&#960;","&frac14;","&frac12;","&frac34;" ]);
// 1/8 - 7/8 - do not display correctly except in editor
config.specialChars = config.specialChars.concat( [ "&#x215B;","&#x215C;","&#x215D;","&#x215E;" ] );
//config.specialChars = config.specialChars.concat( [ "&frac18;","&#8540;","&#8541;","&#8542;" ] );
	
	
config.toolbar = 'QAToolbar';
config.toolbar_QAToolbar = [
	{ name: 'clipboard', items : [ 'Cut','Copy','Paste','PasteText','PasteFromWord','-','Undo','Redo' ] },
	{ name: 'basicstyles', items : [ 'Bold','Italic','Underline','Strike','Subscript','Superscript','-','RemoveFormat' ] },
	{ name: 'paragraph', items : [ 'NumberedList','BulletedList','-','Outdent','Indent','-','JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'] },
	{ name: 'links', items : [ 'Link','Unlink'] },
	'/',
	{ name: 'styles', items : [ 'Styles','Format','Font','FontSize' ] },
	{ name: 'colors', items : [ 'TextColor','BGColor' ] },
	{ name: 'editing', items : [ 'Find','Replace','-','SelectAll','-','ieSpell'] },
	{ name: 'insert', items : [ 'Table','HorizontalRule','SpecialChar','Image' ] },
	{ name: 'document', items : [ 'Source' ] }
] ;


};



