// ----------------------------------------------------------------------------
// markItUp!
// ----------------------------------------------------------------------------
// Copyright (C) 2008 Jay Salvat
// http://markitup.jaysalvat.com/
// ----------------------------------------------------------------------------
// Html tags
// http://en.wikipedia.org/wiki/html
// ----------------------------------------------------------------------------
// Basic set. Feel free to add more tags
// ----------------------------------------------------------------------------
mySettings = {	
	onShiftEnter:  	{keepDefault:false, replaceWith:'<br />\n'},
	onCtrlEnter:  	{keepDefault:false, openWith:'\n<p>', closeWith:'</p>'},
	onTab:    		{keepDefault:false, replaceWith:'    '},
	markupSet:  [ 	
		{name:'link', key:'L', openWith:'<a href="[![Link:!:http://]!]"(!( title="[![Title]!]")!)>', closeWith:'</a>' },
		{name:'bold', key:'B', openWith:'(!(<strong>|!|<b>)!)', closeWith:'(!(</strong>|!|</b>)!)' },
		{name:'italic', openWith:'(!(<em>|!|<i>)!)', closeWith:'(!(</em>|!|</i>)!)'  },
		{name:'blockquote', openWith:'<blockquote>', closeWith:"</blockquote>\n\n", placeHolder:'Okay, Mista Mayor.  Feast your ears on that Spin Doctors mix!' },
		{separator:'---------------' },
		{name:'image', key:'I', replaceWith:'<img src="[![Source:!:http://]!]" />' },
		{name:'youtube Video', key:'Y', replaceWith: function(markItUp) { return miu.youTube(markItUp) }},
		{name:'high five', key:'5', replaceWith:"<img src=\"http://omgtru.com/highfive.gif\" />\n\n" },
		//{separator:'---------------' },
		//{name:'preview', className:'preview',  call:'preview'}
	]
}


// miu nameSpace to avoid conflict.
miu = {      
   youTube: function (markItUp) {
		var myValue = prompt('Enter the URL or id of the YouTube video', 'http://');
		var idRegex = /v=([^&]+)/;
		var movieId = myValue.match(idRegex);

		//if we got an id from a url-ish structure
		if(movieId != null){
			myValue = movieId[1];
		}

		if (myValue) {
			return '<youtube id="' + myValue + '" />';
		}
    }
}