// JavaScript Document
//updated 9/7/98 added show answer
//globals
attempts=0
structure=""
theanswer=0
totl=0
corrt=0
tried=0
newone=""
function clear(){
	document.forms[0].results.value=""
	document.forms[0].total.value=totl
	document.forms[0].correct.value=corrt
}
function dataset(cmpd,type){
	this.cmpd=cmpd
	this.type=type
}
theform1="<form><input type=radio name=ans onClick=answer(1)>sp<input type=radio name=ans onClick=answer(2)>sp<sup>2</sup><input type=radio name=ans onClick=answer(3)>sp<sup>3</sup><input type=radio name=ans onClick=answer(4)>sp<sup>2</sup>d"
theform2="<input type=radio name=ans onClick=answer(5)>sp<sup>3</sup>d<input type=radio name=ans onClick=answer(6)>none<input type=radio name=ans onClick=answer(7)>can't be determined</form>"
htype=new Array()
htype[1]=1
htype[2]=2
htype[3]=3
htype[4]=6
htype[5]=7
htype[6]=2
htype[7]=2
htype[8]=3
htype[9]=3
htype[10]=3
htype[11]=2
htype[12]=2
htype[13]=7
htype[14]=6
htype[15]=2
htype[16]=2
htype[17]=2
htype[18]=3
htype[19]=3
htype[20]=3
htype[21]=6
htype[22]=2
htype[23]=3
htype[24]=2
htype[25]=2
htype[26]=1
htype[27]=1
htype[28]=2
htype[29]=7
htype[30]=3
htype[31]=4
htype[32]=2
htype[33]=7
htype[34]=3
htype[35]=2
htype[36]=6
htype[37]=1
htype[38]=1
htype[39]=2
htype[40]=7
htype[41]=1
htype[42]=3
htype[43]=2
htype[44]=1
htype[45]=2
htype[46]=1
htype[47]=1
htype[48]=1
htype[49]=7
htype[50]=3
htype[51]=3
htype[52]=3
htype[53]=1
htype[54]=1
htype[55]=7
htype[56]=2
htype[57]=3
htype[58]=6
htype[59]=7
htype[60]=3
htype[61]=3
htype[62]=7
htype[63]=6
htype[64]=2
htype[65]=2
htype[66]=3
htype[67]=3
htype[68]=2
htype[69]=7
htype[70]=1
htype[71]=1
htype[72]=2
htype[73]=6
htype[74]=7
htype[75]=2
htype[76]=2
htype[77]=6
htype[78]=3
htype[79]=3
htype[80]=3
htype[81]=2
htype[82]=7
htype[83]=2
htype[84]=2
htype[85]=3
compound=new Array()
compound=new dataset("<U>C</U>H<sub>4</sub>",3)
compound[2]=new dataset("<U><b>C</b></U>F<sub>4</sub>",3)
compound[3]=new dataset("<U><b>C</b></U>O<sub>2</sub>",1)
compound[4]=new dataset("<U><b>C</b></U>Cl<sub>4</sub>",3)
compound[5]=new dataset("H<sub>2</sub><U><b>O</b></U>",3)
compound[6]=new dataset("H<sub>2</sub><U><b>C</b></U>=O",2)
compound[7]=new dataset("<U><B>C</B></U>O",1)
compound[8]=new dataset("H<sub>2</sub><U><b>C</b></U>=CH<sub>2</sub>",2)
compound[9]=new dataset("<B><U>B</U></B>F<SUB>3</SUB>",2)
compound[10]=new dataset("<B><U>B</U></B>Cl<SUB>3</SUB>",2)
compound[11]=new dataset("H<B><U>C</U></B>N:",1)
compound[12]=new dataset(":<B><U>N</U></B>H<SUB>3</SUB>",3)
compound[13]=new dataset("H<U><B>C</B></U>CH",1)
compound[14]=new dataset("H<sub>2</sub><B><U>S</U></B>",5)
compound[83]=new dataset("<b>N</b>H<sub>4</sub><sup>+</sup>",3)

//begin programs
function startit(){
	attempts=0
 	totl++
	tried=0
	document.forms[0].total.value=totl
	document.forms[0].results.value=""
	which=Math.ceil(85*Math.random())
	structure="<img src='../images/hybridizations/struct"+which+".gif'><br />"
	theanswer=htype[which]
	display()
}

function display(){
     thequest=structure+theform1+theform2
	showquest(thequest)
}
function answer(f){
 	attempts++
	if(tried==1){
	alert("Get a new problem. You already answered this one!")}
	else{
		if(f==theanswer){
		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}
		tried=2
	}
	}
}

function showans(){

if(attempts>=3){

	window.newone.document.forms[0].ans[theanswer-1].checked=1

	window.newone.focus()

	}

}
