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 = "#00ffff";
    currentTab.innerHTML = put_tab("off",tab_obj.caption);
  }
  for(k = 0, tab_obj = ts.tabs[k]; tab_obj.id != div.id; k++, tab_obj = ts.tabs[k]) 
  {}
    //div.style.backgroundColor = "#ccccff";
  div.innerHTML = put_tab("on",tab_obj.caption);
  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 SubmitForm()
{  window.alert("Form submitted.  This would normally take you to another page");
   // normally, you would here check the form and submit it.
   // if the form has the name 'tabform', then it is submitted
   // with tabform.submit();
}

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

function writeTab()
{ document.write("<li id='" + this.id + "' onclick='showPane(this)'>" + put_tab("off",this.caption) + "</li>");
}

function writeTabstrip()
{ document.write("<div class='tabsJ'><ul>");
  for(var i = 0; i < this.tabs.length; i++)
  { this.tabs[i].write();
  }
  document.write("</ul></div><br clear='all' />");
  
  for(var k = 0; k < this.tabs.length; k++)
  { this.tabs[k].writeContent();
  }
  initiate();
}

function put_tab(which_tab, content)
{ var tmp
  
  switch(which_tab)
  { case 'on':
     tmp = "<a href=\"#\" class='sel'><span>"+content+"</span></a>"
	 break
    case 'off':
     tmp = "<a href=\"#\"><span>"+content+"</span></a>"
	 break
  }
  return tmp
}