//******************************************************************************* 
//  solutions.js
//******************************************************************************* 
	
function doClear ( form ) {	
 	document.form0.onReset = " return confirm('Are you sure that you want to clear all the data you have entered on this form?')";
  	document.form0.reset();	
}	

function doPutCheckBoxes () {
//******************************************************************************* 
//  This rtn is called when the solutions-form.html page is displayed.
//  Teh cookie is read and the appropropriate checkboxes are checked.
//  The actuall rtn is called from HM_Loader.js, since this is where the onload
//  event is performed.
//******************************************************************************* 
	var ans = 1;
	var theSolutions = getCookie("solutions");   // eg "x0000101110110..."
//	if (theSolutions == null) {
//		alert ("Please check the solutions you want.");
//		return;	
//	}
     
	var len = theSolutions.length
   	for (ix = 1; ix < len; ix++) {
   		if (theSolutions.substr(ix, 1) == "0") {
   			sol = 0;
   		}	
   		else {
   			sol = 1;
   		}	
   		eval("document.form0.Solution_" + ix + ".checked = " + sol);  
	} 
}		


function doGetCheckBoxes ( form ) {	
//******************************************************************************* 
//  Rtn for solutions.html page
// Get the boxes that are checked and store in the solutions cookie.
//******************************************************************************* 
//	var firstmessage="The following questions still need to be answered to determine your ad IQ:\n\n ";
	var errormessage="";
	var solutions = "x";
	
// To remove validation for testing, change one of the numbers to 0.
if (1 == 1) {
	
    var q = new makeArrayImplic("x","x","x","x","x","x","x","x","x","x","x","x","x","x","x","x","x","x","x","x");    
	
	if (document.form0.Solution_1.checked == 1)  q[1] = "1"; else q[1] = "0";
	if (document.form0.Solution_2.checked == 1)  q[2] = "1"; else q[2] = "0";
	if (document.form0.Solution_3.checked == 1)  q[3] = "1"; else q[3] = "0";
	if (document.form0.Solution_4.checked == 1)  q[4] = "1"; else q[4] = "0";
	if (document.form0.Solution_5.checked == 1)  q[5] = "1"; else q[5] = "0";
	if (document.form0.Solution_6.checked == 1)  q[6] = "1"; else q[6] = "0";
	if (document.form0.Solution_7.checked == 1)  q[7] = "1"; else q[7] = "0";
	if (document.form0.Solution_8.checked == 1)  q[8] = "1"; else q[8] = "0";
	if (document.form0.Solution_9.checked == 1)  q[9] = "1"; else q[9] = "0";
	if (document.form0.Solution_10.checked == 1)  q[10] = "1"; else q[10] = "0";
	if (document.form0.Solution_11.checked == 1)  q[11] = "1"; else q[11] = "0";
	if (document.form0.Solution_12.checked == 1)  q[12] = "1"; else q[12] = "0";
	if (document.form0.Solution_13.checked == 1)  q[13] = "1"; else q[13] = "0";
	if (document.form0.Solution_14.checked == 1)  q[14] = "1"; else q[14] = "0";
	if (document.form0.Solution_15.checked == 1)  q[15] = "1"; else q[15] = "0";
	if (document.form0.Solution_16.checked == 1)  q[16] = "1"; else q[16] = "0";
	if (document.form0.Solution_17.checked == 1)  q[17] = "1"; else q[17] = "0";
	if (document.form0.Solution_18.checked == 1)  q[18] = "1"; else q[18] = "0";
	if (document.form0.Solution_19.checked == 1)  q[19] = "1"; else q[19] = "0";
     
    for (ix = 1; ix < 20; ix++) {
 		solutions = solutions + q[ix];
    }
  //alert(solutions);  
}  // end 1 = 1 test 
   
   if (errormessage!="") { alert (firstmessage + errormessage)}
   else {
     setCookie("solutions", solutions); 
     location.href = "solutions-form.html";
//	return(0);  
   }
   
}  

function makeArraySimple (NumElements) {
	var Count;
	this.length = NumElements;
	for (Count = 1; Count <= NumElements; Count++)
		this[Count]=0;
	return (this);
} 
function assocArray (NumElements) {
//*-------------------------------------------------------------
//* Make an associative array
//*-------------------------------------------------------------
	this.length = NumElements;
	return(this);
} 

function allowInString (InString, RefString)  {
	if(InString.length==0) return (false);
	for (Count=0; Count < InString.length; Count++)  {
		TempChar= InString.substring (Count, Count+1);
		if (RefString.indexOf (TempChar, 0)==-1)  
			return (false);
	}
	return (true);
}

function makeArray (NumElements, Fill)  {
	var Count;
	this.length = NumElements;
	for (Count = 1; Count <= NumElements; Count++)  {
		this[Count] = Fill;
	}
	return (this);
}

function makeArrayImplic () {
//*-------------------------------------------------------------
//* Make a 1 dimensional array of from lines.
//*-------------------------------------------------------------
	var count;
	this.length = makeArrayImplic.arguments.length;
	for ( count=1; count < makeArrayImplic.arguments.length+1; count++)
	  {	this[count] = makeArrayImplic.arguments[count-1]; }
	return (this);
}

