//////////////////////////////////////////////////////////////////////
//
// This file contains javascript for the completed nonogram pages
// If you came here looking for the answers, sorry, they're not here!
//
//////////////////////////////////////////////////////////////////////

	var NUM_PUZZLES = 10;

	function setCookie(thisPuzzle) {
		if (puzzleDone(thisPuzzle)) return;
		var puzzlesDone = getCookieParm("nonosDone");
		var expiry = new Date();
		var oneYearFromNow = expiry.getTime() + (365 * 24 * 60 * 60 * 1000);
		expiry.setTime(oneYearFromNow);
		document.cookie = "nonosDone=" + puzzlesDone + thisPuzzle + ";expires=" + expiry.toGMTString() + ";path=/;";
	}
	function puzzleDone(puzzleNum) {
		if (puzzleNum == 10) return puzzleDone('a');
		var puzzlesDone = getCookieParm("nonosDone");
		if (puzzlesDone.indexOf(puzzleNum) >= 0) return true;
		return false;
	}
	function getCookieParm(paramName) {
		var cookieVal = "; " + document.cookie + "; ";
		var sPos = cookieVal.indexOf("; " + paramName + "=");
		if (sPos < 0) return "";
		var ePos = cookieVal.indexOf("; ", sPos + 3);
		cookieVal = cookieVal.substring(sPos + paramName.length + 3, ePos);
		return cookieVal;
	}

	function getProgress() {
		var retVal = "<p class='smallTitle'>Current Progress</p>";
		retVal += "<table border='0'>";
		var allDone = true;
		for (i=1; i<=NUM_PUZZLES; i++) {
			retVal += "<tr><td><img src='../../images/clear.gif' width='50' height='1' alt=''></td><td>Puzzle " +
			 i + "</td><td><img src='../../images/clear.gif' width='5' height='1' alt=''></td><td>";
			if (puzzleDone(i))
				retVal += "<img src='tick.gif' width='25' height='25' alt='finished'>";
			else {
				retVal += "<img src='notick.gif' width='25' height='25' alt='not done yet'>";
				allDone = false;
			}
			retVal += "</td></tr>";
		}
		retVal += "</table>";
		if (allDone) {
			retVal += "<p class='sectionTitle'>You've finished them all!</p>" +
			 "<p>Now see if you can solve them as fast as the <a href='solver.html'>solver</a> can!</p>";
		}
		return retVal;
	}
