answers_attempted=1
answers_correct=1
approval_rating=100	//How far does the player agree with the decisions actually reached? - start at 100.
score=100			//For factual questions
decisions_made=1	//Always start at 1
decisions_matched=1 //Always start at 1

function matched(x)
{
decisions_matched++
decisions_made++
move(x)
}

function nomatch(x)
{
decisions_made++
move(x)
}

function display_scores()
{
approval_rating=Math.round(100/decisions_made*decisions_matched)
score=Math.round(100/answers_attempted*answers_correct)
str="<font size='1' face='Arial, Helvetica, sans-serif'>"
document.getElementById("thescore").innerHTML=str+score+"%</font>"
document.getElementById("approv").innerHTML=str+approval_rating+"%</font>"
theScore=parent.topframe.score+"% Factual Knowledge; "+parent.topframe.approval_rating+"% Rating of Wilhelm";
parent.topframe.submitScoreAutomatically()
}



/////////



function breakinto()
{
frameloc="frameset.htm"
var thisloc = window.parent.location.href;
if (thisloc.indexOf(frameloc)==-1)
	{
	self.location=frameloc
	}
}


function move(x)
{
correct_page=x
display_scores()
parent.mainframe.location="no_back.htm"
}



function check_answer(str,place)
{
answers_attempted++
str=str.toLowerCase()
answer=parent.mainframe.document.question.T1.value.toLowerCase()
if(answer==str)
{alert("Correct!");answers_correct++;display_scores();move(place)}
else{wronganswer();display_scores()}
}



var win = null;
function NewWindow(mypage,myname,w,h,scroll)
{
mypage="popups/"+mypage+".htm"
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings =
'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
win = window.open(mypage,myname,settings)
}



wr=new Array()
wr[0]="Sorry, that's the incorrect answer!"
wr[1]="I'm afraid that's wrong!"
wr[2]="Incorrect!"
wr[3]="Have another go!"
wr[4]="Try again!"
wr[5]="Unfortunately not!"

function wronganswer()
{
alert(wr[Math.floor(Math.random()*wr.length)])
score-=5
display_scores()
}

