UC = UC || -2
Users[-2] = {id:-2, name: "Guest"}
Users[-1] = {id:-1,name:"computer"} 
var Computer = -1

GamesJSON['computer_1']= { 
		id: 'computer', 
		type: '{computer}' , 
	  state_num: 0, 
		win: null, 
		name: "Practice", 
	  backrow: '', 
	  game_state: 'in_play', 
	  request_type: '', 
	  request_id: null, 
		user_white: Users[UC],
		user_black: Users[Computer], 
		turn_user_id: UC, 
		moves: [], 
		allowed_moves: {}, 
		last_action: 'jonah cancels takeback request', 
		white_sq: '#fff', 
		piece_set: 'classic' 
	}
	
	
clicked_move = function (e) { //override
  var cur = e.curSelectedMove
  var f = (parseInt(cur.f.charAt(1)) + 1) * 10 + "xabcdefgh".indexOf(cur.f.charAt(0))
  var t = (parseInt(cur.t.charAt(1)) + 1) * 10 + "xabcdefgh".indexOf(cur.t.charAt(0))
  
  GamesJSON[Game_id].moves.push({f: e.curSelectedMove.f, t: e.curSelectedMove.t})  
  e.$e.find('#move').fadeOut()
  
  e.$e.find('#mode #inner').html("COMPUTER'S MOVE")
  e.$e.find('#mode').removeClass("yourmove") 
      
      
  window.setTimeout(function() { 
    B( P? 119 - f : f )
    B( P? 119 - t : t )
    if(iphoneMode || e.options.click2move)
      e.$e('#game').unbind("click")
    e.$e.find('#mode #inner').html("YOUR MOVE")
    e.$e.find('#mode').addClass("yourmove") 
  
  }, 400)
}

var computer_move_callback = function(from, to, promote) {
  window.setTimeout(function() { setAjaxActive(false) }, 200)
  var f = convert_computer_move(from)
  var t = convert_computer_move(to)
  GamesJSON[Game_id].moves.push({f: f, t: t})  
  
  get_allowed_moves()
  e = $('.embed')[0]
  update_mode("playing", e)
}

var convert_computer_move = function(m) {
  return "xabcdefgh".charAt([m%10]) + ((m-(m%10))/10 - 1)
}

var postInit =function(e) {
  get_allowed_moves(e)
}

var get_allowed_moves= function(e) {
  move_array = Pz(0,K) //build_move_list_array(0, en_passent_dest)
  var all={}
  $.each(move_array, function() {
    f = convert_computer_move(this[1])
    t = convert_computer_move(this[2])
    if(all[f] == null)
      all[f] = []
    all[f].push(t)
  })
  
  GamesJSON[Game_id].allowed_moves = all
}

