/*
GamesByEmail.EmpiresGameForm
*/
/*
   ***** 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.EmpiresGameForm=function(settings)
{
   GamesByEmail.GameForm.apply(this,arguments);
   // Class contructor 
	this.bRelease = true;     //set to true for release!
	this.bAutoPick=true;
	this.bAztecBonus=true;
	
};
GamesByEmail.EmpiresGameForm.$parentClass=GamesByEmail.GameForm;
if (!GamesByEmail.GameForm.$childClasses) GamesByEmail.GameForm.$childClasses=new Array();
GamesByEmail.GameForm.$childClasses.push(GamesByEmail.EmpiresGameForm);
GamesByEmail.EmpiresGameForm.$constructor=GamesByEmail.GameForm.$constructor ? GamesByEmail.GameForm.$constructor : function(){};
GamesByEmail.EmpiresGameForm.$interfaces=new Array();
GamesByEmail.EmpiresGameForm.$name="EmpiresGameForm";
GamesByEmail.EmpiresGameForm.$childClasses=new Array();
GamesByEmail.EmpiresGameForm.$container=GamesByEmail;
GamesByEmail.EmpiresGameForm.prototype={
   constructor:GamesByEmail.EmpiresGameForm,   
   createGameHtml:function(htmlBuilder)
	{
      if (!htmlBuilder)
         htmlBuilder=new Foundation.StringBuilder();
			
		GamesByEmail.GameForm.prototype.createGameHtml.call(this,htmlBuilder);
		
		if(!this.bRelease)
		{
			this.showDebugWindow( htmlBuilder );
			this.showDebugButtons( htmlBuilder );
			htmlBuilder.append( "<br><div id=\""+this.elementId("testJoinHtmlDiv")+"\" style='height:60px'>&nbsp;</div>"  );			
		}	
		
		return htmlBuilder;
   },   
   createGameOptionsHtml:function(h /* htmlBuilder */ )
   {

		h.append("<br><table cellspacing=0 cellpadding=0 border=0>");
		h.append("<tr><td colspan=\"2\" align=\"center\"><B>Options</B></td></tr>");
      h.append("<tr id=\""+this.elementId("rowAutoPick")+"\" ><td valign='top'>");

  		//Check Autopick setting.  It may get turned off by game class when 
  		//starting a new game.
		var sChecked = (this.bAutoPick) ? "CHECKED" : "";

      h.append("<input type=checkbox id=\""+this.elementId("chkAutoPick")+"\" value=\"A\" "+sChecked+" onchange=\""+this.event("chkAutoChanged(this)")+"\" >");      
      h.append("</td><td><label for=\""+this.elementId("chkAutoPick")+"\">");
      h.append("&nbsp;");
      h.append(this.resource(0));
      h.append("</label>");
      h.append("<br>"+this.resource("autoPickDescription"));
      h.append("<br>&nbsp;</td></tr>");

      h.append("<tr id=\""+this.elementId("rowAztecBonus")+"\" ><td valign='top'>");
 
		sChecked=(this.bAztecBonus) ? "CHECKED" : "";

      h.append("<input type=checkbox id=\""+this.elementId("chkAztecBonus")+"\" value=\"Z\" "+sChecked+" onchange=\""+this.event("chkIncasChanged(this)")+"\" >");      
      h.append("</td><td><label for=\""+this.elementId("chkAztecBonus")+"\">");
      h.append(this.resource("aztecBonusDescription")+"</label>");
      h.append("</td></tr></table>");

      return h;
   },   
   chkAutoChanged:function( chk )
   {
   	this.info.bAutoPick=chk.checked;
	},   
   chkIncasChanged:function( chk )
   {   
   	this.info.bAztecBonus=chk.checked;
	}//over-ride this to get options from html, assign to this.info. then start game.
,   
   onCreate:function()
   {
   	var chk=this.getElement("chkAutoPick");
   	this.info.bAutoPick=chk.checked;

   	var chk=this.getElement("chkAztecBonus");
   	this.info.bAztecBonus=chk.checked;
   	
   	if(!this.bRelease)
   	{
   		this.debug( "bAutoPick is:" + this.info.bAutoPick );
   		this.debug( "bAztecBonus is:" + this.info.bAztecBonus );   		
		} 
   	
   	return GamesByEmail.GameForm.prototype.onCreate.call(this);   	
	},   
   joinGameOptionsHtml:function(h)
	{
		h.append("<table cellspacing=0 cellpadding=0 border=0>");
		h.append("<tr><td>");
		
		var bAutoPick=this.info.bAutoPick;
		if( bAutoPick === "True" || bAutoPick===true ) 		
			h.append(this.resource(0));
		else
			h.append(this.resource(1));

		var bAztecBonus=this.info.bAztecBonus;
		if( bAztecBonus === "True" || bAztecBonus===true ) 		
			h.append( "<br/>" + this.resource("aztecBonusDescription"));

		h.append("</td></tr></table>");
		return h;
	}///////// debug functions                          ///////////////////
	//////////////////////////////////////////////////////////////////////
,   
   showDebugWindow:function( html )
	{					
		html.append( "<textarea id=\"debugWindow\" wrap=soft rows=7 cols=\"\" readonly style=\"background-color:#eeeeee;width:100%\" > </textarea><br>" );		
	},   
   showDebugButtons:function( html )
	{
		sClick=this.event('debug("Hi there")'); //careful with your brackets.
		html.append( this.getButtonHtml( "Say Hello", sClick ));
		sClick=this.event('testJoinHtml()');
		html.append( this.getButtonHtml( "Test Join Html", sClick ));		

	},   
   getButtonHtml:function( sName, sOnClick )
	{
		var sButtonHtml = "<input type='button' VALUE='"+sName+"' onClick='"+sOnClick+"' >";
		return sButtonHtml;		
	}//quick and dirty way of testing the markup that'll get injected into the join game panel.
,   
   testJoinHtml:function()
	{
		var div=this.getElement('testJoinHtmlDiv');
		var htmlBuilder = new Foundation.StringBuilder();
		htmlBuilder = this.joinGameOptionsHtml(htmlBuilder);
		div.innerHTML=htmlBuilder.toString();

	},   
   debug:function( sMsg )
	{
		if(this.bRelease)
			return;

		var debugWindow = document.getElementById("debugWindow");
		debugWindow.value += "\r\n"+sMsg;	
	},
   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,
   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,
   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
};
//static data
GamesByEmail.EmpiresGameForm.defaultSettings={
      gameTypes:[66],
      allowedNumPlayers:[4,5,6],
      info:{bAutoPick:true,
				bAztecBonus:true}      
   };
GamesByEmail.EmpiresGameForm.resourcePack={
		authorName: "Troy Chard",
      language:"English",
      gameTitles:{},
      gameDescriptions:{},
      teamTitles:["Red","Purple","Blue","Green","Yellow","Orange"],
      "0":"Empires are dealt automatically.",
      "1":"Players pick empires manually.",
		autoPickDescription: "(If you draw a weak empire, it's automatically given to the highest score player.<br>If dealt a strong empire, you keep it).",
		aztecBonusDescription:"Incas/Aztecs only need 1 resource per monument."
   }
;
GamesByEmail.EmpiresGameForm.getTypePath=GamesByEmail.GameForm.getTypePath;
GamesByEmail.EmpiresGameForm.resource=GamesByEmail.GameForm.resource;
GamesByEmail.EmpiresGameForm.getById=GamesByEmail.GameForm.getById;
GamesByEmail.EmpiresGameForm.getFirst=GamesByEmail.GameForm.getFirst;
GamesByEmail.EmpiresGameForm.getNext=GamesByEmail.GameForm.getNext;
GamesByEmail.EmpiresGameForm.isInstanceOf=GamesByEmail.GameForm.isInstanceOf;
GamesByEmail.EmpiresGameForm.changeDomain=GamesByEmail.GameForm.changeDomain;
GamesByEmail.EmpiresGameForm.importDefaultSettings=GamesByEmail.GameForm.importDefaultSettings;
GamesByEmail.EmpiresGameForm.isEmailAddressFormatValid=GamesByEmail.GameForm.isEmailAddressFormatValid;
GamesByEmail.EmpiresGameForm.handleBuddyResponse=GamesByEmail.GameForm.handleBuddyResponse;
GamesByEmail.EmpiresGameForm.isForGameType=GamesByEmail.GameForm.isForGameType;
GamesByEmail.EmpiresGameForm.findClassForGameType=GamesByEmail.GameForm.findClassForGameType;
GamesByEmail.EmpiresGameForm.createGameForm=GamesByEmail.GameForm.createGameForm;
GamesByEmail.EmpiresGameForm.addCreateGameFormToPage=GamesByEmail.GameForm.addCreateGameFormToPage;
GamesByEmail.EmpiresGameForm.writeJoinGameFormToPage=GamesByEmail.GameForm.writeJoinGameFormToPage;
GamesByEmail.EmpiresGameForm.$constructor();


GamesByEmail.EmpiresGameForm.resourcePack.gameTitles[66]="Empires";
GamesByEmail.EmpiresGameForm.resourcePack.gameDescriptions[66]="A clone of Hasbro's History of the World.";
