this.Home = Class.create(Section,{
  bt_comecar:null,
  campo_usuario:null,
  campo_amigo:null,
  
  initialize: function($super)
  {
    Home.ID = "home";
    $super( Home.ID );
    
    this.config();
  },
  
  config: function()
  {
    this.bt_comecar = jQuery( "#comecar" );
    this.campo_usuario = jQuery( "#usuario .pre" );
    this.campo_amigo = jQuery( "#amigo .pre" );
    
    jQuery( this.bt_comecar ).hide();
    jQuery( this.campo_usuario ).hide();
    jQuery( this.campo_amigo ).hide();
    
    jQuery( this.bt_comecar ).click( delegate( this, this.onPressComecar ) );
    
    jQuery( this.campo_usuario ).keypress( delegate( this, this.onKeyPress ) );
    jQuery( this.campo_amigo ).keypress( delegate( this, this.onKeyPress ) );
  },
  
  onKeyPress: function(e)
  {
    if(e.keyCode == 13) this.onPressComecar();
  },
  
  onPressComecar: function()
  {
    pageTracker._trackEvent('world-cup','clique','comecar');
    this.checkFields();
    //SectionManager.openSection( Game.ID );
  },
  
  checkFields: function()
  {
    var c1 = this.checkField(jQuery("#usuario .pre input"));
    var c2 = this.checkField(jQuery("#amigo .pre input"));
    if( c1 && c2 ) SectionManager.openSection( Game.ID );
  },
  
  checkField: function( field )
  {
    if( !jQuery( field ).val() )
    {
      jQuery( field ).addClass( "erro" );
      return false;
    }
    else
    {
      jQuery( field ).removeClass( "erro" );
      return true;
    }
  },
  
  doOpen: function($super)
  {
    $super();
    jQuery( this.bt_comecar ).show();
    jQuery( this.campo_usuario ).show();
    jQuery( this.campo_amigo ).show();
    this.onOpen();
  },
  
  doClose: function($super)
  {
    $super();
    jQuery( this.bt_comecar ).fadeOut(200);
    jQuery( this.campo_usuario ).fadeOut(300);
    jQuery( this.campo_amigo ).fadeOut(300);
    
    setTimeout( delegate(this, this.onClose ), 500 );
  }
});
