这个脚本每次刷新都感觉有些功能没执行一样.到底哪里出现问题啊?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
                                   
<style type="text/css">
ul{list-style:none;}
*{margin:0;padding:0;}
#wrap{width:200px;overflow:hidden;height:102px;}
#con{width:250%;}
#list1{float:left;margin-top:2px;width:100px;height:10px;background:orange;}
#wrap01{position:relative;width:250px;margin:175px auto 0;}
#num{width:30px;height:20px;background:pink;text-align:center}
#test li{width:100px;height:100px;float:left;margin-left:5px;display:inline;background:orange;}
</style>

</head>
<body>
<div id="wrap01">
<div id="wrap">
<div id="con">
<div id="list1">
</div>
<div style="clear:both"></div>
</div>
</div>
<div id="num"></div>
</div>
<div id="test" style="display:none">
<ul>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<div style="clear:both"></div>
</ul>
</div>
 
 <script type="text/javascript">
 
var $ = function (id){ return document.getElementById(id)};
var wrap = $("wrap");
var list1 = $("list1");
var list2 = $("list2");
var num = $("num");


var time =10;
function autoScroll(){
if(wrap.scrollLeft <= 0){
wrap.scrollLeft = wrap.scrollLeft + list1.offsetWidth;
clearInterval(m);
}
else{
wrap.scrollLeft--;
num.innerHTML = 100-wrap.scrollLeft+"%";
num.style.position = "absolute";
num.style.top = "10px";
num.style.left = num.lastChild.nodeValue;
if(parseInt(num.style.left) == 100){
$("test").style.display ="block";
$("wrap01").style.display = "none";
}
}
}
var m = setInterval("autoScroll()",10);
wrap.onmouseover = function(){
clearInterval(m);
}
wrap.onmouseout = function(){
m=setInterval("autoScroll()",10);
}
var ypos = 0;
function test(){
var test = $("test");
test.style.position = "absolute";
test.style.left = "20%";
if(ypos == 200){
clearTimeout(elem);
return true;

}
if(ypos < 200){
var dist = Math.ceil((200 - ypos)/260);
ypos = ypos + dist;
}
if(ypos > 200){
var dist = Math.ceil((ypos - 200)/260);
ypos = ypos - dist;
}
test.style.top = ypos+"px";
var elem = setTimeout("test()",10);
}
window.onload  = test;
</script>
 

</body>
</html>