(function($){

 	$.fn.extend({ 
 		
		//pass the options variable to the function
 		quickColumns: function(options) {


			//Set the default values, use comma to separate the settings, example:
			var defaults = {
				columns: 2,
				gutter: 80
			}
				
			var options =  $.extend(defaults, options);

    		return this.each(function() {
				var o = options,
					self = $(this),
					QC = {};
				
				QC.container = self;
				QC.columns = o.columns;
				QC.colWidth = parseInt((self.width() - o.gutter) / 2);
				QC.elements = self.children();
				QC.elWidth = QC.elements.first().width();
				
//				console.log(QC);
				
				for (var i = QC.columns - 1; i >= 0; i--){
					$('<div />', {
						'class':'column-'+(i+1),
						'css': {
							'float':'left',
							'width': QC.colWidth+'px'
						}
					}).prependTo(QC.container);
					
					$('div[class*=1]', QC.container).css('margin-right', o.gutter);
				};
				
				$.each(QC.elements, function(i, article) {
					$(this).css({
					  'margin-left': '0',
					  'margin-right': '0'
					});
					
					if ( $(this).hasClass('odd') ) { 
						$(this).appendTo('.column-1');
					} else {
						$(this).appendTo('.column-2');
					}
				});
				
			
    		});
    	}
	});
	
})(jQuery);
