function TbCnt(TbIntfID){
	this.TbIntfID=TbIntfID 
	this.Tbs=document.getElementById(TbIntfID).getElementsByTagName("a") 
	this.EnbTbPersis=true
	this.HtTbPos=[] 
	this.CrtTbInd=0 
	this.SbCntIds=[] 
	this.RvCntIds=[] 
	this.SelClsTrg="Lnk"}
TbCnt.getCookie=function(Name){ 
	var re=new RegExp(Name+"=[^;]+", "i"); 
	if (document.cookie.match(re)) 
		return document.cookie.match(re)[0].split("=")[1]
	return ""}
TbCnt.setCookie=function(name, value){
	document.cookie = name+"="+value+";path=/"}
TbCnt.prototype={
	expandit:function(TbIdOrPos){
		this.cancelautorun() 
		var tabref=""
		try{
			if (typeof TbIdOrPos=="string" && document.getElementById(TbIdOrPos).getAttribute("rel")) 
				tabref=document.getElementById(TbIdOrPos)
			else if (parseInt(TbIdOrPos)!=NaN && this.Tbs[TbIdOrPos].getAttribute("rel")) 
				tabref=this.Tbs[TbIdOrPos]}
		catch(err){alert("Invalid Tab ID or position entered!")}
		if (tabref!="") 
			this.ExpTb(tabref)},
	cycleit:function(dir, autorun){ 
		if (dir=="next"){
			var CrtTbInd=(this.CrtTbInd<this.HtTbPos.length-1)? this.CrtTbInd+1 : 0}
		else if (dir=="prev"){
			var CrtTbInd=(this.CrtTbInd>0)? this.CrtTbInd-1 : this.HtTbPos.length-1}
		if (typeof autorun=="undefined") 
			this.cancelautorun() 
		this.ExpTb(this.Tbs[this.HtTbPos[CrtTbInd]])},
	setpersist:function(bool){ 
			this.EnbTbPersis=bool},
	setselectedClassTarget:function(objstr){ 
		this.SelClsTrg=objstr || "Lnk"},
	getselectedClassTarget:function(tabref){ 
		return (this.SelClsTrg==("linkparent".toLowerCase()))? tabref.parentNode : tabref},
	urlparamselect:function(TbIntfID){
		var result=window.location.search.match(new RegExp(TbIntfID+"=(\\d+)", "i")) 
		return (result==null)? null : parseInt(RegExp.$1)},
	ExpTb:function(tabref){
		var SbCntId=tabref.getAttribute("rel") 
		var AssRvIds=(tabref.getAttribute("rev"))? ","+tabref.getAttribute("rev").replace(/\s+/, "")+"," : ""
		this.ExpSubCnt(SbCntId)
		this.ExpRvCnt(AssRvIds)
		for (var i=0; i<this.Tbs.length; i++){ 
			this.getselectedClassTarget(this.Tbs[i]).className=(this.Tbs[i].getAttribute("rel")==SbCntId)? "selected" : ""}
		if (this.EnbTbPersis)
			TbCnt.setCookie(this.TbIntfID, tabref.tabposition)
		this.StCrtTbInd(tabref.tabposition)},
	ExpSubCnt:function(SbCntId){
		for (var i=0; i<this.SbCntIds.length; i++){
			var subcontent=document.getElementById(this.SbCntIds[i])
			subcontent.style.display=(subcontent.id==SbCntId)? "block" : "none"}},
	ExpRvCnt:function(AssRvIds){
		var allrevids=this.RvCntIds
		for (var i=0; i<allrevids.length; i++){
			document.getElementById(allrevids[i]).style.display=(AssRvIds.indexOf(","+allrevids[i]+",")!=-1)? "block" : "none"}},
	StCrtTbInd:function(tabposition){
		for (var i=0; i<this.HtTbPos.length; i++){
			if (tabposition==this.HtTbPos[i]){
				this.CrtTbInd=i
				break}}},
	autorun:function(){
		this.cycleit('next', true)},
	cancelautorun:function(){
		if (typeof this.autoruntimer!="undefined")
			clearInterval(this.autoruntimer)},
	init:function(automodeperiod){
		var persistedtab=TbCnt.getCookie(this.TbIntfID) 
		var selectedtab=-1 
		var selectedtabfromurl=this.urlparamselect(this.TbIntfID)
		this.automodeperiod=automodeperiod || 0
		for (var i=0; i<this.Tbs.length; i++){
			this.Tbs[i].tabposition=i
			if (this.Tbs[i].getAttribute("rel")){
				var tabinstance=this
				this.HtTbPos[this.HtTbPos.length]=i 
				this.SbCntIds[this.SbCntIds.length]=this.Tbs[i].getAttribute("rel")
				this.Tbs[i].onclick=function(){
					tabinstance.ExpTb(this)
					tabinstance.cancelautorun()
					return false}
				if (this.Tbs[i].getAttribute("rev")){ 
					this.RvCntIds=this.RvCntIds.concat(this.Tbs[i].getAttribute("rev").split(/\s*,\s*/))}
				if (selectedtabfromurl==i || this.EnbTbPersis && selectedtab==-1 && parseInt(persistedtab)==i || !this.EnbTbPersis && selectedtab==-1 && this.getselectedClassTarget(this.Tbs[i]).className=="selected"){
					selectedtab=i}}} 
		if (selectedtab!=-1) 
			this.ExpTb(this.Tbs[selectedtab]) 
		else
			this.ExpTb(this.Tbs[this.HtTbPos[0]]) 
		if (parseInt(this.automodeperiod)>500 && this.HtTbPos.length>1){
			this.autoruntimer=setInterval(function(){tabinstance.autorun()}, this.automodeperiod)}}}
