I have the following code in test.js:

Code JavaScript:
function mytest() {
	document.write('bbb');
}
 
function populate(){
	lefttime=setInterval('mytest()',10000)
}
 
window.onload=populate

It works fine. bbb is written. I want to put all the code in a function, so in test.js I put:

Code JavaScript:
function testFile() {
 
	   function mytest() {
	   	   document.write('bbb');
	   }
 
	   function populate(){
	   	   lefttime=setInterval('mytest()',10000)
	   }
 
	   window.onload=populate
 
}
but now when I call testFile(), I get the error "mytest is not defined".

This is driving me crazy. Why is wrapping the code in a function causing a problem?