function Step2()
{
   $('#flag-langage').hide();  //hide flag
   delete Players;         //make sure previous player(s) array is empty
   Players = new Array();
   var PlayerName = new Array(); //to double check if players have same name
   
   var Counter=0;
   var TmpName='';   
   var Html='<ul>';
   var IsError=false;

   for(var a=0; a < MaxNumberPlayer; a++)
   {
      TmpName = $('#player_name_'+a).val();
      if(TmpName.length>0 && $.inArray(TmpName, PlayerName)>-1)
      {
          IsError=true;  
      }else
      {
         PlayerName.push(TmpName);
         //TmpName = TmpName.toUpperCase();//upper case to all name, disable by now
         TmpName = TmpName.substring(0,MaxNameCharLen);  //resize name to avoid layout to be brocken in match page
         if(TmpName.length>0 && TmpName.length<20 )
         {
            Players.push(new PlayerObject(Counter, TmpName, ''));//need to add shortcut key
            Html+='<li>'+TmpName+'</li>';
            Counter++;
         }
      }         
   }
   Html+='</ul>';
   if(IsError==true)
   {
      AddHtmlToContainer('box-message',MessageDictionnary('Des joueurs ont des noms identiques. Les doublons ont ete supprimes'));
   }
   //save level that was choosen
   //$('#system_level').attr('value',$('#level_name').val()); //to replace by call to var directly?
   //SystemLevel = $('#level_name').val();//disable now as level is not choose now

   //and set no question active to avoid popup window to open
   //$('#system_active_question').attr('value',0);

   //we know what kind of game we play, lets init system game and run init function
   if(Players.length==1)
   {
      SystemGameMode = 'single';
      LabelMode = MessageDictionnary('Entrainement');
   }else
   {
      SystemGameMode = 'multi';   
      LabelMode = MessageDictionnary('Match');
   }
   Run({'mode':'init'});

   //show confirmation of game
   $('#header').html(MessageDictionnary('Confirmation du jeu ?'));
   $('#body').html(Players.length+' '+MessageDictionnary('joueur(s)'));//+' '+MessageDictionnary('Niveau') + $('#level_name').val()+Html);//disable as level is not choose now

   //show additional form
   Html='';

   Html = RunAndReturn({'mode':'step2'});   //this is a critical call because if SystemGameMode is not initialized, then we crash with a infinite loop 

   Html+=RunAndReturn({'mode':'choose_question'});//ChooseQuestion();
   //if(Html.length>0) 
   {
      $('#body').html($('#body').html()+Html);
   }
   //show button for next step  
   FooterMenu({'mode':'step2'});
}
/*
  * Start game, phase 2:
  *  Save player after basic check
  *  Show button to continue or go back
  */
Start game, phase 2:
Save player after basic check
Show button to continue or go back
Start game phase 2 : Save player after basic check Show button to continue or go back
function Step2()
{
   $('#flag-langage').hide();  
   delete Players;         
   Players = new Array();
   var PlayerName = new Array(); 
   var Counter=0;
   var TmpName='';   
   var Html='<ul>';
   var IsError=false;
   for(var a=0; a < MaxNumberPlayer; a++)
   {
      TmpName = $('#player_name_'+a).val();
      if(TmpName.length>0 && $.inArray(TmpName, PlayerName)>-1)
      {
          IsError=true;  
      }else
      {
         PlayerName.push(TmpName);
         TmpName = TmpName.substring(0,MaxNameCharLen);  
         if(TmpName.length>0 && TmpName.length<20 )
         {
            Players.push(new PlayerObject(Counter, TmpName, ''));
            Html+='<li>'+TmpName+'</li>';
            Counter++;
         }
      }         
   }
   Html+='</ul>';
   if(IsError==true)
   {
      AddHtmlToContainer('box-message',MessageDictionnary('Des joueurs ont des noms identiques. Les doublons ont ete supprimes'));
   }
   if(Players.length==1)
   {
      SystemGameMode = 'single';
      LabelMode = MessageDictionnary('Entrainement');
   }else
   {
      SystemGameMode = 'multi';   
      LabelMode = MessageDictionnary('Match');
   }
   Run({'mode':'init'});
   $('#header').html(MessageDictionnary('Confirmation du jeu ?'));
   $('#body').html(Players.length+' '+MessageDictionnary('joueur(s)'));
   Html='';
   Html = RunAndReturn({'mode':'step2'});   
   Html+=RunAndReturn({'mode':'choose_question'});
   {
      $('#body').html($('#body').html()+Html);
   }
   FooterMenu({'mode':'step2'});
}
function Step2 ( ) { $ ( '#flag-langage' ) . hide ( ) ; delete Players ; Players = new Array ( ) ; var PlayerName = new Array ( ) ; var Counter = 0 ; var TmpName = '' ; var Html = '<ul>' ; var IsError = false ; for ( var a = 0 ; a < MaxNumberPlayer ; a ++ ) { TmpName = $ ( '#player_name_' + a ) . val ( ) ; if ( TmpName . length > 0 && $ . inArray ( TmpName , PlayerName ) > - 1 ) { IsError = true ; } else { PlayerName . push ( TmpName ) ; TmpName = TmpName . substring ( 0 , MaxNameCharLen ) ; if ( TmpName . length > 0 && TmpName . length < 20 ) { Players . push ( new PlayerObject ( Counter , TmpName , '' ) ) ; Html += '<li>' + TmpName + '</li>' ; Counter ++ ; } } } Html += '</ul>' ; if ( IsError == true ) { AddHtmlToContainer ( 'box-message' , MessageDictionnary ( 'Des joueurs ont des noms identiques. Les doublons ont ete supprimes' ) ) ; } if ( Players . length == 1 ) { SystemGameMode = 'single' ; LabelMode = MessageDictionnary ( 'Entrainement' ) ; } else { SystemGameMode = 'multi' ; LabelMode = MessageDictionnary ( 'Match' ) ; } Run ( { 'mode' : 'init' } ) ; $ ( '#header' ) . html ( MessageDictionnary ( 'Confirmation du jeu ?' ) ) ; $ ( '#body' ) . html ( Players . length + ' ' + MessageDictionnary ( 'joueur(s)' ) ) ; Html = '' ; Html = RunAndReturn ( { 'mode' : 'step2' } ) ; Html += RunAndReturn ( { 'mode' : 'choose_question' } ) ; { $ ( '#body' ) . html ( $ ( '#body' ) . html ( ) + Html ) ; } FooterMenu ( { 'mode' : 'step2' } ) ; }
Start game, phase 2:
  Save player after basic check
  Show button to continue or go back
Start game phase 2 : Save player after basic check Show button to continue or go back
//hide flag //make sure previous player(s) array is empty //to double check if players have same name //TmpName = TmpName.toUpperCase();//upper case to all name, disable by now //resize name to avoid layout to be brocken in match page //need to add shortcut key //save level that was choosen //$('#system_level').attr('value',$('#level_name').val()); //to replace by call to var directly? //SystemLevel = $('#level_name').val();//disable now as level is not choose now //and set no question active to avoid popup window to open //$('#system_active_question').attr('value',0); //we know what kind of game we play, lets init system game and run init function //show confirmation of game //+' '+MessageDictionnary('Niveau') + $('#level_name').val()+Html);//disable as level is not choose now //show additional form //this is a critical call because if SystemGameMode is not initialized, then we crash with a infinite loop  //ChooseQuestion(); //if(Html.length>0)  //show button for next step  