thepage="Limit Reagent(134)"
refnumber=174
//11/20/02-updated netscape 7
totl=0
corrt=0
first=0
second=0
theanswr=0
theform1="<form><input type=radio name=theans onClick=answer(0)>"
theform2="<input type=radio name=theans onClick=answer(1)>"
theform3="</form>"
given=""
theanswer=""
seq=new Array()
theunits=new Array("moles","grams")
qphrase=new Array("For the balanced equation shown below, what would be the limiting reagent if "," grams of "," were reacted with "," grams of ","?")
ansphrase=new Array("To answer this question, calculate the grams of "," needed to react fully with "," grams of ",", using the gram ratio provided by the balanced equation, as shown below.<br>From the balanced equation: ","Since the needed mass is "," than the mass given in the problem, the "," is "," and the "," is ",".") 
inserts=new Array()
inserts[0]=new Array(" <B>less than</B> "," <B>excess</B> "," <B>limiting</B> ")
inserts[1]=new Array(" <B>more than</B> "," <B>limiting</B> "," <B>excess</B> ")
function clear(){
	document.forms[0].results.value=""
	clearansspot()
	tried=0
}
//clears values and selects an equation using the choose function(part of reactionsets.js)
function startit(){
	clear()
	totl++
	document.forms[0].total.value=totl
	choose()
	if(rxn[choice][0]<2){totl--;startit()}
	else{
	buildquestion()
	}
}
//thefollowing builds an array of the formulas, stoichiometric coeffs and masses in balanced equation
//each array row consists of the formula, the coeff and the reaction mass
//there is one row per compound
//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
	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)
	masses[0]=getmass(first)
	masses[1]=getmass(second)
	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)
		theanswr=1
	}
	else{
		given[2]=number(given[1]/factor,3,3)
		theanswr=0
	}
	thequest=qphrase[0]+given[0]+qphrase[1]+thecmpds[0]+qphrase[2]+given[2]+qphrase[3]+thecmpds[1]+qphrase[4]+"<br>"+equation+theform1+thecmpds[0]+theform2+thecmpds[1]+theform3
	buildanswer(first,second)
	showquest(thequest)
}
function buildanswer(first,second,findex,sindex){
	equn1="(mass of "+thecmpds[1]+")/(mass of "+thecmpds[0]+")="+masses[1]+"/"+masses[0]+"<br>"
	equn2="("+masses[1]+"/"+masses[0]+")*"+given[0]+"="+given[1]
	theanswer=ansphrase[0]+thecmpds[1]+ansphrase[1]+given[0]+ansphrase[2]+thecmpds[0]+ansphrase[3]+equn1+equn2+"<br>"
	theanswer+=ansphrase[4]+inserts[theanswr][0]+ansphrase[5]+thecmpds[1]+ansphrase[6]+inserts[theanswr][1]+ansphrase[7]+thecmpds[0]+ansphrase[8]+inserts[theanswr][2]+ansphrase[9]
}	

function answer(ans){
	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==theanswr){
		document.forms[0].results.value="correct"
		corrt++
		document.forms[0].correct.value=corrt
		tried=1
	}
	else{
		document.forms[0].results.value="incorrect"
		tried=1
		showanswer()
	}}
}
