document.write("<bgsound id=\"numbers1\"src=\"\">\n<bgsound id=\"numbers2\"src=\"\">\n")
aUnits=["","One","Two","Three","Four","Five","Six","Seven","Eight","Nine"]
aTeens=["","Eleven","Twelve","Thirteen","Fourteen","Fifteen","Sixteen","Seventeen","Eighteen","Nineteen"]
aTens =["","Ten","Twenty","Thirty","Forty","Fifty","Sixty","Seventy","Eighty","Ninety"]
currentchar=-1;
actualnumber=0;
var numbertimer=null;
numberbuffer=0;
function say_number(thenum)
{
currentchar=0;
actualnumber=thenum;
clearTimeout(numbertimer);
handle_number()
}
function endofstatus()
{
if(sending_score=="yes")
{
setTimeout("playagain()",700);
return false;
}
if(currentstatus=="caught")
{
duckducks()
}
}
function handle_number()
{
output=ConvertNumberToWords(actualnumber);
output=output.split(" ");
if(output[currentchar]=="")
{
currentchar+=1;
handle_number()
return false;
}
if(output[currentchar]=="undefined")
{
endofstatus()
return false;
}
if(output[currentchar]!="")
{
char="" + output[currentchar] + "";
char=char.toLowerCase();
time=0;
filename="";
if(actualnumber==0)
{
filename="0";
numberbuffer+=1;
if(numberbuffer>=3)
{
numberbuffer=1;
}
filename+=".wav";
numbersoundstring="numbers" + numberbuffer + "";
document.all[numbersoundstring].src=filename
time=750;
numbertimer=setTimeout('endofstatus()',time);
return false;
}
if(char=="one")
{
filename="1";
time=620;
}
if(char=="two")
{
filename="2";
time=620;
}
if(char=="three")
{
filename="3";
time=720;
}
if(char=="four")
{
filename="4";
time=620;
}
if(char=="five")
{
filename="5";
time=720;
}
if(char=="six")
{
filename="6";
time=610;
}
if(char=="seven")
{
filename="7";
time=630;
}
if(char=="eight")
{
filename="8";
time=520;
}
if(char=="nine")
{
filename="9";
time=630;
}
if(char=="ten")
{
filename="10";
time=620;
}
if(char=="eleven")
{
filename="11";
time=620;
}
if(char=="twelve")
{
filename="12";
time=650;
}
if(char=="thirteen")
{
filename="13";
time=710;
}
if(char=="fourteen")
{
filename="14";
time=820;
}
if(char=="fifteen")
{
filename="15";
time=790;
}
if(char=="sixteen")
{
filename="16";
time=760;
}
if(char=="seventeen")
{
filename="17";
time=720;
}
if(char=="eighteen")
{
filename="18";
time=740;
}
if(char=="nineteen")
{
filename="19";
time=780;
}
if(char=="twenty")
{
filename="20";
time=630;
}
if(char=="thirty")
{
filename="30";
time=540;
}
if(char=="forty")
{
filename="40";
time=720;
}
if(char=="fifty")
{
filename="50";
time=620;
}
if(char=="sixty")
{
filename="60";
time=720;
}
if(char=="seventy")
{
filename="70";
time=730;
}
if(char=="eighty")
{
filename="80";
time=620;
}
if(char=="ninety")
{
filename="90";
time=620;
}
if(char=="hundred")
{
filename="hundred";
time=620;
}
if(char=="thousand")
{
filename="thousand";
time=760;
}
if(filename=="")
{
endofstatus()
return false;
}
filename+=".wav";
numberbuffer+=1;
if(numberbuffer>=3)
{
numberbuffer=1;
}
numbersoundstring="numbers" + numberbuffer + "";
document.all[numbersoundstring].src=filename
currentchar+=1;
if(time==-400)
{
endofstatus()
return false;
}
numbertimer=setTimeout('handle_number()',time);
}
}
function getunits(xValue)
{
return (aUnits[xValue])}
function gethund(xValue)
{
return (aUnits[xValue] != '') ? (aUnits[xValue]+' Hundred') : (aUnits[xValue])
}
function teens(xValue)
{
return (aTeens[xValue])
}
function tens(xValue)
{
return (aTens[xValue])
}
function ConvertNumberToWords(nAmount)
{
var sAmount=nAmount.toString();
if (sAmount.indexOf(".") == -1) sAmount+='.00'
var sMax = (12 - sAmount.length)
var cStringAmount='';
var sNumberInWords ='';
for (c=1; c <=sMax; c++)
{
cStringAmount += '0'
}
sAmount=cStringAmount+sAmount;
cStringAmount=sAmount.substring(0,9);
var str1= sAmount.substring(0,3);
var str2= sAmount.substring(3,6);
var str3= sAmount.substring(6,9);
var str4= sAmount.substring(10,12)
if (cStringAmount.length >= 7)
{
sWords = NumberInWords(str1);
if (sWords.length >= 3) sNumberInWords += sWords +" Million ";
cStringAmount=cStringAmount.substring(3,9)
}
if (cStringAmount.length >= 4)
{
sWords = NumberInWords(str2)
if (sWords.length >= 3) sNumberInWords += sWords +" Thousand ";
cStringAmount = cStringAmount.substring(6,9)
}
if (cStringAmount.length <= 3)
{
sWords = NumberInWords(str3);
sNumberInWords += sWords+' '
}
var sTens=gettens(str4);
sTens=((sTens == " ") ? 'Zero' : sTens)
sNumberInWords += ((sTens <= 0) ? '' : '');
//sNumberInWords+='and '+str4+'/100'
return (sNumberInWords)
}
function NumberInWords(cString)
{
xhund =gethund(cString.substring(0,1))
xtens =gettens(cString.substring(1,3))
xwords=xhund
xwords+= ((xtens.length >= 3) ? ' ' : '')+xtens
return (xwords);
}
function gettens(xValue)
{
xval_ =xValue.substring(0,1);
_xval =xValue.substring(1,2);
if (xval_ == '1' && _xval != '0')
{
xnum= teens(_xval)
}
if (xval_ == '1' && _xval == '0') xnum="Ten"

if (xval_ != '1' && (_xval != '0' || _xval == '0'))
{
xnum= tens(xval_)+" "+getunits(_xval);
}
return (xnum)
}