// JavaScript Document
thepage="Direct/Inverse(2)"
//11/18/02-updated netscape 7
//globals
refnumber=3
firstletter=0
secondletter=0
theimage=""
totl=0
corrt=0
tried=0
theanswr=0
theanswer=""
theans=0
myans=0
thelast=0
ivalue=0
whicheqn=0
function parts(p1,p2,p3,p4,p5,p6){
	this.p1=p1
	this.p2=p2
	this.p3=p3
	this.p4=p4
	this.p5=p5
	this.p6=p6
}
function clear(){
	clearansspot()
	document.forms[0].results.value=""
      attempts=0
	}
ansphrase=new parts("In this case the variable pair appears in the equation "," Therefore, the variables are "," related.")
inserts=new Array(10)
inserts[1]=" as a ratio."
inserts[2]=" as a product."
inserts[3]=" on opposite sides of the '=' and the 'same level'."
inserts[4]=" on opposite sides of the '=' and on the 'opposite levels'."
finalword=new Array(10)
finalword[1]="directly"
finalword[2]="inversely"
function where(p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12){
	this.p1=p1
	this.p2=p2
	this.p3=p3
	this.p4=p4
	this.p5=p5
	this.p6=p6
	this.p7=p7
	this.p8=p8
	this.p9=p9
	this.p10=p10
	this.p11=p11
	this.p12=p12
}
letters=new Array(6)
letters[1]="A"
letters[2]="B"
letters[3]="C"
letters[4]="D"
letters[5]="E"
letters[6]="F"
/*this is the position array. It provides the position in the equation of each variable. Each is two terms, with A being the first two, B the second two and so on. A 1 in the first position means the variable is on the left side, a 2 means the right side. A 1 in the second position means the variable is a numerator term a 2 means its a denominator term*/
anset=new Array(20)
anset[1]=new where(1,1,1,1,1,2,1,2,2,1,2,1)
anset[2]=new where(1,1,1,2,1,2,2,1,2,1,2,2)
anset[3]=new where(1,1,1,1,1,2,2,1,2,2,2,2)
anset[4]=new where(1,1,1,2,2,1,2,1,2,2,2,2)
anset[5]=new where(1,1,1,1,1,1,2,1,2,1,2,2)
anset[6]=new where(1,1,1,2,1,2,2,1,2,2,2,2)
anset[7]=new where(1,1,1,1,1,2,1,2,2,1,2,1)
anset[8]=new where(1,1,1,1,2,1,2,1,2,2,2,2)
anset[9]=new where(1,1,1,1,1,1,1,2,1,2,2,1)
anset[10]=new where(1,1,1,2,1,2,2,2,2,2,2,2)
function begin(){
	clear()
	theans=0
	document.forms[0].results.value=""
	tried=0
	totl++
	document.forms[0].total.value=totl
	firstletter=Math.ceil(6*Math.random())
	secondletter=firstletter
	while(firstletter==secondletter){
	secondletter=Math.ceil(6*Math.random())}
	whicheqn=Math.ceil(6*Math.random())
	theimage="<img src='../images/equations/equation"+whicheqn+".png'>"
	lr1=anset[whicheqn]['p'+(2*firstletter-1)]
	tb1=anset[whicheqn]['p'+(2*firstletter)]
	lr2=anset[whicheqn]['p'+(2*secondletter-1)]
	tb2=anset[whicheqn]['p'+(2*secondletter)]
	thequest=theimage+"<br>"+letters[firstletter]+" and "+letters[secondletter]
	showquest(thequest)
	getanswer(lr1,lr2,tb1,tb2)
}

function getanswer(lr1,lr2,tb1,tb2){
if(lr1==lr2){
	if(tb1==tb2){
		theanswr=2
		ivalue=2
		}
	else{
		theanswr=1
		ivalue=1}
	}
else{
	if(tb1!=tb2){
		theanswr=2
		ivalue=4}
	else{
		theanswr=1
		ivalue=3}
	}
if(theanswr==1)thelast=1;
else thelast=2;
theanswer=ansphrase.p1+inserts[ivalue]+ansphrase.p2+finalword[thelast]+ansphrase.p3
}
function display(){
if(ie4){
	showstring=theimage+"<br>"+letters[firstletter]+" and "+letters[secondletter]
	qspot.innerHTML=showstring
	}
else{
	document.qspot.document.open()
	document.qspot.document.write(theimage,"<br>",letters[firstletter]," and ",letters[secondletter]);
	document.qspot.document.close()
}}
function screen(a){
	myans=a
	theans=theanswr
	answer()
}
function answer(){
if(tried==1){alert("You've already done this one. Get a new Problem!")}
else{
if(myans==theans){
	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=1
	showanswer()
	}
}
}
/*
function showanswer(){
	statement=ansphrase.p1+inserts[ivalue]+ansphrase.p2+finalword[thelast]+ansphrase.p3
	if(ie4){
		ansspot.innerHTML=statement
	}
	else{
		document.ansspot.document.open()
		document.ansspot.document.write(statement)
		document.ansspot.document.close()
	}
}
*/
