thepage="Mass relations-rxns(131)"
//updated 12/02/02-netscape 7
refnumber=177
totl=0
corrt=0
first=0
second=0
theanswr=0
theanswer=""
tried=0
attempts=0
qphrase=new Array()
seq=new Array()
introphrase="For the balanced equation shown below, how many grams of "
qphrase[0]=new Array(" will react with "," grams of ","?")
qphrase[1]=new Array(" be produced by "," grams of ","?")
qphrase[2]=new Array(" reacted, if "," grams of "," are produced?")
qphrase[3]=new Array(" will be produced, if "," grams of "," are produced?")
ansphrase=new Array("To answer this question, you use the <b>mass ratio</b> between "," and "," from the <b>balanced</b> equation.","<br>Rearranging the equation and solving yields:<br> ")
function startit(){
	clear()
	totl++
	document.forms[0].total.value=totl
	choose()
	buildquestion()
}
function buildquestion(){
	first=Math.floor(coeffs[choice].length*Math.random())
	second=first
	while(second==first)second=Math.floor(coeffs[choice].length*Math.random())
	if(first<=split)second<=split?option=0:option=1;
	else second<=split?option=2:option=3;
	moles=new Array()
	moles[0]=number(Math.random(),4,3)
	moles[1]=moles[0]*coeffs[choice][second]/coeffs[choice][first]
	moles[1]=theanswr=number(moles[1],4,3)
//masses of the two compounds are gotten by calling the getmass function (part of reactionsets.js)
	themass=new Array()
	themass[0]=number(100*Math.random(),3,3)
	themass[1]=number(themass[0]*masses[second]/masses[first],3,3)
	thewhole=new Array(moles[0],moles[1],themass[0],themass[1],formula[first],formula[second])
	thequest=introphrase+thewhole[5]+qphrase[option][0]+thewhole[2]+qphrase[option][1]+thewhole[4]+qphrase[option][2]+"<br>"+equation
	buildanswer(thewhole)
	theanswr=thewhole[3]
	showquest(thequest)
}
function buildanswer(thewhole){
	eqn1=thewhole[5]+"/"+thewhole[4]+"="+masses[second]+"/"+masses[first]+"=?/"+themass[0]
	eqn2=masses[second]+"/"+masses[first]+"*"+themass[0]+"="+themass[1]
	theanswer=ansphrase[0]+thewhole[4]+ansphrase[1]+thewhole[5]+ansphrase[2]+"<br>"+eqn1+"<br>"+eqn2
}	

function answer(ans){
	attempts++
	if(tried==1)alert("You've done this one. Get a new problem.")
	else{
	if(tried==2){totl++;document.forms[0].total.value=totl}
	if(ans>.95*theanswr & ans<1.05*theanswr){
		document.forms[0].results.value="Correct"
		corrt++
		document.forms[0].correct.value=corrt
		tried=1
	}
	else{
		document.forms[0].results.value="Incorrect"
		tried=2
	}}
}
