dateinc.js

//This include file contains functionality common to date.htm
//and betweendates.htm. Both files display the state of the date
//(for example, how many of each kinds of dice there are) and
//give the user ways of interacting with that state

   var strStatus = "";

   var iRerollableDiceAwarded = 0;

   var iRerollableSuccesses = 0;
   var iSingleRollSuccesses = 0;

   var iRerollFailures = 0;
   var iSingleRollFailures = 0;

   var iAttractionDice = 0;
   var iDateNum = 0;

   var iPermanenceDice = 0;
   var iPermanenceRerolls = 0;

//Compares two functions and returns true if they're
//identical and false otherwise. If neither function
//is valid (for example, if one is null and
//one is 0), they will be counted as identical.
function functionsAreIdentical(function1, function2)
{
    if (!function1)
    {
        return (!function2);
    }
    else
    {
        return (function1 == function2);
    }
}

//This function displays various sorts of types of dice,
//by adding them as child nodes of the element elemContainer.
//Note that this code makes assumptions: for example, that
//the same type of dice will always be added to the same container.
function displayDice(elemContainer, type, result, number, functionOnClick, tooltip)
{
     //First, how many dice are presently displayed?
     var collImgElements = elemContainer.getElementsByTagName("img");

     //Test code
     for (var i = 0; i < collImgElements.length; i ++)
     { 
          if (collImgElements[i].src.indexOf("BlueDieRolling") > 0 || collImgElements[i].src.indexOf("BlueDieGiving") > 0)
          {
              elemContainer.removeChild(collImgElements[i]);
          }
     }

     //Do the dice we've been asked to add have the same
     //click state as the dice already in the container?
     if (collImgElements[0])
     { 
         if (!functionsAreIdentical(collImgElements[0].onclick, functionOnClick))
         {
             //No: we're being asked to add dice with a different click state.
             //So we need to add all the dice again: remove all the dice
             //currently in the container
             while (elemContainer.firstChild) 
             {
                 elemContainer.removeChild(elemContainer.firstChild);
             }
             
             //And, for simplicity, let's get the empty node list again
             collImgElements = elemContainer.getElementsByTagName("img");
         }
     }

     var iDifference = number - collImgElements.length;

     var strImageName = "";

     //If we need to display less dice, remove them
     while (iDifference < 0)
     {
         elemContainer.removeChild(collImgElements[0]);

         iDifference ++;
     }

     //If we need to display more dice, add them
     while (iDifference > 0)
     {
     if (type == "Rerollable")
     {
         strImageName = "BlueDie";
     }
     else
     {
         strImageName = "RedDie";
     }

     //Note that we generate a random number to display on each die:
     //for example, a success may be displayed as either a 5 or a 6.
     //This means different users may see different dice, which isn't
     //entirely satisfactory     
     if (result == "Success")
     {
         strImageName += Math.floor (Math.random() * 2 + 5);
     }
     else if (result == "Failure")
     {
         strImageName += Math.floor (Math.random() * 4 + 1);
     }
     else if (result == "Reroll")
     {
         strImageName += "Reroll" + Math.floor (Math.random() * 4 + 1);
     }
     else
     {
         strImageName += "Unrolled";
     }

     var image = document.createElement('img');

     image.src="images/" + strImageName + ".gif";

     //Make the die clickable, if we need to
          if (functionOnClick)
          {
              image.onclick = functionOnClick;
                  //TODO: Is this right?
                  image.style.cursor = "pointer";
                  image.style.cursor = "hand";
      }

     image.alt = tooltip;
     image.title = tooltip;

     elemContainer.appendChild(image);

        iDifference --;
     }
}

//This function displays the temporary or permanent attraction
function displayAttraction(elemContainer, type, number)
{
     var collImgElements = elemContainer.getElementsByTagName("img");

     var iDifference = number - collImgElements.length;

     var strImageName = "";

     //Remove attraction, if we need to
     while (iDifference < 0)
     {
         elemContainer.removeChild(collImgElements[0]);

         iDifference ++;
     }

     var image = document.createElement('img');

     //Add attraction, if we need to
     while (iDifference > 0)
     {
     if (type == "Permanent")
     {
         strImageName = "PermanentAttraction";
         image.alt = "Permament Attraction will never disappear";
         image.title = "Permament Attraction will never disappear";

     }
     else
     {
         strImageName = "TemporaryAttraction";
         image.alt = "Temporary attraction may disappear at the end of the date";
         image.title = "Temporary attraction may disappear at the end of the date";
     }

     image.src="images/" + strImageName + ".gif";

     elemContainer.appendChild(image);

        iDifference --;
     }
}


   //This function, called by the XML parsing function in include.js,
   //displays each of the direct children of the root node
   //of the XML document.

   //Since this function is used by both date.htm and betweendates.htm,
   //there are some nodes which are displayed by one file but
   //not the other (e.g. "permanencedice" is only used by
   //betweendates.htm).
   function displayNode(node) 
   {
                      switch (node.nodeName)
                      {
                      case "status":
                          setStatusFromXML(node);
                          break;
 
                      case "betweendates":
                          //Note that this function is implemented,
                          //differently, in date.htm and betweendates.htm   
                          setBetweenDatesFromXML(node);
                          break;

                      case "dateno":
                          setDateNoFromXML(node);
                          break;

                      case "turn":
                          setTurnNumFromXML(node);
                          break;

                      case "attractiondicetoaward":
                          setAttractionDiceFromXML(node);
                          break;

                      case "bonusdicetoaward":
                          setBonusDiceFromXML(node);
                          break;

                      case "rerolls":
                          setRerollsFromXML(node);
                          break;

                      case "rerollablesuccesses":
                          setRerollableSuccessesFromXML(node);
                          break;

                      case "singlerollsuccesses":
                          setSingleRollSuccessesFromXML(node);
                          break;

                      case "rerollablediceawarded":
                          setRerollableDiceAwardedFromXML(node);
                          break;

                      case "rerollfailures":
                          setRerollFailuresFromXML(node);
                          break;

                      case "singlerollfailures":
                          setSingleRollFailuresFromXML(node);
                          break;

                      case "myconflict":
                          setMyConflictFromXML(node);
                          break;

                      case "theirconflict":
                          setTheirConflictFromXML(node);
                          break;

                      case "myname":
                          setMyCharacterNameFromXML(node);
                          break;

                      case "theirname":
                          setTheirCharacterNameFromXML(node);
                          break;

                      case "compatibilities":
                          setCompatibilitiesFromXML(node);
                          break;

                      case "mytraits":
                          setMyTraitsFromXML(node);
                          break;

                      case "theirtraits":
                          setTheirTraitsFromXML(node);
                          break;

                      case "permanentattraction":
                          setPermanentAttractionFromXML(node);
                          break;

                      case "temporaryattraction":
                          setTemporaryAttractionFromXML(node);
                          break;

                      case "permanencedice":
                          setPermanenceDiceFromXML(node);
                          break;

                      case "permanencefailures":
                          setPermanenceFailuresFromXML(node);
                          break;

                      case "permanencesuccesses":
                          setPermanenceSuccessesFromXML(node);
                          break;

                      case "permanencererolls":
                          setPermanenceRerollsFromXML(node);
                          break;

                      }
   }

//This function sets our status (active or passive). It
//remembers the value in our internal variable and
//changes to display to suit
function setStatusFromXML(node) 
{
     //Store the value in our internal variable
     strStatus = getTextFromNode(node);

     //Do some simple updates to the display
     var divStatus = document.getElementById("idStatus");

     if (divStatus)
     {
     
     if (strStatus == "active")
     {
         divStatus.innerHTML = "This turn, you're the Active Player. Describe the date to your partner, playing your character when you need to.";

         document.getElementById("buttonEndTurn").style.display = "block";
         document.getElementById("buttonEndDate").style.display = "block";
     }
     else
     {
         divStatus.innerHTML = "You're the Guide this turn. Listen to your partner describe the date, using the dice to reward them when you like what you hear. When you need to, play your character.";

         document.getElementById("buttonEndTurn").style.display = "none";
         document.getElementById("buttonEndDate").style.display = "none";
     }

     //As a cosmetic thing, it looks better if the dice owned 
     //by each player are displayed at the left and other dice
     //displayed to the right. To do this, we move nodes about.
     //TODO: Actually, this isn't efficient. Change back to 
     //having containers for "My Dice" and "Their dice"?
     var nodeRow = document.getElementById("idRowDice");    
 
     if (nodeRow)
     {
     var nodeFirstCell = nodeRow.firstChild;
     
     while (nodeFirstCell.tagName != "TD")
     {
         nodeFirstCell = nodeFirstCell.nextSibling;
     }

     if ((nodeFirstCell.id == "idCellActivePlayer" && strStatus == "passive") || (nodeFirstCell.id == "idCellGuide" && strStatus == "active"))
     {
          var nodeSecondCell = nodeFirstCell.nextSibling;

          while (nodeSecondCell.tagName != "TD")
          {
                 nodeSecondCell = nodeSecondCell.nextSibling;
          }

          var nodeFirstCellClone = nodeFirstCell.cloneNode(true);
          var nodeSecondCellClone = nodeSecondCell.cloneNode(true);

          nodeRow.appendChild(nodeSecondCellClone);
          nodeRow.appendChild(nodeFirstCellClone);

          nodeRow.removeChild(nodeFirstCell);
          nodeRow.removeChild(nodeSecondCell);
     }
     }
     }
}

//TODO: Do we need this at all?
function setTurnNumFromXML(node) 
{
}

//Set the number of attraction dice and change
//the display appropriately
function setAttractionDiceFromXML(node)
{
     iAttractionDice = getTextFromNode(node);

     var elem = document.getElementById("idAttractionDiceToAward");

     if (iAttractionDice > 0)
     {
         //If there's attraction dice to roll, show them and the associated text
         if (strStatus == "passive")
         {
             document.getElementById("idParaAttractionDiceActivePlayer").style.display = "none";
             document.getElementById("idParaAttractionDiceGuide").style.display = "block";
            
                 displayDice(elem, "Rerollable", "Unrolled", iAttractionDice, awardAttractionDice, "Attraction dice: one for each level of attraction. Click to give to your partner.");
         }
         else
         {
             document.getElementById("idParaAttractionDiceActivePlayer").style.display = "block";
             document.getElementById("idParaAttractionDiceGuide").style.display = "none";

                 displayDice(elem, "Rerollable", "Unrolled", iAttractionDice, undefined, "Attraction dice: one for each level of attraction.");
         }
     }
     else
     {
         //If not, hide the dice and the associated text
         document.getElementById("idParaAttractionDiceActivePlayer").style.display = "none";
         document.getElementById("idParaAttractionDiceGuide").style.display = "none";

         displayDice(elem, "Rerollable", "Unrolled", iAttractionDice, undefined, "");
     }
}

//Set the number of bonus dice, changing the display appropriately
function setBonusDiceFromXML(node)
{
     var iBonusDice = getTextFromNode(node);

     var elem = document.getElementById("idBonusDiceToAward");

     if (iBonusDice != -1)
     {
     //If we have bonus dice, and the attraction dice have been rolled, 
     //show them and the associated text
     if (iBonusDice > 0 && iAttractionDice == 0)
     {
         if (strStatus == "passive")
         {
             document.getElementById("buttonAwardBonusDie").style.display = "block";
             document.getElementById("idParaBonusDiceActivePlayer").style.display = "none";
             document.getElementById("idParaBonusDiceGuide").style.display = "block";

                 displayDice(elem, "Rerollable", "Unrolled", iBonusDice, awardBonusDie, "Bonus dice: click to give a die to your partner");
         }
         else
         {
             document.getElementById("buttonAwardBonusDie").style.display = "none";
             document.getElementById("idParaBonusDiceActivePlayer").style.display = "block";
             document.getElementById("idParaBonusDiceGuide").style.display = "none";

                 displayDice(elem, "Rerollable", "Unrolled", iBonusDice, undefined, "Bonus dice");
         }
     }
     else
     {
         //If there's no bonus dice, or the attraction dice haven't been rolled,
         //hide them and the associated text
         document.getElementById("buttonAwardBonusDie").style.display = "none";
         document.getElementById("idParaBonusDiceActivePlayer").style.display = "none";
         document.getElementById("idParaBonusDiceGuide").style.display = "none";

         displayDice(elem, "Rerollable", "Unrolled", 0, undefined);
     }
     }
}

//Show the rerolls and associated text
function setRerollsFromXML(node)
{
     var iRerolls= getTextFromNode(node);

     var elem = document.getElementById("idRerolls");

     if (iRerolls > 0)
     {
          //Show rerolls and appropriate text
          if (strStatus == "active")
          {
              document.getElementById("idParaRerollsActivePlayer").style.display = "block";
              document.getElementById("idParaRerollsGuide").style.display = "none";

              displayDice(elem, "Rerollable", "Reroll" , iRerolls, rerollDie, "Click to reroll this dice and narrate something that puts your character at a disadvantage");
          }
          else
          {
              document.getElementById("idParaRerollsActivePlayer").style.display = "none";
              document.getElementById("idParaRerollsGuide").style.display = "block";

              displayDice(elem, "Rerollable", "Reroll" , iRerolls, undefined, "Your partner may reroll this dice when he narrates something that puts his character at a disadvantage");
          }


     }
     else
     {
          //Hide rerolls and associated text
              document.getElementById("idParaRerollsActivePlayer").style.display = "none";
              document.getElementById("idParaRerollsGuide").style.display = "none";

          displayDice(elem, "Rerollable", "Reroll" , iRerolls, undefined);
     }
}

function setPermanentAttractionFromXML(node)
{
     var iPermanentAttraction = getTextFromNode(node);

     var elem = document.getElementById("idPermanentAttraction");

     displayAttraction(elem, "Permanent", iPermanentAttraction);
}

function setTemporaryAttractionFromXML(node)
{
     var iTemporaryAttraction = getTextFromNode(node);

     var elem = document.getElementById("idTemporaryAttraction");

     displayAttraction(elem, "Temporary", iTemporaryAttraction);
}

//Show the successes that were rolled on
//rerollable dice
function setRerollableSuccessesFromXML(node)
{
     iRerollableSuccesses = getTextFromNode(node);

     var elem = document.getElementById("idRerollableSuccesses");

     displayDice(elem, "Rerollable", "Success", iRerollableSuccesses, undefined, "If you get three successes, you can increase the attraction; four, and you can add a compatibility.");

     updateDisplayForSuccessChange();
}

function setSingleRollSuccessesFromXML(node)
{
     iSingleRollSuccesses = getTextFromNode(node);

     var elem = document.getElementById("idSingleRollSuccesses");

     displayDice(elem, "SingleRoll", "Success", iSingleRollSuccesses, undefined, "If you get three successes, you can increase the attraction; four, and you can add a compatibility.");

     updateDisplayForSuccessChange();
}

function updateDisplayForSuccessChange()
{
     document.getElementById("paraNextDate").style.display = "none";

     if ((parseInt(iRerollableSuccesses) + parseInt(iSingleRollSuccesses)) > 0)
     {
          document.getElementById("idParaSuccesses").style.display = "block";
     }
     else
     {
          document.getElementById("idParaSuccesses").style.display = "none";
     }
      
     if ((parseInt(iRerollableSuccesses) + parseInt(iSingleRollSuccesses)) >= 3 && strStatus == "active")
     {
          document.getElementById("buttonIncreaseAttraction").style.display = "block";
     }
     else
     {
          document.getElementById("buttonIncreaseAttraction").style.display = "none";
     }

     if ((parseInt(iRerollableSuccesses) + parseInt(iSingleRollSuccesses)) >= 4 && strStatus == "active")
     {
          document.getElementById("buttonAddCompatibility").style.display = "block";
          document.getElementById("textAddCompatibility").style.display = "block";
     }
     else
     {
          document.getElementById("buttonAddCompatibility").style.display = "none";
          document.getElementById("textAddCompatibility").style.display = "none";
     }
}

function setRerollFailuresFromXML(node)
{
     iRerollFailures = getTextFromNode(node);
 
     var elem = document.getElementById("idRerollFailures");

     displayDice(elem, "Rerollable", "Failure", iRerollFailures, undefined, "These dice have failed");

     updateDisplayForFailureChange();
}

function setSingleRollFailuresFromXML(node)
{
     iSingleRollFailures = getTextFromNode(node);

     var elem = document.getElementById("idSingleRollFailures");

     displayDice(elem, "SingleRoll", "Failure", iSingleRollFailures, "These dice have failed");

     updateDisplayForFailureChange();
}

function updateDisplayForFailureChange()
{
     if ((parseInt(iRerollFailures) + parseInt(iSingleRollFailures)) > 0)
     {
          document.getElementById("idParaFailures").style.display = "block";
     }
     else
     {
          document.getElementById("idParaFailures").style.display = "none";
     }
}

function setRerollableDiceAwardedFromXML(node)
{
     iRerollableDiceAwarded = getTextFromNode(node);

     var elem = document.getElementById("idRerollableDiceAwarded");

     if ((parseInt(iRerollableDiceAwarded)) > 0)
     {
         if (strStatus == "active")
         {
               document.getElementById("buttonRollDice").style.display = "block";
               document.getElementById("idParaRerollableDiceAwardedActivePlayer").style.display = "block";
               document.getElementById("idParaRerollableDiceAwardedGuide").style.display = "none";

               displayDice(elem, "Rerollable", "Unrolled", iRerollableDiceAwarded, rollDice, "Click to roll all the dice");
         }
         else
         {
               document.getElementById("buttonRollDice").style.display = "none";
               document.getElementById("idParaRerollableDiceAwardedActivePlayer").style.display = "none";
               document.getElementById("idParaRerollableDiceAwardedGuide").style.display = "block";

               displayDice(elem, "Rerollable", "Unrolled", iRerollableDiceAwarded, undefined, "Click to roll all the dice");
         }
     }
     else
     {
               document.getElementById("buttonRollDice").style.display = "none";
               document.getElementById("idParaRerollableDiceAwardedActivePlayer").style.display = "none";
               document.getElementById("idParaRerollableDiceAwardedGuide").style.display = "none";

               displayDice(elem, "Rerollable", "Unrolled", iRerollableDiceAwarded, undefined, "");
     }
}

function setMyConflictFromXML(nodeConflict)
{
     var elem = document.getElementById("idMyConflict");

     var strConflict = getTextFromChildNode(nodeConflict, 'conflict');

     elem.innerHTML = strConflict;

     var iGameUserMapId = getTextFromChildNode(nodeConflict, 'gameusermapid');
     var iConflictDiceToAward = getTextFromChildNode(nodeConflict, 'conflictdicetoaward');
     var strInvocationStatus = getTextFromChildNode(nodeConflict, 'invocationstatus');

     if (strStatus == "active" && iConflictDiceToAward > 0)
     {
          if (strInvocationStatus == "available")
          {
//               elem.innerHTML += "<input type=\"button\" value=\"Propose\" onclick=\"proposeConflict(" + iGameUserMapId + ")\">";
               elem.innerHTML += "<img src='images/ThreeSmallRedDicePropose.gif' onclick='proposeConflict(" + iGameUserMapId + ")' style='cursor:pointer'>";
          }
          else
          {
               elem.innerHTML += "<img src='images/ThreeSmallRedDiceWaiting.gif'>";
          }
     }
}

function setTheirConflictFromXML(nodeConflict)
{
     var elem = document.getElementById("idTheirConflict");

     var strConflict = getTextFromChildNode(nodeConflict, 'conflict');

     elem.innerHTML = strConflict;

     var iGameUserMapId = getTextFromChildNode(nodeConflict, 'gameusermapid');
     var iConflictDiceToAward = getTextFromChildNode(nodeConflict, 'conflictdicetoaward');
     var strInvocationStatus = getTextFromChildNode(nodeConflict, 'invocationstatus');
     
     if (strStatus == "passive" && strInvocationStatus == "proposed" && iConflictDiceToAward > 0)
     {
         elem.innerHTML += "<img src='images/ThreeSmallRedDiceRoll.gif' onclick='rollConflictDice(" + iGameUserMapId + ")' style='cursor:pointer'>";
     }
}

function setMyCharacterNameFromXML(nodeName)
{
     var elem = document.getElementById("idMyName");

     var strName = getTextFromNode(nodeName);

     elem.innerHTML = strName;
}

function setTheirCharacterNameFromXML(nodeName)
{
     var elem = document.getElementById("idTheirName");

     var strConflict = getTextFromNode(nodeName);

     elem.innerHTML = strConflict;
}

//This slightly more complicated function parses
//the children of the "compatibilities" node and
//displays the compatibilities from them
//TODO: Adapt this so it doesn't use innerHTML?
function setCompatibilitiesFromXML(node)
{
     var collCompatibilityNodes = node.getElementsByTagName("compatibility");

     var elem = document.getElementById("idCompatibilities");
 
     var strToAdd = "<p>";

     for (var i = 0; i < collCompatibilityNodes.length; i++)
     {
          var nodeCompatibility = collCompatibilityNodes.item(i);
     
          var strCompatibility = getTextFromChildNode(nodeCompatibility, 'name');

          var iCompatibilityId = getTextFromChildNode(nodeCompatibility, 'compatibilityid');
          var iCompatibilityDiceToAward = getTextFromChildNode(nodeCompatibility , 'compatibilitydicetoaward');
         var strInvocationStatus = getTextFromChildNode(nodeCompatibility , 'invocationstatus');

         if (i > 0)
         {
             strToAdd  += ", ";
         }
     
         if (iCompatibilityDiceToAward > 0)
         {
             if (strStatus == "active")
             {
                if (strInvocationStatus == "available")
                {
                   strToAdd  += strCompatibility + "<img src='images/TwoSmallRedDicePropose.gif' onclick='proposeCompatibility(" + iCompatibilityId + ")' style='cursor:pointer'>";
                }
                else
                {
                   strToAdd  += strCompatibility + "<img src='images/TwoSmallRedDiceWaiting.gif'>";
                }
             }
             else
             {
                if (strInvocationStatus == "proposed")
                {
                   strToAdd  += strCompatibility + "<img src='images/TwoSmallRedDiceRoll.gif' onclick='rollCompatibilityDice(" + iCompatibilityId + ")' style='cursor:pointer'>";
                }
                else
                {
                   strToAdd  += strCompatibility;
                }
                
             }
         }
         else
         {
            strToAdd += strCompatibility;
         }
     }

     strToAdd += "</p>";

     elem.innerHTML = strToAdd;
}

function setMyTraitsFromXML(node)
{
     var collTraitNodes = node.getElementsByTagName("mytrait");

     var elem = document.getElementById("idMyTraits");

     setTraits(collTraitNodes, elem, "mytrait"); 
}

function setTheirTraitsFromXML(node)
{
     var collTraitNodes = node.getElementsByTagName("theirtrait");

     var elem = document.getElementById("idTheirTraits");

     setTraits(collTraitNodes, elem, "theirtrait"); 
}

function setTraits(collTraitNodes, elem, strTagName)
{
     var strToAdd = "<p>";

     for (var i = 0; i < collTraitNodes.length; i++)
     {
          var nodeTrait = collTraitNodes.item(i);
    
          var strTrait = getTextFromNode(nodeTrait, strTagName);

         if (i > 0)
         {
             strToAdd  += "; ";
         }

         strToAdd += strTrait;

     }

     strToAdd += "</p>";

     elem.innerHTML = strToAdd;
}

function preloadImages()
{
if (document.images)
{
  imageBU = new Image(); 
  imageBU.src="images/BlueDieUnrolled.gif"; 
  imageB1 = new Image(); 
  imageB1.src="images/BlueDie1.gif"; 
  imageB2 = new Image(); 
  imageB2.src="images/BlueDie2.gif"; 
  imageB3 = new Image(); 
  imageB3.src="images/BlueDie3.gif"; 
  imageB4 = new Image(); 
  imageB4.src="images/BlueDie4.gif"; 
  imageB5 = new Image(); 
  imageB5.src="images/BlueDie5.gif"; 
  imageB6 = new Image(); 
  imageB6.src="images/BlueDie6.gif"; 
  imageBR1 = new Image(); 
  imageBR1.src="images/BlueDieReroll1.gif"; 
  imageBR2 = new Image(); 
  imageBR2.src="images/BlueDieReroll2.gif"; 
  imageBR3 = new Image(); 
  imageBR3.src="images/BlueDieReroll3.gif"; 
  imageBR4 = new Image(); 
  imageBR4.src="images/BlueDieReroll4.gif"; 

  imageBDR = new Image(); 
  imageBDR.src= "images/BlueDieRolling.gif";

  imageRU = new Image(); 
  imageRU.src="images/RedDieUnrolled.gif"; 
  imageR1 = new Image(); 
  imageR1.src="images/RedDie1.gif"; 
  imageR2 = new Image(); 
  imageR2.src="images/RedDie2.gif"; 
  imageR3 = new Image(); 
  imageR3.src="images/RedDie3.gif"; 
  imageR4 = new Image(); 
  imageR4.src="images/RedDie4.gif"; 
  imageR5 = new Image(); 
  imageR5.src="images/RedDie5.gif"; 
  imageR6 = new Image(); 
  imageR6.src="images/RedDie6.gif"; 

  image2RP = new Image(); 
  image2RP.src="images/TwoSmallRedDicePropose.gif"; 
  image2RR = new Image(); 
  image2RR.src="images/TwoSmallRedDiceRoll.gif"; 
  image2RW = new Image(); 
  image2RW.src="images/TwoSmallRedDiceWaiting.gif"; 

  image3RP = new Image(); 
  image3RP.src="images/ThreeSmallRedDicePropose.gif"; 
  image3RR = new Image(); 
  image3RR.src="images/ThreeSmallRedDiceRoll.gif"; 
  image3RW = new Image(); 
  image3RW.src="images/ThreeSmallRedDiceWaiting.gif"; 

  imagePA = new Image(); 
  imagePA.src="images/PermanentAttraction.gif"; 
  imageTA = new Image(); 
  imageTA.src="images/TemporaryAttraction.gif"; 
}

}

preloadImages();