var Video = Class.create();

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

	remove: function() {
		var hash = arguments[0];
		var userId = arguments[1];
		var redirect = (arguments[2] == undefined )? false : arguments[2];
		var removeSimilar = (arguments[3] == undefined )? 0 : arguments[3];
		if (confirm(lang['confirm'])) {
			new Ajax.Request(PUBLIC_URL+'videos/delete/'+hash, {
				method: 'post',
				postBody: $H({ userId: userId, removeSimilar: removeSimilar }).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+'videos/delete-fail-converted/'+id, {
				method: 'get',
				evalJS: 'force',
				onSuccess: function(transport) {
					systemMessenger.set(lang['deletedSuccess'], 1);
					systemMessenger.display();
					$('cnt_'+id).remove();
				}
			});
		}
	},

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

var video = new Video();