jQuery(document).ready(function() {
"use strict";

	tinymce.create("tinymce.plugins.AoA", {

		init : function(ed, url){

			ed.addButton("aoa", {
				title : "Ad Overlay Anything Shortcode",
				cmd : "aoa",
				text : "aoa"
			});

			ed.addCommand("aoa", function() {
				var selected_text = ed.selection.getContent();
				if ( selected_text.length === 0 ) {
					alert( "Please select something to wrap with the AoA shortcode." );
					return;
				}
				var number = prompt("Which AoA Id do you wish to use?", "0");
				if (number !== null) {
					number = parseInt(number);
					var shortcode = "[aoa id='" + number + "']" + selected_text + "[/aoa]";
					ed.execCommand("mceInsertContent", 0, shortcode);
				}
			});

		},

		getInfo : function() {
			return {
				longname : "AoA Shortcode",
				author : "superblogme",
				authorurl : "http://superblogme.com/",
				infourl : "",
				version : "0.1"
			};
		}

	});

	tinymce.PluginManager.add("aoa", tinymce.plugins.AoA);
	
});	
