text: var MatchGame = {};
  var itiGame = 0;
  var player = 1;
  var acc1 = 0;
  var acc2 = 0;
  
  /*
    Sets up a new game after HTML document has loaded.
    Renders a 4x4 board of cards.
  */
  
  $(document).ready(function() {
    var $game = $('#game');
    var values = MatchGame.generateCardValues();
    MatchGame.renderCards(values, $game);
  });
  
  /*
    Generates and returns an array of matching card values.
   */
  
  MatchGame.generateCardValues = function () {
    var sequentialValues = [];
  
    for (var value = 1; value <= 36; value++) {
      sequentialValues.push(value);
      sequentialValues.push(value);
    }
  
    var cardValues = [];
  
    while (sequentialValues.length > 0) {
      var randomIndex = Math.floor(Math.random() * sequentialValues.length);
      var randomValue = sequentialValues.splice(randomIndex, 1)[0];
      cardValues.push(randomValue);
    }
  
    return cardValues;
  };
  
  /*
    Converts card values to jQuery card objects and adds them to the supplied game
    object.
  */
  
  MatchGame.renderCards = function(cardValues, $game) {
    var colors = [
      'hsl(25, 85%, 65%)',
      'hsl(55, 85%, 65%)',
      'hsl(90, 85%, 65%)',
      'hsl(160, 85%, 65%)',
      'hsl(220, 85%, 65%)',
      'hsl(265, 85%, 65%)',
      'hsl(310, 85%, 65%)',
      'hsl(360, 85%, 65%)',
  	'hsl(25, 85%, 65%)',
      'hsl(55, 85%, 65%)',
      'hsl(90, 85%, 65%)',
      'hsl(160, 85%, 65%)',
      'hsl(220, 85%, 65%)',
      'hsl(265, 85%, 65%)',
      'hsl(310, 85%, 65%)',
      'hsl(360, 85%, 65%)',
  	'hsl(25, 85%, 65%)',
      'hsl(55, 85%, 65%)',
      'hsl(90, 85%, 65%)',
      'hsl(160, 85%, 65%)',
      'hsl(220, 85%, 65%)',
      'hsl(265, 85%, 65%)',
      'hsl(310, 85%, 65%)',
      'hsl(360, 85%, 65%)',
  	'hsl(25, 85%, 65%)',
      'hsl(55, 85%, 65%)',
      'hsl(90, 85%, 65%)',
      'hsl(160, 85%, 65%)',
      'hsl(220, 85%, 65%)',
      'hsl(265, 85%, 65%)',
      'hsl(310, 85%, 65%)',
      'hsl(360, 85%, 65%)',
  	'hsl(25, 85%, 65%)',
      'hsl(55, 85%, 65%)',
      'hsl(90, 85%, 65%)',
      'hsl(160, 85%, 65%)',
      'hsl(220, 85%, 65%)',
      'hsl(265, 85%, 65%)',
      'hsl(310, 85%, 65%)',
      'hsl(360, 85%, 65%)'];
  
    $game.empty();
    $game.data('flippedCards', []);
  
    for (var valueIndex = 0; valueIndex < cardValues.length; valueIndex++) {
      var value = cardValues[valueIndex];
      var color = colors[value - 1];
      var data = {
        value: value,
        color: color,
        isFlipped: false
      };
  
      var $cardElement = $('<div class="col-xs-1 smallcard"></div>');
      $cardElement.data(data);
  
      $game.append($cardElement);
    }
  
    $('.smallcard').click(function() {
      MatchGame.flipCard($(this), $('#game'));
    });
  };
  
  /*
    Flips over a given card and checks to see if two cards are flipped over.
    Updates styles on flipped cards depending whether they are a match or not.
   */
  
  MatchGame.flipCard = function($card, $game) {
    if ($card.data('isFlipped')) {
      return;
    }
  
    $card.css('background-color', $card.data('color'))
        .text($card.data('value'))
        .data('isFlipped', true);
  
    var flippedCards = $game.data('flippedCards');
    flippedCards.push($card);
  
    if (flippedCards.length === 2) {
  	itiGame++;
  	/*document.getElementById("countplay" ).value = itiGame*/  
  	/*document.write(itiGame)*/
  	document.getElementById('countplay').innerHTML = itiGame;
    if (player === 1) {
  	player = 2;
  	} else {
  	player = 1;
  	}
  	document.getElementById('player').innerHTML = player;
      if (flippedCards[0].data('value') === flippedCards[1].data('value')) {
        var matchCss = {
          backgroundColor: 'rgb(153, 153, 153)',
          color: 'rgb(204, 204, 204)'
        };
        flippedCards[0].css(matchCss);
        flippedCards[1].css(matchCss);
  	  if (player === 2) {
  		acc1++;
  		document.getElementById('acc1').innerHTML = acc1;
  		} else {
  		acc2++;
  		document.getElementById('acc2').innerHTML = acc2;
       }}else {
        var card1 = flippedCards[0];
        var card2 = flippedCards[1];
        window.setTimeout(function() {
          card1.css('background-color', 'rgb(119, 119, 76)')
              .text('')
              .data('isFlipped', false);
          card2.css('background-color', 'rgb(119, 119, 76)')
              .text('')
              .data('isFlipped', false);
        }, 2000);
      }
      $game.data('flippedCards', []);
    }
  };