/*------------------------------------------ SIMPLE SLIDER PLUGIN ----------------------------------------*/
/*--------------------------------------------------------------------------------------------------------*/





(function($){

	var $pages = new Array();
	var $activeIndex = 0;
	var $zIndex = 100;
	
	var methods = {
    	
    	init 	: function(options) {
		    		
		    		return this.each(function() {      
						
		        		defaults = $.extend(defaults, options);
				    	
				    	$(this).find("img").each(function(){
				    		$pages.push($(this).css({"z-index" : $zIndex-1}).hide());
						});
						
						$pages[$activeIndex].fadeIn(defaults.speed);
							
						setInterval ("$(this).simpleSlider('pageUp')", defaults.interval);
			    	});
  
    	},
    	pageUp 	: function() {
    				
    				var $currentIndex = $activeIndex;	
		    		$activeIndex += 1;	
			    		
		    		if($activeIndex >= $pages.length){	
		    			$activeIndex = 0;
		    		}
	    			
	    			$pages[$activeIndex]
	    				.css({
	    					"z-index" : $zIndex
	    				})
	    				.fadeIn(defaults.speed, function(){
	    					$pages[$currentIndex].hide();
	    				})
	    				
	    			$zIndex += 1;
    	}
  	};
  	
  	var defaults = {
		'speed' : 300,
		'interval' : 10000
	};

	$.fn.simpleSlider = function(method) {
  		
  	    if (methods[method]) {
	      return methods[method].apply( this, Array.prototype.slice.call(arguments, 1 ));
	    } else if (typeof method === "object" || ! method) {
	      return methods.init.apply(this, arguments);
	    } else {
	      $.error("Method " + method + " does not exist on simpleslider.gd.0.0.1");
	    }

    };
    
})( jQuery );
