var Basicform=function(){
	this.test=function(){
		console.log('La clase Basicform ha sido instanciado correctamente');
	}
	this.save=function(e){
		e.preventDefault();
		var $form=$(e.target);
		$form.find(":submit").prop('disabled', true);
		var _this=this;
		$form.ajaxSubmit({
			success:function(response){
				if(response=="1"){
					toastr.options = {
					  "closeButton": true,
					  "progressBar": true,
					  "positionClass": "toast-top-right"
					}
					toastr.success('La accion se ha completado con &eacute;xito');
					var callback=$form.attr('data-onsave')
					if (typeof callback !== typeof undefined && callback !== false){
						eval(callback);
					}
					Custombox.close(); 
				}else{
					toastr.options = {
					  "closeButton": true,
					  "progressBar": true,
					  "positionClass": "toast-top-right"
					}
					toastr.error('&iexcl;Ha ocurrido un error! <br/> La accion NO se ha podido completado');
					Custombox.close(); 
				}
			}
		});
	}
}

var basicform=new Basicform();


var Imageform=function(){
	this.img=null;
	this.setImage=function($img){
		this.img=$img;
	}
	this.save=function(e){
		e.preventDefault();
		var $form=$(e.target);
		$form.find(":submit").prop('disabled', true);
		var _this=this;
		var dataCropper=_this.img.cropper('getData','round');
		if(!$.isEmptyObject(dataCropper)){
			_this.img.next('.cropper_data_serialized').val(JSON.stringify(dataCropper));
			$form.ajaxSubmit({
				success:function(response){
					if(response=="1"){
						toastr.options = {
						  "closeButton": true,
						  "progressBar": true,
						  "positionClass": "toast-top-right"
						}
						toastr.success('La accion se ha completado con &eacute;xito');
						var callback=$form.attr('data-onsave')
						if (typeof callback !== typeof undefined && callback !== false){
							eval(callback);
						}
						Custombox.close(); 
					}else{
						toastr.options = {
						  "closeButton": true,
						  "progressBar": true,
						  "positionClass": "toast-top-right"
						}
						toastr.error('&iexcl;Ha ocurrido un error! <br/> La accion NO se ha podido completado');
						Custombox.close(); 
					}
				}
			});
		}else{
			toastr.options = {
			  "closeButton": true,
			  "progressBar": true,
			  "positionClass": "toast-top-right"
			}
			toastr.error('Selecione una imagen para continuar.');
			$form.find(":submit").prop('disabled', false);
			return false;
		}
	}
}