if(typeof(TabTable) == 'undefined')
{
	function TabTable(){
		this.arHandles = null;
		this.arTables = null;
		this.handleEvent = 'onclick';
		this.curHandleId = null;
		
		this.init = function(handles,tables,paramHandleEvent){
			handles = handles.split(',');
			tables = tables.split(',');
			if(paramHandleEvent) this.handleEvent = paramHandleEvent;
	
			this.arHandles = new Array();
			for(var i=0;i < handles.length;i++){
				var tmp = document.getElementById(handles[i]);
				if(tmp){
					//tmp.style.cursor = 'hand';
					var f = this.proxycall(this,this.showTable,[tmp.id,tables[i]]);
					this.attachEventEx(tmp,this.handleEvent,f);
					
					//mouse 放在handle上时，改变样式
					if(this.handleEvent.toLowerCase() != 'onmouseover'){
						var fhover = this.proxycall(this,this.showHover,[tmp.id,tables[i]]);
						this.attachEventEx(tmp,'onmouseover',fhover);
						
						var fout = this.proxycall(this,this.showHover,[null,null]);
						this.attachEventEx(tmp,'onmouseout',fout);
					}
					
					this.arHandles.push(tmp);
				}
			}
	
			this.arTables = new Array();
			for(var i=0;i < tables.length;i++){
				var tmp = document.getElementById(tables[i]);
				if(tmp) this.arTables.push(tmp);
			}
	
			return this;
		}
		
		this.showHover = function(handelId,tableId){
			for(var i=0;i < this.arHandles.length;i++){
				var tmp = this.arHandles[i];
				if(tmp && tmp.id == this.curHandleId) continue;
				if(tmp && tmp.id == handelId){
					if(tmp.imghover) tmp.innerHTML = "<img src='"+ tmp.imghover +"' />";
					if(tmp.bgimghover) tmp.style.backgroungImage = tmp.bgimghover;
					if(tmp.bghover) tmp.style.backgroundColor = tmp.bghover;
					if(tmp.colorhover) tmp.style.color = tmp.colorhover;
					if(tmp.classhover) tmp.className = tmp.classhover;
				}else{
					if(tmp.imgoff) tmp.innerHTML = "<img src='"+ tmp.imgoff +"' />";
					if(tmp.bgimgoff) tmp.style.backgroungImage = tmp.bgimgoff;
					if(tmp.bgoff) tmp.style.backgroundColor = tmp.bgoff;
					if(tmp.coloroff) tmp.style.color = tmp.coloroff;
					if(tmp.classoff) tmp.className = tmp.classoff;
				}
			}
		}
	
		this.showTable = function(handelId,tableId){
			for(var i=0;i < this.arHandles.length;i++){
				var tmp = this.arHandles[i];
				if(tmp && tmp.id == handelId){
					if(tmp.imgon) tmp.innerHTML = "<img src='"+ tmp.imgon +"' />";
					if(tmp.bgimgon) tmp.style.backgroungImage = tmp.bgimgon;
					if(tmp.bgon) tmp.style.backgroundColor = tmp.bgon;
					if(tmp.coloron) tmp.style.color = tmp.coloron;
					if(tmp.classon) tmp.className = tmp.classon;
					this.curHandleId = handelId;
				}else{
					if(tmp.imgoff) tmp.innerHTML = "<img src='"+ tmp.imgoff +"' />";
					if(tmp.bgimgoff) tmp.style.backgroungImage = tmp.bgimgoff;
					if(tmp.bgoff) tmp.style.backgroundColor = tmp.bgoff;
					if(tmp.coloroff) tmp.style.color = tmp.coloroff;
					if(tmp.classoff) tmp.className = tmp.classoff;
				}
			}
	
			for(var i=0;i < this.arTables.length;i++){
				var tmp = this.arTables[i];
				if(tmp && tmp.id == tableId){
					tmp.style.display = 'block';
				}else{
					tmp.style.display = 'none';
				}
			}
		}
	
		this.proxycall = function(obj,method,args){
			var f = (function(){ method.apply(obj, args);});
			return f;
		}
	
		this.attachEventEx = function (eid,env,action){
			var object = typeof(eid)=='object'?eid:document.getElementById(eid);
			if (object && object.addEventListener){
				object.addEventListener(env,action,true);
			}else if(object){
				object.attachEvent(env,action);
			}
		}
	}
}