ls = {
	
	/* *************************************************************************
	* 
	* start the initial binding of the list columns
	*
	************************************************************************* */
	init : function( params ) {
		
		var p = params;		
		
		$(p._variable + " " + p._clickable).unbind('click');	
		$(p._variable + " " + p._clickable).bind('click', function() {
			ls.move_left( p, $(this) );
		});
		
		if ( p._update_list ) {
			$(p._constant + " " + p._clickable).unbind('click');	
			$(p._constant + " " + p._clickable).bind('click', function() {
				ls.move_right( p, $(this) );
			});
		}
		
		// update the list array field
		ls.track_selected_elements( p );
		
	},
	/* *************************************************************************
	* END :::
	************************************************************************* */
	
	
	
	
	
	
	
	
	/* *************************************************************************
	* 
	* Moves selected element from the variable list to the constant list
	*
	************************************************************************* */
	move_left : function( p, obj ) {
		
		var p = p;
		
		if ( p._update_list ) {
		
			obj_id = $( obj ).attr('id');
			
			// this object exists in the other list
			// just remove it from existing list
			if ( $( p._constant ).find( '#' + obj_id ).length > 0 ) {
				obj.remove();
				$( p._constant ).find( '#' + obj_id ).removeClass('selected');

			} else {
				$(p._constant).append( obj );
				obj.removeClass( 'selected' );
				
				ls.sort_list( p, p._constant );
				obj.unbind('click');	
				obj.bind('click', function() {
					ls.move_right( p, $(this) );
				});
			}
		
		} else {
			if ( obj.hasClass('selected') ) {
				obj.removeClass( 'selected' );
			} else {
				obj.addClass( 'selected' );
			}
		}
		
		// update the list array field
		ls.track_selected_elements( p );
	},
	/* *************************************************************************
	* END :::
	************************************************************************* */	
	
	
	
	
	
	
	
	
	/* *************************************************************************
	* 
	* Moves selected element from the contstant list to the variable list
	*
	************************************************************************* */
	move_right : function( p, obj ) {
		
		var p = p;
		
		obj_id = $( obj ).attr('id');
		
		// this object exists in the other list
		// just remove it from existing list
		if ( $( p._variable ).find( '#' + obj_id ).length > 0 ) {
			obj.remove();
			
		} else {
			$(p._variable).append( obj );
			obj.addClass( 'selected' );
			
			ls.sort_list( p, p._variable );
			obj.unbind('click');	
			obj.bind('click', function() {
				ls.move_left( p, $(this) );
			});
		}
		
		// update the list array field
		ls.track_selected_elements( p );
	},
	/* *************************************************************************
	* END :::
	************************************************************************* */
	
	
	
	
	
	
	
	
	/* *************************************************************************
	* 
	* When append to the list(s), the ordering is off. This alphabetically 
	* sort the list items
	*
	************************************************************************* */
	sort_list : function ( p, obj ) {
		
		var parent = obj;
		
		var items = $(obj + ' ' + p._clickable).get();
		items.sort(function(a,b){ 
			var keyA = $(a).text();
			var keyB = $(b).text();
			
			if (keyA < keyB) return -1;
			if (keyA > keyB) return 1;
			return 0;
		});
			var ul = $(parent);
			$.each(items, function(i, li){
				ul.append(li);
			});
	},
	/* *************************************************************************
	* END :::
	************************************************************************* */
	
	
	
	
	
	
	
	
	/* *************************************************************************
	* 
	* appends the list of selected LI elements in a hidden input box. will 
	* allow you to get the values on form post without any jquery or javascript
	*
	************************************************************************* */
	track_selected_elements : function( p ) {
			var p = p;
			var ls_list_array = [];
			
			_class = ( p._update_list ) ? '' : '.selected';
			
			/* *******************************************
			* remove the old list to null it out        */
				$('#ls_update_list_array').remove();
			
			
			/* ******************************************
			* get the complete list of selected li's   */
				$(p._variable + ' li' + _class).each(function() { ls_list_array.push($(this).attr('id')) });
			
			
			/* *******************************************
			* append the array list as an hidden input  */
				var ls_input = '<input type="hidden"'
							+ 'id="ls_update_list_array" '
							+ 'name="ls_update_list_array" '
							+ 'value="' + ls_list_array + '" />'
				
				$(p._variable).append(ls_input)
	}
}