var Audio = Class.create();

Audio.prototype = {
	/**
	 * default constructor
	 */
	initialize: function() {
	},

	remove: function() {
		var hash = arguments[0];
		var userId = arguments[1];
		var redirect = arguments[2];
		if (confirm(lang['confirm'])) {
			new Ajax.Request(PUBLIC_URL+'audios/delete/'+hash, {
				method: 'post',
				postBody: $H({ userId: userId }).toQueryString(),
				evalJS: 'force',
				onSuccess: function(transport) {
					systemMessenger.set(lang['deletedSuccess'], 1);
					systemMessenger.display();
					if (redirect) {
						  window.location = redirect;
						} else {
						  $('cnt_'+hash).remove();
						}
				}
			});
		}
	},

	removeFailConverted: function(id) {
		if (confirm(lang['confirm'])) {
			new Ajax.Request(PUBLIC_URL+'audios/delete-fail-converted/'+id, {
				method: 'get',
				evalJS: 'force',
				onSuccess: function(transport) {
					systemMessenger.set(lang['deletedSuccess'], 1);
					systemMessenger.display();
					$('cnt_'+id).remove();
				}
			});
		}
	},

	addToMyAudios: function() {
		new Ajax.Request(PUBLIC_URL+'audios/add-to-my-audios', {
			method: 'post',
			postBody: $H({description: $F('descriptionUpload'), categoryId: $F('categoryId'), randomCode: $F('randomCode'), ownerId: $F('ownerId')}).toQueryString(),
			evalJS: 'force'
		});
	}
}

var audio = new Audio();