var Columns = new Class({
  
  unit      : '%',
  
  initialize: function(container,unit){
    
	if(unit && unit !== false && unit !== null && unit.split(" ").join("") !== "") {
	  this.unit = unit;
	} 
	
	var $_cols = $$(container+' div.col');
	
	for(var $_i=0; $_i<$_cols.length; $_i++) {
      var $_col   = $_cols[$_i];
	  var $_class = this.checkClass($_col.className);
	  
	  this.setStyles($_col,$_class);
    }
  },
  
  checkClass: function(value) {
    var $_arr  = value.split(" ");
    var $_temp = new Array();	
	
	for($_i=0; $_i<$_arr.length; $_i++) {
	  if($_arr[$_i] != undefined && $_arr[$_i].split(" ").join("") != "") {
	    $_temp.push($_arr[$_i]);
	  }
	}
	
	return $_temp;
  },
  
  setStyles: function(obj,arr) {
    for($_i=0; $_i<arr.length; $_i++) {
	  if(!isNaN(arr[$_i])) {
		obj.setStyles({
		  'width' : (this.checkWidth(arr[$_i])+this.unit),
		  'float' : 'left'
		});
	  } else if(arr[$_i] == "wrap") {
	    this.injectClearDiv(obj);
	  }
	}
  },
  
  checkWidth: function(value) {
    value < 0   ? value = 0   : null;
	
	if(this.unit == '%') {
	  value > 100 ? value = 100 : null;
	}
	return value;
  },
  
  injectClearDiv: function(obj) {
    $_clear = new Element('div',{
	  'html'   : '',
	  'styles' : {
	    'clear' : 'both'
	  }
	}).inject(obj,'after');
  }
});