// XHTMLSuite
// $Id: xhtmlsuite_config.js,v 2.0 2008/06/01 14:37:04 bpfeifer Exp $
/**
* @ Content code
* @ Package XHTMLSuite
* @ Copyright © 2004-2009 Team XHTMLSuite - www.xhtmlsuite.com
* @ All rights reserved
* @ Released under XHTMLSuite License
* @ Version $Revision: 2.0 $
**/

XHTMLSuite.Config = function () {
	this.version = '2.0.2 Build 070720091152';

	this.outputHTML401 = false;

	if (this.outputHTML401) {
		this.doctype = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/loose.dtd">';
	} else {
		this.outputXHTML = true;
		this.doctype = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
	}

	this.charSet = _xs_editor_encoding;

	this.width = '650px';
	this.height = '350px';

	this.fullScreen = false;

	this.statusBar = true;
	this.showResizeBar = true;

	this.propertiesInspector = true;
	this.collapsedPropertiesBar = false;

	this.keepSelectionInHtmlView = true;
	this.syntaxHighlighting = true;
	this.wrapSourceCode = false;
	this.liveSyntaxHighlighting = true;
	this.indentChar = '   ';

	this.wymiwygMode = false;
	this.customEditorCSS = false;

	this.richDropDowns = true;
	this.showQuickTableDialog = true;
	this.fadeMenus = true;

	this.ImageManagerViewMode = 'simple';
	this.ImageManagerListMode = 'filmstrip';

	this.editorClassicStyle = false;

	this.flashUseSatayMethod = false;
	this.flashCLSID = 'clsid:D27CDB6E-AE6D-11CF-96B8-444553540000';
	this.flashPluginsPage = 'http://www.adobe.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash';
	this.flashCodeBase = 'http://fpdownload.adobe.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0';

	this.quicktimeCLSID = 'clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B';
	this.quicktimePluginsPage = 'http://www.apple.com/quicktime/download/';
	this.quicktimeCodeBase = 'http://www.apple.com/qtactivex/qtextension.cab';

	this.windowsmediaCLSID = 'clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95';
	this.windowsmediaPluginsPage = 'http://www.microsoft.com/Windows/Downloads/Contents/MediaPlayer/';
	this.windowsmediaCodeBase = 'http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701';

	this.useParagraph = true;
	this.disableColorPopup = false;

	this.undoSteps = 30;
	this.undoTimeout = 500;

	this.pageStyle = '';

	this.customCssClasses = false;
	this.nativeCssClasses = (typeof _xs_editing_css_url == 'undefined' ? false : XHTMLSuite.readCssFile(_xs_editing_css_url));
	this.editorBodyCssClass = false;

	this.killWordOnPaste = true;

	this.baseURL = _xs_site_url;

	this.adminURL = 'administrator';
	this.adminURLSearchString = '[^:]*:\/\/[^\/].*\/(' + this.adminURL + '\/)';
	this.RE_adminURL = new RegExp (this.adminURLSearchString);
	this.stripBaseURL = false;
	this.imgURL = 'themes/' + _xs_icon_theme + '/images/';
	this.popupURL = 'dialogs/';
	this.helpURL = _xs_editor_url + 'includes/help/help.html';

	var path = window.location.href.match(this.RE_adminURL);
	if (path !== null && path.length > 1) {
		this.popupURL2 = path[1];
	} else {
		this.popupURL2 = '';
	}

	this.make7BitPrintableURLs = false;
	this.disableSpecialCharEncoding = false;
	this.numericalEntities = false;

	this.specialReplacements = false;
	this.htmlRemoveTags = null;
	this.removeScripts = false;

	this.highlightAccessibilityTags = true;
	this.sourceCodeFormatting = true;

	this.statusbarHoverTips = true;

	this.clipBoardHelperUrl = 'https://vmacs.vmth.ucdavis.edu/userpages/compsrv/firefox-extensions/allowclipboardhelper.xpi';

	this.fontname = {
		'&mdash; Font &mdash;' 		: '',
		'Arial'						: 'arial,helvetica,sans-serif',
		'Arial Black'				: 'arial black,arial,helvetica,sans-serif',
		'Comic sans'				: 'comic sans ms,comic sans,comic,sans-serif',
		'Courier New'				: 'courier new,courier,monospace',
		'Georgia'					: 'georgia,times new roman,times,serif',
		'Impact'					: 'impact,charcoal,sans-serif',
		'Lucida Sans Unicode'		: 'lucida sans unicode,lucida grande,lucida sans,sans-serif',
		'Tahoma'					: 'tahoma,arial,helvetica,sans-serif',
		'Times New Roman'			: 'times new roman,times,serif',
		'Trebuchet'					: 'trebuchet ms,sans-serif',
		'Verdana'					: 'verdana,arial,helvetica,sans-serif'
	};

	this.fontsize = {
		'&mdash; Size &mdash;'		: '',
		'size_1'					: '1',
		'size_2'					: '2',
		'size_3'					: '3',
		'size_4'					: '4',
		'size_5'					: '5',
		'size_6'					: '6',
		'size_7'					: '7'
	};

	this.formatblock = {
		'&mdash; Format &mdash;': '',
		'Paragraph'				: 'p',
		'Div'					: 'div',
		'Heading 1'				: 'h1',
		'Heading 2'				: 'h2',
		'Heading 3'				: 'h3',
		'Heading 4'				: 'h4',
		'Heading 5'				: 'h5',
		'Heading 6'				: 'h6',
		'Address'				: 'address',
		'Formatted'				: 'pre'
	};

	this.customSelects = {};

	function cut_copy_paste(e, cmd, obj) {
		e.execCommand(cmd);
	}

	this.btnList = {
		bold : ['Bold', 'ed_format_bold.gif', false, function (e) {e.execCommand('bold');}],
		italic : ['Italic', 'ed_format_italic.gif', false, function (e) {e.execCommand('italic');}],
		underline : ['Underline', 'ed_format_underline.gif', false, function (e) {e.execCommand('underline');}],
		strikethrough : ['Strikethrough', 'ed_format_strike.gif', false, function (e) {e.execCommand('strikethrough');}],
		subscript : ['Subscript', 'ed_format_sub.gif', false, function (e) {e.execCommand('subscript');}],
		superscript : ['Superscript', 'ed_format_sup.gif', false, function (e) {e.execCommand('superscript');}],
		justifyleft : ['Justify Left', 'ed_align_left.gif', false, function (e) {e.execCommand('justifyleft');}],
		justifycenter : ['Justify Center', 'ed_align_center.gif', false, function (e) {e.execCommand('justifycenter');}],
		justifyright : ['Justify Right', 'ed_align_right.gif', false, function (e) {e.execCommand('justifyright');}],
		justifyfull : ['Justify Full', 'ed_align_justify.gif', false, function (e) {e.execCommand('justifyfull');}],
		insertorderedlist : ['Ordered List', 'ed_list_num.gif', false, function (e) {e.execCommand('insertorderedlist');}],
		insertunorderedlist : ['Bulleted List', 'ed_list_bullet.gif', false, function (e) {e.execCommand('insertunorderedlist');}],
		outdent : ['Decrease Indent', 'ed_indent_less.gif', false, function (e) {e.execCommand('outdent');}, 'blockquote'],
		indent : ['Increase Indent', 'ed_indent_more.gif', false, function (e) {e.execCommand('indent');}],
		forecolor : ['Font Color', 'ed_color_fg.gif', false, function (e) {e.execCommand('forecolor');}],
		hilitecolor : ['Background Color', 'ed_color_bg.gif', false, function (e) {e.execCommand('hilitecolor');}],
		inserthorizontalrule : ['Horizontal Rule', 'ed_hr.gif', false, function (e) {e.execCommand('inserthorizontalrule');}],
		createlink : ['Insert/Edit Web Link', 'ed_link.gif', false, function (e) {e.execCommand('createlink', true);}],
		unlink: ['Remove Link', 'ed_unlink.gif', false, function (e) {e.execCommand('Unlink');}, 'a'],
		insertimage : ['Insert Image', 'ed_insert_image.gif', false, function (e) {e.execCommand('insertimage');}],
		insertmedia : ['Insert Streaming Media', 'ed_insert_flash.gif', false, function (e) {e.execCommand('insertmedia');}],
		insertflash : ['Insert Flash Movie', 'ed_insert_flash.gif', false, function (e) {e.execCommand('insertflash');}],
		insertcharacter : ['Insert special character', 'ed_charmap.gif', false, function (e) {e.execCommand('insertcharacter');}],
		inserttable : ['Insert Table', 'ed_insert_table.gif', false, function (e) {e.execCommand('inserttable');}],
		inserttemplate : ['Insert HTML-Template', 'ed_insert_template.gif', false, function (e) {e.execCommand('inserttemplate');}],
		inserttime : ['Insert time string', 'ed_insert_time.gif', false, function (e) {e.execCommand('inserttime');}],
		insertdate : ['Insert date string', 'ed_insert_date.gif', false, function (e) {e.execCommand('insertdate');}],
		toggleborders : ['Activate/deactivate layout borders for tables without borders', 'ed_show_0_border.gif', false, function (e) {e.execCommand('toggleborders');}, 'table'],
		insertfile : ['Insert File', 'ed_linktofile.gif', false, function (e) {e.execCommand('insertfile');}],
		htmlmode : ['Toggle HTML Source', 'ed_html.gif', true, function (e) {e.execCommand('htmlmode');}],
		fullscreenmode : ['Enlarge Editor', 'ed_fullscreen_maximize.gif', true, function (e) {e.execCommand('fullscreenmode');}],
		about : ['About this editor', 'ed_about.gif', true, function (e) {e.execCommand('about');}],
		showhelp : ['Help using editor', 'ed_help.gif', true, function (e) {e.execCommand('showhelp');}],
		undo : ['Undoes your last action', 'ed_undo.gif', false, function (e) {e.execCommand('undo');}],
		redo : ['Redoes your last action', 'ed_redo.gif', false, function (e) {e.execCommand('redo');}],
		killword : ['Clean up Word tags', 'ed_clean_word.gif', false, function (e) {e.execCommand('killword');}],
		removeformat : ['Remove format', 'ed_remove_format.gif', false, function (e) {e.execCommand('removeformat');}],
		tidycode : ['Tidy source code', 'ed_tidycode.gif', false, function (e) {e.execCommand('tidycode');}],
		cut : ['Cut selection', 'ed_cut.gif', false, cut_copy_paste],
		copy : ['Copy selection', 'ed_copy.gif', false, cut_copy_paste],
		paste : ['Paste from clipboard', 'ed_paste.gif', false, cut_copy_paste],
		mosimage : ['Insert {mosimage} tag', 'ed_jos_image.gif', false, function (e) {e.focusEditor();e.insertHTML('{mosimage}');}],
		mospagebreak : ['Insert {mospagebreak} tag', 'ed_jos_pagebreak.gif', false, function (e) {e.focusEditor();e.insertHTML('{mospagebreak}');}],
		accessibilitycheck : ['Accessibility Check', 'ed_accessibility.gif', false, function (e) {e.execCommand('accessibilitycheck');}],
		xsabbr : ['Mark as abbreviation', 'ed_abbr.gif', false, function (e) {e.execCommand('xsabbr');}],
		xsacronym : ['Mark as acronym', 'ed_acronym.gif', false, function (e) {e.execCommand('xsacronym');}],
		xsquote : ['Mark as citation', 'ed_citation.gif', false, function (e) {e.execCommand('xsquote');}],
		preview : ['Preview', 'ed_preview.gif', true, function (e) {e.execCommand('preview');}],
		savedocument : ['Save', 'ed_save.gif', true, function (e) {e.execCommand('savedocument');}],
		uppercasetext : ['Convert selected characters to uppercase', 'ed_uppercasetext.gif', false, function (e) {e.execCommand('uppercasetext');}],
		lowercasetext : ['Convert selected characters to lowercase', 'ed_lowercasetext.gif', false, function (e) {e.execCommand('lowercasetext');}],
		lefttoright : ['Direction left to right', 'ed_left_to_right.gif', false, function (e) {e.execCommand('lefttoright');}],
		righttoleft : ['Direction right to left', 'ed_right_to_left.gif', false, function (e) {e.execCommand('righttoleft');}],
		syntaxhighlighting : ['Syntax Highlight HTML Code', 'ed_syntaxhighlighting.gif', false, function (e) {e.execCommand('syntaxhighlighting');}],
		togglewhitespace : ['Toggle whitespace', 'ed_toggle_whitespace.gif', false, function (e) {e.execCommand('togglewhitespace');}]
	};

	this.toolbar = [];
	this.toolbarTabNames = [];
	this.extensionToolBars = [];

	if (this.toolbarTabNames.length < this.toolbar.length) {
		this.toolbar.length = this.toolbarTabNames.length;
	}

	this.tabBarButtons = [];
	this.swatchColors = [];
	this.langMarks = {};
	this.tagsArray = false;

	for (var i in this.btnList) {
		var btn = this.btnList[i];
		if (typeof btn != 'object') {
			continue;
		}
		btn[1] = _xs_editor_url + this.imgURL + btn[1];
		if (typeof XHTMLSuite.I18N.tooltips[i] != 'undefined') {
			btn[0] = XHTMLSuite.I18N.tooltips[i];
		}
	}
};

XHTMLSuite.Config.prototype.registerButton = function (id, tooltip, image, textMode, action, context) {
	var the_id;
	if (typeof id == 'string') {
		the_id = id;
	} else if (typeof id == 'object') {
		the_id = id.id;
	} else {
		alert('ERROR [XHTMLSuite.Config::registerButton]:\ninvalid arguments');
		return false;
	}
	switch (typeof id) {
		case 'string':
			this.btnList[id] = [tooltip, image, textMode, action, context];
		break;
		case 'object':
			this.btnList[id.id] = [id.tooltip, id.image, id.textMode, id.action, id.context];
		break;
	}
	return true;
};

XHTMLSuite.Config.prototype.registerDropdown = function (object) {
	this.customSelects[object.id] = object;
};

XHTMLSuite.Config.prototype.hideButtons = function (remove) {
	var toolbar = this.toolbar;
	for (var i in toolbar) {
		var line = toolbar[i];
		for (var j = line.length; --j >= 0; ) {
			if (remove.indexOf(' ' + line[j] + ' ') >= 0) {
				var len = 1;
				if (/separator|space/.test(line[j + 1])) {
					len = 2;
				}
				line.splice(j, len);
			}
		}
	}
};