// JavaScript Document
(function($){
	$.tab = function(options){
		var defaults = {
			showPic:null,          
			list:null,             
			on:"on",               
			curWindow:"on",        
			nowIndex:0,            
			url:1,
			tabjson:null
		}
		var settings = $.extend({},defaults,options);
		var index,nowIndex = settings.nowIndex;
		
		 
		if( settings.showPic == null) { return null; }
		
		if( settings.list != null ){
			var _selfList = $(settings.list);
		}
		
		if( settings.url ){
			var arr,tag,last=null,cur;
			settings.url = window.location.href;
			tag = settings.url.indexOf("#");
			if(tag > 0){
				arr = settings.url.split("#");
				last = arr[arr.length-1].toLowerCase();
			}
			if(last != null && settings.tabjson != null ){
				cur = settings.tabjson[last];
				if( cur != undefined ){ settings.nowIndex = cur;  }
			}
		}
		
		if( settings.nowIndex ){
			$(settings.showPic).eq(nowIndex).hide().end().eq(settings.nowIndex).show();
			_selfList.eq(nowIndex).removeClass(settings.on).end().eq(settings.nowIndex).addClass(settings.on);
			nowIndex = settings.nowIndex;
		}
		
		if( _selfList ){
			_selfList.mouseenter(function(){
				index = _selfList.index($(this));
				simple();
			});
		}
		
		function simple(){
			if(index != nowIndex ){
				$(settings.showPic).eq(nowIndex).hide().end().eq(index).show();
				_selfList.eq(nowIndex).removeClass(settings.on).end().eq(index).addClass(settings.on);
				$(".dd").eq(nowIndex).hide().end().eq(index).show();
				$(".ss").eq(nowIndex).hide().end().eq(index).show();
				nowIndex = index;
			}
		}
				
	}
})($);
