
var imageArray = new Array(6); // Array of image objects

//For loop creating array

for (var i = 0; i <=5; i++)
{
	imageArray[i] = new Image();
}


//Preload the images off-screen

image[0].src = "images/dice1.gif";
image[1].src = "images/dice2.gif";
image[2].src = "images/dice3.gif";
image[3].src = "images/dice4.gif";
image[4].src = "images/dice5.gif";
image[5].src = "images/dice6.gif";




//Play Game

function play()

{
	var amountBet; 
	amountBet = prompt("Please enter the value you wish to bet", "");

	var image1;    // The first colour
	var image2;	  // The second colour
	var total;	// Total 

	amountBet=parseInt(amountBet); 
	amountBet=Math.round(amountBet);

// Randomly generate image 1

	image1 = Math.round(Math.random() * 5) + 1;
	document.images[0].src = "images/dice" + image1 + ".gif"
  
// Randomly generate image 2

	image2 = Math.round(Math.random() * 5) + 1;
	document.images[1].src = "images/dice" + image2 + ".gif"
  

//Calculates what the player wins

	total = image1 + image2;


	if ((total == 3) || (total== 4) || (total == 9) || (total == 10) || (total == 11))
     	  {
	   alert("you win $" + amountBet);
          }
        else if ((total == 5) || (total== 6) || (total == 7) || (total == 8)) 
          {
           alert("You lose $" + amountBet);
          }
        else if (total == 2) 
          {
           alert("You win"+ (amountBet*2));
          }
        else if (total == 12) 
          {
        alert("You win"+ (amountBet*3));
          }
}

var newwindow;
function poptastic(url)
{
	newwindow=window.open(url,'name','height=900,width=900');
	if (window.focus) {newwindow.focus()}
}
