(function($) {
	$.fn.syFocus = function(options){  
		var defaults = {
			auto:			true,     
			speed: 			1000,
			pause:			3000
		}; 
	    var options = $.extend(defaults, options);
		var Me = this;
		var that = $("a",this);
		that.each(function(e){$(this).attr("autoindex",e);if(e != 0){$(this).hide();}})
		this.append('<div id="textindex" style="display:none"><ul></ul></div>');
		for(var i=1;i<=that.length;i++){
		    $("#textindex").find("ul").append("<li>" + i + "</li>");
		}
		$("#textindex li").eq(0).addClass("hov");

		var n = 0;
		var timeout; 
		if(options.auto){
			me();
		}
		that.hover(function(){
			Me.stopTime(); 
		},function(){
			me();
		});



        $("#textindex li").each(function (e) {
			$(this).mouseover(function(){
				 Me.stopTime();
				 var len = e;
				 show(len,100);
			}).mouseout(function(){
				 me();
			})
		})
		function me(){
			Me.everyTime(options.pause,function(){
				autotime();			  
			});	
		}
		function show(e,pauses){
		    that.parents(".rightimg").find("#textindex li").removeClass();
		    that.parents(".rightimg").find("#textindex li").eq(e).addClass("hov");

				that.hide();
				that.removeClass("show");
				that.eq(e).fadeIn();
				that.eq(e).addClass("show");
			n = e;
		}
		function autotime(){
				n++;if(n==that.length){n=0;}
				show(n,500);
		} 
	}
})(jQuery);

$(function(){
    $(".rightimg").syFocus();	
})
