Below is the result of a program which shows how scope (local versus global variables) works. Follow that code and see what it is doing....
<script type="text/vbscript">
dim name, dummy
name = "Frank"
document.write(name)
dummy=someFunction
document.write(name)
function someFunction()
dim name
name="Richard"
document.write(name)
end function
//-->
</script>