function createTabs(TabId){

	var tabControl	= new Object();
	var table		= document.getElementById(TabId);
	var content		= table.getElementsByTagName('TD')[0];
	tabControl.id	= TabId;
	tabControl.tabs		= table.getElementsByTagName('TH');
	tabControl.targetLayer	= content.getElementsByTagName('DIV')[0];
	
	tabControl.loading	= "<br><br><h2 align='center'>Loading.....</h2>";
	
	content.colSpan		= tabControl.tabs.length;
	table.cellSpacing	= 0;
	table.cellPadding	= 0;
	tabControl.scrolling= "yes";
	table.className		= "topjob_tab_controller";
	tabControl.targetLayer.id	= "topjob_tab_target";
	
	tabControl.divContent	= Array();
	tabControl.set			= function(num,html){
		this.divContent[num]= html;
		if(num==this.getCookie("TJtabs_"+tabControl.id))
			this.targetLayer.innerHTML = html;
	}
	
	tabControl.setScrolling	= function(str){
		this.scrolling	= str;
	}
	
	tabControl.displayTab	= function(tabNum){
		if(tabNum>=this.tabs.length) tabNum = this.tabs.length-1;
		else if (tabNum<0) tabNum = 0;
		for(var i=0;i<this.tabs.length;i++){
			if( i<tabNum )
				this.tabs[i].className	= "left";
			else
				this.tabs[i].className	= "right";
		}
		this.tabs[tabNum].className	= "selected";
		if(this.divContent[tabNum] && this.divContent[tabNum]!=null){
			this.targetLayer.className	= this.scrolling;
			this.targetLayer.innerHTML	= this.divContent[tabNum];
			
		} else {
			var ifr	= this.targetLayer.getElementsByTagName("IFRAME");
			if(ifr[0]&&ifr[0].id==("tj_frame_"+TabId)){
				ifr	= ifr[0].contentWindow;
				try{ ifr.document.body.innerHTML	= this.loading; } catch(err){};
				ifr.location	= this.tabs[tabNum].scope;
			} else {
			this.targetLayer.className	= "no";
			this.targetLayer.innerHTML	= "<iframe id='tj_frame_"+TabId+"' name='"+TabId+"' width='100%' height='100%' style='overflow:"+((this.scrolling=="no")?"hidden":"auto")+";' scrolling='"+this.scrolling+"' frameborder='0' src='"+this.tabs[tabNum].scope+"'></iframe>"
			}
		}
		this.setCookie("TJtabs_"+this.id,tabNum);
	}
	
	for(var i=0;i<tabControl.tabs.length;i++){
		tabControl.tabs[i].onclick		= function(){tabControl.displayTab(this.cellIndex);return false;};
		tabControl.tabs[i].id			= "topjob_tab_head";
	}
	
	tabControl.curTab	= function(){
		return this.getCookie("TJtabs_"+tabControl.id);
	}
		
	tabControl.getCookie=function(Name){ 
	var re=new RegExp(Name+"=[^;]+", "i");
	if (document.cookie.match(re))
		return document.cookie.match(re)[0].split("=")[1];
	return null;
	}
	tabControl.setCookie=function(name, value){
		document.cookie = name+"="+value+";path=/";
	}
	
	if(tabControl.getCookie("TJtabs_"+tabControl.id)!=null){
		tabControl.displayTab(tabControl.getCookie("TJtabs_"+tabControl.id));
	} else {
		tabControl.displayTab(0);
		tabControl.setCookie("TJtabs_"+tabControl.id,0)
	}
	
	tabControl.setHeight	= function(height){
		this.targetLayer.style.height	= height+"px";
	}
	tabControl.setWidth		= function(Width){
		this.targetLayer.style.width	= Width+"px";
	}
	
	tabControl.setLoading = function(elementId){
		this.loading = document.getElementById(elementId).innerHTML;
	}
	
	return tabControl;
}
