var no = 0;
var yes = 1;

function item(name, perc)
{
        this.name = name;
        this.perc = perc;
}

bond = new item(6);

bond[0] = new item('Sean Connery', 0);
bond[1] = new item('George Lazenby', 0);
bond[2] = new item('Roger Moore', 0);
bond[3] = new item('Timothy Dalton', 0);
bond[4] = new item('Pierce Brosnan', 0);
bond[5] = new item('Daniel Craig', 0);

function change(who, n, perc, yesno)
{
	if (yesno == yes)
	{
		bond[who].perc = bond[who].perc + Math.round(n*perc);	
	}
	else // if yesno == no
	{
		bond[who].perc = bond[who].perc + Math.round(4*perc) - Math.round(n*perc);
	}
} // end function change()


function update()
{
	var sean = 0;
	var sean100 = 3;	// 12 * 7 = 84 (3)
	var sean75 = 2.5;	// 10 * 1 = 10 (2.5)
	var sean50 = 1.5;	// 6 * 1 = 6 (1.5)
	var george = 1;
	var george100 = 2.75;	// 11 * 8 = 88 (2.75)
	var george50 = 1.5;		// 6 * 2 = 12 (1.5)
	var roger = 2;
	var roger100 = 3.125;	// 12.5 * 8 = 100 (3.125)
	var timothy = 3
	var timothy100 = 3.75;		// 15 * 6 = 90 (3.75)
	var timothy50 = 2.5;		// 10 * 1 = 10 (2.5)
	var pierce = 4;
	var pierce100 = 3;		// 12 * 7 = 84 (3)
	var pierce50 = 2;		// 8 * 2 = 16 (2)
	var daniel = 5;
	var daniel100 = 3.75;		// 15 * 6 = 90 (3.75)
	var daniel50 = 2.5;		// 10 * 1 = 10 (2.5)
	
	  
	for (var n = 0; n < 6; n++)
		bond[n].perc = 0;
			
	// Have you been in the Navy?
	for (n = 0; n < 5; n++)
	{
		if (document.fm.sean1[n].checked)
		{
			change(sean, n, sean100, yes);	
		}
	}
	
	// Are you suave?
	for (n = 0; n < 5; n++)
	{
		if (document.fm.sean2[n].checked)
		{
			change(sean, n, sean75, yes);	
			change(george, n, george50, yes);
			change(roger, n, roger100, yes);
			change(pierce, n, pierce50, yes);
		}
	}
	
	// Do you have a Scottish accent?
	for (n = 0; n < 5; n++)
	{
		if (document.fm.sean3[n].checked)
		{
			change(sean, n, sean100, yes);	
		}
	}
	
	// Do you have an English accent?
	for (n = 0; n < 5; n++)
	{
		if (document.fm.sean4[n].checked)
		{
			change(sean, n, sean50, yes);
			change(george, n, george50, yes);
			change(roger, n, roger100, yes);
			change(timothy, n, timothy50, yes);	
			change(pierce, n, pierce50, yes);
			change(daniel, n, daniel100, yes);
		}
	}
	
	// Are you muscular?
	for (n = 0; n < 5; n++)
	{
		if (document.fm.sean5[n].checked)
		{
			change(sean, n, sean100, yes);
			change(daniel, n, daniel50, yes);	
		}
	}
	
	// Are you gritty?
	for (n = 0; n < 5; n++)
	{
		if (document.fm.sean6[n].checked)
		{
			change(sean, n, sean100, yes);	
			change(timothy, n, timothy100, yes);
			change(daniel, n, daniel100, yes);
		}
	}
	
	// Have you been knighted?
	for (n = 0; n < 5; n++)
	{
		if (document.fm.sean7[n].checked)
		{
			change(sean, n, sean100, yes);	
		}
	}
	
	// Do you have light colored hair?
	if (document.fm.sean8[0].checked)
	{
		bond[sean].perc = bond[sean].perc + Math.round(sean100*1);
		bond[george].perc = bond[george].perc + Math.round(george100*3);
		bond[roger].perc = bond[roger].perc + Math.round(roger100*1);
		bond[timothy].perc = bond[timothy].perc + Math.round(timothy100*3);
		bond[pierce].perc = bond[pierce].perc + Math.round(pierce100*4);
		bond[daniel].perc = bond[daniel].perc + Math.round(daniel100*0);
	}
	if (document.fm.sean8[1].checked)
	{
		bond[sean].perc = bond[sean].perc + Math.round(sean100*2);
		bond[george].perc = bond[george].perc + Math.round(george100*4);
		bond[roger].perc = bond[roger].perc + Math.round(roger100*2);
		bond[timothy].perc = bond[timothy].perc + Math.round(timothy100*4);
		bond[pierce].perc = bond[pierce].perc + Math.round(pierce100 *3);
		bond[daniel].perc = bond[daniel].perc + Math.round(daniel100*1);	
	}
	if (document.fm.sean8[2].checked)
	{
		bond[sean].perc = bond[sean].perc + Math.round(sean100*4);
		bond[george].perc = bond[george].perc + Math.round(george100*3);
		bond[roger].perc = bond[roger].perc + Math.round(roger100*3);
		bond[timothy].perc = bond[timothy].perc + Math.round(timothy100*3);
		bond[pierce].perc = bond[pierce].perc + Math.round(pierce100*2);
		bond[daniel].perc = bond[daniel].perc + Math.round(daniel100*2);	
	}
	if (document.fm.sean8[3].checked)
	{
		bond[sean].perc = bond[sean].perc + Math.round(sean100*2);
		bond[george].perc = bond[george].perc + Math.round(george100*2);
		bond[roger].perc = bond[roger].perc + Math.round(roger100*4);
		bond[timothy].perc = bond[timothy].perc + Math.round(timothy100*2);
		bond[pierce].perc = bond[pierce].perc + Math.round(pierce100*1);
		bond[daniel].perc = bond[daniel].perc + Math.round(daniel100*3);
	}	
	if (document.fm.sean8[4].checked)
	{
		bond[sean].perc = bond[sean].perc + Math.round(sean100*1);
		bond[george].perc = bond[george].perc + Math.round(george100*1);
		bond[roger].perc = bond[roger].perc + Math.round(roger100*3);
		bond[timothy].perc = bond[timothy].perc + Math.round(timothy100 *1);
		bond[pierce].perc = bond[pierce].perc + Math.round(pierce100*0);
		bond[daniel].perc = bond[daniel].perc + Math.round(daniel100*4);
	}
	
	// Do you have a hairy chest?
	for (n = 0; n < 5; n++)
	{
		if (document.fm.sean9[n].checked)
		{
			change(sean, n, sean100, yes);
			change(george, n, george100, yes);
			change(roger, n, roger100, no);	
			change(timothy, n, timothy100, no);
			change(pierce, n, pierce100, yes);
			change(daniel, n, daniel100, no);
		}
	}
	
	// Do you have an Australian accent?
	for (n = 0; n < 5; n++)
	{
		if (document.fm.george1[n].checked)
		{
			change(george, n, george100, yes);	
		}
	}
	
	// Are you a Model?
	for (n = 0; n < 5; n++)
	{
		if (document.fm.george2[n].checked)
		{
			change(george, n, george100, yes);	
		}
	}
	
	// Have you married a Bond girl?
	for (n = 0; n < 5; n++)
	{
		if (document.fm.george3[n].checked)
		{
			change(george, n, george100, yes);
			change(pierce, n, pierce100, yes);	
		}
	}
	
	// Are you arrogant?
	for (n = 0; n < 5; n++)
	{
		if (document.fm.george4[n].checked)
		{
			change(george, n, george100, yes);	
		}
	}
	
	// Have you been in the army?
	for (n = 0; n < 5; n++)
	{
		if (document.fm.george5[n].checked)
		{
			change(george, n, george100, yes);
			change(roger, n, roger100, yes);	
		}
	}
	
	// Have you been in love?
	for (n = 0; n < 5; n++)
	{
		if (document.fm.george6[n].checked)
		{
			change(george, n, george100, yes);	
			change(daniel, n, daniel100, yes);
		}
	}
	
	// Are you a pretty boy?
	for (n = 0; n < 5; n++)
	{
		if (document.fm.roger1[n].checked)
		{
			change(roger, n, roger100, yes);	
		}
	}
	
	// Do you enjoy the spotlight?
	for (n = 0; n < 5; n++)
	{
		if (document.fm.roger2[n].checked)
		{
			change(roger, n, roger100, yes);	
		}
	}
	
	// Are you serious?
	for (n = 0; n < 5; n++)
	{
		if (document.fm.roger3[n].checked)
		{
			change(roger, n, roger100, no);	
		}
	}
	
	// Do you have a Welsh accent?
	for (n = 0; n < 5; n++)
	{
		if (document.fm.timothy1[n].checked)
		{
			change(timothy, n, timothy100, yes);	
		}
	}
	
	// Do you get angry a lot?
	for (n = 0; n < 5; n++)
	{
		if (document.fm.timothy2[n].checked)
		{
			change(timothy, n, timothy100, yes);
			change(pierce, n, pierce100, yes);	
		}
	}
	
	// Do you like to do study and research?
	for (n = 0; n < 5; n++)
	{
		if (document.fm.timothy3[n].checked)
		{
			change(timothy, n, timothy100, yes);	
		}
	}
	
	// Do you have an Irish accent?
	for (n = 0; n < 5; n++)
	{
		if (document.fm.pierce1[n].checked)
		{
			change(pierce, n, pierce100, yes);	
		}
	}
	
	// Are you a fire-eater?
	for (n = 0; n < 5; n++)
	{
		if (document.fm.pierce2[n].checked)
		{
			change(pierce, n, pierce100, yes);	
		}
	}
	
	// Are you mischievous?
	for (n = 0; n < 5; n++)
	{
		if (document.fm.pierce3[n].checked)
		{
			change(pierce, n, pierce100, yes);	
		}
	}
	
	// Do you make mistakes?
	for (n = 0; n < 5; n++)
	{
		if (document.fm.daniel1[n].checked)
		{
			change(daniel, n, daniel100, yes);	
		}
	}
	
	if (bond[roger].perc > 100)
		bond[roger].perc = 100;
	
	// The stuff below this line is for testing
	// to display the scores while answering:
	
	//document.fm.sean.value = bond[0].perc;
	//document.fm.george.value = bond[1].perc;
	//document.fm.roger.value = bond[2].perc;
	//document.fm.timothy.value = bond[3].perc;
	//document.fm.pierce.value = bond[4].perc;
	//document.fm.daniel.value = bond[5].perc;
	
	
}  // end function update





function copyForm()
{
	parent.location = 'result2.htm?a='+bond[0].perc+
		'&b='+bond[1].perc+
		'&c='+bond[2].perc+
		'&d='+bond[3].perc+
		'&e='+bond[4].perc+
		'&f='+bond[5].perc;
		
} // end copyForm()

document.write('<STYLE type="text/css"> TD { border-bottom:1px gray solid} </STYLE>');

var n = 0;

document.write('<TABLE><TR ALIGN="right"><TD>');
	
document.write('<FORM NAME="fm">');

//document.write('<TABLE><TR ALIGN="right"><TD>');
//document.write('<BR>sean <INPUT TYPE=TEXT NAME="sean" VALUE="0" SIZE="5">');
//document.write('<BR>george <INPUT TYPE=TEXT NAME="george" VALUE="0" SIZE="5">');
//document.write('<BR>roger <INPUT TYPE=TEXT NAME="roger" VALUE="0" SIZE="5">');
//document.write('<TD>');
//document.write('<BR>timothy <INPUT TYPE=TEXT NAME="timothy" VALUE="0" SIZE="5">');
//document.write('<BR>pierce <INPUT TYPE=TEXT NAME="pierce" VALUE="0" SIZE="5">');
//document.write('<BR>daniel <INPUT TYPE=TEXT NAME="daniel" VALUE="0" SIZE="5">');
//document.write('</TR></TABLE>');

document.write('<DIV STYLE="background-color: #FFFFFF; overflow: auto; width: 500px; height: 230; border-top: 1px gray solid; border-left: 1px gray solid; border-bottom: 1px gray solid; padding:0px; margin: 0px">');

document.write('<TABLE><COL WIDTH=250><COL WIDTH=200>');

document.write('<TR><TD>Have you been in the navy? <TD> (No)');
for (n = 0; n < 5; n++)
{
document.write('<INPUT TYPE="radio" NAME="sean1" value="'+ n +'" onClick="update()">');
}
document.write('(Yes)</TR>');

document.write('<TR><TD>Are you suave? <TD>(No)');
for (n = 0; n < 5; n++)
{
document.write('<INPUT TYPE="radio" NAME="sean2" value="'+ n +'" onClick="update()">');
}
document.write('(Yes)</TR>');

document.write('<TR><TD>Do you have a Scottish accent? <TD>(No)');
for (n = 0; n < 5; n++)
{
document.write('<INPUT TYPE="radio" NAME="sean3" value="'+ n +'" onClick="update()">');
}
document.write('(Yes)</TR>');

document.write('<TR><TD>Do you have an English accent? <TD>(No)');
for (n = 0; n < 5; n++)
{
document.write('<INPUT TYPE="radio" NAME="sean4" value="'+ n +'" onClick="update()">');
}
document.write('(Yes)</TR>');

document.write('<TR><TD>Are you muscular? <TD>(No)');
for (n = 0; n < 5; n++)
{
document.write('<INPUT TYPE="radio" NAME="sean5" value="'+ n +'" onClick="update()">');
}
document.write('(Yes)</TR>');

document.write('<TR><TD>Are you gritty? <TD>(No)');
for (n = 0; n < 5; n++)
{
document.write('<INPUT TYPE="radio" NAME="sean6" value="'+ n +'" onClick="update()">');
}
document.write('(Yes)</TR>');

document.write('<TR><TD>Have you been knighted? <TD>(No)');
for (n = 0; n < 5; n++)
{
document.write('<INPUT TYPE="radio" NAME="sean7" value="'+ n +'" onClick="update()">');
}
document.write('(Yes)</TR>');

document.write('<TR><TD>Do you have light colored hair? <TD>(No)');
for (n = 0; n < 5; n++)
{
document.write('<INPUT TYPE="radio" NAME="sean8" value="'+ n +'" onClick="update()">');
}
document.write('(Yes)</TR>');

document.write('<TR><TD>Do you have a hairy chest? <TD>(No)');
for (n = 0; n < 5; n++)
{
document.write('<INPUT TYPE="radio" NAME="sean9" value="'+ n +'" onClick="update()">');
}
document.write('(Yes)</TR>');

document.write('<TR><TD>Do you have an Australian accent? <TD>(No)');
for (n = 0; n < 5; n++)
{
document.write('<INPUT TYPE="radio" NAME="george1" value="'+ n +'" onClick="update()">');
}
document.write('(Yes)</TR>');

document.write('<TR><TD>Are you a model? <TD>(No)');
for (n = 0; n < 5; n++)
{
document.write('<INPUT TYPE="radio" NAME="george2" value="'+ n +'" onClick="update()">');
}
document.write('(Yes)</TR>');

document.write('<TR><TD>Have you married a Bond girl? <TD>(No)');
for (n = 0; n < 5; n++)
{
document.write('<INPUT TYPE="radio" NAME="george3" value="'+ n +'" onClick="update()">');
}
document.write('(Yes)</TR>');

document.write('<TR><TD>Are you arrogant? <TD>(No)');
for (n = 0; n < 5; n++)
{
document.write('<INPUT TYPE="radio" NAME="george4" value="'+ n +'" onClick="update()">');
}
document.write('(Yes)</TR>');

document.write('<TR><TD>Have you been in the army? <TD>(No)');
for (n = 0; n < 5; n++)
{
document.write('<INPUT TYPE="radio" NAME="george5" value="'+ n +'" onClick="update()">');
}
document.write('(Yes)</TR>');

document.write('<TR><TD>Have you been in love? <TD>(No)');
for (n = 0; n < 5; n++)
{
document.write('<INPUT TYPE="radio" NAME="george6" value="'+ n +'" onClick="update()">');
}
document.write('(Yes)</TR>');

document.write('<TR><TD>Are you a pretty boy? <TD>(No)');
for (n = 0; n < 5; n++)
{
document.write('<INPUT TYPE="radio" NAME="roger1" value="'+ n +'" onClick="update()">');
}
document.write('(Yes)</TR>');

document.write('<TR><TD>Do you enjoy the spotlight? <TD>(No)');
for (n = 0; n < 5; n++)
{
document.write('<INPUT TYPE="radio" NAME="roger2" value="'+ n +'" onClick="update()">');
}
document.write('(Yes)</TR>');

document.write('<TR><TD>Are you serious? <TD>(No)');
for (n = 0; n < 5; n++)
{
document.write('<INPUT TYPE="radio" NAME="roger3" value="'+ n +'" onClick="update()">');
}
document.write('(Yes)</TR>');

document.write('<TR><TD>Do you have a Welsh accent? <TD>(No)');
for (n = 0; n < 5; n++)
{
document.write('<INPUT TYPE="radio" NAME="timothy1" value="'+ n +'" onClick="update()">');
}
document.write('(Yes)</TR>');

document.write('<TR><TD>Do you get angry a lot? <TD>(No)');
for (n = 0; n < 5; n++)
{
document.write('<INPUT TYPE="radio" NAME="timothy2" value="'+ n +'" onClick="update()">');
}
document.write('(Yes)</TR>');

document.write('<TR><TD>Do you like to do study and research? <TD>(No)');
for (n = 0; n < 5; n++)
{
document.write('<INPUT TYPE="radio" NAME="timothy3" value="'+ n +'" onClick="update()">');
}
document.write('(Yes)</TR>');

document.write('<TR><TD>Do you have an Irish accent? <TD>(No)');
for (n = 0; n < 5; n++)
{
document.write('<INPUT TYPE="radio" NAME="pierce1" value="'+ n +'" onClick="update()">');
}
document.write('(Yes)</TR>');

document.write('<TR><TD>Are you a fire-eater? <TD>(No)');
for (n = 0; n < 5; n++)
{
document.write('<INPUT TYPE="radio" NAME="pierce2" value="'+ n +'" onClick="update()">');
}
document.write('(Yes)</TR>');

document.write('<TR><TD>Are you mischievous? <TD>(No)');
for (n = 0; n < 5; n++)
{
document.write('<INPUT TYPE="radio" NAME="pierce3" value="'+ n +'" onClick="update()">');
}
document.write('(Yes)</TR>');

document.write('<TR><TD>Do you make mistakes? <TD>(No)');
for (n = 0; n < 5; n++)
{
document.write('<INPUT TYPE="radio" NAME="daniel1" value="'+ n +'" onClick="update()">');
}
document.write('(Yes)</TR>');

document.write('</TABLE>');
document.write('</DIV>');

document.write('<TD VALIGN=bottom ALIGN=left>');
document.write('<FONT SIZE=4><B>&larr;</B> Scroll Down</FONT>');
document.write('<BR><BR><BR<BR><BR><BR><BR><BR><BR><BR>');

document.write('<FONT SIZE=4><B>&larr;</B> Scroll Down</FONT>');
document.write('</TABLE>');
document.write('<TABLE BORDER=0 WIDTH=500px><TR><TD>');
document.write('<INPUT TYPE="reset" NAME="Reset">');

document.write('</TD><TD ALIGN=RIGHT>');
document.write('<INPUT TYPE="button" NAME="Done" VALUE="Done" onClick="copyForm()">');
document.write('</TR></TABLE>');
document.write('</FORM>');

waitMessage();  // make "wait for quiz" message disappear
