var currentPaneStyle = 0;
var currentTab = 0;

function tabstrip()
{
this.tabs = new Array();
this.add = addTab;
this.write = writeTabstrip;
}

function tab(caption,content)
{
this.setId = setId;
this.caption = caption;
this.content = content;
this.write = writeTab;
this.writeContent = writePane;
}

function addTab(tab)
{
tab.setId("tab" + this.tabs.length);
this.tabs[this.tabs.length] = tab;
}

function setId(id)
{
this.id = id;
}

function initiate()
{
var div = document.getElementById("tab0");
showPane(div);
}

function showPane(div)
{
if(currentTab != 0)
{
currentTab.style.backgroundColor = "#333366";
}
div.style.backgroundColor = "#999999";
currentTab = div;

if(currentPaneStyle != 0)
currentPaneStyle.display = "none";
var paneId = "pn_" + div.id;
var objPaneStyle = document.getElementById(paneId).style;
objPaneStyle.display = "block";
currentPaneStyle = objPaneStyle;
}

function writePane()
{
document.write("<div class='pane' id='pn_" + this.id + "'>" + this.content + "</div>");
}

function writeTab()
{
document.write("<td class='tabs'><div class='tabs' id='" + this.id + "' onclick='showPane(this)'>" + this.caption + "</div></td>");
}

function writeTabstrip()
{
document.write("<table border='0' class='tabs'><tr>");
for(var i = 0; i < this.tabs.length; i++)
{
this.tabs[i].write();
}
document.write("</tr></table>");

for(var k = 0; k < this.tabs.length; k++)
{
this.tabs[k].writeContent();
}
initiate();
}

