thepage="Using Limiting Reagents(136)"
refnumber=176
totl=0
corrt=0
first=0
second=0
theanswer=0
thecmpds=""
masses=""
given=""
ansr=0
attempts=0
seq=new Array()
theunits=new Array("moles","grams")
qphrase=new Array("For the balanced equation shown below, if "," grams of "," were reacted with "," grams of ",", how many grams of "," would be produced?")
ansphrase=new Array("To answer this question, first identify the limiting reagent. If your are not familiar with that process, you should review it or go to the following web page <a href='099_stoichiometry__using_limiting_reagents_wp.htm'>Limiting reagents</a> to practice. In this case, the limiting reagent is "," The mass of "," is then determined using the <B>mass ratio from the balanced equation:</B><br>") 
//clears values and selects an equation using the choose function(part of reactionsets.js)
function startit(){
	clear()
	totl++
	document.forms[0].total.value=totl
	document.forms[0].results.value=""
	choose()
	//alert(choice+","+rxn[choice][0])
	if(rxn[choice][0]<2)startit();
	else{
	buildquestion()
	}
}
//choice is the index of the selected reaction
function buildquestion(){
	first=Math.ceil(rxn[choice][0]*Math.random())
	second=first
	while(second==first)second=Math.ceil(rxn[choice][0]*Math.random())
	first+=1
	second+=1
	third=1+rxn[choice][0]+Math.ceil(rxn[choice][1]*Math.random())
	if(second<first){
		temp=second
		second=first
		first=temp
	}
	//this creates a random factor that will generate the values for the question
	factor=0
	while(factor<.5 || factor>.8)factor=Math.random();
	factor=number(factor,3,3)
	masses=new Array()
	thecmpds=new Array()
	thecmpds[0]=getformula(first)
	thecmpds[1]=getformula(second)
	thecmpds[2]=getformula(third)
	masses[0]=getmass(first)
	masses[1]=getmass(second)
	masses[2]=getmass(third)
	given=new Array()
	given[0]=number(100*Math.random(),3,3)
	given[1]=number(given[0]*masses[1]/masses[0],3,3)
	if(Math.random()>.5){
		given[2]=number(given[1]*factor,3,3)
		ansr=number(given[2]*masses[2]/masses[1],3,3)
		buildanswer(1,2)
	}
	else{
		given[2]=number(given[1]/factor,3,3)
		ansr=number(given[0]*masses[2]/masses[0],3,3)
		buildanswer(0,0)
	}
	thequest=qphrase[0]+given[0]+qphrase[1]+thecmpds[0]+qphrase[2]+given[2]+qphrase[3]+thecmpds[1]+qphrase[4]+thecmpds[2]+qphrase[5]+"<br><br>"+equation+"<br>"
	//thequest+=(masses+"<br>"+given)
	showquest(thequest)
}
function buildanswer(x,y){
	eqn="(mass of "+thecmpds[2]+")/(mass of "+thecmpds[x]+")="+masses[2]+"/"+masses[x]+"=(mass of "+thecmpds[2]+")/"+given[y]+"<br>"
	eqn+="("+masses[2]+"/"+masses[x]+")*"+given[y]+"="+ansr
	theanswer=ansphrase[0]+thecmpds[x]+ansphrase[1]+thecmpds[2]+ansphrase[2]+eqn
	//showanswer(theanswer)
}	
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*ansr & ans<1.05*ansr){
		document.forms[0].results.value="correct"
		corrt++
		document.forms[0].correct.value=corrt
		tried=1
	}
	else{
		document.forms[0].results.value="incorrect"
		tried=2
	}}
}
