When I try to run it everything is displayed but I can't play because the Error Console says that my PutCross function is not defined. Can anyone help me with this? Thanks

<script language="javascript" type="text/javascript">
//Tic Tac Toe

//variable global
var playing = true

//function check movement------------------------------------------------
function CheckMovement(board, chip) {
//checks that there is a probability to win the game in a row, column or diagonal.
//returns the position where you have to put your chip. To do it and - 1 if there is not game.
var x, y

for(x = 0; x < 9; x += 3) { //check rows
if ((board.elements[x].value == chip) && (board.elements[x + 1].value == chip))
if (board.elements[x + 2].value == "")
return (x + 2)
if ((board.elements[x].value == chip) && (board.elements[x + 2].value == chip))
if (board.elements[x + 1].value == "")
return (x + 1)
if ((board.elements[x + 1].value == chip) && (board.elements[x + 2].value == chip))
if (board.elements[x].value == "")
return (x)
}

for(x = 0; x < 3; x++) { //check columns
if ((board.elements[x].value == chip) && (board.elements[x + 3].value == chip))
if (board.elements[x + 6].value == "")
return (x + 6)
if ((board.elements[x].value == chip) && (board.elements[x + 6].value == chip))
if (board.elements[x + 3].value == "")
return (x + 3)
if ((board.elements[x + 3].value == chip) && (board.elements[x + 6].value == chip))
if (board.elements[x].value == "")
return (x)
}

//check diagonals
if ((board.elements[2].value == chip) && (board.elements[4].value == chip) && (board.elements[6].value == ""))
return (6)
if ((board.elements[2].value == chip) && (board.elements[4].value == "") && (board.elements[6].value == chip))
return (4)
if ((board.elements[2].value == "") && (board.elements[4].value == chip) && (board.elements[6].value == chip))
return (2)
if ((board.elements[0].value == chip) && (board.elements[4].value == chip) && (board.elements[8].value == ""))
return (8)
if ((board.elements[0].value == chip) && (board.elements[4].value == "") && (board.elements[8].value == chip))
return (4)
if ((board.elements[0].value == "") && (board.elements[4].value == chip) && (board.elements[8].value == chip))
return (0)

return -1
}


//Function Horizontal Pair---------------------------------------------------
function HorizontalPair(board, chip) {
//Checks if it's possible to put 2 in a row, if the other case of the same row is empty.
//Returns the row to allows to do it, or - 1 in the opposite.

var x, y

for(x = 0; x < 9; x += 3) { //check rows
if ((board.elements[x].value == chip) && (board.elements[x + 1].value == "") && (board.elements[x + 2].value == ""))
return (x)
if ((board.elements[x].value == "") && (board.elements[x + 1].value == chip) && (board.elements[x + 2].value == ""))
return (x + 1)
if ((board.elements[x].value == "") && (board.elements[x + 1].value == "") && (board.elements[x + 2].value == chip))
return (x + 2)
}

return -1
}


//FUNCION Vertical Pair---------------------------------------------------
function VerticalPair(board, chip, gameHtal) {
//Checks if it's possible to put 2 in a column, if the other case of the same column is empty.
//Returns the row to allows to do it, or - 1 in the opposite.



var x, y

for(x = 0; x < 3; x++) { //check columns
if ((board.elements[x].value == chip) && (board.elements[x + 3].value == "") && (board.elements[x + 6].value == ""))
if (x != gameHtal) //If it's horizontal pair it doesn't interest as much as vertical
return (x)
if ((board.elements[x].value == "") && (board.elements[x + 3].value == chip) && (board.elements[x + 6].value == ""))
if ((x + 3) != gameHtal)
return (x + 3)
if ((board.elements[x].value == "") && (board.elements[x + 3].value == "") && (board.elements[x + 6].value == chip))
if ((x + 6) != gameHtal)
return (x + 6)
}

return -1
}


//FUNCTION OBTAIN POSITION-------------------------------------------------
function ObtainPosition(gameHtal, gameVcal) {
//looks for the position to make a vertical and horizontal game at the same time
//known the rows and columns where you can make pairs

var x, y, row, column
var posit= 0
position = new Array(3)

for (x = 0; x < 3; x++) { //creates a position for rows and columns
position[x] = new Array(3)
for (y = 0; y < 3; y++) {
position[x][y] = posit
posit++
}
}

for (x = 0; x < 3; x++) { //looks for row and column
for (y = 0; y < 3; y++) {
if (position[x][y] == gameHtal) //found the row
row = x
if (position[x][y] == gameVcal) //found the column
}
}

return (position[row][column]) //returns posit game
}


//Function put the circle-------------------------------------------------
function PutCircle(board) {
//plays the computer

var gamet, gameHtal, gameVcal

//attack and win
gamet = CheckMovement(board, "O")
if (gamet != -1) {
board.elements[gamet].value = "O"
alert('ˇYo gano!')
document.score.lose.value++
playing = false
return 1
}

//defends trying to don't lose
gamet = CheckMovement(board, "X")
if (gamet != -1) {
board.elements[gamet].value = "O"
return 1
}

//attack and win next
gameHtal = HorizontalPair(board, "O")
gameVcal = VerticalPair(board, "O", gameHtal)
if ((gameHtal != -1) && (gameVcal != -1)) { //Can put 2 in the row and 2 in column.
if ((gameHtal != 4) || (gameVcal != 4)) { //it's not the center.
gamet = ObtainPosition(gameHtal, gameVcal) //finds where to move.
board.elements[gamet].value = "O"
return 1
}
}

//attacks and puts 2 in row
if ((gameHtal != -1) && (gameVcal == -1)) {
if ((gameHtal != 2) && (gameHtal != 5) && (gameHtal != 8)) //this is arbitrary
board.elements[gameHtal + 1].value = "O" //move right
else
board.elements[gameHtal - 1].value = "O" //move left
return 1
}

//attacks and puts 2 in column
if ((gameHtal == -1) && (gameVcal != -1)) {
if ((gameVcal != 6) && (gameVcal != 7) && (gameVcal != 8))
board.elements[gameVcal + 3].value = "O" //moves down
else
board.elements[gameVcal - 3].value = "O" //moves up
return 1
}

//moves center
if (board.elements[4].value == "") {
board.elements[4].value = "O"
return 1
}

//moves the first free one
for (x = 0; x < 9; x++)
if (board.elements[x].value == "") {
board.elements[x].value = "O"
return 1
}

alert('draw.')
document.score.draw.value++
playing = false
return -1
}


//Function put cross------------------------------------------------------
function PutCross(board, position) {

//checsk that we're playing
if (playing) {
if (board.elements[position].value != "") //box not empty
alert('This box is has been already taken.')
else { //box empty, you can move there
board.elements[position].value = "X"

//checks if win
if ( CheckVictory(board, "X") ) {
alert('ˇCongratulations! You won.')
document.score.won.value++
playing = false
} else
PutCircle(board)
}
} else {
alert('To start a new game press/ New game.')
}
}


//Function Check Victory ----------------------------------------------
function CheckVictory(board, chip) {

//Checks the winner

var x

for(x = 0; x < 9; x += 3) { //check rows
if ((board.elements[x].value == chip) && (board.elements[x + 1].value == chip) && (board.elements[x + 2].value == chip))
return true
}

for(x = 0; x < 3; x++) { //check columns
if ((board.elements[x].value == chip) && (board.elements[x + 3].value == chip) && (board.elements[x + 6].value == chip))
return true
}

//check diagonales
if ((board.elements[2].value == chip) && (board.elements[4].value == chip) && (board.elements[6].value == chip))
return true
if ((board.elements[0].value == chip) && (board.elements[4].value == chip) && (board.elements[8].value == chip))
return true

return false
}

</script>