Hi, I've attached a cut-down version of a script I am working on. It's a pretty simple button with a function attached, which creates a random number and compares it with a preset value.

I can't seem to get the function to read the variables!
Can anyone point me in the right direction?

#<html header>
<script language="javascript" type="text/javascript">
var firstrun=0;
var a=80;
var b=0;
var rdm=0;
var total=a + b;

function calc()	{
	alert('firstrun: ' + firstrun);
	alert('total at start of function: ' + total);
	if (firstrun=0)	{
	alert ('firstrun after if: ' + firstrun)	
	//create a random number, multiply by 100
	alert ('total before random:  ' + total);
	//round this number to a whole number (integer)
	alert ('final random number: ' + rdm1);
	alert('final total number: ' + total);
	if (rdm<sgl)	{
		alert('the random number was LESS than a')
       }	else	{
		alert('the random number was MORE than the a) 

<INPUT TYPE="button" NAME="myButton" VALUE="Calculate onClick="calc()">