/*
GamesByEmail.GambitGameForm
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.GambitGameForm=function(settings)
{
   GamesByEmail.GameForm.apply(this,arguments);
};
GamesByEmail.GambitGameForm.$parentClass=GamesByEmail.GameForm;
if (!GamesByEmail.GameForm.$childClasses) GamesByEmail.GameForm.$childClasses=new Array();
GamesByEmail.GameForm.$childClasses.push(GamesByEmail.GambitGameForm);
GamesByEmail.GambitGameForm.$constructor=GamesByEmail.GameForm.$constructor ? GamesByEmail.GameForm.$constructor : function(){};
GamesByEmail.GambitGameForm.$interfaces=new Array();
GamesByEmail.GambitGameForm.$name="GambitGameForm";
GamesByEmail.GambitGameForm.$childClasses=new Array();
GamesByEmail.GambitGameForm.$container=GamesByEmail;
GamesByEmail.GambitGameForm.prototype={
   constructor:GamesByEmail.GambitGameForm,   
   peekRowDisplay:function()
   {
      return (this.gameType==16 ? "none" : "");
   },   
   onGameTypeChange:function(gameType)
   {
      GamesByEmail.GameForm.prototype.onGameTypeChange.call(this,gameType);
      this.getElement("info_PeekRow").style.display=this.peekRowDisplay();
   },   
   setTradeType:function(tradeType)
   {
      this.getElement("info_"+tradeType).click();
      this.info.i_tradeInCap=parseInt(this.getElement("info_i_tradeInCap").value);
      this.info.i_artillery=parseInt(this.getElement("info_i_artillery").value);
      this.info.i_infantry=parseInt(this.getElement("info_i_infantry").value);
      this.info.i_cavalry=parseInt(this.getElement("info_i_cavalry").value);
      this.info.i_each=parseInt(this.getElement("info_i_each").value);
   },   
   createGameOptionsHtml:function(htmlBuilder)
   {
      if (!htmlBuilder)
         htmlBuilder=new Foundation.StringBuilder();
      htmlBuilder.append("<table>");
      htmlBuilder.append("<tr id=\""+this.elementId("info_PeekRow")+"\" style=\"display:"+this.peekRowDisplay()+"\">");
      htmlBuilder.append("<td nowrap valign=top align=right style=\"padding-top:5px\"><b>Peeking:</b></td>");
      htmlBuilder.append("<td valign=top><input type=checkbox id=\""+this.elementId("info_b_xPeek")+"\" "+(this.info.b_xPeek ? "checked" : "")+" onclick=\""+this.event("info.b_xPeek=this.checked;")+"\"></td>");
      htmlBuilder.append("<td valign=top style=\"padding-top:5px\"><label for=\""+this.elementId("info_b_xPeek")+"\">Allow eliminated players to see full board before game ends.</label></td>");
      htmlBuilder.append("</tr>");
      htmlBuilder.append("<tr>");
      htmlBuilder.append("<td rowspan=2 nowrap valign=top align=right style=\"padding-top:5px\"><b>Board Setup:</b></td>");
      htmlBuilder.append("<td valign=top><input type=radio align=absmiddle name=\""+this.elementId("info_startType")+"\" value=\"territories\" id=\""+this.elementId("info_territories")+"\" "+(this.info.startType=='territories' ? "checked" : "")+" onclick=\""+this.event("info.startType=this.value;")+"\"></td>");
      htmlBuilder.append("<td valign=top style=\"padding-top:5px\"><label for=\""+this.elementId("info_territories")+"\">Randomly assigned territories, players distribute all armies on their first turn.</label></td>");
      htmlBuilder.append("</tr>");
      htmlBuilder.append("<tr>");
      htmlBuilder.append("<td valign=top><input type=radio align=absmiddle name=\""+this.elementId("info_startType")+"\" value=\"territoriesArmies\" id=\""+this.elementId("info_territoriesArmies")+"\" "+(this.info.startType=='territoriesArmies' ? "checked" : "")+" onclick=\""+this.event("info.startType=this.value;")+"\"></td>");
      htmlBuilder.append("<td valign=top style=\"padding-top:5px\"><label for=\""+this.elementId("info_territoriesArmies")+"\">Randomly assigned territories and randomly distributed armies.</label></td>");
      htmlBuilder.append("</tr>");
      htmlBuilder.append("<tr>");
      htmlBuilder.append("<td nowrap valign=top align=right style=\"padding-top:5px\"><b>Air Strikes:</b></td>");
      htmlBuilder.append("<td valign=top><input type=checkbox id=\""+this.elementId("info_b_airstrikes")+"\" "+(this.info.b_airstrikes ? "checked" : "")+" onclick=\""+this.event("info.b_airstrikes=this.checked;")+"\"></td>");
      htmlBuilder.append("<td valign=top style=\"padding-top:5px\"><label for=\""+this.elementId("info_b_airstrikes")+"\">A player can attack a territory whose card they hold from another territory whose card they hold even if those territories are not adjacent.</label></td>");
      htmlBuilder.append("</tr>");
      htmlBuilder.append("<tr>");
      htmlBuilder.append("<td rowspan=3 nowrap valign=top align=right style=\"padding-top:5px\"><b>Card Trade&nbsp;<br>In Value:</b></td>");
      htmlBuilder.append("<td valign=top><input type=radio align=absmiddle name=\""+this.elementId("info_tradeIn")+"\" value=\"uncapped\" id=\""+this.elementId("info_uncapped")+"\" "+(this.info.tradeIn=='uncapped' ? "checked" : "")+" onclick=\""+this.event("info.tradeIn=this.value;")+"\"></td>");
      htmlBuilder.append("<td valign=top style=\"padding-top:5px\"><label for=\""+this.elementId("info_uncapped")+"\">Regular trade increments, no maximum value.</label></td>");
      htmlBuilder.append("</tr>");
      htmlBuilder.append("<tr>");
      htmlBuilder.append("<td valign=top style=\"padding-top:4px\"><input type=radio align=absmiddle name=\""+this.elementId("info_tradeIn")+"\" value=\"capped\" id=\""+this.elementId("info_capped")+"\" "+(this.info.tradeIn=='capped' ? "checked" : "")+" onclick=\""+this.event("info.tradeIn=this.value;")+"\"></td>");
      htmlBuilder.append("<td valign=top><label for=\""+this.elementId("info_capped")+"\">Regular trade increments, maximum value of </label><input type=text align=absmiddle id=\""+this.elementId("info_i_tradeInCap")+"\" value=\""+this.info.i_tradeInCap+"\" size=2 onclick=\"this.onchange(event);\" onchange=\""+this.event("setTradeType('capped');")+"\"><label for=\""+this.elementId("info_capped")+"\"> armies.</label></td>");
      htmlBuilder.append("</tr>");
      htmlBuilder.append("<tr>");
      htmlBuilder.append("<td valign=top style=\"padding-top:4px\"><input type=radio align=absmiddle name=\""+this.elementId("info_tradeIn")+"\" value=\"fixed\" id=\""+this.elementId("info_fixed")+"\" "+(this.info.tradeIn=='fixed' ? "checked" : "")+" onclick=\""+this.event("info.tradeIn=this.value;")+"\"></td>");
      htmlBuilder.append("<td valign=top><label for=\""+this.elementId("info_fixed")+"\">Fixed trade values: </label><input type=text align=absmiddle id=\""+this.elementId("info_i_artillery")+"\" value=\""+this.info.i_artillery+"\" size=2 onclick=\"this.onchange(event);\" onchange=\""+this.event("setTradeType('fixed');")+"\"><label for=\""+this.elementId("info_fixed")+"\"> armies for three artillery, </label><input type=text align=absmiddle id=\""+this.elementId("info_i_infantry")+"\" value=\""+this.info.i_infantry+"\" size=2 onclick=\"this.onchange(event);\" onchange=\""+this.event("setTradeType('fixed');")+"\"><label for=\""+this.elementId("info_fixed")+"\"> armies for three infantry, </label><input type=text align=absmiddle id=\""+this.elementId("info_i_cavalry")+"\" value=\""+this.info.i_cavalry+"\" size=2 onclick=\"this.onchange(event);\" onchange=\""+this.event("setTradeType('fixed');")+"\"><label for=\""+this.elementId("info_fixed")+"\"> armies for three cavalry, and </label><input type=text align=absmiddle id=\""+this.elementId("info_i_each")+"\" value=\""+this.info.i_each+"\" size=2 onclick=\"this.onchange(event);\" onchange=\""+this.event("setTradeType('fixed');")+"\"><label for=\""+this.elementId("info_fixed")+"\"> armies for one of each.</label></td>");
      htmlBuilder.append("</tr>");
      if (!this.isStartNewGame)
      {
         htmlBuilder.append("<tr>");
         htmlBuilder.append("<td valign=top style=\"padding-top:4px\" colspan=3>Be sure to check out <a target=\"_blank\" href=\"/Games/Gambit/BattleOdds\">GameByEmail.com's Gambit Battle Odds Calculator</a>.</td>");
         htmlBuilder.append("</tr>");
      }
      htmlBuilder.append("</table>");
      return htmlBuilder;
   },   
   joinGameOptionsHtml:function(htmlBuilder)
   {
      if (!htmlBuilder)
         htmlBuilder=new Foundation.StringBuilder();
      htmlBuilder.append("<table cellspacing=0 cellpadding=0 border=0>");
      if (this.gameType!=16 && this.info.b_xPeek)
         htmlBuilder.append("<tr><td>Peeking by eliminated players allowed.</td></tr>");
      if (this.info.startType=="territories")
         htmlBuilder.append("<tr><td>Random territories, players distribute armies.</td></tr>");
      if (this.info.startType=="territoriesArmies")
         htmlBuilder.append("<tr><td>Random territories and armies.</td></tr>");
      if (this.info.b_airstrikes)
         htmlBuilder.append("<tr><td>Airstrikes enabled.</td></tr>");
      if (this.info.tradeIn=="uncaped")
         htmlBuilder.append("<tr><td>Regular trade increments.</td></tr>");
      if (this.info.tradeIn=="capped")
         htmlBuilder.append("<tr><td>Regular trade increments, capped at "+this.info.i_tradeInCap+".</td></tr>");
      if (this.info.tradeIn=="fixed")
         htmlBuilder.append("<tr><td>Fixed trade values: three artillary:"+this.info.i_artillery+", three infantry:"+this.info.i_infantry+", three cavalry:"+this.info.i_cavalry+", one of each:"+this.info.i_each+".</td></tr>");
      htmlBuilder.append("</table>");
      return htmlBuilder;
   },
   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,
   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,
   teamTitle:GamesByEmail.GameForm.prototype.teamTitle,
   requestGame:GamesByEmail.GameForm.prototype.requestGame,
   gleanGame:GamesByEmail.GameForm.prototype.gleanGame,
   handleRequestGameResponse:GamesByEmail.GameForm.prototype.handleRequestGameResponse,
   jsSerialize:GamesByEmail.GameForm.prototype.jsSerialize,
   onCreate:GamesByEmail.GameForm.prototype.onCreate,
   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,
   isPlayerShownOnJoin:GamesByEmail.GameForm.prototype.isPlayerShownOnJoin,
   joinGamePlayersHtml:GamesByEmail.GameForm.prototype.joinGamePlayersHtml,
   joinGamePlayerHtml:GamesByEmail.GameForm.prototype.joinGamePlayerHtml,
   positionsAvailableToJoin:GamesByEmail.GameForm.prototype.positionsAvailableToJoin,
   onRequestJoinLock:GamesByEmail.GameForm.prototype.onRequestJoinLock,
   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,
   onJoin:GamesByEmail.GameForm.prototype.onJoin,
   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.GambitGameForm.defaultSettings={
      gameTypes:[16,17,18,19],
      allowedNumPlayers:[2,3,4,5,6],
      info:{
         b_xPeek:false, // false,true
         startType:"territories", // "territories","territoriesArmies"
         b_airstrikes:false, // false,true
         tradeIn:"uncapped",// "uncapped","capped","fixed"
         i_tradeInCap:30,
         i_artillery:4,
         i_infantry:6,
         i_cavalry:8,
         i_each:10
      }
   };
GamesByEmail.GambitGameForm.resourcePack={
      language:"English",
      gameTitles:{},
      gameDescriptions:{},
      teamTitles:["Red","Yellow","Green","Cyan","Blue","Magenta"]
   }
;
GamesByEmail.GambitGameForm.getTypePath=GamesByEmail.GameForm.getTypePath;
GamesByEmail.GambitGameForm.resource=GamesByEmail.GameForm.resource;
GamesByEmail.GambitGameForm.getById=GamesByEmail.GameForm.getById;
GamesByEmail.GambitGameForm.getFirst=GamesByEmail.GameForm.getFirst;
GamesByEmail.GambitGameForm.getNext=GamesByEmail.GameForm.getNext;
GamesByEmail.GambitGameForm.isInstanceOf=GamesByEmail.GameForm.isInstanceOf;
GamesByEmail.GambitGameForm.changeDomain=GamesByEmail.GameForm.changeDomain;
GamesByEmail.GambitGameForm.importDefaultSettings=GamesByEmail.GameForm.importDefaultSettings;
GamesByEmail.GambitGameForm.isEmailAddressFormatValid=GamesByEmail.GameForm.isEmailAddressFormatValid;
GamesByEmail.GambitGameForm.handleBuddyResponse=GamesByEmail.GameForm.handleBuddyResponse;
GamesByEmail.GambitGameForm.isForGameType=GamesByEmail.GameForm.isForGameType;
GamesByEmail.GambitGameForm.findClassForGameType=GamesByEmail.GameForm.findClassForGameType;
GamesByEmail.GambitGameForm.createGameForm=GamesByEmail.GameForm.createGameForm;
GamesByEmail.GambitGameForm.addCreateGameFormToPage=GamesByEmail.GameForm.addCreateGameFormToPage;
GamesByEmail.GambitGameForm.writeJoinGameFormToPage=GamesByEmail.GameForm.writeJoinGameFormToPage;
GamesByEmail.GambitGameForm.$constructor();


GamesByEmail.GambitGameForm.resourcePack.gameTitles[16]="Gambit";
GamesByEmail.GambitGameForm.resourcePack.gameDescriptions[16]="A clone of Hasbro's RISK.";

GamesByEmail.GambitGameForm.resourcePack.gameTitles[17]="Dark Gambit";
GamesByEmail.GambitGameForm.resourcePack.gameDescriptions[17]="You can only see the color and strength of armies in territories bordering your own.";

GamesByEmail.GambitGameForm.resourcePack.gameTitles[18]="Blind Gambit";
GamesByEmail.GambitGameForm.resourcePack.gameDescriptions[18]="You can only tell which armies are yours, you cannot distinguish between your opponent's armies. You can see the strength of all armies.";

GamesByEmail.GambitGameForm.resourcePack.gameTitles[19]="Spy Gambit";
GamesByEmail.GambitGameForm.resourcePack.gameDescriptions[19]="You can only tell which armies are yours, you cannot see the color or size of other armies. You can \"spy\" on opponents to see which territories they occupy.";
