/*
GamesByEmail.PoliticsGameForm
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.PoliticsGameForm=function(settings)
{
   GamesByEmail.GameForm.apply(this,arguments);
};
GamesByEmail.PoliticsGameForm.$parentClass=GamesByEmail.GameForm;
if (!GamesByEmail.GameForm.$childClasses) GamesByEmail.GameForm.$childClasses=new Array();
GamesByEmail.GameForm.$childClasses.push(GamesByEmail.PoliticsGameForm);
GamesByEmail.PoliticsGameForm.$constructor=GamesByEmail.GameForm.$constructor ? GamesByEmail.GameForm.$constructor : function(){};
GamesByEmail.PoliticsGameForm.$interfaces=new Array();
GamesByEmail.PoliticsGameForm.$name="PoliticsGameForm";
GamesByEmail.PoliticsGameForm.$childClasses=new Array();
GamesByEmail.PoliticsGameForm.$container=GamesByEmail;
GamesByEmail.PoliticsGameForm.prototype={
   constructor:GamesByEmail.PoliticsGameForm,   
   createGameOptionsHtml:function(htmlBuilder)
   {
      if (!htmlBuilder)
         htmlBuilder=new Foundation.StringBuilder();
      htmlBuilder.append("<table cellspacing=0 cellpadding=0 border=0>");
      htmlBuilder.append("<tr><td>");
      htmlBuilder.append("<label for=\""+this.elementId("Info_i_orderTimeLimit")+"\">");
      htmlBuilder.append(this.resource(0));
      htmlBuilder.append("</label>");
      htmlBuilder.append("</td><td>");
      htmlBuilder.append("<select id=\""+this.elementId("info_i_orderTimeLimit")+"\" value=\""+this.info.i_orderTimeLimit+"\" onchange=\""+this.event("info.i_orderTimeLimit=this.value;")+"\">");
      for (var i=0;i<this.allowedTimeLimits.length;i++)
         htmlBuilder.append("<option value=\""+this.allowedTimeLimits[i]+"\" "+(this.info.i_orderTimeLimit==this.allowedTimeLimits[i] ? "selected" : "")+">"+this.resource("tl_"+this.allowedTimeLimits[i])+"</option>");
      htmlBuilder.append("</select>");
      htmlBuilder.append("</td></tr>");
      htmlBuilder.append("</table>");
      return htmlBuilder;
   },   
   joinGameOptionsHtml:function(htmlBuilder)
   {
      if (!htmlBuilder)
         htmlBuilder=new Foundation.StringBuilder();
      htmlBuilder.append("<table cellspacing=0 cellpadding=0 border=0>");
      htmlBuilder.append("<tr><td>");
      if (this.info.i_orderTimeLimit==0)
         htmlBuilder.append(this.resource(2));
      else
         htmlBuilder.append(this.resource(1,'t',this.resource("tl_"+this.info.i_orderTimeLimit)));
      htmlBuilder.append("</td></tr>");
      htmlBuilder.append("</table>");
      return htmlBuilder;
   },   
   onCreate:function()
   {
      if (!GamesByEmail.GameForm.prototype.onCreate.call(this))
         return false;
      switch (this.numberOfDistinctPlayers)
      {
      case 3 :
         this.setPlayer(3,this.players[0]);
         this.setPlayer(4,this.players[0]);
         this.setPlayer(5,this.players[1]);
         this.setPlayer(6,this.players[2]);
         this.numPlayers=7;
         break;
      case 4 :
         this.setPlayer(4,this.players[0]);
         this.setPlayer(5,this.players[1]);
         this.setPlayer(6,this.players[3]);
         this.numPlayers=7;
         break;
      }
      return true;
   },   
   onRequestJoinLock:function(playerIndex)
   {
      switch (this.numberOfDistinctPlayers)
      {
      case 3 :
         if (playerIndex==0)
            return [0,3,4];
         else if (playerIndex==1)
            return [1,5];
         else if (playerIndex==2)
            return [2,6];
         break;
      case 4 :
         if (playerIndex==0)
            return [0,4];
         else if (playerIndex==1)
            return [1,5];
         else if (playerIndex==2)
            return [2];
         else if (playerIndex==3)
            return [3,6];
         break;
      }
      return [playerIndex];
   },   
   onJoin:function(playerIndex)
   {
      var indices=new Array();
      indices[0]=playerIndex;
      switch (this.numberOfDistinctPlayers)
      {
      case 3 :
         if (playerIndex==0)
         {
            this.setPlayer(indices[1]=3,this.players[0]);
            this.setPlayer(indices[2]=4,this.players[0]);
         }
         else if (playerIndex==1)
            this.setPlayer(indices[1]=5,this.players[1]);
         else if (playerIndex==2)
            this.setPlayer(indices[1]=6,this.players[2]);
         break;
      case 4 :
         if (playerIndex==0)
            this.setPlayer(indices[1]=4,this.players[0]);
         else if (playerIndex==1)
            this.setPlayer(indices[1]=5,this.players[1]);
         else if (playerIndex==3)
            this.setPlayer(indices[1]=6,this.players[3]);
         break;
      }
      return indices;
   },   
   isPlayerShownOnJoin:function(playerIndex)
   {
      return (playerIndex<this.numberOfDistinctPlayers);
   },   
   teamTitle:function(index)
   {
      var num=this.numberOfDistinctPlayers;
      if (num<0)
         num=this.numPlayers;
      switch (num)
      {
      case 3 :
         switch (index)
         {
         case 0 : return GamesByEmail.GameForm.prototype.teamTitle.call(this,3)+"/"+GamesByEmail.GameForm.prototype.teamTitle.call(this,4)+"/"+GamesByEmail.GameForm.prototype.teamTitle.call(this,0);
         case 1 : return GamesByEmail.GameForm.prototype.teamTitle.call(this,5)+"/"+GamesByEmail.GameForm.prototype.teamTitle.call(this,1);
         case 2 : return GamesByEmail.GameForm.prototype.teamTitle.call(this,2)+"/"+GamesByEmail.GameForm.prototype.teamTitle.call(this,6);
         }
         break;
      case 4 :
         switch (index)
         {
         case 0 : return GamesByEmail.GameForm.prototype.teamTitle.call(this,0)+"/"+GamesByEmail.GameForm.prototype.teamTitle.call(this,2);
         case 1 : return GamesByEmail.GameForm.prototype.teamTitle.call(this,1)+"/"+GamesByEmail.GameForm.prototype.teamTitle.call(this,5);
         case 2 : return GamesByEmail.GameForm.prototype.teamTitle.call(this,3);
         case 3 : return GamesByEmail.GameForm.prototype.teamTitle.call(this,4)+"/"+GamesByEmail.GameForm.prototype.teamTitle.call(this,6);
         }
         break;
      case 5 :
         if (index>=3)
            index++;
      case 6 :
         if (index>=1)
            index++;
         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.PoliticsGameForm.defaultSettings={
      gameTypes:[32],
      allowedNumPlayers:[7,6,5,4,3],
      info:{i_orderTimeLimit:10080},
      allowedTimeLimits:[0,129600,43200,10080,8640,7200,5760,4320,2880,1440,720,360,240,120,60,30,10,5,2]
   };
GamesByEmail.PoliticsGameForm.resourcePack={
      language:"English",
      gameTitles:{},
      gameDescriptions:{},
      teamTitles:["Austria-Hungary","Italy","France","England","Germany","Russia","Turkey"],
      "0":"Orders can be forced in:&nbsp;",
      "1":"Orders can be forced in <b>%t</b>",
      "2":"No time limit on orders",
      "tl_0":"Never",
      "tl_129600":"90 Days",
      "tl_43200":"30 Days",
      "tl_10080":"7 Days",
      "tl_8640":"6 Days",
      "tl_7200":"5 Days",
      "tl_5760":"4 Days",
      "tl_4320":"3 Days",
      "tl_2880":"2 Days",
      "tl_1440":"1 Day",
      "tl_720":"12 Hours",
      "tl_360":"6 Hours",
      "tl_240":"4 Hours",
      "tl_120":"2 Hours",
      "tl_60":"1 Hour",
      "tl_30":"30 Minutes",
      "tl_10":"10 Minutes",
      "tl_5":"5 Minutes",
      "tl_2":"2 Minutes"
   }
;
GamesByEmail.PoliticsGameForm.getTypePath=GamesByEmail.GameForm.getTypePath;
GamesByEmail.PoliticsGameForm.resource=GamesByEmail.GameForm.resource;
GamesByEmail.PoliticsGameForm.getById=GamesByEmail.GameForm.getById;
GamesByEmail.PoliticsGameForm.getFirst=GamesByEmail.GameForm.getFirst;
GamesByEmail.PoliticsGameForm.getNext=GamesByEmail.GameForm.getNext;
GamesByEmail.PoliticsGameForm.isInstanceOf=GamesByEmail.GameForm.isInstanceOf;
GamesByEmail.PoliticsGameForm.changeDomain=GamesByEmail.GameForm.changeDomain;
GamesByEmail.PoliticsGameForm.importDefaultSettings=GamesByEmail.GameForm.importDefaultSettings;
GamesByEmail.PoliticsGameForm.isEmailAddressFormatValid=GamesByEmail.GameForm.isEmailAddressFormatValid;
GamesByEmail.PoliticsGameForm.handleBuddyResponse=GamesByEmail.GameForm.handleBuddyResponse;
GamesByEmail.PoliticsGameForm.isForGameType=GamesByEmail.GameForm.isForGameType;
GamesByEmail.PoliticsGameForm.findClassForGameType=GamesByEmail.GameForm.findClassForGameType;
GamesByEmail.PoliticsGameForm.createGameForm=GamesByEmail.GameForm.createGameForm;
GamesByEmail.PoliticsGameForm.addCreateGameFormToPage=GamesByEmail.GameForm.addCreateGameFormToPage;
GamesByEmail.PoliticsGameForm.writeJoinGameFormToPage=GamesByEmail.GameForm.writeJoinGameFormToPage;
GamesByEmail.PoliticsGameForm.$constructor();


GamesByEmail.PoliticsGameForm.resourcePack.gameTitles[32]="Politics";
GamesByEmail.PoliticsGameForm.resourcePack.gameDescriptions[32]="A clone of Hasbro's Diplomacy.";
