// last selected Tab
var old_tab = null;
// styles for events
var styles = {
  'over' : ['#000', 'pointer','rgb(255,113,19)'],
  'out'  : ['#222', 'auto','rgb(255,113,19)'],
  'click': ['rgb(255,113,19)', 'default','#222']
};

// handler for Tabs
function selTab( tab, type_select )
{
  // method ignore for select Tab
  if (tab.className != 'sel-tabs')
  {
    with (tab.style)
    {
      if (type_select == 1) // onMouseOver
      {
        // set background
        backgroundColor = styles['over'][0];
        // set cursor type
        cursor = styles['over'][1];
        // set color
        color  = styles['over'][2];
      }
      else if (type_select == 2)  // onClick
      {
        if (old_tab)
        {
          // unset of class name
          old_tab.className = '';
          // reconstruction of default style
          selTab( old_tab, 0 );
        }
        // set class name (for the selected Tab)
        tab.className = 'sel-tabs';
        // set background
        backgroundColor = styles['click'][0];
        // set cursor type
        cursor = styles['click'][1];
        // set color
        color  = styles['click'][2];
        // save select tab
        old_tab = tab;
      }
      else // onMouseOut
      {
        // set background
        backgroundColor = styles['out'][0];
        // set cursor type
        cursor = styles['out'][1];
        // set color
        color  = styles['out'][2];
      } 
    }
  }
}



// 
function UpdateTab( findclas, groupby )
{
  
  // id for update
  var id_name  = 'ajax-tabs-content';
  // show 'loading...'
  var text  = '<img src="images/tabs_loading.gif" style="padding:5px; margin-left:220px;">';
  // use cache
  var caching  = true;
  // template  
  var template  = '%ajaxhtml%';
  
  callUrl='itemclastabs.php?clasrefr='+findclas+'&showalll=1&groupby='+groupby+'&seed='+Math.random();    
  
  // request
  cbaUpdateElement(
    id_name,
    callUrl,
    text,
    caching,
    template);
}
                    
// Test version
function UpdateTabTest( tab, request )
{
  // id for update
  var id_name  = 'ajax-tabs-content';
  // show 'loading...'
  var text  = '<img src="/images/tabs_loading.gif" style="padding:5px; margin-left:220px;">';
  // use cache
  var caching  = false;
  // template
  //var template  = '<h3>%header%</h3><div class="code">%code%</div>';
  var template  = '%ajaxhtml%';
  // Tab select
  if (tab != null)
    selTab( tab, 2 );
  // request
  cbaUpdateElement(
    id_name,
    '/itemclastabs.php?findclas=Wooden_sheds&showalll=1&groupby='+request,
    text,
    caching,
    template);
}
