mySettings = {
	onShiftEnter:	{keepDefault:false, replaceWith:'<br />\n'},
	onCtrlEnter:	{keepDefault:false, openWith:'\n<p>', closeWith:'</p>\n'},
	onTab:			{keepDefault:false, openWith:'	 '},
	markupSet: [
		{name:'Heading 1', key:'1', openWith:'<h1(!( class="[![Class]!]")!)>', closeWith:'</h1>', placeHolder:'Your title here...' },
		{name:'Heading 2', key:'2', openWith:'<h2(!( class="[![Class]!]")!)>', closeWith:'</h2>', placeHolder:'Your title here...' },
		{name:'Heading 3', key:'3', openWith:'<h3(!( class="[![Class]!]")!)>', closeWith:'</h3>', placeHolder:'Your title here...' },
		{name:'Heading 4', key:'4', openWith:'<h4(!( class="[![Class]!]")!)>', closeWith:'</h4>', placeHolder:'Your title here...' },
		{name:'Heading 5', key:'5', openWith:'<h5(!( class="[![Class]!]")!)>', closeWith:'</h5>', placeHolder:'Your title here...' },
		{name:'Heading 6', key:'6', openWith:'<h6(!( class="[![Class]!]")!)>', closeWith:'</h6>', placeHolder:'Your title here...' },
		{name:'Paragraph', openWith:'<p(!( class="[![Class]!]")!)>', closeWith:'</p>' },
		{separator:'---------------' },
		{name:'Bold', key:'B', openWith:'(!(<strong>|!|<b>)!)', closeWith:'(!(</strong>|!|</b>)!)' },
		{name:'Italic', key:'I', openWith:'(!(<em>|!|<i>)!)', closeWith:'(!(</em>|!|</i>)!)' },
		{name:'Stroke through', key:'S', openWith:'<del>', closeWith:'</del>' },
		{separator:'---------------' },
		{name:'Ul', openWith:'<ul>\n', closeWith:'</ul>\n' },
		{name:'Ol', openWith:'<ol>\n', closeWith:'</ol>\n' },
		{name:'Li', openWith:'<li>', closeWith:'</li>' },
		{separator:'---------------' },
		{name:'Picture', key:'P', replaceWith:'<img src=\'[![Source:!:http://]!]\' class="padMe" alt="[![Alternative text]!]" />' },
		{name:'Link', key:'L', openWith:'<a href="[![Link:!:http://]!]"(!( title="[![Title]!]")!)>', closeWith:'</a>', placeHolder:'Your text to link...' },
		{separator:'---------------' },
		{name:'Clean', className:'clean', replaceWith:function(markitup) { return markitup.selection.replace(/<(.*?)>/g, "") } },
		{name:'Preview', className:'preview', call:'preview' },
		{name:'Save', className:'save', beforeInsert:function(markItUp) { miu.save(markItUp) } },
        {name:'Load', className:'load', beforeInsert:function(markItUp) { miu.load(markItUp) } },
		{name:'New', className:'new2', beforeInsert:function(markItUp) { miu.new2(markItUp) } },
		{	name:'Date of the Day', 
			className:"dateoftheday", 
			replaceWith:function(h) { 
				date = new Date()
				weekday = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];
				monthname = ["January","February","March","April","May","June","July","August","September","October","November","December"];
				D = weekday[date.getDay()];
				d = date.getDate();
				m = monthname[date.getMonth()];
				y = date.getFullYear();
				h = date.getHours();
				i = date.getMinutes();
				s = date.getSeconds();
				return (D +" "+ d + " " + m + " " + y + " " + h + ":" + i + ":" + s);
			}
		}
	]
}
miu = {
    save: function(markItUp) {
		toUpdate = (markItUp.textarea.id);
		tabletoUpdate = (markItUp.textarea.name);
        data = encodeURIComponent(markItUp.textarea.value);
        ok = confirm("Save the content?");
        if (!ok) {
            return false;
        }
        $.post(markItUp.root+"utils/quicksave/save.php", "toUpdate="+toUpdate+"&data="+data+"&table="+tabletoUpdate, function(response) {
                if(response === "MIU:OK") {
                    alert("Saved!");
                }
            }
        ); 
    },
	
	new2: function(markItUp) {
		toUpdate = (markItUp.textarea.id);
		tabletoUpdate = (markItUp.textarea.name);
        data = encodeURIComponent(markItUp.textarea.value);
        ok = confirm("Save the content?");
        if (!ok) {
            return false;
        }
        $.post(markItUp.root+"utils/quicksave/new.php", "toUpdate="+toUpdate+"&data="+data+"&table="+tabletoUpdate, function(response) {
                if(response === "MIU:OK") {
                    alert("Saved!");
                }
            }
        ); 
    },
	
    load: function(markItUp) {
        $.get(markItUp.root+"utils/quicksave/load.php", function(response) {
                if(response === "MIU:EMPTY") {
                    alert("Nothing to load");
                } else {
                    ok = confirm("Load the previously saved content?");
                    if (!ok) {
                        return false;
                    }
                    markItUp.textarea.value = response;
                    alert("Loaded!");
                }
            }
        );
    }      
}
