// ismail kaplan tarafından hazırlanmıştır
// 30.04.2010 // 02:00
// ismail@ismailkaplan.com
// kullanım, değiştirme ve benzeri herşey serbesttir. :)
// kafanıza göre takılın :)

(function($){
$.fn.eslide = function(options) {
		var defaults={
			fncTip:'slide',
			fncAnim:'easeinout',
			fncSlideSpeed:700,
			fndCaptionSpeed:400,
			fncSure:4000
		};
		
		
		var options = $.extend(defaults, options);

		var speed = 700;
		var toplam = $('#slides ul li').length-1;
		var tek = $('li:first',this).width();
		var bilgici = $('img').eq(0).attr('rel');
		$('#caption span').html(bilgici);
		
		
		if(options.fncTip=='slide'){	
			$("#slides").css({'width':(tek*(toplam+1))+'px'});
			$("#slides ul li").css({'float':'left'});	
			$('li:first',this).animate({opacity:1});			
		}else{
			$("#slides").css({'width':'414px'});
			$("#slides ul li").css({'position':'absolute'});	
			$("#slides ul li").animate({opacity:0},50);		
			$("#slides ul li").eq(0).animate({opacity:1},50);					
		}
		
   return this.each(function() {						
		var $this = $(this).children();
		
		slide();
		
		var x = 0;
	
		function slide(){

			setInterval(function(){
				var gen = $this.width();					
				if(options.fncTip=='slide'){							 
					if(x==toplam){	
						$this.animate({'left': 0}, speed, options.fncAnim)
								$('#caption').slideUp(400,function(){
								$('#caption span').html('');
								});
							var bilgix = $('img').eq(0).attr('rel');
					    	$('#caption').slideDown(400,function(){
								$('#caption span').html(bilgix);	
								});							

						x = -1;
					}else{
						$this.animate({'left': '-='+gen}, speed, options.fncAnim);
							$('#caption').slideUp(400,function(){
								$('#caption span').html('');
								});						
							var bilgic = $('img').eq(x).attr('rel');
					    	$('#caption').slideDown(400,function(){
								$('#caption span').html(bilgic);	
								});				
					}
				}else{
					if(x==toplam){	
						$this.animate({opacity: 0}, speed, options.fncAnim),
							$('#caption').slideUp(400,function(){
									$('#caption span').html('');
							});
						$this.eq(0).animate({opacity: 1}, speed, options.fncAnim);
							var bilgim = $('img').eq(0).attr('rel');
					    	$('#caption').slideDown(400,function(){
								$('#caption span').html(bilgim);	
								});
						x = -1;
					}else{
							$this.animate({opacity: 0}, speed, options.fncAnim),
								$('#caption').slideUp(400,function(){
								$('#caption span').html('');
							});
							$this.eq(x+1).animate({opacity: 1}, speed, options.fncAnim);
							var bilgi = $('img').eq(x+1).attr('rel');
					    	$('#caption').slideDown(400,function(){
								$('#caption span').html(bilgi);	
								});
					}
				}
				x=x+1;
				},4000);
		}
			
	});
   
};
})(jQuery); 

