﻿// JScript 文件

//匿名函数，调用多个方法
window.onload=function()
{
    //start();
    time_rota();
    menuFix();
}

//Logo图片渐隐渐现脚本
var i=1;
var temp=true;
function start()
{
    var us=document.getElementById("us");
	if(document.all)
	{
		if(temp==true)
		{
			i++;
		}
		if(i==100)
		{
			i--;
			temp=false;
		}
		if(i==5)
		{
			i++;
			temp=true;
		}
		if(temp==false)
		{
			i--;
		}
	}
	us.filters.alpha.opacity=0+i;
	setTimeout("start()",50);  
}

//导航条下拉列表脚本
function menuControl(show)
{
	window.event.cancelBubble=true;   
	var objID=event.srcElement.id;   
	var index=objID.indexOf("_");   
	var mainID=objID.substring(0,index);   
	var numID=objID.substring(index+1,objID.length);
	if(mainID=="menubar")
	{
		if(show==1)
		{
			eval("showMenu("+"menu_"+numID+")");
		}
		else
		{
			eval("hideMenu("+"menu_"+numID+")");  
		}
	}
}
var nbottom=0,speed=7;
function displayMenu(obj)
{
	obj.style.clip="rect(0   100%   "+nbottom+"%   0)";
	nbottom+=speed;
	if(nbottom<=100)
	{
		var timerID=setTimeout("displayMenu("+obj.id+"),70");
	}
	else
	{
		clearTimeout(timerID);
	}
}
function showMenu(obj)
{ 
	obj.style.display="block";
	obj.style.clip="rect(0   0   0   0)"; 
	nbottom=5;
	displayMenu(obj);
}
function hideMenu(obj)
{
	nbottom=0;
	obj.style.display="none";
}
function keepMenu(obj)
{
	obj.style.display="block"; 
}

//显示时间脚本
function time_rota() 
{ 
    var ss=document.getElementById("CurentTime");
    var CLOCK=document.getElementById("CLOCK");
    now = new Date(); 
    h="0"+now.getHours(); 
    m="0"+now.getMinutes(); 
    s="0"+now.getSeconds(); 
    if(h>9){h=now.getHours()} 
    if(m>9){m=now.getMinutes()} 
    if(s>9){s=now.getSeconds()} 
    var vYear=now.getFullYear();
    var vMon=now.getMonth()+1;
    var vDay=now.getDate();
    var myweekday=now.getDay();
    var weekday="";
    if(myweekday == 0)
    weekday=" SUN ";
    else if(myweekday == 1)
    weekday=" MON ";
    else if(myweekday == 2)
    weekday=" TUS ";
    else if(myweekday == 3)
    weekday=" WEN  ";
    else if(myweekday == 4)
    weekday=" THUR ";
    else if(myweekday == 5)
    weekday=" FRI  ";
    else if(myweekday == 6)
    weekday=" SAT ";
    CLOCK.value =" "+h+"："+m+"："+s+"       ";
    ss.value=vYear+"-"+vMon+"-"+vDay+"  "+weekday;
    setTimeout('time_rota()',1000);
} 


//文本框只能输入数字
function onKeyPressInputInteger()
{
	var nKey = window.event.keyCode;

	if (nKey < 48 || nKey > 57)
		window.event.keyCode = 0;
}
// JScript 主菜单
function menuFix() 
{
    var sfEls = document.getElementById("nav").getElementsByTagName("li");
    for (var i=0; i<sfEls.length; i++) 
    {
        sfEls[i].onmouseover=function() 
        {
            this.className+=(this.className.length>0? " ": "") + "sfhover";
        }
        sfEls[i].onMouseDown=function() 
        {
            this.className+=(this.className.length>0? " ": "") + "sfhover";
        }
        sfEls[i].onMouseUp=function() 
        {
            this.className+=(this.className.length>0? " ": "") + "sfhover";
        }
        sfEls[i].onmouseout=function() 
        {
            this.className=this.className.replace(new RegExp("( ?|^)sfhover\\b"),"");
        }
    }
} 

