function CI(image, newName)
{
	document.images[image].src = newName
}


function calPV()
{
	var PV = 0

	for (n=0; n < document.force.number.length; n++)
	{
		curPV = document.force.number[n].value * document.force.pv[n].value
		if (document.force.number[n].value)
			document.force.modelpv[n].value = curPV
		else
			document.force.modelpv[n].value = ""

		PV = PV + curPV
	}


	for (n=0; n < document.force.character.length; n++)
	{
		if (document.force.character[n].checked)
		{
			curPV = Number(document.force.charpv[n].value)
			document.force.characterpv[n].value = curPV
		}
		else
		{
			curPV = 0
			document.force.characterpv[n].value = ""
		}
		PV = PV + curPV
	}


	for (n=0; n < document.force.forcePV.length; n++)
		document.force.forcePV[n].value = PV

	window.status = "Total Force PV: " + PV
}


function changeValue(control, amount)
{
	control.value = Math.floor(Number(control.value)) + Number(amount)
}


function printForceList()
{
	forcelist = window.open("", "forcelist")
	forcelist.document.open()

	forcelist.document.writeln('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/strict.dtd">\n<html lang="en">\n<head>\n<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-15">\n<title>' + document.force.forcename.value + ' Force List</title>\n<link rel="stylesheet" href="styles.css" type="text/css">\n</head>\n\n<body>')

	forcelist.document.writeln('<h1>' + document.force.forcename.value + ' Force List <small>(' + document.force.forcePV[0].value + ' PV)</small></h1>')

	forcelist.document.writeln('<table width="100%" class="pvlist" cellspacing="0" cellpadding="0" border="0">')

	forcelist.document.writeln('<tr><th colspan="2"></th> <th class="r">Number</th> <th>PV Each</th> <th>PV Total</th></tr>')

	for (n=0; n < document.force.desc.length; n++)
	{
		if (document.force.number[n].value)
		{
			forcelist.document.write('<tr><th>')
			if (document.force.desc[n].value.charAt(0) != "*")
				forcelist.document.write(document.force.desc[n].value + '</th> <td colspan="2"')
			else
				forcelist.document.write('</th> <td>' + document.force.desc[n].value.slice(1) + '</td> <td')

			forcelist.document.write(' class="r">' + document.force.number[n].value + '&times;</td> <td class="r">')

			if (document.force.desc[n].value.charAt(0) == "*")
				forcelist.document.write('+')

			forcelist.document.write(document.force.pv[n].value + '</td> <td class="r">' + document.force.modelpv[n].value)

			forcelist.document.writeln('</td></tr>')
		}
	}

	// Special characters
	for (n=0; n < document.force.chardesc.length; n++)
	{
		if (document.force.character[n].checked)
		{
			forcelist.document.write('<tr><th>')
			if (document.force.chardesc[n].value.charAt(0) != "*")
				forcelist.document.write(document.force.chardesc[n].value + '</th> <td colspan="2"')
			else
				forcelist.document.write('</th> <td>' + document.force.chardesc[n].value.slice(1) + '</td> <td')

			forcelist.document.write(' class="r">1&times;</td> <td class="r">')

			if (document.force.chardesc[n].value.charAt(0) == "*")
				forcelist.document.write('+')

			forcelist.document.write(document.force.charpv[n].value + '</td> <td class="r">' + document.force.characterpv[n].value)

			forcelist.document.writeln('</td></tr>')
		}
	}

	forcelist.document.writeln('</table>')

	forcelist.document.writeln('</body>\n</html>')
	forcelist.document.close()
}
