/*
	CheckLoginForm()
	会员登录前台数据判断
*/
function CheckLoginForm()
{
	//判断用户名是否为空
	if(document.regForm.UserName.value == "")
	{
		alert("用户名不可为空!");
		document.regForm.UserName.focus();
		return false;
	}
	//判断密码是否为空
	if(document.regForm.PassWord.value == "")
	{
		alert("密码不可为空!");
		document.regForm.PassWord.focus();
		return false;
	}
}

/*
	LoginErrorMsg(divId,txtMsg,iconId)	显示登录错误信息
	divId	div id		加载错误信息的标签
	txtMsg	文本
	iconId	icon图标	"1"为警告,"2"为错误
*/
function LoginErrorMsg(divId,txtMsg,iconId)
{
	var MsgHtml = "";
	if(iconId == "1")
	{
			MsgHtml = '<img src="images/icon_error.gif" height="12" />';
	}
	else if(iconId == "2")
	{
			MsgHtml = '<img src="images/icon_error2.gif" height="12" />';
	}
	else if(iconId == "3")
	{
			MsgHtml = '<img src="images/icon_ok.gif" height="12" />';
	}
	
	if(txtMsg == "")
	{
		document.getElementById(divId).innerHTML = "";
	}
	else
	{
		MsgHtml = MsgHtml + "<span class='red'>" + txtMsg +"</span>";
		document.getElementById(divId).innerHTML = MsgHtml;
	}
}

/*
	CheckRegForm()
	会员注册前台数据判断
*/
function CheckRegForm()
{
	//判断用户名是否为空
	if(document.regForm.UserName.value == "")
	{
		alert("用户名不可为空!");
		document.regForm.UserName.focus();
		return false;
	}
//	//判断是否有非法字符
//	var n=document.regForm.UserName.value.length;
//	var tempmsg="";
//	for(var i=0;i<n;i++)
//	{
//		var zm=document.regForm.UserName.value.charCodeAt(i);
//		if(!((zm >= 48&&zm <= 57)||(zm >= 65&&zm <= 90)||(zm>= 97 &&zm<= 122)))
//		{
//			tempmsg += "\"" + document.regForm.UserName.value.charAt(i)+"\"，";
//			var flag = 1;
//		}
//	}
//	if(flag){
//		alert('您输入的ＩＤ中包含下列不合法的字符：'+tempmsg);
//		document.regForm.UserName.focus();
//		return false;
//	}
	//判断用户名是否超长
	if(getByteLen(document.regForm.UserName.value) > 14)
	{
		alert("用户名长度不可超过14个字节,或7个汉字!");
		document.regForm.UserName.focus();
		return false;
	}

	//判断密码是否为空
	if(document.regForm.PassWord.value == "")
	{
		alert("密码不可为空!");
		document.regForm.PassWord.focus();
		return false;
	}
	//判断密码是否为空
	if(document.regForm.PassWord.value != document.regForm.PassWord2.value)
	{
		alert("两次密码不相同,请重新输入!");
		document.regForm.PassWord2.focus();
		return false;
	}
	//判断年龄是否为空
	if(document.regForm.Age.value == "")
	{
		alert("年龄不可为空!");
		document.regForm.Age.focus();
		return false;
	}
	//判断邮箱地址是否为空
	if(document.regForm.Email.value == "")
	{
		alert("Email不可为空!");
		document.regForm.Email.focus();
		return false;
	}
	//检查E-mail
	if(document.regForm.Email.value==""){
		alert('请输入你的E-mail！');
		document.regForm.Email.focus();
		return false;
	}
	if(document.regForm.Email.value.indexOf("@")==-1){
		alert('请输入你的正确E-mail，必须包括“@”!');
		document.regForm.Email.focus();
		return false;
	}
	tempmsg=document.regForm.Email.value.substring(0,document.regForm.Email.value.indexOf("@"));
	if(tempmsg.length<3){
		alert('请输入你的完整的E-mail!\"@\"前面的字符长度不能小于3位！');
		document.regForm.Email.focus();
		return false;
	}
	if(!((document.regForm.Email.value.indexOf(".com")!=-1)||(document.regForm.Email.value.indexOf(".net")!=-1)||(document.regForm.Email.value.indexOf(".net")!=-1)||(document.regForm.Email.value.indexOf(".edu")!=-1))){
		alert('请输入你邮箱的后缀名！后缀名为小写！');
		document.regForm.Email.focus();
		return false;
	}
	tempmsg=regForm.Email.value.substring((regForm.Email.value.indexOf("@")+1),regForm.Email.value.indexOf("."));
	if(tempmsg.length<2){
		alert('请输入你邮箱的完整形式！\"@\"和\".\"之间的字符长度不小于2');
		regForm.Email.focus();
		return false;
	}
}

//判断字符串字节
function getByteLen(str)   
{   
	var l = str.length;   
	var n = l;   
	for(var i=0;i<l;i++)   
	if(str.charCodeAt(i)<0||str.charCodeAt(i)>255)   
	n++;   
	return n;
} 

/*
	OpenWind(sUrl,sName,sWitdh,sHeight)
		sUrl 路径
		sName 窗口名
		sWitdh 窗口宽
		sHeight 窗口高
	弹出自定义窗口
*/
function OpenWind(sUrl,sName,sWitdh,sHeight,isScrollbars)
{
	window.open(sUrl,sName,"width="+sWitdh+",Height="+sHeight+",Scrollbars="+isScrollbars+"");
}

/*
	checkForm()
	判断Q&A提交表单
*/
function checkQAForm()
{
	if(document.getElementById("company").value == "")
	{
		alert("呢称不可为空！");
		document.getElementById("company").focus();
		return false;
	}
	if(document.getElementById("title").value == "")
	{
		alert("留言标题不可为空！");
		document.getElementById("title").focus();
		return false;
	}
	if(document.getElementById("content").value == "")
	{
		alert("留言内容不可为空！");
		document.getElementById("content").focus();
		return false;
	}
	return true;
}

/*
	showMenu(nowId,sSrc)
	nowId:当前菜单
	sSrc:图片路径
	左侧菜单切换
*/
function showMenu(nowId,sSrc)
{
	if(nowId != pageId)
	{
		eval("document.getElementById('"+nowId+"').src = '"+ sSrc +"';");	
	}
}

function setDivShow(div)
{
	document.getElementById(div).style.display = "block";	
}


