thepage="Arrhenius eqn(123)"
refnumber=161
totl=0
corrt=0
tried=0
attempts=0
R=.008314
A=1e12
option=0
theanswer=""
k1=0
k2=0
fillin="<form><input type=text size=8 name=ans>"
function question(p1,p2,p3,p4,p5,p6,p7,p8){
	this.p1=p1
	this.p2=p2
	this.p3=p3
	this.p4=p4
	this.p5=p5
	this.p6=p6
	this.p7=p7
	this.p8=p8
}
thedata=new Array()
datalabels=new Array("Ea","k<sub>1</sub>","T<sub>1</sub>","k<sub>2</sub>","T<sub>2</sub>")
dataunit=new Array("KJ/mole","sec<sup>-1</sup>","K","sec<sup>-1</sup>","K")
equations=new Array("<img src='arrhenius1.gif' width=100>","<img src='arrhenius2.gif'>","<img src='arrhenius2.gif'>")
anskey=new Array(1,3,0)
quest=new Array()
ansphrase=new Array()
quest[0]=new question("A reaction is found to have an activation energy of "," at ",". What is the value of the rate constant?")
ansphrase[0]=new question("Since you are given Ea and T, k can be calculated from the equation below, using the value of 10<sup>12</sup> for A.<br>","<br>Substitute the values provided<br>","and solve for k.")
quest[1]=new question("A reaction is found to have a rate constant of "," at "," and an activation energy of ",". What is the value of the rate constant at ","?")
ansphrase[1]=new question("To determine the value of the rate constant at a given temperature with the other constants known, use the equation:<br>","<br>The solution can be most easily gotten by the following steps. First, fully evaluate the right side of the equation, arranging the data such that the missing k is k<sub>2</sub>.<br>","Then, take e<sup>x</sup> of both sides.","Finally, solve for k<sub>2</sub>.")
quest[2]=new question("Given the following: ","What is the activation energy in KJ/mole?")
ansphrase[2]=new question("To determine the value of the activation energy,when you have values of k at two different temperatures, use the equation:<br>","<br>The solution can be most easily gotten by the following steps. First, fully evaluate the temperature term and the term in k.","Then, rearrange and solve for Ea.")
function startit(){
	tried=0
	totl++
	document.forms[0].total.value=totl
	thedata[2]=gettemp()
	thedata[4]=gettemp()
	thedata[0]=getact()
	k1=calck(2)
	thedata[1]=number(k1,3,2)
	k2=calck(4)
	thedata[3]=number(k2,3,2)
	makequestion()
}
function calck(x){
	k=-(thedata[0]/(R*thedata[x]))
	k=A*Math.pow(2.71828,k)
	return number(k,3,1)
	}
function makequestion(){
	option=Math.floor(3*Math.random())
	if(option==0){
	thequest=quest[0].p1+thedata[0]+dataunit[0]+quest[0].p2+thedata[2]+dataunit[2]+quest[0].p3
	}
	if(option==1){
	thequest=quest[1].p1+thedata[1]+dataunit[1]+quest[1].p2+thedata[2]+dataunit[2]+quest[1].p3+thedata[0]+dataunit[0]+quest[1].p4+thedata[4]+dataunit[4]+quest[1].p5
	}
if(option==2){
	thetable="<table><tr><td align=center>T(K)</td><td>k(sec<sup-1</sup>)</td></tr><tr><td>"+thedata[2]+"</td><td>"+thedata[1]+"</td></tr><tr><td>"+thedata[4]+"</td><td>"+thedata[3]+"</td></tr></table>";
	thequest=quest[2].p1+thetable+quest[2].p2
	}
	showquest(thequest)
	buildanswer(option)
}
function getact(){
	act=0
	while(act<10 || act>200){
	act=Math.round(5000*Math.random())/10
	}
	return act
}
function buildanswer(option){
	theanswer=ansphrase[option].p1+equations[option]+ansphrase[option].p2+getnext(option)
	if(option==0)theanswer+=("<br>k="+thedata[1]+dataunit[1])
}
function getnext(option){
	if(option==0){
		eqn="k=10<sup>12</sup>*e<sup>"+thedata[0]+"/(.008314*"+thedata[2]+")</sup>"
	}
	if(option==1){
		eqn="ln(k<SUB>2</SUB>/k<SUB>1</SUB>)="+thedata[0]+"/.008314*(1/"+thedata[2]+"-1/"+thedata[4]+")"
		thevalue=(thedata[0]/.008314)*(1/thedata[2]-1/thedata[4])
		thevalue=number(thevalue,3,3)
		eqn+=("<br>ln(k<SUB>2</SUB>/k<SUB>1</SUB>)="+thevalue)
		eqn+="<br>"+ansphrase[1].p3+("<br>k<SUB>2</SUB>/k<SUB>1</SUB>=e<sup>"+thevalue+"</sup>")
		factor=number(Math.pow(2.71828,thevalue),3,2)
		eqn+="<br>"+ansphrase[1].p4+("<br>k<SUB>2</SUB>=k<SUB>1</SUB>*"+factor)
		eqn+=("<br>k<SUB>2</SUB>="+thedata[3])
	}
	if(option==2){
		thevalue=(1/thedata[2]-1/thedata[4])
		thevalue=number(thevalue,3,3)
		ratio=k2/k1
		kterm=number(Math.log(ratio),3,3)
		eqn="<br>ln(k<SUB>2</SUB>/k<SUB>1</SUB>)="+kterm+"<br>"
		eqn+="(1/T<sub>1</sub>-1/T<sub>2</sub>)=(1/"+thedata[2]+"-1/"+thedata[4]+")="+thevalue+"<br>"+ansphrase[2].p2
		eqn+="<br>Ea=.008314*"+kterm+"/"+thevalue+"<br>"
		eqn+="Ea="+number(.008314*(kterm/thevalue),3,3)+dataunit[0]		
	}
	return eqn
}
function gettemp(){
	temperature=0
	while(temperature<250){
		temperature=Math.ceil(550*Math.random())
	}
	return temperature
}
function getk(){
	c=Math.pow(10,Math.random())
	c=Math.round(10*c)/10
	ex=Math.ceil(7*Math.random())
	if(Math.random()>.5){ex=-1*ex}
	k=c+"e"+ex
	return k
}

function getanswer(){
	if(option==0)theanswr=k1
	if(option==1)theanswr=k2
	if(option==2)theanswr=thedata[0]
	return theanswr
}
function answer(ans){
if(tried==1){alert("You've already done this one. Get a new Problem!")}
else{
theanswr=getanswer()
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"
	if(tried==2){totl++;document.forms[0].total.value=totl}
	attempts++
	tried=2
	}
}
}
