var intSelectedNumber = 10;
var errorCellsToColor = '';
var gameTimerSec = -1;
var gameTimerMin = 0;
var gameTimerHour = 0;
function gameTimerFunc() {
gameTimerSec++;
if (gameTimerSec==60){
gameTimerSec=0;
gameTimerMin++;
}
if (gameTimerMin==60) {
gameTimerMin=0;
gameTimerHour++;
}
document.getElementById('gameTimer').innerHTML = ((gameTimerHour<=9)?'0'+gameTimerHour:gameTimerHour)+':'+((gameTimerMin<=9)?'0'+gameTimerMin:gameTimerMin)+':'+((gameTimerSec<=9)?'0'+gameTimerSec:gameTimerSec);
setTimeout("gameTimerFunc()", 1000);
}
//addLoadEvent(gameTimerFunc());
function closeInfoPop(){
document.getElementById("infoPop").style.display = "none";
}
function loadurl(dest){
resetBoardColors();
document.getElementById("serverOutput").innerHTML = "
Contacting server.

";
var intLeftPos = (document.body.clientWidth - 335) / 2;
document.getElementById("infoPop").style.left = intLeftPos+'px';
document.getElementById("infoPop").style.display = "block";
try{ xmlhttp = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP"); }
catch (e){ /* do nothing */ }
xmlhttp.onreadystatechange = triggered;
xmlhttp.open("GET", dest);
xmlhttp.send(null);
}
function triggered(){
if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200)){
// check to see if we need to color some error cells...
errorCellsToColor = xmlhttp.responseText.substring(0,xmlhttp.responseText.indexOf('|'));
htmlMessage = xmlhttp.responseText.substring(xmlhttp.responseText.indexOf('|')+1);
highlightSelectedNumber(intSelectedNumber);
document.getElementById("serverOutput").innerHTML = htmlMessage;
}
}
function checkBoard(){
var boardCheckURL = 'check.php?s=';
var elem = document.getElementById('game').elements;
for(var i = 0; i < elem.length; i++){
if (elem[i].type == 'text' || elem[i].type == 'hidden') tempVal = elem[i].value;
if (tempVal == '') tempVal = '-';
boardCheckURL += tempVal;
}
loadurl(boardCheckURL);
}
function resetBoardColors(){
for(i=0;i<81;i++){
thisElName = 'tCell'+i;
document.getElementById(thisElName).style.backgroundColor = "transparent";
if (document.getElementById(thisElName).innerHTML.indexOf("type='text'")){
thisElName = 'fCell'+i;
document.getElementById(thisElName).style.color = "#999999";
}
}
}
function highlightSelectedNumber(n){
intSelectedNumber = n;
resetBoardColors();
var elem = document.getElementById('game').elements;
for(var i = 0; i < elem.length; i++){
if (elem[i].value == intSelectedNumber){
thisElName = elem[i].name.replace(/fCell/g,"tCell");
document.getElementById(thisElName).style.backgroundColor = "#eeeeee";
}
}
updateUnsolved();
colorErrorCells();
}
function checkInput(strIn) {
strOut = '';
if (strIn != ''){
for (var i=0, valid="123456789"; i 0){
return true;
}else{
alert('Select the difficulty level you want to play at.');
document.getElementById('newPuzzle').elements['intLevel'].focus();
return false;
}
}
function handleElClick(elID){
if (intSelectedNumber>0 && intSelectedNumber<10 && document.getElementById(elID).value==''){
document.getElementById(elID).value = intSelectedNumber;
}else if (intSelectedNumber>0 && intSelectedNumber<10 && document.getElementById(elID).value==intSelectedNumber){
document.getElementById(elID).value = '';
}
if (errorCellsToColor != ''){
arErrorCells = errorCellsToColor.split(',');
strNewErrorCells = '';
cellNum = elID.replace(/fCell/g,"");
for(var i = 0; i < arErrorCells.length; i++){
//alert(arErrorCells[i]+' - '+cellNum);
if (arErrorCells[i] != cellNum){
if (strNewErrorCells != '') strNewErrorCells += ',';
strNewErrorCells += arErrorCells[i];
}
}
//alert(errorCellsToColor+' -> '+strNewErrorCells);
errorCellsToColor = strNewErrorCells;
}
highlightSelectedNumber(intSelectedNumber);
}
function addLoadEvent(func) {
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
}else{
window.onload = function() {
if (oldonload) {
oldonload();
}
func();
}
}
}
function colorErrorCells(){
if (errorCellsToColor != ""){
arErrorCellsToColor = errorCellsToColor.split(',');
for(var i = 0; i < arErrorCellsToColor.length; i++){
tCellName = 'tCell'+arErrorCellsToColor[i];
fCellName = 'fCell'+arErrorCellsToColor[i];
document.getElementById(tCellName).style.backgroundColor = "#f45c5c";
document.getElementById(fCellName).style.color = "#ffffff";
}
}
}
function showTab(intTabID){
var elem = document.getElementById('topTabs').getElementsByTagName('li');
for(var i = 0; i < elem.length; i++) elem[i].className="";
var elem = document.getElementById('selectedTabContentWrapper').getElementsByTagName('div');
for(var i = 0; i < elem.length; i++) elem[i].style.display = "none";
var thisTabName = 'tab'+intTabID;
var thisContentName = 'tabContent'+intTabID;
document.getElementById(thisTabName).className='selected';
document.getElementById(thisContentName).style.display='block';
}
function leaveClan(){
if (confirm('Are you SURE you want to leave your clan?!?!')){
document.location = '/clan_leave_clan.php';
}
}
function kickClanMember(uID){
if (confirm('Are you SURE you want to kick this person out of your clan?!?!')){
document.location = '/clan_kick_member.php?uID='+uID;
}
}