/*
GamesByEmail.ReflektitGameForm
Copyright © 2008 Sean Hunt, 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.ReflektitGameForm=function(settings)
{
   GamesByEmail.GameForm.apply(this,arguments);
};
GamesByEmail.ReflektitGameForm.$parentClass=GamesByEmail.GameForm;
if (!GamesByEmail.GameForm.$childClasses) GamesByEmail.GameForm.$childClasses=new Array();
GamesByEmail.GameForm.$childClasses.push(GamesByEmail.ReflektitGameForm);
GamesByEmail.ReflektitGameForm.$constructor=GamesByEmail.GameForm.$constructor ? GamesByEmail.GameForm.$constructor : function(){};
GamesByEmail.ReflektitGameForm.$interfaces=new Array();
GamesByEmail.ReflektitGameForm.$name="ReflektitGameForm";
GamesByEmail.ReflektitGameForm.$childClasses=new Array();
GamesByEmail.ReflektitGameForm.$container=GamesByEmail;
GamesByEmail.ReflektitGameForm.prototype={
   constructor:GamesByEmail.ReflektitGameForm,   
   onBoardSetupChange:function(index)
  {
    var setup=this.resource("setups")[index];
    this.info.board=setup.board;
    this.getElement("boardDisplay").src=this.gameBoardUrl(setup.image);
  },   
   createGameOptionsHtml:function(htmlBuilder)
  {
    if (!htmlBuilder)
      htmlBuilder=new Foundation.StringBuilder();
    htmlBuilder.append("<table>");
    htmlBuilder.append("<tr><td valign=top>");
    htmlBuilder.append("<table>");
    htmlBuilder.append("<tr>");
    htmlBuilder.append("<td colspan=2 nowrap align=left style=\"padding-top:5px\"><b>"+this.resource(0)+"</b></td>");
    htmlBuilder.append("<tr>");
    var setups=this.resource("setups");
    var image="";
    for (var i=0;i<setups.length;i++)
    {
      var setup=setups[i];
      if (this.info.board==setup.board)
        image=setup.image;
      htmlBuilder.append("<tr>");
      htmlBuilder.append("<td valign=top><input type=radio align=absmiddle name=\""+this.elementId("info_board")+"\" value=\""+i+"\" id=\""+this.elementId("info_board_"+i)+"\" "+(this.info.board==setup.board ? "checked" : "")+" onclick=\""+this.event("onBoardSetupChange("+i+");")+"\"></td>");
      htmlBuilder.append("<td valign=top style=\"padding-top:5px\"><label for=\""+this.elementId("info_board_"+i)+"\">"+setup.description.htmlEncode()+"</label></td>");
      htmlBuilder.append("</tr>");
    }
    htmlBuilder.append("</table>");
    htmlBuilder.append("</td><td valign=top>");
    htmlBuilder.append("<img id=\""+this.elementId("boardDisplay")+"\" src=\""+this.gameBoardUrl(image)+"\" width=\"107\" height=\"129\">");
    htmlBuilder.append("</td></tr>");
    htmlBuilder.append("</table>");
    return htmlBuilder;
  },   
   joinGameOptionsHtml:function(htmlBuilder)
  {
     if (!htmlBuilder)
        htmlBuilder=new Foundation.StringBuilder();
     var setups=this.resource("setups");
     for (var i=0;i<setups.length;i++)
        if (this.info.board==setups[i].board)
           htmlBuilder.append(this.resource(1
                                            ,'d',setups[i].description.htmlEncode()
                                            ,'b',"<img id=\""+this.elementId("boardDisplay")+"\" src=\""+this.gameBoardUrl(setups[i].image)+"\" width=\"107\" height=\"129\" align=absmiddle>"
                                           ));
     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,
   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,
   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.ReflektitGameForm.defaultSettings={
    gameTypes:[25],
    allowedNumPlayers:[2],
    info:{
      description:"Classic",
      board:
        "   ne   " + // Bottom row
        "        " +
        " s SW  W" +
        "  W    T" +
        "t  lR  G" +
        "g  rL  T" +
        "t    e  " +
        "e  en N " +
        "        " +
        "   WS   " , // Classic
      image:"Setups/Classic.gif"
    }
  };
GamesByEmail.ReflektitGameForm.resourcePack={
    language:"English",
    gameFolder:"Reflektit",
    gameTitles:{},
    gameDescriptions:{},
    teamTitles:["Silver","Red"],
    authorName:"Sean Hunt",
    0:"Board Setup:",
    1:"<table cellspacing=0 cellpadding=0><tr><td width=1 height=1 nowrap align=right valign=top><b>Board&nbsp;Setup:</b><br>%d</td><td valign=top style=\"padding-left:6px\">%b</td></tr></table>",
    setups:[
    // Initialize board.
      {
        description:"Classic",
        board:
          "   ne   " + // Bottom row
          "        " +
          " s SW  W" +
          "  W    T" +
          "t  lR  G" +
          "g  rL  T" +
          "t    e  " +
          "e  en N " +
          "        " +
          "   WS   " , // Classic
        image:"Setups/ClassicSmall.gif"
      },
      {
        description:"Priestly",
        board:
          "   ne   " + // Bottom row
          "   SW   " +
          "       R" +
          "  W  S T" +
          "t  ER  G" +
          "g  rw  T" +
          "t n  e  " +
          "r       " +
          "   en   " +
          "   WS   " , // Classic
        image:"Setups/PriestlySmall.gif"
      },
      {
        description:"Legacy",
        board:
          "  ne    " + // Bottom row
          "        " +
          "   l    " +
          "    wR W" +
          "s sW TGT" +
          "tgt eN N" +
          "e rE    " +
          "    L   " +
          "        " +
          "    WS  " , // Classic
        image:"Setups/LegacySmall.gif"
      }
    ]
  }
;
GamesByEmail.ReflektitGameForm.getTypePath=GamesByEmail.GameForm.getTypePath;
GamesByEmail.ReflektitGameForm.resource=GamesByEmail.GameForm.resource;
GamesByEmail.ReflektitGameForm.getById=GamesByEmail.GameForm.getById;
GamesByEmail.ReflektitGameForm.getFirst=GamesByEmail.GameForm.getFirst;
GamesByEmail.ReflektitGameForm.getNext=GamesByEmail.GameForm.getNext;
GamesByEmail.ReflektitGameForm.isInstanceOf=GamesByEmail.GameForm.isInstanceOf;
GamesByEmail.ReflektitGameForm.changeDomain=GamesByEmail.GameForm.changeDomain;
GamesByEmail.ReflektitGameForm.importDefaultSettings=GamesByEmail.GameForm.importDefaultSettings;
GamesByEmail.ReflektitGameForm.isEmailAddressFormatValid=GamesByEmail.GameForm.isEmailAddressFormatValid;
GamesByEmail.ReflektitGameForm.handleBuddyResponse=GamesByEmail.GameForm.handleBuddyResponse;
GamesByEmail.ReflektitGameForm.isForGameType=GamesByEmail.GameForm.isForGameType;
GamesByEmail.ReflektitGameForm.findClassForGameType=GamesByEmail.GameForm.findClassForGameType;
GamesByEmail.ReflektitGameForm.createGameForm=GamesByEmail.GameForm.createGameForm;
GamesByEmail.ReflektitGameForm.addCreateGameFormToPage=GamesByEmail.GameForm.addCreateGameFormToPage;
GamesByEmail.ReflektitGameForm.writeJoinGameFormToPage=GamesByEmail.GameForm.writeJoinGameFormToPage;
GamesByEmail.ReflektitGameForm.$constructor();


GamesByEmail.ReflektitGameForm.resourcePack.gameTitles[25]="Reflektit";
GamesByEmail.ReflektitGameForm.resourcePack.gameDescriptions[25]="A chess-based game where you reflect a laser to destroy your opponents pieces!";
