var res = false;

if (window.focus) self.focus();



/*
get the binary value 
 of an array of controls where the 
 value is 2 raised to the index of each 
 checked control
 ie element 0 : 2 ^ 0 returns 1
elements 0 and 2 : 2^0 + 2^2 returns 5 */
//create binary rep. of checkbox state; index into responses 
/* technote: bitwise left shift operator used to optimize code (eliminates
 the need of doing code like: form.elements[i].checked * (Math.pow(2,combodex-i));
*/


function getResponse(form) {
  var numChoices = 5;
  var combodex = numChoices;
  var combo = 0;
  
  combodex--; // so that combo will be assigned a zero-based index for array.
  
  for (var i=0; i < numChoices; i++){
      combo += form.elements[i].checked << (combodex - i) ;
      
  }
  
  if (combo == 26) { combo = 10; }       // answers #26 and #10 are the same
  if (combo == 29) { combo = 28; }       // answers #29 and #28 are the same
  
  
  // testing with bad result:
  //combo = 42;
  // end testing
  
  document.forms[0].elements['combo'].value = combo;
  res = Validate(combo);

  //form.responseText.value = response[combo];
}

function Validate(val)
{   
  //alert('in function and val is ' + val);
     if ( (val >= 0) &&  (val <= 31) )
	 {
	     return true;
	 }
	 else
	 {
	     return false;
	}	 
}
function PuffAppear()
{
Effect.Puff('jdm');
setTimeout("$('artborder').morph('height:100px;')",1000);
setTimeout("$('artborder').style.background='transparent'",1500); 
setTimeout("Effect.Appear('jdmtab')",1000);
setTimeout("Effect.Appear('resp')",1000);
setTimeout("Effect.Appear('nav')",1000);
}

function morphColorShape()
{
	$('pic').morph('background:#990033; height:130px;');
}

function restoreColorShape()
{
	$('pic').morph('background:#ff9999; height:65px');
}


function ajaxMe()
{
//ajax updater sets mydiv to value returned by php script.
    var objx = Form.getElements("actionplan");
	// workaround b/c I couldn't get Forms.serialize("myform")
	var parms = ""; 
	for (var i=0, max = objx.length-1; i<max; i++)
	{
		parms += objx[i].id + "=" + objx[i].value + "&";
	}
	new Ajax.Updater("dm_decision", "decisionsResponse-3.php", {                    
 		method : 'post',
 		parameters : parms,
 		onFailure : function(resp) {
  			 alert("Oops, there's been an error.");
 		}
 	});
}  




