previous

page 21

next
<script>
var arr=[12,52,38,26];
var s1="<img src='cards/back.png' n='";
var s2="' onClick='card_clicked(this);'>";
for (var i=0; i<4; i++) {
document.write(s1 + arr[i] + s2);
}
var card1='';
function card_clicked(image) {
var n=image.getAttribute('n');
image.src='cards/'+n+'.png';
if (card1=='') {
card1=image;
} else {
var n1=card1.getAttribute('n');
var n2=image.getAttribute('n');
n1=n1%13;
n2=n2%13;
if (n1==n2) {
setTimeout(clear,1000,card1);
setTimeout(clear,1000,image);
} else {
setTimeout(turn,2000,card1);
setTimeout(turn,2000,image);
}
card1='';
}
}
function clear(image) {
image.src='cards/0.png';
}
function turn(image) {
image.src='cards/back.png';
}
</script>
previous
next