// Created by: Stephen Collins 12/17/09

// Create a <div> element with an id of 'columnArea' - Case Sensitive
// Within 'columnArea' create a <ul> with an id of 'columns'

// The plug-in will take all of the <li> items from the <ul id="columns"> and
// create new <ul>'s equal to the nuber of columns you want
// and the <li>'s will be evenly distributed to each <ul>

// Each unordered list will be marked up as follows
// <ul class="column col#"> where '#' = the current column number

// To call the plug-in just add
// $().columns(#);
// into the jQuery section of your code
// change '#' to the number of columns you need

jQuery.fn.columns = function(numColumns){

	var columnNumber = numColumns
	var numLines = $("#columns li").size()
	var colNumberAverage = numLines / columnNumber
	var colHeight = Math.round(colNumberAverage)
	
	if (colHeight < colNumberAverage)
  		{colHeight = colHeight + 1}
  	else
  		{colHeight = colHeight};

	var i=1;
		do
  			{
				$("#columnArea").append("<ul class='column col"+i+"'></ul>");
				$(".col"+i).append($("#columns li").slice(0,colHeight));
				i++;
			}
		while (i < columnNumber+1);
	
	$("#columns").remove();
	
};
