in the x == true
portion of the if statement, you should set the curPin to be one otherwise you are duplicating the curPin = 1.
function pinF() {
if (x == true) {
--curPin;
if (curPin == 0) {
curPin = 1;
x = false;
}
}
if (x == false) {
++curPin;
if (curPin == 8) {
x = true;
}
}
document.getElementById("pin").src = pin[curPin].src;
}