function resizeable(elem, dimension){
	this.elem = elem;
	this._events = [
		{name: "resize", func_name: "_resizeBy"}	
	];
	this.onafterresize = new DOMEvent(this);
	this.saveFloatX = new Nums.SaveFloatPoint();
	this.saveFloatY = new Nums.SaveFloatPoint();
	this.resizedX = 0;
	this.resizedY = 0;
	this.resX = 0;
	this.resY = 0;
	this.dimension = dimension ? dimension.toUpperCase() :  false;
	this.count = 0;
	this.limits = {};
	this.init();
	if(this.constructor._TO_INSTANCES){
		this.constructor._instances.push(this);
	}
}
resizeable.prototype.init = function(){
	this.initEvents();
	var dims = Style.$D(this.elem);
	this.width = new Nums.Positive(dims.width);
	this.height = new Nums.Positive(dims.height);
	this.onzerowidth = DOMEvent.cloneEvent(this.width.onzero, this);
	this.onzeroheight = DOMEvent.cloneEvent(this.height.onzero, this);
}
resizeable.prototype.initEvents = _initEvents;
resizeable.prototype.resize = function(){
	if(!this.dimension){
		this.elem.style.width = this.width + "px";
		this.elem.style.height = this.height + "px";
	}else{
		if(this.dimension == "X"){
			this.elem.style.width = this.width + "px";
		}else if(this.dimension == "Y"){
			this.elem.style.height = this.height + "px";
		}
	}
	this.count++;
	this.onafterresize.fire();
}
resizeable.prototype.resizeTo = function(w, h){
	var wVal = w - this.width;
	var hVal = h - this.height;
	this.resizeBy(wVal, hVal);
}
resizeable.prototype.resizeBy = function(w, h){
	this.resX = this.saveFloatX.test(w);
	this.resY = this.saveFloatY.test(h);
	return this._resizeBy();
}
resizeable.prototype._resizeBy = function(){
	this.saveFloatX.add();
	this.saveFloatY.add();
	this.width.add(this.resX);
	this.height.add(this.resY);
	this.resize();
}
resizeable.prototype.setLimits = function(type, value, startValue){
	type = type.toUpperCase();
	if(this.limits[type]){
		return;
	}
	var PRESETS = resizeable.LIMITS[type]
	this.limits[type] = new Limit(0, value);
	if(startValue){
		this.limits[type].value = startValue;
	}
	this.limits[type].type = type;
	this.limits[type].MINUS_REACHED = false
	this.limits[type].PLUS_REACHED = false;
	this.limits[type]._REACHED = false;
	this.limits[type].onmore.register(
		'limit-more',
		function(objLim){
			this['res' + objLim.type] = objLim.MORE_VALUE;
			objLim._REACHED = true;
			objLim.MORE_REACHED = true;
		}.bind(this, this.limits[type])
	);
	this.limits[type].onless.register(
		'limit-less',
		function(objLim){
			this['res' + objLim.type] = objLim.LESS_VALUE;
			objLim._REACHED = true;
			objLim.LESS_REACHED = true;
		}.bind(this, this.limits[type])
	);
	this[PRESETS.onmore] = DOMEvent.cloneEvent(this.limits[type].onmore, this);
	this[PRESETS.onless] = DOMEvent.cloneEvent(this.limits[type].onless, this);
	this[PRESETS.onmore].register = function(name, func, times){
		this.limits[type].onmore.register(name, function(){
			this.onafterresize.register(name, func, 1);
		}.bind(this), times);
	}.bind(this);
	this[PRESETS.onless].register = function(name, func, times){
		this.limits[type].onless.register(name, function(){
			this.onafterresize.register(name, func, 1);
		}.bind(this), times);
	}.bind(this);
	this.onresize.register(
		'limit' + type, 
		function(objLim){
			objLim.change(this['res' + objLim.type]);
		}.bind(this, this.limits[type]), null, 0
	);
}	
resizeable.prototype.setResizeSpace = function(X, Y, sX, sY){
	if(!this.moveSpace){
		this.moveSpace = {};
		this.onresizespacereach = new E_Connection();
	}
	if(X || X === 0){
		this.moveSpace.X = X;
		this.setLimits('X', X, sX || 0);
		this.onresizespacereach.add(this.onwidthless, "width-less");
		this.onresizespacereach.add(this.onwidthmore, "width-more");
	}
	if(Y || Y === 0){
		this.moveSpace.Y = Y;
		this.setLimits('Y', Y,  sY || 0);
		this.onresizespacereach.add(this.onheightless, "height-less");
		this.onresizespacereach.add(this.onheightmore, "height-more");
	}
	return this.moveSpace;
}
resizeable.prototype.addMoveable = function(oM, change){
	this.moveable = oM;
	this._cm = change || 0;
	this.onresize.register("change moveable", function(){
		if(this._cm){
			this.moveable.moveBy(this.resX * this._cm, this.resY * this._cm);
		}
	});
}
resizeable.prototype.unset = function(){
	this.elem.style.height = "auto";
	this.elem.style.width = "auto";
}
resizeable.prototype.set = function(param){
	if(param){
		var dims = Style.getDimensions(this.elem);
		this.width.set(dims.width);
		this.height.set(dims.height);
	}
	this.elem.style.width = this.width + "px";
	this.elem.style.height = this.height + "px";
}
resizeable.prototype.toString = __toString;
resizeable.prototype.__name = "resizeable";
resizeable.LIMITS = {
	X: {
		onless: 'onwidthless',
		onmore: 'onwidthmore',
		onmoreout: 'onwidthmoreout',
		onlessout: 'onwidthlessout',
		less: 'width-less',
		more: 'width-more'
	},
	Y: {
		onless: 'onheightless',
		onmore: 'onheightmore',
		onmoreout: 'onheightmoreout',
		onlessout: 'onheightlessout',
		less: 'height-less',
		more: 'height-more'		
	}
}
resizeable._instances = [];
resizeable._TO_INSTANCES = true;
