var AdultChoices;
var ExpChoices, seenExp;
var ChildChoices, seenChild;

function ShowPlanName(plan) {
  document.write( PlanNames[plan] );
}

function BulletItems() {
    var allAnswered = 1;

    if( AdultChoices ) {    // were all adult results questions answered?
	var i;
	for(i=0; i<NumPlans; i++) {
	  if( AdultChoices[i] == 0 ) {
	    allAnswered = 0;
	    break;
	  }
	}
    }
    else
	allAnswered = 0;

    if( allAnswered && ChildChoices ) {  // were all child results questions answered?
	var i;
	for(i=0; i<NumPlans; i++) {
	  if( ChildChoices[i] == 0 ) {
	    allAnswered = 0;
	    break;
	  }
	}
    }

    if( allAnswered && ExpChoices ) {  // were all exp user results questions answered?
	var i;
	for(i=0; i<NumPlans; i++) {
	  if( ExpChoices[i] == 0 ) {
	    allAnswered = 0;
	    break;
	  }
	}
    }


    // display the following if any questions were unanswered.

    if( allAnswered == 0 ) {
      document.writeln( '<li>'
	+ 'The "?" symbol in Your Worksheet indicates that you didn\'t answer  '
	+ 'all the questions in the Survey Results section.  Click on the "?" symbol '
	+ 'to go back to the Survey Results section and answer the questions.<p>'
	//+ 'Go back to <a href="ratin3c.htm"><b>Review '
	//+ 'the Survey Results</b></a> '
	//+ 'and answer the questions.  Your answers will appear in Your '
	//+ 'Worksheet.'
	);
    }

    document.write( '<li>You can fill out the last three columns after you collect more '
	+ 'information from your benefits office, the plans, and your doctor.'
	);
}


function InitWorkSheet() {
    seenChild = GetCookie("seenChild");
    seenExp = GetCookie("seenExp");
    ExpChoices = GetCookie("expchoices");
    ChildChoices = GetCookie("childchoices");
    AdultChoices = GetCookie("adultchoices");

//debug
//document.write('AdultChoices:' + AdultChoices + '<br>');

}

function WorkSheetHeadings() {
    var colSpan = 1;

//var x = GetCookie("seenChild");
//alert("seenChild cookie=(" + x + ")");

    if( seenChild ) {
	colSpan += 1
    }

//var x = GetCookie("seenExp");
//alert("seenExp cookie= " + x + ")");

    if( seenExp ) {
	colSpan += 1;
    }

    document.write( '<tr>' );
    document.write( '<td colspan=2><br></td>' );
    document.write( '<td colspan=' + colSpan + ' bgcolor="#ffffff"><center>' );
    document.write( '<font size=-1 color="#AA0000">Here are your answers from '
	+ 'the Survey Results section.</font></center></td>'
	+ '<td colspan=3 bgcolor="#ffffff"><center><font size=-1 color="#AA0000">'
	+ 'Answer these questions using<br>the information you collect.</font></center></td>'
	+ '</tr>'
	);

    document.writeln( '<tr>' );
    document.writeln( '<td width=55 valign=bottom>'
	+ '<img src="images/blank.gif" border=0 height=1 width=55>'
	+ '</td><td width=40 bgcolor="#cccc99" valign=bottom>'
	+ '<font size=-1><b>Plan Type</b></td>'
	+ '<td bgcolor="#cccc99" valign=bottom><font size=-1>'
	+ '<b>Did this plan do well for '
	+ '<a href="ratin3c.htm">adults</a>?</b></td>'
	);

    if( seenChild )
      document.writeln( '<td bgcolor="#cccc99" valign=bottom><font size=-1>'
	+ '<b>Did this plan do well on '
	+ '<a href="ratin4c.htm">children\'s care</a>?</b></td>'
	);

    if( seenExp )
      document.writeln( '<td bgcolor="#cccc99" valign=bottom><font size=-1>'
	+ '<b>Did this plan do well for '
	+ '<a href="ratin5c.htm">people with 3\+ visits</a>?</b></td>'
	);

    document.write( '<td bgcolor="#cccc99" valign=bottom><font size=-1><b>Does the plan have '
	+ '<a href="doctors1.htm">doctors</a> you like?</b></td>'
	+ '<td bgcolor="#cccc99" valign=bottom><font size=-1><b>Does the plan have '
	+ '<a href="benefit1.htm">benefits</a> you want?</b></td>'
	+ '<td bgcolor="#cccc99" valign=bottom><font size=-1><b>Does the plan have '
	+ '<a href="costs1.htm"">costs</a> you can afford?</b></td>'
	);
    document.writeln( '</tr>' );

//  ExpChoices = GetCookie("expchoices");
//  ChildChoices = GetCookie("childchoices");
//  AdultChoices = GetCookie("adultchoices");

return;
//debug

    if( ExpChoices )
    alert("ExpChoices:1=" + ExpChoices[0]
	+ ",2=" + ExpChoices[1]
	+ ",3=" + ExpChoices[2]
	+ ",4=" + ExpChoices[3]
	+ ",5=" + ExpChoices[4]
	);
    if( AdultChoices )
    alert("AdultChoices:1=" + AdultChoices[0]
	+ ",2=" + AdultChoices[1]
	+ ",3=" + AdultChoices[2]
	+ ",4=" + AdultChoices[3]
	+ ",5=" + AdultChoices[4]
	);
    if( ChildChoices )
    alert("ChildChoices:1=" + ChildChoices[0]
	+ ",2=" + ChildChoices[1]
	+ ",3=" + ChildChoices[2]
	+ ",4=" + ChildChoices[3]
	+ ",5=" + ChildChoices[4]
	);
}

function ShowWorkSheetRow(plan) {
  var ans;

  document.writeln( '<tr>' );
  document.writeln( '<td bgcolor="#cccc99"><font size=-1>'
    + PlanNames[plan] + '</font></td>' );

  document.writeln( '<td bgcolor="#eeeecc"><font size=-1>'
    + PlanType[plan] + '</font></td>' );

  // always show adult column
  //
  //ans = '?';
  ans = '<a href=ratin3c.htm><font size=+1>?</font></a>';

  var x = 0;

  if( AdultChoices ) {
    //x = AdultChoices[plan-1]; //debug
    x = AdultChoices.substr(plan-1,1);

    //if( AdultChoices[plan-1] == 1 ) {
    if( x == 1 ) {
      ans = 'Yes';
    }
    //else if( AdultChoices[plan-1] == 2 ) {
    else if( x == 2 ) {
      ans = 'No';
    }
    else {
      //ans = '?';
      ans = '<a href=ratin3c.htm><font size=+1>?</font></a>';
      //ans = '&nbsp;';
    }
  }
  document.writeln( '<td align=center bgcolor="#eeeecc"><b>' + ans + '</b></td>' );
  //debug
  //document.writeln( '<td align=center bgcolor="#eeeecc"><b>' + ans +
  // 'ac=' + AdultChoices + 'plan=' + plan + 'x=' + x + '</b></td>' );

  if( seenChild ) { // show child column if child ratings were viewed
    if( ChildChoices ) {
      x = ChildChoices.substr(plan-1,1);

      //if( ChildChoices[plan-1] == 1 )
      if( x == 1 )
	ans = 'Yes';
      //else if( ChildChoices[plan-1] == 2 )
      else if( x == 2 )
	ans = 'No';
      else
      // ans = '?';
      //ans = '&nbsp;';
	ans = '<a href=ratin4c.htm><font size=+1>?</font></a>';
    }
    else {
      ans = '<a href=ratin4c.htm><font size=+1>?</font></a>';
      //ans = '?';
    }
    document.writeln( '<td align=center bgcolor="#eeeecc"><b>' + ans + '</b></td>' );
  }

  if( seenExp ) {   // show exp user column if exp user ratings were viewed
    if( ExpChoices ) {
      x = ExpChoices.substr(plan-1,1);
      //if( ExpChoices[plan-1] == 1 )
      if( x == 1 )
	ans = 'Yes';
      //else if( ExpChoices[plan-1] == 2 )
      else if( x == 2 )
	ans = 'No';
      else
	//ans = '&nbsp;';
	ans = '<a href=ratin5c.htm><font size=+1>?</font></a>';
	//ans = '?';
    }
    else {
      //ans = '?';
	ans = '<a href=ratin5c.htm><font size=+1>?</font></a>';
    }
    document.writeln( '<td align=center bgcolor="#eeeecc"><b>' + ans + '</b></td>' );
  }

  document.write( '<td bgcolor="#eeeecc">&nbsp;</td>' );
  document.write( '<td bgcolor="#eeeecc">&nbsp;</td>' );
  document.write( '<td bgcolor="#eeeecc">&nbsp;</td>' );

  document.writeln( '</tr>' );
}

function ShowWorkSheet() {
  var i;

  WorkSheetHeadings();
//for(i = 1; i <= NumPlans; i++)
//  ShowWorkSheetRow(i);

  var pt, list;
  for (pt in PlanTypes) {
    list = PlanTypes[pt].split(",");
    for (i in list) {
      ShowWorkSheetRow( list[i] );
    }
  }

}


