var carray = ['#ccffcc', '#ffffcc','#ccccff','#00ff00','#eecc44','#ffcccc','#ff9933', '#ff9999', '#ffff33', '#99ffff', '#0099ff', '#99ffcc','#ff99cc','#cccc99','#ccff00','#cccccc','#ff9999','#993399','#999999','#ffffff',];
function placevalues() {

for (var i =0; i < 7; i++) {
	for (var j =0; j < 7; j++) {
if (spos[i][j]) {
var setvalue = document.getElementById("cell"+[i]+[j]);
if (spos[i][j] == "0") { }  
else { 
if (spos[i][j] == "-") { setvalue.value = 0; }  
else {
setvalue.value = spos[i][j]; } }

//setvalue.readOnly = true;
}
if (scol[i][j]) {
var startcol = document.getElementById("cell"+[i]+[j]);
var gc = scol[i][j];
startcol.style.background = carray[gc-1];
document.getElementById("td"+[i]+[j]).style.background = carray[gc-1];
}
//countup = countup + 1;
}
}


} //close function

var countup = 0;
function showsolution() {
var allInputs = document.getElementsByTagName("input");
for (var i =0; i < 7; i++) {
	for (var j =0; j < 7; j++) {
if (allInputs[countup].type=="text") {
//allInputs[countup].style.color = inputlettersol;
allInputs[countup].value = cells[i][j];
allInputs[countup].style.color = '#000000';
//allInputs[countup].style.fontSize = "14pt";
allInputs[countup].style.fontStyle = "normal";
}
countup = countup + 1;
}
}
countup = 0;
}

function showsindiv() {
var thisone = document.getElementById("show00");
var that = thisone.innerHTML;
alert (that);
thisone.style.background = "#ccffcc";

}

function checksolution() {
var allInputs = document.getElementsByTagName("input");
for (var i =0; i < 7; i++) {
	for (var j =0; j < 7; j++) {
if (allInputs[countup].type=="text") {

if (cells[i][j] == allInputs[countup].value) {

}
else {
var mistakes = "1";
}
}
countup = countup + 1;
}
}
countup = 0;
if (!mistakes) {
alert ("Congratulations! You got the answer right!");
}
else {
alert ("Sorry, your answer is not currently correct");
}
mistakes = 0;
}

function resetgrid() {

var allInputs = document.getElementsByTagName("input");
for (var i =0; i < 7; i++) {
	for (var j =0; j < 7; j++) {
if (allInputs[countup].type=="text") {
allInputs[countup].value = '';
}
countup = countup + 1;
}
}
countup = 0;
placevalues();
}

function helpcell() {

}
function savelastmove() {

}

//
var font, fcolor, setcheckval;
function showmistakes(thisrow,thiscol) {

var thisref = document.getElementById("cell"+thisrow+thiscol);
checkon = thisref.style.background;
if (checkon == "#000000") {
var setonto = scol[thisrow][thiscol]; 
setcolor = carray[setonto-1];
thisref.style.background = setcolor;
thisref.style.color = "#000000";
}
else {
//set color to black
thisref.style.background = "#000000";
thisref.style.color = "#ffffff";
}
}
