jQuery.fn.trim_whitespace = function() {
	this.each(function() {
		alert(this.html());
	});
/*	try {
	    var val = this.text();
	    alert('*'+val+'*');
	    if (val=="null") {
		    this.html("");
		}
		else {
		    val = val.replace(/\s+/g,'');
		    val = val.replace(/\t+/g,'');
		    val = val.replace(/\n+/g,'');
		    //this.html(val);
	    }
	} catch(e) { ; }*/
};
jQuery.fn.columnize = function(options) {
	/* Requires the following parent HTML: div. */
	/* ISSUE: MSIE 1) slow performance, 2) removed elements not empty, hence their parents left unremoved */
    if (!options) { options = {columns:4,width:"900"}; }
    var width = options.width;
    var columns = options.columns;
    var rows = $(this).find("li").length;
    var per_column = Math.ceil(rows / columns);
    var parent = $(this).parent();
    parent.repeat(columns, "<div class=\"columnized\"></div>");
    width = (width.indexOf('%')>-1) ? ((width.replace('%','')-1+1)/columns)+"%" : (width/columns)+"px";
    var root = $(this).clone(true);
    parent.find("div.columnized").append(root.clone(true));
    parent.find("div.columnized").css("width",width);
    
	if ($(this).attr("nodeName")=="UL") {
	    for (var i=0; i<columns; i++) {
		    var lt = (i)*per_column; gt = (i+1)*per_column-1;
	        parent.find(".columnized:eq("+i+") a:lt("+lt+")").remove();
	        parent.find(".columnized:eq("+i+") a:gt("+(per_column-1)+")").remove();
	    }
	}
	else {
	    for (var i=0; i<columns; i++) {
		    var lt = (i)*per_column; gt = (i+1)*per_column-1;
	        parent.find(".columnized:eq("+i+") *:lt("+lt+")").remove();
	        parent.find(".columnized:eq("+i+") *:gt("+(per_column-1)+")").remove();
	    }
	}
    /*
    while (parent.find("li:empty")[0] || parent.find("ul:empty")[0]) {
        parent.find("li:empty").remove();
        parent.find("ul:empty").remove();
    }
    */
    var parent = this.parent();
    $(document).keydown(function(e) {
	    if (e == null) { keycode = event.keyCode; } // ie 
		else { keycode = e.which; } // mozilla 
		if (keycode==27) { parent.slideUp("slow"); }
	});
    $(this).remove();
};
