﻿// JScript 文件
//=========层滚动=================2008.8.9======（牟）
window.onload=FuDong2008MU;
window.onscroll=FuDong20080501MU;
window.onresize=FuDong20080501MU;

var $StarHeigth,$Heigth,$EndHeigth,num=0,$clearid;
var $state=true;
function FuDong2008MU(){
    var divStyle="color:red;position:absolute;z-index:999;display:block;";
    setStyle("FuDong2008MU",divStyle);
    $StarHeigth=Top();
    document.getElementById("FuDong2008MU").style.top=$StarHeigth+"px";
    document.getElementById("FuDong2008MU").style.left=Left()+"px";
	FuDong20080501MU();
}

function setStyle(id,style){
    var $S=document.getElementById(arguments[0]);
    $S.setAttribute("style",style);
    $S.style.cssText=style;
}

function FuDong20080501MU(){
    try
    {window.clearInterval($clearid);}
    catch(ex){}
    
    $EndHeigth=Top();
    $Heigth = $EndHeigth-$StarHeigth;
    
    if($Heigth>0){
        $state=true
    }else{
        $state=false;
        $Heigth=-$Heigth;
    }
    
    if($Heigth!=0){
        MaxNum=$Heigth%10;
        XMun=parseInt($Heigth/10);
        if(MaxNum!=0){
            XMun=XMun+1;
        }
       $clearid=setInterval("MOVEDIVMU()",10);
    }
}

function Top(){
    var retVal=document.documentElement.scrollTop;
    retVal=retVal+document.documentElement.clientHeight;
    retVal=retVal-document.getElementById("FuDong2008MU").offsetHeight;
    retVal=retVal-10;
    return retVal;
}
function Left(){
    var retVal=document.documentElement.scrollLeft;
    retVal=retVal+document.documentElement.clientWidth;
    retVal=retVal-document.getElementById("FuDong2008MU").offsetWidth;
    retVal=retVal-0;
    return retVal;
}
function MOVEDIVMU(){
    num++;
    if(num<=XMun){
        if($state){
            if(num==XMun && MaxNum!=0){
                document.getElementById("FuDong2008MU").style.top=($StarHeigth+(num-1)*10+MaxNum)+"px";
            }else{
                document.getElementById("FuDong2008MU").style.top=($StarHeigth+num*10)+"px";
            }
        }else{
            if(num==XMun && MaxNum!=0){
                document.getElementById("FuDong2008MU").style.top=($StarHeigth-(num-1)*10-MaxNum)+"px";
            }else{
                document.getElementById("FuDong2008MU").style.top=($StarHeigth-num*10)+"px";
            }
        }
    }
    else{
        window.clearInterval($clearid);
        $StarHeigth=Top();
        num=0
    }
}
//================================
