CmdUtils.CreateCommand({
	name: "trakz",
	takes: {"url to shorten": noun_arb_text},
	icon: "http://tra.kz/favicon.ico",
	homepage: "http://tra.kz/",
	author: { name: "Jordan Harband", email: "jordan@mixmatchmusic.com"},
	description: "Shortens the selected music-related link with tra.kz!",
	help: "Use this command to shorten URLs for pages with or about audio using Tra.kz, the URL shortener for all things music!",

	preview: function (pblock, urlToShorten) {
		pblock.innerHTML = "Replaces the selected URL with a Tra.kz short URL.";
		var regexp = /(ftp|http|https):\/\/(\w+:{01}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/,
			baseUrl = "http://tra.kz/api/shorten?api=ubiquity&l=";
		jQuery.getJSON( baseUrl + urlToShorten.text, function (resp) {
			pblock.innerHTML = "Replaces the selected URL with " + (resp.y ? "http://tra.kz/"+resp.s : "a Tra.kz short URL.");
		});
	},
	execute: function (urlToShorten) {
		var baseUrl = "http://tra.kz/api/shorten?api=ubiquity&l=";
		jQuery.getJSON( baseUrl + urlToShorten.text, function (resp) {
			if (resp.y) { CmdUtils.setSelection("http://tra.kz/"+resp.s); }
		});
	}
});