thepage="Calc Eo(141)"
//11/18/02-updated netscape 7
//global variables
refnumber=185
corrt=0
tried=0
totl=0
theanswer=0
which=0
thecmpds=""
hrxn=""
attempts=0
first=3
second=0
option=0
potentials=""
thecell="<input type=text size=8 value=''>"
thebutton="<input type=button value='Check Answer' onClick='answer(this.form)'></form>"
halfrxn=new Array()
halfrxn[0]=new Array("F2","F-",2,3.06)
halfrxn[1]=new Array("F2O","F-",4,2.1)
halfrxn[2]=new Array("O3","O2",2,2.07)
halfrxn[3]=new Array("S2O8-2","SO4-2",2,2.01)
halfrxn[4]=new Array("NO3-","NO2",1,1.80)
halfrxn[5]=new Array("MnO4-","Mn+2",5,1.69)
halfrxn[6]=new Array("ClO2-","ClO-",2,1.64)
halfrxn[7]=new Array("BrO3-","Br2",10,1.52)
halfrxn[8]=new Array("PbO2","Pb+2",2,1.455)
halfrxn[9]=new Array("Au+3","Au+",2,1.41)
halfrxn[10]=new Array("Cl2","Cl-",2,1.36)
halfrxn[11]=new Array("Cr2O7-2","Cr+3",6,1.33)
halfrxn[12]=new Array("MnO2","Mn+2",2,1.23)
halfrxn[13]=new Array("IO3-","I2",10,1.20)
halfrxn[14]=new Array("ClO4-","ClO3-",2,1.19)
halfrxn[15]=new Array("Br2","Br-",2,1.087)
halfrxn[16]=new Array("VO2+","VO+2",1,1.00)
halfrxn[17]=new Array("HNO2","NO",1,.99)
halfrxn[18]=new Array("NO3-","NO",3,.96)
halfrxn[19]=new Array("ClO2","ClO2-",1,.954)
halfrxn[20]=new Array("HgO","Hg",2,.926)
halfrxn[21]=new Array("Ag+","Ag",1,.7995)
halfrxn[22]=new Array("Fe+3","Fe+2",1,.771)
halfrxn[23]=new Array("Hg+2","Hg2+2",2,.92)
halfrxn[24]=new Array("ClO-","Cl-",2,.89)
halfrxn[25]=new Array("AsO2-","As",3,.68)
halfrxn[26]=new Array("I2","I-",2,.628)
halfrxn[27]=new Array("MnO4-","MnO2",3,.588)
halfrxn[28]=new Array("Sb2O5","SbO+",4,.559)
halfrxn[29]=new Array("I3-","I-",2,.545)
halfrxn[30]=new Array("VO+2","V+3",1,.337)
halfrxn[31]=new Array("UO2+2","U+4",2,.334)
halfrxn[32]=new Array("BiO+","Bi",3,.32)
halfrxn[33]=new Array("PbO2","PbO",2,.28)
halfrxn[34]=new Array("SbO+","Sb",3,.212)
halfrxn[35]=new Array("Mo+3","Mo",3,.20)
halfrxn[36]=new Array("SO4-2","SO2",2,.17)
halfrxn[37]=new Array("Sn+4","Sn+2",2,.154)
halfrxn[38]=new Array("Sb2O3","Sb",6,.152)
halfrxn[39]=new Array("TiO+3","Ti+3",1,.10)
halfrxn[40]=new Array("Sn+2","Sn",2,.01)
halfrxn[41]=new Array("H+","H2",2,0)
halfrxn[42]=new Array("GeO2","GeO",2,-.118)
halfrxn[43]=new Array("H3PO3","H3PO2",2,-.50)
halfrxn[44]=new Array("SO3-2","S2O3-2",4,-.58)
halfrxn[45]=new Array("H3BO3","B",3,-.87)
halfrxn[46]=new Array("Cr+2","Cr",2,-.91)
halfrxn[47]=new Array("Al+3","Al",3,-1.66)
halfrxn[48]=new Array("Th+4","Th",4,-1.90)
halfrxn[49]=new Array("Mg+2","Mg",2,-2.37)
halfrxn[50]=new Array("Be2O3-2","Be",4,-2.62)
choice=new Array()
choice[0]=new Array("<b>I</b>","<b>II</b>","E<sub>red I</sub>-E<sub>red II</sub>",0,1)
choice[1]=new Array("<b>II</b>","<b>I</b>","E<sub>red II</sub>-E<sub>red I</sub>",1,0)
ansphrase=new Array("The half reactions (both written as reductions) are as shown below.<br>","The overall reaction is written such that reaction "," is the reduction and reaction "," is the oxidation.<br> Therefore, the overall E<sup>o</sup> is:<br>")
function startit(){
	clear()
	thedata=new Array()
	totl++
	document.forms[0].total.value=totl
	document.forms[0].results.value=""
	first=Math.floor(Math.random()*halfrxn.length)
	second=first
	while(second==first)second=Math.floor(Math.random()*halfrxn.length)
	getcmpds(first,second)
	theE=number(halfrxn[first][3]-halfrxn[second][3],3,3)
	reaction=""
	reaction="What is E<sup>o</sup> for the following?<br>"+thecmpds[1]+" + "+thecmpds[2]+" => "+thecmpds[3]+" + "+thecmpds[4]+"<br>"
	showquest(reaction)
	buildanswer()
}
function getcmpds(first,second){
	hrxn=new Array()
	thecmpds=new Array()
	option=Math.floor(2*Math.random())
	option=1
	if(option==0){
	thecmpds[1]=completeformula(halfrxn[first][0])
	thecmpds[2]=completeformula(halfrxn[second][1])
	thecmpds[3]=completeformula(halfrxn[first][1])	
	thecmpds[4]=completeformula(halfrxn[second][0])
	electrons=new Array(halfrxn[first][2],halfrxn[second][2])
	potentials=new Array(halfrxn[first][3],halfrxn[second][3])
	hrxn[1]="(I)"+thecmpds[1]+"+"+electrons[0]+"e<sup>-</sup> =>"+thecmpds[3]+" E<sub>&#189;</sub>="+potentials[0]+"<br>"
	hrxn[2]="(II)"+thecmpds[4]+"+"+electrons[1]+"e<sup>-</sup> => "+thecmpds[2]+" E<sub>&#189;</sub>="+potentials[1]+"<br>"
	}
	else{
	thecmpds[2]=completeformula(halfrxn[first][0])
	thecmpds[1]=completeformula(halfrxn[second][1])
	thecmpds[4]=completeformula(halfrxn[first][1])	
	thecmpds[3]=completeformula(halfrxn[second][0])
	electrons=new Array(halfrxn[second][2],halfrxn[first][2])
	potentials=new Array(halfrxn[second][3],halfrxn[first][3])
	hrxn[1]="(I)"+thecmpds[3]+"+"+electrons[0]+"e<sup>-</sup> =>"+thecmpds[1]+" E<sub>&#189;</sub>="+potentials[0]+"<br>"
	hrxn[2]="(II)"+thecmpds[2]+"+"+electrons[1]+"e<sup>-</sup> => "+thecmpds[4]+" E<sub>&#189;</sub>="+potentials[1]+"<br>"
	}
	
}
function getn(second,second){
	gain=halfrxn[first][2]
	lost=halfrxn[second][2]
	if(gain==lost)return gain;
	else if(gain%lost==0)return gain;		
	else if(lost%gain==0)return lost;
	else {
		while(gain%2==0 & lost%2==0){gain=gain/2;lost=lost/2}
		while(gain%3==0 & lost%3==0){gain=gain/3;lost=lost/3}
		ne=gain*halfrxn[second][2]
		return ne
		}
}
function buildanswer(){
	theanswer=ansphrase[0]+hrxn[1]+hrxn[2]+ansphrase[1]+choice[option][0]+ansphrase[2]+choice[option][1]+ansphrase[3]+choice[option][2]+"="+potentials[choice[option][3]]+"-"+potentials[choice[option][4]]+"="+theE
	}
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}
	right=0
	attempts++
	if(theE<0){
		if(ans>.95*theE || ans<1.05*theE){
		right++ 
    			}
	}
	else{
		if(ans<.95*theE || ans>theE){
		right++ 
    			}
	}
	if(right==0){
		tried=1
		corrt++
		document.forms[0].results.value="correct"
		document.forms[0].correct.value=corrt
	}
	else{
		tried=2
		document.forms[0].results.value="incorrect"
	}
}}
stringlist="0123456789"
signlist="+-"

function constants(){
var cont=window.open("","cont","toolbar=yes,scrollbars=yes,width=300,height=300")
cont.document.writeln ("<html>");
cont.document.writeln ("<head><title>Ionization Constants</title>");
cont.document.writeln ("</head>");
cont.document.writeln ("Potentials for abbreviated half reactions<br><table>");
for(k=0;k<halfrxn.length;k++){
cont.document.writeln("<tr><td>",completeformula(halfrxn[k][0]),"=>",completeformula(halfrxn[k][1]),"  E<sub>o</sub>=",halfrxn[k][3],"V</td></tr>");
}
cont.document.writeln("</table><form><input type=button value='Close Window' onClick='window.close()'></form>");
cont.document.writeln("<html>");
cont.document.close();
cont.focus();
}