function TabView(titlePanel,tabPanel){
	if(titlePanel){
		this.titlePanel = titlePanel;
	}else{
		this.titlePanel = document.getElementById("tabview_titleContainer");
	}
	if(tabPanel){
		this.tabPanel = tabPanel;
	}else{
		this.tabPanel = document.getElementById("tabview_tabContainer");
	}
	this.titles = new Array();
	this.tabs = new Array();
	this.selectedIndex = 0;
	this.unselectedTabTitleStyle = null;//"tabview_unselectedTabTitle";
	this.selectedTabTitleStyle = "selectedtab";//"tabview_selectedTabTitle";
	this.unselectedTabStyle = "tabview_unselectedTab";
	this.selectedTabStyle = "tabview_selectedTab";
}
TabView.prototype.choice = function(titleElement){
	var index;
	var i;
	for(i=0; i < this.titles.length;i++){
		if(this.titles[i] == titleElement){
			index = i;
			break;
		}
	}
	this.choiceByIndex(index);
}
TabView.prototype.choiceByIndex = function(index){
	if(index<0 || index >= this.titles.length)
		return;
	this.titles[this.selectedIndex].className = this.unselectedTabTitleStyle;
	this.titles[index].className = this.selectedTabTitleStyle;
	this.tabs[this.selectedIndex].className = this.unselectedTabStyle;
	this.tabs[index].className = this.selectedTabStyle;
	this.selectedIndex = index;
}
TabView.prototype.addTab = function(titleText,bodyId,isChoice){
	var titleParent = document.createElement("li");
	var title = document.createElement("A");
	title.href ="javascript: void(0);";
	titleParent.appendChild(title);
	title.innerHTML = titleText;
	title.className = this.unselectedTabTitleStyle;
	if(typeof this.onClickTabTitle =="function")
		title.onclick = this.onClickTabTitle;
	this.titlePanel.appendChild(titleParent);
	this.titles[this.titles.length] = title;
	body = document.getElementById(bodyId);
	body.className = this.unselectedTabStyle;
	//body.parentNode.removeChild(body);
	//this.tabPanel.appendChild(body);
	this.tabs[this.tabs.length]=body;
	if(this.tabs.length == 1 || isChoice){
		this.choice(title);
	}
}
