function dhtabStrip(){
	//author:dh20156;
	this.rid = "dhtabstrip";
	this.width = 400;
	this.height = 450;
	this.tabwidth = 70;

	var dhts = this;
	var tabsplit = null;
	var tabcontent = null;
	var tabbutton = null;
	var splitObj = [];
	var length = 0;
	var currenttab = 0;
	var currentlist = [];
	var currentlistl = 0;
	var showmore = false;

	var isMSIE = (navigator.appName == "Microsoft Internet Explorer");

	var lb = document.createElement("BUTTON");
	lb.innerHTML = "&nbsp;";
	lb.className = "dhtbvlbtn";
	lb.style.width = "18px";
	lb.style.height = "18px";
	lb.style.fontSize = "12px";
	lb.onclick = function(){viewpre();}

	var rb = document.createElement("BUTTON");
	rb.innerHTML = "&nbsp;";
	rb.className = "dhtbvrbtn";
	rb.style.width = "18px";
	rb.style.height = "18px";
	rb.style.fontSize = "12px";
	rb.onclick = function(){viewnext();}

	var mb = document.createElement("DIV");
	mb.style.styleFloat = "right";
	mb.style.cssFloat = "right";
	mb.style.position = "relative";
	mb.style.right = "0px";
	mb.style.padding = "0px";
	mb.style.background = "transparent";
	mb.style.border = "none";
	mb.style.width = "36px";
	mb.style.height = "20px";

	mb.appendChild(lb);
	mb.appendChild(rb);

	this.showTab = function(index){
		if(0<=index && length>0 && index<length){
			if(index!=currenttab){
				splitObj[currenttab].ts.className = "";
				splitObj[currenttab].tc.style.display = "none";
				splitObj[index].tc.style.display = "block";
			}

			splitObj[index].ts.className = "nowtabsplit";

			currenttab = index;
		}
	}

	function viewpre(){
		var cl = currentlistl;
		if(currentlist[0]!=0){
			var tcl = currentlist;
			for(var i=0;i<cl;i++){
				try{
					if(tabsplit.childNodes[i].tagName!="DIV"){
						var ni = parseInt(tcl[i])-1;
						tabsplit.replaceChild(splitObj[ni].ts,tabsplit.childNodes[i]);
						currentlist[i] = ni;
					}
				}catch(e){}
			}
			rb.removeAttribute("disabled");
			if(currentlist[0]==0){
				lb.setAttribute("disabled","true");
			}
		}
	}

	function viewnext(){
		var cl = currentlistl;
		if(currentlist[cl-1]!=parseInt(length)-1){
			var tcl = currentlist;
			for(var i=cl-1;i>-1;i--){
				try{
					if(tabsplit.childNodes[i].tagName!="DIV"){
						var ni = parseInt(tcl[i])+1;
						tabsplit.replaceChild(splitObj[ni].ts,tabsplit.childNodes[i]);
						currentlist[i] = ni;
					}
				}catch(e){}
			}
			lb.removeAttribute("disabled");
			if(currentlist[cl-1]==parseInt(length)-1){
				rb.setAttribute("disabled","true");
			}
		}
	}

	this.init = function(targetObj){
		var tabstrip = document.createElement("DIV");
		tabstrip.id = this.rid;
		tabstrip.style.width = this.width;
		tabstrip.style.height = this.height;
		tabstrip.setAttribute("unselectable","on");

		var ts = document.createElement("DIV");
		ts.id = "dhtabsplit";
		ts.style.height = "21px";
		ts.style.lineHeight = "21px";
		ts.setAttribute("unselectable","on");

		var tc = document.createElement("DIV");
		tc.id = "dhtabcontent"
		tc.style.height = this.height-80+"px";

		var tb = document.createElement("DIV");
		tb.id = "dhtabbutton"
		tb.setAttribute("unselectable","on");

		tabstrip.appendChild(ts);
		tabstrip.appendChild(tc);
		tabstrip.appendChild(tb);
		targetObj.appendChild(tabstrip);

		tabsplit = ts;
		tabcontent = tc;
		tabbutton = tb;
	}

	this.addTab = function(tab,content){
		var tempint = length;
		var tsil = document.createElement("A");
		tsil.setAttribute("index",length);
		tsil.setAttribute("href","javascript:void(0)");
		tsil.setAttribute("hideFocus","hideFocus");
		var tsils = document.createElement("SPAN");
		tsils.title = tab;
		tsils.innerHTML = tab;
		tsil.appendChild(tsils);
		tsil.onclick = function(){dhts.showTab(this.getAttribute("index"));}
		tsil.onkeydown = function(e){e=e||window.event;arrowkey(e);}

		//判断内容为容器或字串
		if(typeof[content]=="object" && content.tagName!=undefined){
			content.style.display = "none";
			tabcontent.appendChild(content);
			if(0 == length){
				tsil.className = "nowtabsplit"
				content.style.display = "block";
			}
			splitObj[length] = {"ts":tsil,"tc":content};
		}else{
			var tbcobj = document.createElement("DIV");
			tbcobj.id = "dhtabcontent"+length;
			tbcobj.innerHTML = content;
			tbcobj.style.display = "none";
			tabcontent.appendChild(tbcobj);
			if(0 == length){
				tsil.className = "nowtabsplit"
				tbcobj.style.display = "block";
			}
			splitObj[length] = {"ts":tsil,"tc":tbcobj};
		}

		length += 1;

		if(length*this.tabwidth<this.width){
			tabsplit.appendChild(tsil);
			currentlist.push(length-1);
			currentlistl += 1;
		}else{
			if(!showmore){
				lb.setAttribute("disabled","true");
				tabsplit.appendChild(mb);
				showmore = true;
			}else{
				rb.removeAttribute("disabled");
			}
		}
	}

	this.removeTab = function(index){
		if(0<=index && index<length){

			var rindex = splitObj[index].ts.getAttribute("index");

			//移除标签及内容
			length -= 1;
			splitObj[index].ts = null;
			splitObj[index].tc.style.display = "none";
			tabcontent.removeChild(splitObj[index].tc);
			splitObj[index].tc = null;

			splitObj.splice(index,1);

			//判断所移除的标签是否为显示状态
			var atb = null;
			currentlist.sort();
			for(var i=0;i<currentlistl;i++){
				if(rindex==currentlist[i]){
					atb = i;
				}
			}

			//标签出现滚动
			if(showmore){
				//给所有标签重新赋值
				for(var s=0;s<splitObj.length;s++){
					splitObj[s].ts.setAttribute("index",s);
				}
				//移除的标签为显示状态
				if(atb!=null){
					if(0==index){
						for(var n=currentlistl-1;n>atb-1;n--){
							var ni = parseInt(currentlist[n]);
							tabsplit.replaceChild(splitObj[ni].ts,tabsplit.childNodes[n]);
							currentlist[n] = ni;
						}
						currentlist.sort();
					}else if (index==length){
						for(var n=0;n<currentlistl;n++){
							var ni = parseInt(currentlist[n])-1;
							tabsplit.replaceChild(splitObj[ni].ts,tabsplit.childNodes[n]);
							currentlist[n] = ni;
						}
					}else{
						if(currentlist[0]>0){
							for(var n=0;n<currentlistl;n++){
								var ni = parseInt(currentlist[n])-1;
								if(n<atb+1){
									tabsplit.replaceChild(splitObj[ni].ts,tabsplit.childNodes[n]);
								}
								currentlist[n] = ni;
							}
						}else{
							for(var n=currentlistl-1;n>atb-1;n--){
								var ni = parseInt(currentlist[n]);
								tabsplit.replaceChild(splitObj[ni].ts,tabsplit.childNodes[n]);
								currentlist[n] = ni;
							}
						}
					}
				}else{
					//显示状态下标签重新赋值
					if(index<currentlist[0]){
						for(var cs=0;cs<currentlistl;cs++){
							currentlist[cs] -= 1;
						}
					}
				}
			}else{
				//标签未出现滚动
				if(atb!=null){
					tabsplit.removeChild(tabsplit.childNodes[atb]);	
					currentlist.splice(atb,1);
					currentlistl -= 1;
					for(var b=0;b<currentlistl;b++){
						currentlist[b] = b;
						splitObj[b].ts.setAttribute("index",b);
					}
				}
			}

			if(0==splitObj.length){
				currenttab = 0;
			}else{
				if(currenttab==index){
					if(currenttab<length){
						currenttab = index;
					}else{
						currenttab -= 1;
					}
				}else{
					if(currenttab>0 && currenttab>index){
						currenttab -= 1;
					}
				}
			}

			if(length>0){
				splitObj[currenttab].tc.style.display = "block";
				splitObj[currenttab].ts.className = "nowtabsplit";
			}

			if(showmore){
				if(length*this.tabwidth<this.width){
					tabsplit.removeChild(tabsplit.childNodes[tabsplit.childNodes.length-1]);
					rb.removeAttribute("disabled");
					showmore = false;
				}
			}
		}
	}

	this.removeAll = function(){
			if(showmore){
				tabsplit.removeChild(tabsplit.childNodes[tabsplit.childNodes.length-1]);
				showmore = false;
			}
			for(var i=length-1;i>-1;i--){
				if(currentlistl>=i){
					tabsplit.removeChild(tabsplit.childNodes[i]);
				}
				splitObj[i].tc.style.display = "none";
				tabcontent.removeChild(splitObj[i].tc);
				splitObj[i].tc = null;
			}
			length = 0;
			splitObj = [];
			currentlist = [];
			currentlistl = 0;
			currenttab = 0;
	}

	function arrowkey(e){
		e=e||window.event;
		c=e.which||e.keyCode;
		switch(c){
			case 37://left;
				dhts.showTab(parseInt(currenttab)-1);
				if(isMSIE){
					e.keyCode = 0;
				}
				break;
			case 39://right;
				dhts.showTab(parseInt(currenttab)+1);
				if(isMSIE){
					e.keyCode = 0;
				}
				break;
			case 9://tab;
				if(isMSIE){
					e.keyCode = 0;
				}else{
					e.preventDefault();
				}
				break;
			default:break;
		}
	}

	this.setButton = function(btnstr){
		tabbutton.innerHTML = btnstr;
	}

	this.getChildNodes = function(){
		return splitObj;
	}

	this.getCurrentNode = function(){
		return splitObj[currenttab];
	}
}