
Vn.Photos = new Class
({
	Extends: Vn.Module

	,activate: function ()
	{
		this.$('schema').value = 'catalog';
		this.$('photo-size').value = 10 /* MB */ * 1048576;
		this.$('photo-id').focus ();
	}

	,onFormSubmit: function ()
	{
		this.$('schema-field').value = this.$('schema').value;
		this.$('submit').disabled = true;
		this.gui.loaderPush ();
	}

	,onImageUpload: function ()
	{	
		this.gui.loaderPop ();
		this.$('submit').disabled = false;

		try {
			var responseText = this.$('iframe').contentDocument.body.textContent;
			var response = eval ('('+ responseText +')');

			if (response.data)
			{
				this.$('photo-id').value = '';
				this.$('photo-id').focus ();
				Htk.Toast.showMessage (_('ImageUploaded'));
			}
			else
				Htk.Toast.showError (response.error.message +' ('+ response.error.code +')');
		}
		catch (e) {}
	}
});

