function cuSelUpdate(o) {
	var w = parseInt(jQuery(o).width());
	var scrollPanel = jQuery(o).find(".cusel-scroll-pane");
	if(w>=scrollPanel.width()) {
		$(this).find(".jScrollPaneContainer").width(w);
		scrollPanel.width(w);
	}
	
	var resize = function(o){
		$(o).parent().css("width", 500);
		var w = $(o).parent().find(".cuselText:first").width() + 28;
		$(o).parent().css("width", w + 'px');
		$(o).find('.cuselText').css("width", (w - 8) + 'px');
	}
	$(o).find("input").change(function(){
		resize(this);
	});
	
	$(o).find("span").each(function(){
		if($(this).attr("selected") == "") {
			$(o).parent().find(".cuselText:first").html($(this).html());
		}
	});
	
	resize($(o).find("input"));
}

$(document).ready(function(){
	$(".cusel").each(function() {		
		cuSelUpdate(this);
	});
});
