
if (window.XMLHttpRequest){

          // If IE7, Mozilla, Safari, etc: Use native object
          var objXml = new XMLHttpRequest()

}
else
{
if (window.ActiveXObject){

          // ...otherwise, use the ActiveX control for IE5.x and IE6
          var objXml = new ActiveXObject("Microsoft.XMLHTTP");
          }

}

function highlight(therowID){
		document.getElementById(therowID).style.backgroundColor = "#caffca";
}

function unhighlight(therowID){
		document.getElementById(therowID).style.backgroundColor = "#FFFFFF";
}


//highlighted coil cells
var selectedcoil = new Array();
var solved = 0;

function addcell(cellID) {
	selectedcoil.push(cellID)
}

function removecell(cellID) {
	var x=0
	for (x=0; x<selectedcoil.length; x++)
	{
		if (selectedcoil[x] == cellID) {
			selectedcoil.splice(x,1)
		}
	}
}

s = ''
	
function solve(r,objID)
{
	
	var thepath = selectedcoil.toString()
	var resp = document.getElementById("solution")
	
	if (solved == 0) {
		
		s = s + r + ',';
		var url = "solve.cfm?path="+thepath+"&objID="+objID;
		
		new Ajax.Request(url, {
		  method: 'get',
		  onSuccess: function(transport) {
		   	var theresponse = transport.responseText;
			theresponse = theresponse.slice(theresponse.lastIndexOf("|")+1,theresponse.length);
			
		    if (theresponse != '')
			{
				resp.innerHTML = theresponse;
				
			}
				
			document.getElementById(r).className = "coilhighlighted";
			var ismiss = transport.responseText;
			
			ismiss = ismiss.slice(ismiss.indexOf("|")+1,ismiss.lastIndexOf("|"));
			
			if (theresponse.match("Good Job"))
				{
					coilsolved();
					Stop();
					solved = 1;
					//Reset();
				}
			if (ismiss.search('||') > -1) {
				highlightwrong("row" + ismiss);
			}
		  }
		});

	}
	
}

function coilsolved()
{
	document.getElementById('hint').innerHTML = '';
}

function highlightwrong(therowID){
	document.getElementById(therowID).className = 'coilwrong';
	removecell(therowID);
}

function rate(objID,rating)
{
	var resp = document.getElementById("solution")
	
		objXml.open("GET","rate.cfm?objID="+objID+"&rating="+rating, true);
		objXml.onreadystatechange=function() {
				if (objXml.readyState==4) {
					resp.innerHTML=objXml.responseText;
					
				}
			}
			objXml.send(null);
}


function hint(objID)
{
	var thepath = selectedcoil.toString()
	
	if (solved == 0) {
		//resp.innerHTML='<strong>Checking Solution...</strong>';
		objXml.open("GET","hint.cfm?path="+thepath+"&objID="+objID, true);
		objXml.onreadystatechange=function() {
				if (objXml.readyState==4) {
						var theresponse = objXml.responseText;
						theresponse = theresponse.replace(' ','');
						//alert(theresponse.indexOf("|"));
						//alert(theresponse.lastIndexOf("|"));
						
						theresponse = theresponse.slice(theresponse.indexOf("|")+1,theresponse.lastIndexOf("|"));
						
						//alert(theresponse);
						highlight(theresponse);
						
						solve(theresponse,objID);
				}
			}
			objXml.send(null);
	}
	
}


<!--
// please keep these lines on when you copy the source
// made by: Nicolas - http://www.javascript-page.com

var timerID = 0;
var tStart  = null;

function UpdateTimer() {
   if(timerID) {
      clearTimeout(timerID);
      clockID  = 0;
   }

   if(!tStart)
      tStart   = new Date();

   var   tDate = new Date();
   var   tDiff = tDate.getTime() - tStart.getTime();

   tDate.setTime(tDiff);
   
   mytimer = document.getElementById("thetimer")
   mytimer.innerHTML = 'Your estimated time: ' + tDate.getMinutes() + ":" + tDate.getSeconds() + '';
   
   timerID = setTimeout("UpdateTimer()", 1000);
}

function Start() {
   tStart   = new Date();

   mytimer = document.getElementById("thetimer")
   mytimer.innerHTML = 'Your estimated time: 0:0';

   timerID  = setTimeout("UpdateTimer()", 1000);
}

function Stop() {
   if(timerID) {
      clearTimeout(timerID);
      timerID  = 0;
   }

   tStart = null;
}

function Reset() {
   tStart = null;

   mytimer = document.getElementById("thetimer")
   mytimer.innerHTML = 'Your estimated time: 0:0';
}

//-->
