var axura = {
	ver : 0.1
}

axura.qta = function(el) {
	this.qta = 1;
	var _self = this;
	_self.el = jQuery(el).attr('value', this.qta)

	this.aPlus = jQuery('<a>').html('+').attr('href', 'javascript:void(0)').addClass('qty-plus')
			.click(function() {
				_self.increment()
			});

	this.aMinus = jQuery('<a>').html('-').attr('href', 'javascript:void(0)').addClass('qty-minus')
			.click(function() {
				_self.decrement()
			});

	_self.el.after(this.aMinus)
	this.aMinus.after(this.aPlus)

	this.increment = function() {
		this.qta++;
		_self.el.attr('value', this.qta)
	}
	this.decrement = function() {
		this.qta--;
		if (this.qta < 0)
			this.qta = 0;
		_self.el.attr('value', this.qta)
	}
	this.el.keyup(function(event) {
		_self.parse(this.value);
	})
	this.el.keydown(function(event) {
		if (event.keyCode == 38 || event.keyCode == 39) {
			_self.increment();
		} else if (event.keyCode == 40 || event.keyCode == 37) {
			_self.decrement();
		}
	})

	this.parse = function(value) {
		if (isNaN(parseInt(value))) {
			this.qta = 0
		} else {
			this.qta = parseInt(value);
		}

	}

}
