lshow = 230; //出现部分的宽度
var move=10;  //步伐
menuSpeed=30  //速度
var moveOnScroll = true; 
var tim;
var ltop;

function makeMenu(obj,nest){
    nest = (!nest) ? '':'document.'+nest+'.';
    this.css = eval(obj+'.style')
    this.state = 1
    this.go = 0
    this.width = eval(obj+'.offsetWidth')
    this.right = b_getright 
    this.obj = obj + "Object";         
	eval(this.obj + "=this")
}
function b_getright(){
        var gright = eval(this.css.pixelRight);
        return gright;
}
function moveMenu(){
        if(!oMenu.state){
               clearTimeout(tim)
                mIn()
        }else{
                clearTimeout(tim)
                mOut()
        }
}
function closeMenu(){
        if(!oMenu.state){
                clearTimeout(tim)
                mIn()
				}
}
function mIn(){
        if(oMenu.right()>-oMenu.width+lshow){
                oMenu.go=1
                oMenu.css.right=oMenu.right()-move
                tim=setTimeout("mIn()",menuSpeed)
        }else{
                oMenu.go=0
                oMenu.state=1
        }
}
function mOut(){
		if(oMenu.right()<-2){ 
                oMenu.go=1
                oMenu.css.right = oMenu.right()+move
                tim=setTimeout("mOut()",menuSpeed)
        }else{
                oMenu.go=0
                oMenu.state=0
        }
}
function checkScrolled(){
        if(!oMenu.go) oMenu.css.top=eval(scrolled)+ltop
}
function menuInit(){ 
        oMenu = new makeMenu('divmenu') 
        scrolled = "document.documentElement.scrollTop" //仅支持符合W3C的
								//scrolled = "document.body.scrollTop" //仅支持不符合W3C的
		oMenu.css.right = -oMenu.width+lshow
        ltop = 20;
        oMenu.css.visibility = 'visible'
		setInterval("checkScrolled()",100) 
}
onload = menuInit;