//Support for cookies used on Games.html

  function getCookieVal(offset) {
    var endstr = document.cookie.indexOf (";", offset);
    if (endstr == -1)
      endstr = document.cookie.length;
    return unescape(document.cookie.substring(offset, endstr));
  }

  function getCookie(name) {
    var arg = name + "=";
    var alen = arg.length;
    var clen = document.cookie.length;
    var i = 0;
    while (i < clen) {
      var j = i + alen;
      if (document.cookie.substring(i, j) == arg)
        return getCookieVal (j);
      i = document.cookie.indexOf(" ", i) + 1;
      if (i == 0) break;
                      }
    return null;
  }

  function ChooseSudoku() {
	binShowSudoku = "True";
	upDateChoice()
  }
  function unChooseSudoku() {
	binShowSudoku = "False";
	upDateChoice()
  }

  function ChooseOthelo() {
	binShowOthelo = "True";
	upDateChoice()
  }
  function unChooseOthelo() {
	binShowOthelo = "False";
	upDateChoice()
  }

  function ChooseMastermind() {
	binShowMastermind = "True";
	upDateChoice()
  }
  function unChooseMastermind() {
	binShowMastermind = "False";
	upDateChoice()
  }

  function ChooseSolitaire() {
	binShowSolitaire = "True";
	upDateChoice()
  }
  function unChooseSolitaire() {
	binShowSolitaire = "False";
	upDateChoice()
  }

  function upDateChoice() {
	document.cookie = "c2cShowSudoku=" + binShowSudoku + expires;
	document.cookie = "c2cShowOthelo=" + binShowOthelo + expires;
	document.cookie = "c2cShowMastermind=" + binShowMastermind + expires;
	document.cookie = "c2cShowSolitaire=" + binShowSolitaire + expires;
	upDatePage()
  }

  function upDatePage() {
	showhide("Sudoku",binShowSudoku)
	showhide("Othelo",binShowOthelo)
	showhide("Mastermind",binShowMastermind)
	showhide("Solitaire",binShowSolitaire)
  }

  function showhide(id,bin){
	if (document.getElementById){
		obj = document.getElementById(id);
		if (bin == "True"){
			obj.style.display = "";
		} else {
			obj.style.display = "none";
		}
	}
  }
