 (function($) {
    defaults  = {
       		img:   'playbox',
			num:	 'num',
			n:0,
			numhtml:	'',
			len:0,
			playtype:1,
			ling:0,
			prevId: 		'prevBtn',
			prevText: 		'Previous',
			nextId: 		'nextBtn',	
			nextText: 		'Next',
			orientation:	'', //  'vertical' is optional;
			speed: 		 4500		
    };    
 
 
	$.fn.Slider = function(settings) {
 

		this.options = $.extend({}, defaults, settings);
		
					var autoStart;
					var n = this.options.n; 
					var img = this.options.img;
					var num = this.options.num;
					var time = this.options.speed;
					var numhtml = this.options.numhtml;
					var ling = this.options.ling;
					var playtype = this.options.playtype;
					var len  =   $(img + '  dl').siblings().length; 
					if(!numhtml){
						numhtml = '<ul>';
						for(i=1;i<=len;i++){ 
							if(ling){
							numhtml = numhtml + '<li>0'+i+'</li>';	 
							}else{
							numhtml = numhtml + '<li>'+i+'</li>';	 
							}
						
						}
						numhtml =  numhtml + '</ul>'; 
						$(num).html(numhtml);
					}else{
						numhtml=$(img).html();
						$(num).html( '<ul class="pic">'+numhtml+'</ul>');
						$(num+' a').attr('href','javascript:void(0)');
						$(num+' a').attr('target','_self');
					}


					$(img + ' dl').hover(function(){
									 clearAuto();					 
							},
							 function(){
									 setAuto(); 
							}
					 );

					 $(num + '  li').click(function(){
						    clearAuto();		
							n  = $(num + '  li').index($(this)[0]); 
							plays(n);
							setAuto(); 
					 });
 

					function plays(value){

						if(playtype==1){
							$(img + ' dl').eq(value).stop(true,true).fadeIn(500).siblings().fadeOut(500);
						}else  if(playtype==2){						
							$(img + ' dl dt ').eq(value-1).animate({ top: '0px' }, 250,function () {
								$(img + ' dl dt ').eq(value-1).animate({ top: '30px' }, 250)  
							});
							$(img + ' dl dt ').eq(value).animate({ top: '30px' }, 250,function () {
								$(img + ' dl dt ').eq(value).animate({ top: '0px' }, 250)	});
							$(img + ' dl').eq(value).stop(true,true).fadeIn(500).siblings().fadeOut(500);
						
						}else  if(playtype==3){
							height=$(img + ' dl').height();			 
							$(img + ' dl').eq(value).siblings().animate({top: height+'px', opacity: 'hide'}, 650)  ;
							$(img + ' dl').eq(value).animate({top: height+'px' , opacity: 'hide' }, 650,function () {
								$(img + ' dl').eq(value).animate({top: '0px', opacity: 'show'  }, 650)	
							});

						}else{
						
						}

						$(num + '  li').eq(value).addClass("on").siblings().removeClass("on");;
						n++;					 
					}

		 
					function clearAuto(){ clearInterval(autoStart);}
					function setAuto(){ autoStart=setInterval(function(){
												plays(n);												
												if(n>len){n=0;plays(0)}; 
												} ,  time);}//ÇÐ»»Ê±¼ä

					plays(n);
					setAuto();


	};
})(jQuery);
