function readCookie(name)   
  
{   
  
  var cookieValue = "";   
  
  var search = name + "=";   
  
  if(document.cookie.length > 0)   
  
  {    
  
    offset = document.cookie.indexOf(search);   
  
    if (offset != -1)   
  
    {    
  
      offset += search.length;   
  
      end = document.cookie.indexOf(";", offset);   
  
      if (end == -1) end = document.cookie.length;   
  
      
	  var arrStr = document.cookie.substring(offset, end).split("&");  
     if(arrStr.length > 0)
	 {
	 cookieValue = arrStr[0]
	 }
	 else
	 {
	 cookieValue = document.cookie.substring(offset, end)
	 }
    }   
  
  }   
  

  return cookieValue;
}  

function dlorlb() 
{
if(readCookie("bideeduusername")=="")
{
document.getElementById("topdlzc").innerHTML="<div class=toptb><span onclick=mask.style.visibility='visible';massage_box.style.visibility='visible' style='cursor: hand' id=topdlimg><a href='#'><img src='http://www.bideedu.com/bideimg/new_top_lo_01.gif' border='0' /></a></span></div><div class=topkg>&nbsp;</div><div class=toptb><span onclick=mask.style.visibility='visible';massage_boxzc.style.visibility='visible'  style='cursor: hand' id=topzcimg><a href='#'><img src='http://www.bideedu.com/bideimg/new_top_lo_03.gif' border='0' /></a></span></div>";	

this.formreg.regan.value="提交注册";
	this.formdl.tjdl.value="登 录";
}
else
{
	document.getElementById("topdlzc").innerHTML="<div class=topwz><b><a title=用户中心 href=http://centra.bideedu.com/default.asp>" + readCookie('bideeduusername')+ "</a></div><div class=topkg></div><div class=topwz><a href='http://www.bideedu.com/logout.asp'>退出</a></b></div>";

}
}

function dlyzm() 
{
document.getElementById('getbideeducodedl').innerHTML="<img src=http://centra.bideedu.com/getbideeducode.asp?pp=Math.random()>";
if(this.formdl.yzm.value=='点击获取'){
	this.formdl.yzm.value='';
	}
}

function dlyzmb() 
{
document.getElementById('getbideeducodedlb').innerHTML="<img src=http://centra.bideedu.com/getbideeducode.asp?pp=Math.random()>";
if(this.formdlb.yzm.value=='点击获取'){
	this.formdlb.yzm.value='';
	}
}

function zcyzm() 
{
document.getElementById('getbideeducodezc').innerHTML="<img src=http://centra.bideedu.com/getbideeducode.asp?pp=Math.random()>";
if(this.formreg.yzm.value=='点击获取'){
	this.formreg.yzm.value='';
	}
}

function openwyfb() 
{
location.href='http://centra.bideedu.com/wyfb.asp';
}



function openwyqz()
{
if(readCookie("bideeduusername")=="")	
{
var sUrl=window.location.href;
location.href='http://centra.bideedu.com/default.asp?comeurl=' +sUrl ;	
}
else
{
location.href='http://centra.bideedu.com/wdqz.asp?wdqzaction=wyqz';

}
}


function ignoreSpaces(string) {
var temp = "";
string = '' + string;
splitstring = string.split(" ");
for(i = 0; i < splitstring.length; i++)
temp += splitstring[i];
return temp;
}
// End -->


 function checkdl()
 {
  if(this.formdl.username.value=="")
  {
    alert('用户名不能为空！');
	this.formdl.username.focus();
	return false;
  }
  else
  {
  if (this.formdl.username.value.length < 2 || this.formdl.username.value.length > 10 ) 
{
	alert('用户名长度必须为2--10位');
	this.formdl.username.focus();
	return false;
}
var check = /^[A-Za-z0-9\_]*$/;
if (!check.test(this.formdl.username.value))
{
	alert("用户名" + "必须为英文,数字和下划线");
	this.formdl.username.focus();
	return false;
}
}
  if(this.formdl.password.value=="")
  {
   alert('密码不能为空');
   this.formdl.password.focus();
   return false;
  }
  else
  {
    var check = /^[A-Za-z0-9]*$/;
if (!check.test(this.formdl.password.value))
{
	alert("密码" + "必须为英文,数字");
	this.formdl.password.focus();
	return false;
}
    if(this.formdl.password.value.length<6||this.formdl.password.value.length>20)
	{
	 alert('密码长度必须在6~20个字符');
	 this.formdl.password.focus();
	 return false;
	}
  }
  
   if(this.formdl.yzm.value=="")
  {
    alert('验证码不能为空！');
	this.formdl.yzm.focus();
	return false;
  }
  else
  {
  var check = /^[0-9]*$/;
if (!check.test(this.formdl.yzm.value))
{
	alert("验证码" + "必须为数字");
	this.formdl.yzm.focus();
	return false;
}
}
   }
   
   
   function checkdlb()
 {
  if(this.formdlb.username.value=="")
  {
    alert('用户名不能为空！');
	this.formdlb.username.focus();
	return false;
  }
  else
  {
  if (this.formdlb.username.value.length < 2 || this.formdlb.username.value.length > 10 ) 
{
	alert('用户名长度必须为2--10位');
	this.formdlb.username.focus();
	return false;
}
var check = /^[A-Za-z0-9\_]*$/;
if (!check.test(this.formdlb.username.value))
{
	alert("用户名" + "必须为英文,数字和下划线");
	this.formdlb.username.focus();
	return false;
}
}
  if(this.formdlb.password.value=="")
  {
   alert('密码不能为空');
   this.formdlb.password.focus();
   return false;
  }
  else
  {
    var check = /^[A-Za-z0-9]*$/;
if (!check.test(this.formdlb.password.value))
{
	alert("密码" + "必须为英文,数字");
	this.formdlb.password.focus();
	return false;
}
    if(this.formdlb.password.value.length<6||this.formdlb.password.value.length>20)
	{
	 alert('密码长度必须在6~20个字符');
	 this.formdlb.password.focus();
	 return false;
	}
  }
  
   if(this.formdlb.yzm.value=="")
  {
    alert('验证码不能为空！');
	this.formdlb.yzm.focus();
	return false;
  }
  else
  {
  var check = /^[0-9]*$/;
if (!check.test(this.formdlb.yzm.value))
{
	alert("验证码" + "必须为数字");
	this.formdlb.yzm.focus();
	return false;
}
}
   }
   
   
   var Obj='' 
document.onmouseup=MUp 
document.onmousemove=MMove

function MDown(Object){ 
Obj=Object.id 
document.all(Obj).setCapture() 
pX=event.x-document.all(Obj).style.pixelLeft; 
pY=event.y-document.all(Obj).style.pixelTop; 
}

function MMove(){ 
if(Obj!=''){ 
   document.all(Obj).style.left=event.x-pX; 
   document.all(Obj).style.top=event.y-pY; 
} 
}

function MUp(){ 
if(Obj!=''){ 
   document.all(Obj).releaseCapture(); 
   Obj=''; 
} 
} 

 function checkUserName()
  {
  var ch=document.getElementById("checkname");
	ch.innerHTML="<img src='http://www.bideedu.com/bideimg/20090628084940536.gif'>"+"正在检验用户名。。。";
	
   username=document.getElementById("username").value;
   var xmlhttp;
   try
   {
	 xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
   }
   catch (e)
   {
     try
     {
       xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
     }
     catch (e)
     { 
	    try
	    {
			xmlhttp=new XMLHttpRequest();
	    }
	    catch (e)
	    {
	    }
     }
   }
  if (username.replace(/(^\s*)|(\s*$)/g,"")=="")
  {
    msg="用户名不能为空";
	var ch=document.getElementById("checkname");
	ch.innerHTML="<font color='#aaaaaa'>"+msg+"</font>";	   
	return false;
  }

  //创建请求，并使用escape对username编码，以避免乱码
   xmlhttp.open("get","http://centra.bideedu.com/checkuser.asp?username="+escape(username)+ "&t=" +  new Date().getTime());
   xmlhttp.onreadystatechange=function()
   {
     if(4==xmlhttp.readyState)
	 {
	   if(200==xmlhttp.status)
	   {
	     if (xmlhttp.responseText=="yes")
	     { 
		   msg="此用户名已经存在";
	     }
		 else
		 {
		  msg="输入正确";
		 }		
	   }
	   else
	   {
	     msg="网络链接失败";
	   }
	   var ch=document.getElementById("checkname");
	   ch.innerHTML="<font color='#aaaaaa'>"+msg+"</font>";	   
	 }
   }
   xmlhttp.send(null);  
   return false;
   }  


  function checkpass1()
  {
    var Inform="formreg";
	var Inputname="password1";
    var Form=Inform+"."
    eval("Temp="+Form+Inputname+".value;"); 
	//alert(Temp);
	if(Temp.replace(/(^\s*)|(\s*$)/g,"")==""){ 
	msg="请确认你输入的密码";
	}
	else
	{ 	
      var Inputname1="password";
	    eval("Temp1="+Form+Inputname1+".value");
		if (Temp!=Temp1)
		{
          eval(Form+Inputname+".value='';");
		  eval(Form+Inputname1+".value='';");
		  eval(Form+Inputname1+".focus();");
		  msg="两次密码不一样！";	
		  msg1="";
		  var ch1=document.getElementById("password2");
		  ch1.innerHTML="<font color='#aaaaaa'>"+msg1+"</font>";
		}
		else
		{
		  msg="输入正确";
		}
	  }
	
	var ch=document.getElementById("password3");
	ch.innerHTML="<font color='#aaaaaa'>"+msg+"</font>";	
  }
    function checkpass()
  {
    var Inform="formreg";
	var Inputname="password";
    var Form=Inform+"."
    eval("Temp="+Form+Inputname+".value;"); 
	//alert(Temp);
	if(Temp.replace(/(^\s*)|(\s*$)/g,"")==""){ 
	msg="密码不能为空";	
	}
	else
	{ 	
      if(Temp.length<6||Temp.length>20)
	  {
	    msg="密码必须在6~20个字符之间";
	  }
	  else
	  {
	    msg="输入正确";
	  }
	}
	var ch=document.getElementById("password2");
	ch.innerHTML="<font color='#aaaaaa'>"+msg+"</font>";
  }


 function checkreg()
 {
  if(this.formreg.username.value=="")
  {
    alert('用户名不能为空！');
	this.formreg.username.focus();
	return false;
  }
  else
  {
  if (this.formreg.username.value.length < 2 || this.formreg.username.value.length > 10 ) 
{
	alert('用户名长度必须为2--10位');
	this.formreg.username.focus();
	return false;
}
var check = /^[A-Za-z0-9\_]*$/;
if (!check.test(this.formreg.username.value))
{
	alert("用户名" + "必须为英文,数字和下划线");
	this.formreg.username.focus();
	return false;
}
}
  if(this.formreg.password.value=="")
  {
   alert('密码不能为空');
   this.formreg.password.focus();
   return false;
  }
  else
  {
    var check = /^[A-Za-z0-9]*$/;
if (!check.test(this.formreg.password.value))
{
	alert("密码" + "必须为英文,数字");
	this.formreg.password.focus();
	return false;
}
    if(this.formreg.password.value.length<6||this.formreg.password.value.length>20)
	{
	 alert('密码长度必须在6~20个字符');
	 this.formreg.password.focus();
	 return false;
	}
  }
  
  if (this.formreg.email.value.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
   {
   }
   else
   {
    alert('电子邮件格式错误');
	 this.formreg.email.focus();
	 return false;
   }
  
   if(this.formreg.niname.value=="")
  {
   alert('昵称不能为空');
   this.formreg.niname.focus();
   return false;
  }
  else
  {
    if(this.formreg.niname.value.length<2||this.formreg.niname.value.length>6)
	{
	 alert('昵称必须在2~6个字符');
	 this.formreg.niname.focus();
	 return false;
	}
  }
  
   if(this.formreg.yzm.value=="")
  {
    alert('验证码不能为空！');
	this.formreg.yzm.focus();
	return false;
  }
  else
  {
  var check = /^[0-9]*$/;
if (!check.test(this.formreg.yzm.value))
{
	alert("验证码" + "必须为数字");
	this.formreg.yzm.focus();
	return false;
}
}

   }



