(function() {
function hmSlideShow(el, options) {
	var that = this, doc = document;
	that.el = typeof el == 'object' ? el : document.getElementById(el);
	
	that.options = {
		itemCount: 10,
		itemWidth: 95,
		itemStart : 2,
		itemStep: 3
	}
	for(i in options){
		that.options[i] = options[i];
	}
	that.init();
};

hmSlideShow.prototype = {

	init : function() {
		var that = this;
		that.x = parseInt($(that.el).css("left").replace(/px/g, ""));
		that.dx = dx = (that.options.itemWidth * that.options.itemStep);
	},
	start : function() {
		var that = this;
		setTimeout(function(){
			that._next(that.options.itemStart);
		}, 2000);
	},
	_next : function(c) {
		var that = this;
		that.c = c;
		$(that.el).animate({
				"left":"-="+dx+"px"
			}, 
			function() {
				var w = parseInt($(that.el).css("width").replace(/px/g, "")) + that.dx;
				$(that.el).css("width", w);
				for(var i = 0; i < that.options.itemStep; i++){
					var ele = $(that.el).find("div:eq(" + (that.c - that.options.itemStart + i) + ")");
					$(that.el).append("<div  class='item'>" + ele.html() + "</div>");
					ele.html("");
				}
			}
		);
		setTimeout(function(){
			that._next(c + that.options.itemStep);
		}, 2000);
	}
};
window.hmSlideShow = hmSlideShow;
})();
