// ----------------------------------------------------------------------------
// markItUp!
// ----------------------------------------------------------------------------
// © 2008 Jay Salvat
// http://markitup.jaysalvat.com/
// ----------------------------------------------------------------------------
// BBCode tags example
// http://en.wikipedia.org/wiki/Bbcode
// ----------------------------------------------------------------------------
// Feel free to add more tags
// ----------------------------------------------------------------------------
markItUpSettingsBBCode = {
	className: "bbcode",
	previewParserPath: "", // path to your BBCode parser
	markupSet: [
		{name: "Cut", className: "cut", replaceWith: "", call: function(markitup) {
			if (window.clipboardData && window.clipboardData.setData) window.clipboardData.setData("Text", markitup.selectedText);
		}},
		{name: "Copy", className: "copy", call: function(markitup) {
			if (window.clipboardData && window.clipboardData.setData) window.clipboardData.setData("Text", markitup.selectedText);
		}},
		{name: "Paste", className: "paste", replaceWith: "", call: function(markitup) {
			if (window.clipboardData && window.clipboardData.setData) markitup.openTag = window.clipboardData.getData("Text");
		}},
		{separator: true},
		{name: "Bold", className: "bold", key: "B", openTag: "[b]", closeTag: "[/b]"},
		{name: "Italic", className: "italic", key: "I", openTag: "[i]", closeTag: "[/i]"},
		//{name: "Underline", className: "underline", key: "U", openTag: "[u]", closeTag: "[/u]"},
		{name: "Strikethrough", className: "strikethrough", key: "S", openTag: "[s]", closeTag: "[/s]"},
		{separator: true},
		/*{name: "Size", className: "font", dropMenu: [
			{name: "Big", openTag: "[size=200]", closeTag: "[/size]"},
			{name: "Normal", openTag: "[size=100]", closeTag: "[/size]"},
			{name: "Small", openTag: "[size=50]", closeTag: "[/size]"}
		]},*/
		{name: "Colour", className: "palette", dropMenu: [
			{name: "Automatic", className: "colour-automatic", openTagRegExp: "\\[color(?:=[^\\]]*)?\\]", closeTagRegExp: "\\[/color\\]"},

			{name: "Grey", className: "col8-1", openTag: "[color=white]", closeTag: "[/color]", openTagRegExp: "\\[color(?:=[^\\]]*)?\\]"},
			{name: "Grey", className: "col8-2", openTag: "[color=#d3d7cf]", closeTag: "[/color]", openTagRegExp: "\\[color(?:=[^\\]]*)?\\]"},
			{name: "Grey", className: "col8-3", openTag: "[color=#babdb6]", closeTag: "[/color]", openTagRegExp: "\\[color(?:=[^\\]]*)?\\]"},

			{name: "Grey", className: "col9-1", openTag: "[color=#888a85]", closeTag: "[/color]", openTagRegExp: "\\[color(?:=[^\\]]*)?\\]"},
			{name: "Grey", className: "col9-2", openTag: "[color=#555753]", closeTag: "[/color]", openTagRegExp: "\\[color(?:=[^\\]]*)?\\]"},
			{name: "Grey", className: "col9-3", openTag: "[color=black]", closeTag: "[/color]", openTagRegExp: "\\[color(?:=[^\\]]*)?\\]"},

			{name: "Yellow", className: "col1-1", openTag: "[color=yellow]", closeTag: "[/color]", openTagRegExp: "\\[color(?:=[^\\]]*)?\\]"},
			{name: "Yellow", className: "col1-2", openTag: "[color=#edd400]", closeTag: "[/color]", openTagRegExp: "\\[color(?:=[^\\]]*)?\\]"},
			{name: "Yellow", className: "col1-3", openTag: "[color=#c4a000]", closeTag: "[/color]", openTagRegExp: "\\[color(?:=[^\\]]*)?\\]"},

			{name: "Orange", className: "col2-1", openTag: "[color=#fcaf3e]", closeTag: "[/color]", openTagRegExp: "\\[color(?:=[^\\]]*)?\\]"},
			{name: "Orange", className: "col2-2", openTag: "[color=#f57900]", closeTag: "[/color]", openTagRegExp: "\\[color(?:=[^\\]]*)?\\]"},
			{name: "Orange", className: "col2-3", openTag: "[color=#ce5c00]", closeTag: "[/color]", openTagRegExp: "\\[color(?:=[^\\]]*)?\\]"},

			{name: "Brown", className: "col3-1", openTag: "[color=#e9b96e]", closeTag: "[/color]", openTagRegExp: "\\[color(?:=[^\\]]*)?\\]"},
			{name: "Brown", className: "col3-2", openTag: "[color=#c17d11]", closeTag: "[/color]", openTagRegExp: "\\[color(?:=[^\\]]*)?\\]"},
			{name: "Brown", className: "col3-3", openTag: "[color=#8f5902]", closeTag: "[/color]", openTagRegExp: "\\[color(?:=[^\\]]*)?\\]"},

			{name: "Green", className: "col4-1", openTag: "[color=#8ae234]", closeTag: "[/color]", openTagRegExp: "\\[color(?:=[^\\]]*)?\\]"},
			{name: "Green", className: "col4-2", openTag: "[color=#73d216]", closeTag: "[/color]", openTagRegExp: "\\[color(?:=[^\\]]*)?\\]"},
			{name: "Green", className: "col4-3", openTag: "[color=#4e9a06]", closeTag: "[/color]", openTagRegExp: "\\[color(?:=[^\\]]*)?\\]"},

			{name: "Blue", className: "col5-1", openTag: "[color=#729fcf]", closeTag: "[/color]", openTagRegExp: "\\[color(?:=[^\\]]*)?\\]"},
			{name: "Blue", className: "col5-2", openTag: "[color=#3465a4]", closeTag: "[/color]", openTagRegExp: "\\[color(?:=[^\\]]*)?\\]"},
			{name: "Blue", className: "col5-3", openTag: "[color=#204a87]", closeTag: "[/color]", openTagRegExp: "\\[color(?:=[^\\]]*)?\\]"},

			{name: "Purple", className: "col6-1", openTag: "[color=#ad7fa8]", closeTag: "[/color]", openTagRegExp: "\\[color(?:=[^\\]]*)?\\]"},
			{name: "Purple", className: "col6-2", openTag: "[color=#75507b]", closeTag: "[/color]", openTagRegExp: "\\[color(?:=[^\\]]*)?\\]"},
			{name: "Purple", className: "col6-3", openTag: "[color=#5c3566]", closeTag: "[/color]", openTagRegExp: "\\[color(?:=[^\\]]*)?\\]"},

			{name: "Red", className: "col7-1", openTag: "[color=red]", closeTag: "[/color]", openTagRegExp: "\\[color(?:=[^\\]]*)?\\]"},
			{name: "Red", className: "col7-2", openTag: "[color=#cc0000]", closeTag: "[/color]", openTagRegExp: "\\[color(?:=[^\\]]*)?\\]"},
			{name: "Red", className: "col7-3", openTag: "[color=#a40000]", closeTag: "[/color]", openTagRegExp: "\\[color(?:=[^\\]]*)?\\]"}
		]},
		{separator: true},
		{name: "Bulleted list", className: "list-bullet", prependLine: "*", replaceWith: function(markitup) {
			var str = markitup.textarea.value, str2 = markitup.selectedText, i = str.lastIndexOf("\n", markitup.selectionStart - 1);
			markitup.textarea.value = (str.substring(0, i + 1) + "*" + str.substring(i + 1, markitup.selectionStart + str2.length).replace(/(\r\n|\r|\n)/g, "\r\n*") + str.substring(markitup.selectionStart + str2.length));
			markitup.select(markitup.selectionStart + 1, str2.replace(/(\r\n|\r|\n)/g, "\n*").length);
		}},
		{name: "Numeric list", className: "list-numeric", prependLine: "#", replaceWith: function(markitup) {
			var str = markitup.textarea.value, str2 = markitup.selectedText, i = str.lastIndexOf("\n", markitup.selectionStart - 1);
			markitup.textarea.value = (str.substring(0, i + 1) + "#" + str.substring(i + 1, markitup.selectionStart + str2.length).replace(/(\r\n|\r|\n)/g, "\r\n#") + str.substring(markitup.selectionStart + str2.length));
			markitup.select(markitup.selectionStart + 1, str2.replace(/(\r\n|\r|\n)/g, "\n#").length);
		}},
		//{name: "List item", className: "list-item", openTag: "[*] "},
		{separator: true},
		{name: "Quote", className: "quote", key: "Q", openTag: "[quote]", closeTag: "[/quote]", openTagRegExp: "\\[quote(?:=[^\\]]*)?\\]", multiLine: true},
		{name: "Code", className: "code", key: "O", openTag: "[code]", closeTag: "[/code]", openTagRegExp: "\\[code(?:=[^\\]]*)?\\]", multiLine: true},
		{separator: true},
		{name: "Image", className: "image", key: "M", replaceWith: "[img=url_goes_here]"},
		{name: "Link", className: "link", key: "L", openTag: "[url=url_goes_here]", closeTag: "[/url]", placeHolder: "Link text goes here..."},
		{separator: true},
		{name: "Remove tags from selection", className: "remove-tags", key: "R", replaceWith: function(markitup) {
			return markitup.selectedText.replace(/\[[^\]]*\]/g, "");
		}},
		//{separator: true},
		//{name: "Preview", className: "preview", call: "preview"},
		{separator: true},
		{name: "Expand", className: "expand", call: "expand"},
		{name: "Shrink", className: "shrink", call: "shrink"}
	]
};
