(function($){

	/*
	 * 	easyListSplitter 1.0.2 - jQuery Plugin
	 *	written by Andrea Cima Serniotti	
	 *	http://www.madeincima.eu
	 *
	 *	Copyright (c) 2010 Andrea Cima Serniotti (http://www.madeincima.eu)
	 *	Dual licensed under the MIT (MIT-LICENSE.txt)
	 *	and GPL (GPL-LICENSE.txt) licenses.
	 *
	 *	Built for jQuery library
	 *	http://jquery.com
	 *
	 */
	 
	jQuery.fn.easyListSplitter = function(options) {
		
		var j = 1;
		
		var defaults = {			
			colNumber: 3, // Insert here the number of columns you want. Consider that the plugin will create the number of cols requested only if there are enough items in the list.
			direction: 'horizontal'
		};
		
		this.each(function() {
			
			var obj = jQuery(this);
			var settings = jQuery.extend(defaults, options);
			var totalListElements = jQuery(this).children('li').size();
			var baseColItems = Math.ceil(totalListElements / settings.colNumber);
			var listClass = jQuery(this).attr('class');
			
			// -------- Create List Elements given colNumber ------------------------------------------------------------------------------
			
			for (i=1;i<=settings.colNumber;i++) {	
				if(i==1){
					jQuery(this).addClass('listCol1').wrap('<div class="listContainer'+j+'"></div>');
				} else if(jQuery(this).is('ul')){ // Check whether the list is ordered or unordered
					jQuery(this).parents('.listContainer'+j).append('<ul class="listCol'+i+'"></ul>');
				} else{
					jQuery(this).parents('.listContainer'+j).append('<ol class="listCol'+i+'"></ol>');
				}
					jQuery('.listContainer'+j+' > ul,.listContainer'+j+' > ol').addClass(listClass);
			}
			
			var listItem = 0;
			var k = 1;
			var l = 0;	
		
			if(settings.direction == 'vertical'){ // -------- Append List Elements to the respective listCol  - Vertical -------------------------------
				
				jQuery(this).children('li').each(function(){
					listItem = listItem+1;
					if (listItem > baseColItems*(settings.colNumber-1) ){
						jQuery(this).parents('.listContainer'+j).find('.listCol'+settings.colNumber).append(this);
					} 
					else {
						if(listItem<=(baseColItems*k)){
							jQuery(this).parents('.listContainer'+j).find('.listCol'+k).append(this);
						} 
						else{
							jQuery(this).parents('.listContainer'+j).find('.listCol'+(k+1)).append(this);
							k = k+1;
						}
					}
				});
				
				jQuery('.listContainer'+j).find('ol,ul').each(function(){
					if(jQuery(this).children().size() == 0) {
					jQuery(this).remove();
					}
				});	
				
			} else{  // -------- Append List Elements to the respective listCol  - Horizontal ----------------------------------------------------------
				
				jQuery(this).children('li').each(function(){
					l = l+1;
		
					if(l <= settings.colNumber){
						jQuery(this).parents('.listContainer'+j).find('.listCol'+l).append(this);
						
					} else {
						l = 1;
						jQuery(this).parents('.listContainer'+j).find('.listCol'+l).append(this);
					}				
				});
			}
		
			jQuery('.listContainer'+j).find('ol:last,ul:last').addClass('last'); // Set class last on the last UL or OL	
			j = j+1;
		
		});
	};
	
})(this.jQuery);
;
(function ($) {
	$(document).ready(function(){
	    $('#footer #sitemap .menu-block-wrapper > ul').easyListSplitter({ 
			colNumber: 4 // Insert here the number of columns you want. Consider that the plugin will create the number of cols requested only if there's enough items in the list.
		});
		
  	/*	var regSpace = new RegExp("[ ]", "g"); // a regexp to split spaces
		$.get('/rss_proxy/kuusamo', function(d) {
				$('#weather #temperature').prepend(d);  
		});*/
	});
})(jQuery);;

