/*
GamesByEmail.WW2GameForm
Copyright © 2005-2010 Scott Nesin, all rights reserved.
*/
/*
   ***** Preprocessed code, any modifications will be lost. *****
     Foundation.js, object oriented JavaScript framework:
     http://FoundationDotJS.org/
     Preprocessed for speed:
     http://FoundationDotJS.org/Foundation.Preprocessor.htm
*/
GamesByEmail.WW2GameForm=function(settings)
{
   GamesByEmail.GameForm.apply(this,arguments);
};
GamesByEmail.WW2GameForm.$parentClass=GamesByEmail.GameForm;
if (!GamesByEmail.GameForm.$childClasses) GamesByEmail.GameForm.$childClasses=new Array();
GamesByEmail.GameForm.$childClasses.push(GamesByEmail.WW2GameForm);
GamesByEmail.WW2GameForm.$constructor=GamesByEmail.GameForm.$constructor ? GamesByEmail.GameForm.$constructor : function(){};
GamesByEmail.WW2GameForm.$interfaces=new Array();
GamesByEmail.WW2GameForm.$name="WW2GameForm";
GamesByEmail.WW2GameForm.$childClasses=new Array();
GamesByEmail.WW2GameForm.$container=GamesByEmail;
GamesByEmail.WW2GameForm.prototype={
   constructor:GamesByEmail.WW2GameForm,   
   createGameOptionsHtml:function(htmlBuilder)
   {
      if (!htmlBuilder)
         htmlBuilder=new Foundation.StringBuilder();
      htmlBuilder.append("<table cellspacing=0 cellpadding=0 border=0>");
      htmlBuilder.append("<tr><td>");
      htmlBuilder.append("<input type=checkbox value=\"true\" "+(this.info.b_UssrNoCombatFirstRound ? "checked" : "")+" id=\""+this.elementId("info_b_UssrNoCombatFirstRound")+"\" onclick=\""+this.event("info.b_UssrNoCombatFirstRound=this.checked;")+"\">");
      htmlBuilder.append("</td><td>");
      htmlBuilder.append("<label for=\""+this.elementId("info_b_UssrNoCombatFirstRound")+"\">");
      htmlBuilder.append(this.resource(0));
      htmlBuilder.append("</label>");
      htmlBuilder.append("</td></tr>");
      htmlBuilder.append("<tr><td>");
      htmlBuilder.append("<input type=checkbox value=\"true\" "+(this.info.b_NoAxisEconomicVictory ? "checked" : "")+" id=\""+this.elementId("info_b_NoAxisEconomicVictory")+"\" onclick=\""+this.event("info.b_NoAxisEconomicVictory=this.checked;")+"\">");
      htmlBuilder.append("</td><td>");
      htmlBuilder.append("<label for=\""+this.elementId("info_b_NoAxisEconomicVictory")+"\">");
      htmlBuilder.append(this.resource(2));
      htmlBuilder.append("</label>");
      htmlBuilder.append("</td></tr>");
      htmlBuilder.append("</table>");
      return htmlBuilder;
   },   
   onCreate:function()
   {
      if (!GamesByEmail.GameForm.prototype.onCreate.call(this))
         return false;
      switch (this.numberOfDistinctPlayers)
      {
      case 2 :
         this.setPlayer(2,this.players[0]);
         this.setPlayer(3,this.players[1]);
         this.setPlayer(4,this.players[0]);
         break;
      case 3 :
         this.setPlayer(3,this.players[1]);
         this.setPlayer(4,this.players[0]);
         break;
      case 4 :
         this.setPlayer(4,this.players[0]);
         break;
      }
      this.numPlayers=5;
      return true;
   },   
   onRequestJoinLock:function(playerIndex)
   {
      switch (this.numberOfDistinctPlayers)
      {
      case 2 :
         if (playerIndex==0)
            return [0,2,4];
         else if (playerIndex==1)
            return [1,3];
         break;
      case 3 :
         if (playerIndex==0)
            return [0,4];
         else if (playerIndex==1)
            return [1,3];
         break;
      case 4 :
         if (playerIndex==0)
            return [0,4];
         break;
      }
      return [playerIndex];
   },   
   onJoin:function(playerIndex)
   {
      var indices=new Array();
      indices[0]=playerIndex;
      switch (this.numberOfDistinctPlayers)
      {
      case 2 :
         if (playerIndex==0)
         {
            this.setPlayer(indices[1]=2,this.players[0]);
            this.setPlayer(indices[2]=4,this.players[0]);
         }
         else if (playerIndex==1)
            this.setPlayer(indices[1]=3,this.players[1]);
         break;
      case 3 :
         if (playerIndex==0)
            this.setPlayer(indices[1]=4,this.players[0]);
         else if (playerIndex==1)
            this.setPlayer(indices[1]=3,this.players[1]);
         break;
      case 4 :
         if (playerIndex==0)
            this.setPlayer(indices[1]=4,this.players[0]);
         break;
      }
      return indices;
   },   
   joinGameOptionsHtml:function(htmlBuilder)
   {
      if (!htmlBuilder)
         htmlBuilder=new Foundation.StringBuilder();
      htmlBuilder.append("<table cellspacing=0 cellpadding=0 border=0>");
      htmlBuilder.append("<tr><td>");
      htmlBuilder.append(this.resource(this.info.b_UssrNoCombatFirstRound ? 0 : 1));
      htmlBuilder.append("</td></tr>");
      htmlBuilder.append("</table>");
      return htmlBuilder;
   },   
   isPlayerShownOnJoin:function(playerIndex)
   {
      return (playerIndex<this.numberOfDistinctPlayers);
   },   
   teamTitle:function(index)
   {
      var num=this.numberOfDistinctPlayers;
      if (num<0)
         num=this.numPlayers;
      switch (num)
      {
      case 2 :
         switch (index)
         {
         case 0 : return GamesByEmail.GameForm.prototype.teamTitle.call(this,0)+"/"+GamesByEmail.GameForm.prototype.teamTitle.call(this,2)+"/"+GamesByEmail.GameForm.prototype.teamTitle.call(this,4);
         case 1 : return GamesByEmail.GameForm.prototype.teamTitle.call(this,1)+"/"+GamesByEmail.GameForm.prototype.teamTitle.call(this,3);
         }
         break;
      case 3 :
         switch (index)
         {
         case 0 : return GamesByEmail.GameForm.prototype.teamTitle.call(this,0)+"/"+GamesByEmail.GameForm.prototype.teamTitle.call(this,4);
         case 1 : return GamesByEmail.GameForm.prototype.teamTitle.call(this,1)+"/"+GamesByEmail.GameForm.prototype.teamTitle.call(this,3);
         case 2 : return GamesByEmail.GameForm.prototype.teamTitle.call(this,2);
         }
         break;
      case 4 :
         switch (index)
         {
         case 0 : return GamesByEmail.GameForm.prototype.teamTitle.call(this,0)+"/"+GamesByEmail.GameForm.prototype.teamTitle.call(this,4);
         case 1 : return GamesByEmail.GameForm.prototype.teamTitle.call(this,1);
         case 2 : return GamesByEmail.GameForm.prototype.teamTitle.call(this,2);
         case 3 : return GamesByEmail.GameForm.prototype.teamTitle.call(this,3);
         }
         break;
      }
      return GamesByEmail.GameForm.prototype.teamTitle.call(this,index);
   },
   dispose:function()
   {
      if (GamesByEmail.GameForm.prototype.dispose) GamesByEmail.GameForm.prototype.dispose.call(this);
   },
   server:GamesByEmail.GameForm.prototype.server,
   serverSerialized:GamesByEmail.GameForm.prototype.serverSerialized,
   serverSynchronous:GamesByEmail.GameForm.prototype.serverSynchronous,
   resource:GamesByEmail.GameForm.prototype.resource,
   event:GamesByEmail.GameForm.prototype.event,
   elementId:GamesByEmail.GameForm.prototype.elementId,
   getElement:GamesByEmail.GameForm.prototype.getElement,
   getElementValue:GamesByEmail.GameForm.prototype.getElementValue,
   parseElementId:GamesByEmail.GameForm.prototype.parseElementId,
   attachEvent:GamesByEmail.GameForm.prototype.attachEvent,
   detachEvent:GamesByEmail.GameForm.prototype.detachEvent,
   createPlayer:GamesByEmail.GameForm.prototype.createPlayer,
   requestSessionInfo:GamesByEmail.GameForm.prototype.requestSessionInfo,
   importSettings:GamesByEmail.GameForm.prototype.importSettings,
   setStartAnotherGamePlayers:GamesByEmail.GameForm.prototype.setStartAnotherGamePlayers,
   getHtml:GamesByEmail.GameForm.prototype.getHtml,
   createGameHtml:GamesByEmail.GameForm.prototype.createGameHtml,
   getDefaultTitle:GamesByEmail.GameForm.prototype.getDefaultTitle,
   onGameTypeChange:GamesByEmail.GameForm.prototype.onGameTypeChange,
   updateEmailStyle:GamesByEmail.GameForm.prototype.updateEmailStyle,
   focusOnPlayer:GamesByEmail.GameForm.prototype.focusOnPlayer,
   setPlayer:GamesByEmail.GameForm.prototype.setPlayer,
   recordMe:GamesByEmail.GameForm.prototype.recordMe,
   recordFriend:GamesByEmail.GameForm.prototype.recordFriend,
   recordAll:GamesByEmail.GameForm.prototype.recordAll,
   numPlayersOnChange:GamesByEmail.GameForm.prototype.numPlayersOnChange,
   createGamePlayersHtml:GamesByEmail.GameForm.prototype.createGamePlayersHtml,
   createGamePlayerHtml:GamesByEmail.GameForm.prototype.createGamePlayerHtml,
   createGamePlayButtonHtml:GamesByEmail.GameForm.prototype.createGamePlayButtonHtml,
   playThisTeam:GamesByEmail.GameForm.prototype.playThisTeam,
   getOurEmail:GamesByEmail.GameForm.prototype.getOurEmail,
   onMicroLoginShow:GamesByEmail.GameForm.prototype.onMicroLoginShow,
   attachHelpers:GamesByEmail.GameForm.prototype.attachHelpers,
   inviteSomeone:GamesByEmail.GameForm.prototype.inviteSomeone,
   attemptLogin:GamesByEmail.GameForm.prototype.attemptLogin,
   handleBuddyResponse:GamesByEmail.GameForm.prototype.handleBuddyResponse,
   openInvitation:GamesByEmail.GameForm.prototype.openInvitation,
   playerModeBack:GamesByEmail.GameForm.prototype.playerModeBack,
   requestGame:GamesByEmail.GameForm.prototype.requestGame,
   gleanGame:GamesByEmail.GameForm.prototype.gleanGame,
   handleRequestGameResponse:GamesByEmail.GameForm.prototype.handleRequestGameResponse,
   jsSerialize:GamesByEmail.GameForm.prototype.jsSerialize,
   play:GamesByEmail.GameForm.prototype.play,
   sendPlay:GamesByEmail.GameForm.prototype.sendPlay,
   updateJoinForm:GamesByEmail.GameForm.prototype.updateJoinForm,
   updatePlayerCreate:GamesByEmail.GameForm.prototype.updatePlayerCreate,
   updatePlayerJoin:GamesByEmail.GameForm.prototype.updatePlayerJoin,
   onCreateSuccess:GamesByEmail.GameForm.prototype.onCreateSuccess,
   catchResponseError:GamesByEmail.GameForm.prototype.catchResponseError,
   responseErrorReported:GamesByEmail.GameForm.prototype.responseErrorReported,
   handlePlayResponse:GamesByEmail.GameForm.prototype.handlePlayResponse,
   getPlayUrl:GamesByEmail.GameForm.prototype.getPlayUrl,
   setShowGameControl:GamesByEmail.GameForm.prototype.setShowGameControl,
   showGame:GamesByEmail.GameForm.prototype.showGame,
   joinGameHtml:GamesByEmail.GameForm.prototype.joinGameHtml,
   startNewGame:GamesByEmail.GameForm.prototype.startNewGame,
   joinGamePlayersHtml:GamesByEmail.GameForm.prototype.joinGamePlayersHtml,
   joinGamePlayerHtml:GamesByEmail.GameForm.prototype.joinGamePlayerHtml,
   positionsAvailableToJoin:GamesByEmail.GameForm.prototype.positionsAvailableToJoin,
   joinThisGame:GamesByEmail.GameForm.prototype.joinThisGame,
   onJoinLockSuccess:GamesByEmail.GameForm.prototype.onJoinLockSuccess,
   handleJoinResponse:GamesByEmail.GameForm.prototype.handleJoinResponse,
   onCancelJoin:GamesByEmail.GameForm.prototype.onCancelJoin,
   cancelJoin:GamesByEmail.GameForm.prototype.cancelJoin,
   joinGame:GamesByEmail.GameForm.prototype.joinGame,
   onJoinSuccess:GamesByEmail.GameForm.prototype.onJoinSuccess,
   handleJoinedResponse:GamesByEmail.GameForm.prototype.handleJoinedResponse,
   recommendThisGame:GamesByEmail.GameForm.prototype.recommendThisGame,
   recommendingGame:GamesByEmail.GameForm.prototype.recommendingGame,
   cancelRecommend:GamesByEmail.GameForm.prototype.cancelRecommend,
   handleRecommendResponse:GamesByEmail.GameForm.prototype.handleRecommendResponse,
   gameBoardUrl:GamesByEmail.GameForm.prototype.gameBoardUrl
};
GamesByEmail.WW2GameForm.defaultSettings={
      gameTypes:[33],
      allowedNumPlayers:[2,3,4,5],
      info:{b_UssrNoCombatFirstRound:false,
            b_NoAxisEconomicVictory:false}
   };
GamesByEmail.WW2GameForm.resourcePack={
      language:"English",
      gameTitles:{},
      gameDescriptions:{},
      teamTitles:["U.S.S.R.","Germany","United Kingdom","Japan","United States"],
      "0":"No combat moves for U.S.S.R. first round.",
      "1":"U.S.S.R. can make combat moves first round.",
      "2":"No economic victory allowed for the Axis.",
      "3":"Economic victory allowed for the Axis."
      
   }
;
GamesByEmail.WW2GameForm.getTypePath=GamesByEmail.GameForm.getTypePath;
GamesByEmail.WW2GameForm.resource=GamesByEmail.GameForm.resource;
GamesByEmail.WW2GameForm.getById=GamesByEmail.GameForm.getById;
GamesByEmail.WW2GameForm.getFirst=GamesByEmail.GameForm.getFirst;
GamesByEmail.WW2GameForm.getNext=GamesByEmail.GameForm.getNext;
GamesByEmail.WW2GameForm.isInstanceOf=GamesByEmail.GameForm.isInstanceOf;
GamesByEmail.WW2GameForm.changeDomain=GamesByEmail.GameForm.changeDomain;
GamesByEmail.WW2GameForm.importDefaultSettings=GamesByEmail.GameForm.importDefaultSettings;
GamesByEmail.WW2GameForm.isEmailAddressFormatValid=GamesByEmail.GameForm.isEmailAddressFormatValid;
GamesByEmail.WW2GameForm.handleBuddyResponse=GamesByEmail.GameForm.handleBuddyResponse;
GamesByEmail.WW2GameForm.isForGameType=GamesByEmail.GameForm.isForGameType;
GamesByEmail.WW2GameForm.findClassForGameType=GamesByEmail.GameForm.findClassForGameType;
GamesByEmail.WW2GameForm.createGameForm=GamesByEmail.GameForm.createGameForm;
GamesByEmail.WW2GameForm.addCreateGameFormToPage=GamesByEmail.GameForm.addCreateGameFormToPage;
GamesByEmail.WW2GameForm.writeJoinGameFormToPage=GamesByEmail.GameForm.writeJoinGameFormToPage;
GamesByEmail.WW2GameForm.$constructor();


GamesByEmail.WW2GameForm.resourcePack.gameTitles[33]="W.W.II";
GamesByEmail.WW2GameForm.resourcePack.gameDescriptions[33]="A clone of Hasbro's Axis & Allies.";

