(function($) { // secure $ jQuery alias
/*******************************************************************************************/
// jquery.classbysize.js - rev 4
// Copyright (c) 2011, Larry (http://larionov.biz)
// Liscensed under the BSD License (BSD-LICENSE.txt)
// http://www.opensource.org/licenses/bsd-license.php
// Created: 2011-01-18
/*******************************************************************************************/

$.ClassBySize = function(element, config) {
	var self = this;
	this.element = $(element);
	this.config = config;
	$(window).resize(function() {
		self.resize.call(self);
	});
	this.resize();
};
$.ClassBySize.prototype.resize = function() {
	var w = this.element.width();
	for (var i = 0, len = this.config.length; i < len; i++) {
		this.element[(w >= this.config[i].minWidth && w < this.config[i].maxWidth)? 'addClass': 'removeClass'](this.config[i].className);
	}
};
$.fn.ClassBySize = function(config) {
	return this.each(function(i, element) {
		new $.ClassBySize(element, config);
	});
};

})(jQuery);

