// JavaScript Document
(function(){
	$.fn.picshow = function(o){
		var o = $.extend({
			 pause:5000,
			 auto:true
		}, o||{});
		return this.each(function(){
			var $cont = $(".ps-cont > a", this), $title = $(".ps-title > h3", this), $nav = $(".ps-nav > a", this),
			len = $cont.length;
			var interval = null, index = 0;
			$cont.hover(function(){
				clearInterval(interval);
			}, auto);
			$nav.each(function(i){
				$(this).hover(function(){
					clearInterval(interval);
					roll(i);
				}, auto);
			});
			if(o.auto){
				$cont.eq(index).show();
				$nav.eq(index).addClass("hover");
				auto();
			}
			function auto(){
				clearInterval(interval);
				interval = setInterval(function(){ roll(index==(len-1) ? 0 : index+1);}, o.pause);
			}
			function roll(i){
				$cont.hide();
				$cont.eq(i).fadeIn(1000);
				$nav.removeClass("hover");
				$nav.eq(i).addClass("hover");
				$title.hide();
				$title.eq(i).show()
				index = i;
			}
		});
	}
})(jQuery);