﻿//产品导航菜单
function SwitchMenu(id)
{
	imgLaunches = new Image();
	imgClose = new Image();
	imgLaunches.src = 'img/arrow1.gif';
	imgClose.src = 'img/arrow2.gif';
	
	var img = document.getElementById("img" + id);
	var tr = document.getElementById("tr" + id);
	if(tr != null)
	{
		if(tr.style.display == "none")
		{
	        tr.style.display = "block";
			img.src = imgLaunches.src;
		}
		else
		{
			tr.style.display = "none";
			img.src = imgClose.src;
		}
	}
	else
	{
		if(img.src == imgClose.src)
		{
			img.src = imgLaunches.src;
		}
		else
		{
			img.src = imgClose.src;
		}

	}
}


//弹出新窗口
function MM_openBrWindow(theURL,winName,features)
{
	window.open(theURL,winName,features);
}


//下拉导航菜单
function Menu(obj,action)
{
	var el = document.getElementById(obj);
	if(document.getElementById && action == "show")
	{
		el.style.display = "block";
	}
	else
	{
		if(document.getElementById && action == "hide")
		{
			el.style.display = "none";
		}
	}
	
}


//自动调整图片
function autoImg(img,w,h)
{
	if(w<=0 || h<=0) return;
	var image=new Image();
	image.src=img.src;
	//判断宽
	if(image.width>w)
	{
		newHeight=image.height/image.width*w;
		img.width=w;
		img.height=newHeight;
	}
	//判断高
	if(img.height>h)
	{
		newWidth=image.width/image.height*h;
		img.height=h;
		img.width=newWidth;
	}      
}


//验证用户登录
function CheckForm()
{
	if(document.UserLogin.UserName.value == "")
	{
		alert("请输入用户名！");
		document.UserLogin.UserName.focus();
		return false;
	}
	if(document.UserLogin.Password.value == "")
	{
		alert("请输入密码！");
		document.UserLogin.Password.focus();
		return false;
	}
	return true;
}


//显示当前日期
function showTime()
{
	today = new Date();
	var year,month,date,week,hour,day,hello,wel;
	
	year = today.getYear();
	month = today.getMonth() + 1;
	date = today.getDate();
	week = today.getDay();
	hour = today.getHours();
	/*
	if(hour < 6) hello='凌晨好'
	else if(hour < 9) hello='早上好'
	else if(hour < 12) hello='上午好'
	else if(hour < 14) hello='中午好'
	else if(hour < 17) hello='下午好'
	else if(hour < 19) hello='傍晚好'
	else if(hour < 22) hello='晚上好'
	else {hello='夜里好'}
	*/
	if(week == 0) day='星期日'
	else if(week == 1) day='星期一'
	else if(week == 2) day='星期二'
	else if(week == 3) day='星期三'
	else if(week == 4) day='星期四'
	else if(week == 5) day='星期五'
	else if(week == 6) day='星期六'
	wel = '今天是' + year + '年' + month + '月' + date + '日'+ ' ' + day ;
	document.write(wel);
}

