function FeatureSlider(container, events) {
    var obj = this;
    obj.container = container = $(container);
    obj.events = events || {};
    obj.container.setStyle({position:'relative',overflow:'hidden'});
    obj.items = container.childElements();
    obj.index = 1;

    // Get the width and height of the container element
    obj.dimensions = obj.container.getDimensions();

    // Build a helper box within the container
    obj.helper = new Element('div', {className:'feature-slider-helper'});
    obj.helper.morph = obj.helper.morph||obj.helper.setStyle; // If scripaculous is loaded, we can animate. Otherwise, use prototype.
    obj.container.appendChild(obj.helper);

    // Build container boxes for each element to be fitted in the container.
    // Hierarchy: 'container' -> 'helper' -> 'itembox' -> 'item'
    obj.items.each(function(item) {
            var itembox = new Element('div', {className:'feature-slider-item-box'});
            itembox.appendChild(item);
            obj.helper.appendChild(itembox);
        });

    // Handle element sizes
    obj.resize = function() {
	    obj.dimensions = obj.container.getDimensions();
	    obj.helper.setStyle({height:obj.dimensions.height+'px', width:(obj.dimensions.width*obj.items.length)+'px', overflow:'hidden'});
	    obj.helper.select('.feature-slider-item-box').each(function(e) {
        	    	e.setStyle({height:obj.dimensions.height+'px', width:obj.dimensions.width+'px', overflow:'hidden', float:'left'});
	        });
	}
    obj.resize();

    if(typeof(obj.events.onLoad)=='function') obj.events.onLoad(obj);
    if(typeof(obj.events.onChange)=='function') obj.events.onChange(obj,1);

    obj.go = function(i){if(i<1||i>obj.items.length) return(false); if(typeof(obj.events.onChange)=='function') obj.events.onChange(obj, i); obj.helper.morph({marginLeft:((i-1)*obj.dimensions.width*-1)+'px'}, {duration:.3}); obj.index=i; return(true);}
    obj.first = function(){return(obj.go(1));}
    obj.last = function(){return(obj.go(obj.items.length));}
    obj.previous = function(){return(obj.go(obj.index-1));}
    obj.next = function(){return(obj.go(obj.index+1));}
}

