// -------------------------------------------------------------------
// markItUp!
// -------------------------------------------------------------------
// Copyright (C) 2008 Jay Salvat
// http://markitup.jaysalvat.com/
// -------------------------------------------------------------------
// MarkDown tags example
// http://en.wikipedia.org/wiki/Markdown
// http://daringfireball.net/projects/markdown/
// -------------------------------------------------------------------
// Feel free to add more tags
// -------------------------------------------------------------------
mySettings = {
	previewParserPath:	'',
	onShiftEnter:		{keepDefault:false, openWith:'\n\n'},
	//onShiftEnter:  	{keepDefault:false, replaceWith:'<br />\n'},
	markupSet: [
		//{name:'First Level Heading', key:'1', placeHolder:'Your title here...', closeWith:function(markItUp) { return miu.markdownTitle(markItUp, '=') } },
		//{name:'Second Level Heading', key:'2', placeHolder:'Your title here...', closeWith:function(markItUp) { return miu.markdownTitle(markItUp, '-') } },
		{name:'Heading 1', key:'', openWith:'# ', placeHolder:'Your title here...' },
		{name:'Heading 2', key:'', openWith:'## ', placeHolder:'Your title here...' },
		{name:'Heading 3', key:'', openWith:'### ', placeHolder:'Your title here...' },
		{name:'Heading 4', key:'', openWith:'#### ', placeHolder:'Your title here...' },
		//{name:'Heading 5', key:'5', openWith:'##### ', placeHolder:'Your title here...' },
		//{name:'Heading 6', key:'6', openWith:'###### ', placeHolder:'Your title here...' },
		{separator:'---------------' },		
		{name:'Bold', key:'', openWith:'**', closeWith:'**'},
		{name:'Italic', key:'', openWith:'_', closeWith:'_'},
		{separator:'---------------' },
		{name:'Bulleted List', openWith:'* ' },
		{name:'Numeric List', openWith:function(markItUp) {
			return markItUp.line+'. ';
		}},		
		{separator:'---------------' },
		//{name:'Picture', key:'P', replaceWith:'![[![Alt text]!]]([![Url:!:http://]!])'},
		{name:'Picture', key:'', replaceWith:'<img src="[![Url:!:http://]!]" alt="[![Alt text]!]" />'},
		//{separator:'---------------'},
		{name:'Link', key:'L', openWith:'[', closeWith:']([![Url:!:http://]!])', placeHolder:'Your text to link here...' },
		{name:'Page Link', key:'', openWith:'[', closeWith:']([![Page Number:!:]!])', placeHolder:'Your text to link here...' },	
		//{name:'Email Link', key:'T', openWith:'[', closeWith:']([![Email Address:!:mailto:]!])', placeHolder:'Your text to link here...' },
		//{name:'Phone Link', key:'T', openWith:'[', closeWith:']([![Phone Number:!:tel:]!])', placeHolder:'Your text to link here...' },
		//{name:'Home Link', key:'H', replaceWith:'[Back to Home] (1)'},	
		//{separator:'---------------'},
		{name:'Add Page', key:'', replaceWith:'([![Page Number]!]) \n# [![Title]!]'},
		{name:'Map', key:'', replaceWith:'<div class="map">[![Paste Map Code]!]</div>'},
		//{separator:'---------------'},	
		//{name:'Code', openWith:'(!(\t|!|`)!)', closeWith:'(!(`)!)'},
		//{name:'Blockquote', openWith:'> '},
		//{separator:'---------------'},
		//{name:'Preview', call:'preview', className:"preview"}
	]
}

// mIu nameSpace to avoid conflict.
miu = {
	markdownTitle: function(markItUp, char) {
		heading = '';
		n = $.trim(markItUp.selection||markItUp.placeHolder).length;
		for(i = 0; i < n; i++) {
			heading += char;
		}
		return '\n'+heading;
	}
}
