﻿function img_resize(id, xlimit, skinRatio) {
try{
	id = $(id);
	var ratio = (id.width/xlimit);
	h = id.height;
	id.width /= ratio;	
	return ratio;}catch(e){}
}

var cropImg = Class.create({
	initialize: function(ratio) {
		this.ratio = ratio;
		this.top = this.left = this.width = this.height = "";
	},

	getSelectedArea: function( coords, dimensions ) {
		this.top = coords.y1;
		this.left = coords.x1;
		this.width = dimensions.width;
		this.height = dimensions.height;
	},
	crop: function() {
		this.top *= this.ratio;
		this.left *= this.ratio;
		this.width *= this.ratio;
		this.height *= this.ratio;
		
		this.top = Math.ceil(this.top);
		this.left = Math.ceil(this.left);
		this.width = Math.ceil(this.width);
		this.height = Math.ceil(this.height);
		
		return {y: this.top, x: this.left, w: this.width, h: this.height};
	}

});
