var Coords = Class.create({
	
	x: 0,

	y: 0,
	 
	initialize: function(a, b) {
	
		// no args: default constructor 
		if (typeof(a) == "undefined") return;

		// first arg is a class with x and y coords: copy constr
		if ((typeof(a.x) != "undefined") && (typeof(a.y) != "undefined")){
			this.x = a.x;
			this.y = a.y;
			return
		}		

		// first arg no class with x and y, and no second arg? default constr		
		if (typeof(b) == "undefined") return;
		
		// coords constructor
		this.x = a;
		this.y = b;
	},
	
	setXy: function(x, y) {
		this.x = x;
		this.y = y;
	},
	
	set: function(coords) {
		this.x = coords.x;
		this.y = coords.y;
	},
	
	setFromStyle: function(element) {
		if (!element.style.left) {
			this.x = 0;
		} else {
			this.x = parseInt(element.style.left); 
		}
		if (!element.style.top) {
			this.y = 0;
		} else {
			this.y = parseInt(element.style.top);
		}
	},
	
	subtract: function(coords) {
		return (new Coords(this.x - coords.x, this.y - coords.y));
	},
	
	add: function(coords) {
		return (new Coords(this.x + coords.x, this.y + coords.y));
	},
	
	limit: function(min, max) {
		var limited = new Coords();
		limited.x = ((this.x<min.x)?min.x:((this.x>max.x)?max.x:this.x));
		limited.y = ((this.y<min.y)?min.y:((this.y > max.y)?max.y:this.y));
		return limited;
	}
	
});