function TabStrip(id)
{
  this.id = id;
  this.title = '';
  this.currentTab = null;
  this.tabList = new Array();
  
  this.onTabSelect = new REvent();
  this.onTabUnselect = new REvent();

  RegisterControl.statics.getInstance().add(this);
}
TabStrip.statics = new Object();

TabStrip.prototype.attach = function(node)
{
  var tabContainer = document.createElement("div");
  tabContainer.className = "tabStrip tabStripLineStyle";
  node.appendChild(tabContainer);
  
  var tabListNode = document.createElement("ul");
  tabListNode.id = this.id;
  tabContainer.appendChild(tabListNode);

  if (1<this.tabList.length)
  {
    for (var i=0; i<this.tabList.length; i++)
    {
      var tab = this.tabList[i];

      var li = document.createElement("li");
      tabListNode.appendChild(li);
      var a = document.createElement("a");
      li.appendChild(a);
      var text = document.createTextNode(tab.getTabText());
      a.appendChild(text);

      li.id = RegisterControl.statics.encodeId(this, tab.getId(), "tab");
      li.onclick = TabStrip.statics.onClick;
    }
  }
  
  var text = document.createTextNode(this.title);
  tabContainer.appendChild(text);
  
  this.setCurrentTab(this.currentTab);
}

TabStrip.statics.onClick = function()
{
  var params = new Array();
  var instance = RegisterControl.statics.decodeId(this.id, params);

  var tab = instance.getTab(params[0]);
  instance.setCurrentTab( tab );
}

TabStrip.prototype.setTitle = function(t)
{
  this.title = t;
}

TabStrip.prototype.setCurrentTab = function(tab)
{
  if (tab == this.currentTab)
    return;

  var tabNode;
  if (this.currentTab != null)
  {
    var tabNode = document.getElementById(RegisterControl.statics.encodeId(this, this.currentTab.getId(), "tab"));
    if(tabNode)
      tabNode.className = '';
    this.onTabUnselect.trigger(this.currentTab);
  }
  
  this.currentTab = tab;
  
  var tabNode = document.getElementById(RegisterControl.statics.encodeId(this, this.currentTab.getId(), "tab"));
  if(tabNode)
    tabNode.className = 'selected';

  this.onTabSelect.trigger(this.currentTab);
  this.currentTab.onShow.trigger();
}

TabStrip.prototype.getId = function()
{
  return this.id;
}

TabStrip.prototype.getTab = function(id)
{
  for (var i in this.tabList)
  {
    var tab = this.tabList[i];
    if (tab.getId() == id)
      return tab;
  }
}

TabStrip.prototype.getCurrentTab = function()
{
  return this.currentTab;
}

TabStrip.prototype.addTab = function(tab)
{
  this.tabList.push(tab);
}

TabStrip.prototype.getTabList = function()
{
  return this.tabList;
}



function ITabPage()
{
}
ITabPage.prototype.getId = function()
{
}
ITabPage.prototype.getTabText = function()
{
}