$(function(){
	$.fn.simpleSlider = function( options ){
		var $this = $( this );
		
		var opts = $.extend({}, {
			timer : 10000,
			from : 1, // 1 = slide from bottom to top, 0 = slide from left to right
			speed : 500, // animation speed
			easing : 'linear' // easing for better sliding effect
		}, options );
		
		$( this ).wrap( '<div id="main-holder" />' ).css({
			position : 'relative',
			width : opts.from == 0 ? ( $this.find( 'li:first' ).width() * $this.find( 'li' ).length ) + 'px' : $this.find( 'li:first' ).width + 'px'
		}).parent( '#main-holder' ).click(function(){
			if( opts.from == 0 ){
				$this.animate({
					left : ( $( '#main-holder' ).width() * -1 ) + 'px'
				}, {
					duration : opts.speed,
					specialEasing : opts.easing,
						complete : function(){
						var li = $this.find( 'li:first' ).html();
						
						$this.find( 'li:first' ).remove().end().css({
							left : 0 + 'px'
						});
						
						$this.append( "<li />" ).find( 'li:last' ).css( childcss ).html( li );
					}
				});
			} else{
				$this.animate({
					top : ( $( '#main-holder' ).height() * -1 ) + 'px'
				}, {
						duration : opts.speed,
						specialEasing : opts.easing,
						complete : function(){
						var li = $this.find( 'li:first' ).html();
						
						$this.find( 'li:first' ).remove().end().css({
							top : 0 + 'px'
						});
						
						$this.append( "<li />" ).find( 'li:last' ).css( childcss ).html( li );
					}
				});
			}
		});
		
		var parent_details = {
			width : $( '#main-holder' ).width(),
			height : $( '#main-holder' ).height(),
			children : $this.find( 'li' )
		};
		
		var childcss = opts.from == 0 ? {
			width : parent_details.width + 'px',
			height : parent_details.height + 'px',
			float : 'left'
		} : {
			width : parent_details.width + 'px',
			height : parent_details.height + 'px'
		}
		
		parent_details.children.each(function(){
			var $this = $( this );
			// fix height and width of child elements
			$this.css( childcss );
		});
		
		// animate
		var run = setInterval(function(){
			$( '#main-holder' ).click();
		}, opts.timer );
		
		$this.hover(function(){
			clearInterval( run );
		}, function(){
			run = setInterval(function(){
				$( '#main-holder' ).click();
			}, opts.timer );
		});
	};
});
