﻿//验证用户
function RegUserCheck()
{
     if (document.form1.UserName.value == ""){
    alert("对不起，请输入用户名..");
	document.form1.UserName.focus();
	return false;
	}
	return true;
}
//验证注册信息
function formCheck(){
  if (document.form1.UserName.value == ""){
    alert("对不起，请输入用户名..");
	document.form1.UserName.focus();
	return false;
  }
  if(!(new RegExp(/^[A-Za-z0-9]/).test(document.form1.UserName.value)))
  {
      alert("对不起，用户名只能是字母或数字..");
      document.form1.UserName.value=""; 
	  document.form1.UserName.focus();
	  return false;
  }
  if (document.form1.UserPass.value == ""){
    alert("对不起，请输入密码..");
	document.form1.UserPass.focus();
	return false;
  }
    if (document.form1.UserPass.value.length<6){
    alert("对不起，密码位数不够...");
	document.form1.UserPass.focus();
	return false;
  }
   if (document.form1.UserPass.value !== document.form1.UserPass1.value){
    alert("对不起，两次密码输入不相同");
    document.form1.UserPass1.value=""; 
	document.form1.UserPass1.focus();
	return false;
  }
  if (document.form1.WebName.value == ""){
    alert("对不起，请输入网站名称..");
	document.form1.WebName.focus();
	return false;
  }
  if (document.form1.WebHttp.value == ""){
    alert("对不起，请输入网址..");
	document.form1.WebHttp.focus();
	return false;
  }
  if (document.form1.TrueName.value == ""){
    alert("对不起，请输入联系人..");
	document.form1.TrueName.focus();
	return false;
  }
  if (!(new RegExp(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/).test(document.form1.Email.value)))
  {
    alert("对不起，邮箱格式不正确!请正确输入..");
   document.form1.Email.value=""; 
	document.form1.Email.focus();
	return false;
  }
  if (document.form1.Mobile.value == ""){
    alert("对不起，请输入固定电话或者手机..");
	document.form1.Mobile.focus();
	return false;
  }
  if (document.form1.Bank.value == ""){
    alert("对不起，请输入收款银行..");
	document.form1.Bank.focus();
	return false;
  }
  if (document.form1.BankAccount.value == ""){
    alert("对不起，请输入银行帐号..");
	document.form1.BankAccount.focus();
	return false;
  }
  if (document.form1.BankName.value == ""){
    alert("对不起，请输入收款单位名称或个人姓名..");
	document.form1.BankName.focus();
	return false;
  }
  if (document.form1.lg.checked == ""){
    alert("\您必须阅读并接受“中大宏图远程教育网站招生联盟协议”才能注册!");
	document.form1.lg.focus();
	return false;
  }
}
//修改密码验证
function UpdatePwd()
{
      if (document.form1.txtOldP.value == ""){
    alert("对不起，原密码不能为空..");
	document.form1.txtOldP.focus();
	return false;
  }
    if (document.form1.txtNewP.value.length<6){
    alert("对不起，新密码位数不够...");
	document.form1.txtNewP.focus();
	return false;
  }
   if (document.form1.txtNewP.value !== document.form1.txtNewPR.value){
    alert("对不起，两次密码输入不相同");
    document.form1.txtNewPR.value=""; 
	document.form1.txtNewPR.focus();
	return false;
  }
}

//显示当前时间
function Clock() {
	var date = new Date();
	this.year = date.getFullYear();
	this.month = date.getMonth() + 1;
	this.date = date.getDate();
	this.day = new Array("星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六")[date.getDay()];
	this.hour = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
	this.minute = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
	this.second = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();

	this.toString = function() {
		return "现在是:" + this.year + "年" + this.month + "月" + this.date + "日 " + this.hour + ":" + this.minute + ":" + this.second + " " + this.day; 
	};
	
	this.toSimpleDate = function() {
		return this.year + "-" + this.month + "-" + this.date;
	};
	
	this.toDetailDate = function() {
		return this.year + "-" + this.month + "-" + this.date + " " + this.hour + ":" + this.minute + ":" + this.second;
	};
	
	this.display = function(ele) {
		var clock = new Clock();
		ele.innerHTML = clock.toString();
		window.setTimeout(function() {clock.display(ele);}, 1000);
	};
}


//验证是否符合标签的规则
function IsLabel(ob)
{
    var pat=/^\{#+\-+[a-zA-z]+\-+#\}+$/;//验证表达式
    var result=pat.test(ob.value);
    return result;
}

//样式标签添加与修改后，对数据进行提交前的验证
function LabelSubmitInfo()
{
    var name=document.getElementById("txtStyleName");//样式标签的名称
    var info=document.getElementById("txtStyleInfo");//样式标签的内容 
     if(name.value=="")
     {
        alert("标签名称不能为空！");
        name.focus();
        return false;
     }
     if(info.value=="")
     {
        alert("标签内容不能为空！");
        info.focus();
        return false;
     }
     else
     {
        if(!IsLabel(info))
        {
            alert("标签格式不正确！{#-**-#}");
            info.value="";
            info.focus();
           return false;   
        }
        return true;
     }
     return true;
}

// 在集成样式内容管理中，修改与添加数据提交时，对数据进行有效性验证
function  StyleSubmitInfo()
{
    var name=document.getElementById("txtStyleName");//集成样式内容的名称
    var info=document.getElementById("txtStyleInfo");//集成样式的内容 
     if(name.value=="")
     {
        alert("集成样式名称不能为空！");
        name.focus();
        return false;
     }
     if(info.value=="")
     {
        alert("集成样式内容不能为空！");
        info.focus();
        return false;
     }   
     return true;
}
//刷新验证码
 function ChangeMyCode()
       {
         var Obj=document.images["MyCheckCode"].src="AgentWeb/VMap.aspx?Tm="+new Date().getTime();
       }
//登录的验证事件
function forLSum()
{
    var name=document.getElementById("txtName");//登录名
    var pwd=document.getElementById("txtPwd");//登录密码
    var code=document.getElementById("txtCode");//验证码  
     if(name.value=="")
     {
        alert("登录名不能为空！");
        name.focus();
        return false;
     }
     if(pwd.value=="")
     {
        alert("登录密码不能为空！");
        pwd.focus();
        return false;
     }
     if(code.value=="")
     {
        alert("验证码不能为空！");
        code.focus();
        return false;
     }
     document.form1.submit();
     return true;
}

//CSS背景控制
function overColor(Obj)
{
	var elements=Obj.childNodes;
	for(var i=0;i<elements.length;i++)
	{
		elements[i].className="TR_BG"
		Obj.bgColor="";//颜色要改
	}
	
}
function outColor(Obj)
{
	var elements=Obj.childNodes;
	for(var i=0;i<elements.length;i++)
	{
		elements[i].className="TR_BG_list";
		Obj.bgColor="";
	}
}
//显示隐藏事件
function IsShowTr(Obj)
{
    var tr=document.getElementById(Obj);
   if(tr.style.display=="none")  
  {
    tr.style.display="";
  }    
  else
  {
    tr.style.display="none"
  }
}
