﻿( function()
{
  $( '#tabbed_items' ).ready( function()
  {
    var DefaultTab = '';
    var ThisFilePath = document.location.pathname.substring( 0, document.location.pathname.lastIndexOf( "." ) ) + "/tab/";

    $( '#tabs > DIV' ).click( function()
    {
      try
      {
        Moxi.TrackEvent( ThisFilePath + this.getAttribute( 'rel' ) );
      }
      catch(e){}

      $( '#tabs > DIV' ).removeClass( 'selected' );
      $( this ).addClass( 'selected' );
      $( '#tabbed_items .item' ).hide();
      $( '#' + this.getAttribute( 'rel' ) ).show();
    });

    if( Moxi.query.tab )
    {
      $( document ).ready( function()
      {
        $( '#tabs > DIV' ).removeClass( 'selected' );
        $( '#tabs > DIV[rel=' + Moxi.query.tab + ']' ).addClass( 'selected' );
        $( '#tabbed_items .item' ).hide();
        $( '#' + Moxi.query.tab ).show();
      });
    }
    else
    {
      $( '#tabbed_items .item' ).hide();
      $( '#tabbed_items .item:first' ).show();
    }
  });

})();
