// JavaScript Document
//function search(){
//  if(checkspace(document.selsearch.selclass.value)) 
//  {
//		alert("请选择分类！")
//        document.selsearch.selclass.focus();
//        return false;
//  }
// document.selsearch.submit();
//}
//=====================缩略图====================
function checkspace(checkstr) {
  var str = '';
  for(i = 0; i < checkstr.length; i++) {
    str = str + ' ';
  }
  return (str == checkstr);
}
function set_img(objimg,imgwidth,imgheight)
{
	if(objimg.width>imgwidth)	
        {		
          objimg.height=(objimg.height*(imgwidth/objimg.width)).toFixed(0);		               objimg.width=imgwidth;	
        }	
        if(objimg.height>imgheight)	
        {		
          objimg.width=(objimg.width*(imgheight/objimg.height)).toFixed(0);		          objimg.height=imgheight;
	}
}
function chkLogin() 
{
if(checkspace(document.Login.UserName.value))
{
alert("请输入用户名!");
document.Login.UserName.focus();
return false;
}

if(checkspace(document.Login.UserPassWord.value))
{
alert("请输入密码!");
document.Login.UserPassWord.focus();
return false;
}
}
//==============图片放大功能===========开始

function show(_this) { 
document.getElementById("enlarge_images").innerHTML = "<img src='" + _this.src + "' >"; 
document.getElementById("enlarge_images").style.visibility="visible";
document.onmousemove =move_layer; 
} 
function hide(_this) { 
document.getElementById("enlarge_images").innerHTML = ""; 
document.getElementById("enlarge_images").style.visibility="hidden";
document.onmousemove =""; 
} 
function move_layer(event){ 
event = event || window.event; 
document.getElementById("enlarge_images").style.left=event.clientX+document.body.scrollLeft+20;
document.getElementById("enlarge_images").style.top=event.clientY+document.body.scrollTop; 
} 


//==============图片放大功能==========结束

//===========留言添加===============
function GbAdd_onsubmit() 
{
if(checkspace(document.mymsg.U_Name.value))
{
alert("您必须输入您的姓名!");
document.mymsg.U_Name.focus();
return false;
}
if(!checkspace(document.mymsg.U_Email.value))
  {
    if(document.mymsg.U_Email.value.charAt(0)=="." ||        
         document.mymsg.U_Email.value.charAt(0)=="@"||       
         document.mymsg.U_Email.value.indexOf('@', 0) == -1 || 
         document.mymsg.U_Email.value.indexOf('.', 0) == -1 || 
         document.mymsg.U_Email.value.lastIndexOf("@")==document.mymsg.U_Email.value.length-1 || 
         document.mymsg.U_Email.value.lastIndexOf(".")==document.mymsg.U_Email.value.length-1)
     {
      alert("Email地址格式不正确！");
      document.mymsg.U_Email.focus();
      return false;
      }
   }

if(checkspace(document.mymsg.where2.value))
{
alert("请选择你来自区域!");
document.mymsg.where2.focus();
return false;
}
if(checkspace(document.mymsg.Title.value))
{
alert("您必须输入您的咨询标题!");
document.mymsg.Title.focus();
return false;
}
if(checkspace(document.mymsg.Content.value))
{
alert("您必须输入您的留言内容!");
document.mymsg.U_Name.focus();
return false;
}
if(document.mymsg.Content.value.length>600)
{
alert("您输入留言内容超过600字!");
document.mymsg.Content.focus();
return false;
}
if(checkspace(document.mymsg.vcode.value.length))
{
alert("您必须验证码!");
document.mymsg.vcode.focus();
return false;
}
return true;
}

function enGbAdd_onsubmit() 
{
if(checkspace(document.mymsg.U_Name.value))
{
alert("please enter your name!");
document.mymsg.U_Name.focus();
return false;
}
if(!checkspace(document.mymsg.U_Email.value))
  {
    if(document.mymsg.U_Email.value.charAt(0)=="." ||        
         document.mymsg.U_Email.value.charAt(0)=="@"||       
         document.mymsg.U_Email.value.indexOf('@', 0) == -1 || 
         document.mymsg.U_Email.value.indexOf('.', 0) == -1 || 
         document.mymsg.U_Email.value.lastIndexOf("@")==document.mymsg.U_Email.value.length-1 || 
         document.mymsg.U_Email.value.lastIndexOf(".")==document.mymsg.U_Email.value.length-1)
     {
      alert("Email address format is incorrect！");
      document.mymsg.U_Email.focus();
      return false;
      }
   }

if(checkspace(document.mymsg.where2.value))
{
alert("Please select where you come from!");
document.mymsg.where2.focus();
return false;
}
if(checkspace(document.mymsg.Title.value))
{
alert("please enter your title");
document.mymsg.Title.focus();
return false;
}
if(checkspace(document.mymsg.Content.value))
{
alert("You must enter your Message!");
document.mymsg.U_Name.focus();
return false;
}
if(document.mymsg.Content.value.length>600)
{
alert("Message content you enter more than 600 words!");
document.mymsg.Content.focus();
return false;
}
if(checkspace(document.mymsg.vcode.value.length))
{
alert("You must verify code!");
document.mymsg.vcode.focus();
return false;
}
return true;
}
//========================================
function checkuserinfo()
{
   var filter=/^\s*[A-Za-z0-9_]{3,20}\s*$/;
   if (!filter.test(document.userinfo.uname.value))
   { 
    alert("可使用的字符为（A-Z a-z 0-9 _),注意不要使用空格");
	document.userinfo.uname.focus();
	document.userinfo.uname.select();
	return false;
	} 
	
	 var filter=/^\s*[A-Za-z0-9_]{6,16}\s*$/;
	if (!filter.test(document.userinfo.upwd.value)) 
	{ 
	alert("密码填写不正确,请重新填写！可使用的字符为（A-Z a-z 0-9 _),注意不要使用空格");
	document.userinfo.upwd.focus();
	document.userinfo.upwd.select();
	return false;
	}        

if(checkspace(document.userinfo.upwd.value) || document.userinfo.upwd.value.length < 6 || document.userinfo.upwd.value.length >20) {
	document.userinfo.upwd.focus();
    alert("密码长度不对，必须在6位到20位之间，请重新输入！");
	return false;
  }
    if(document.userinfo.upwd.value != document.userinfo.upwd2.value) {
	document.userinfo.upwd.focus();
	document.userinfo.upwd.value = '';
	document.userinfo.upwd2.value = '';
    alert("两次输入的密码不同，请重新输入！");
	return false;
  }
  
 if(checkspace(document.userinfo.userzhenshiname.value)) 
{
	document.userinfo.userzhenshiname.focus();
   alert("真实姓名必须填写！");
	return false;
}
 if(document.userinfo.useremail.value.length!=0)
  {
    if (document.userinfo.useremail.value.charAt(0)=="." ||        
         document.userinfo.useremail.value.charAt(0)=="@"||       
         document.userinfo.useremail.value.indexOf('@', 0) == -1 || 
         document.userinfo.useremail.value.indexOf('.', 0) == -1 || 
         document.userinfo.useremail.value.lastIndexOf("@")==document.userinfo.useremail.value.length-1 || 
         document.userinfo.useremail.value.lastIndexOf(".")==document.userinfo.useremail.value.length-1)
     {
      alert("Email地址格式不正确！");
      document.userinfo.useremail.focus();
      return false;
      }
	  
   }
   else
	  {
	  alert("请输入Email地址");
	  document.userinfo.useremail.focus();
      return false;
	  }
	  
    if(checkspace(document.userinfo.usermobile.value)){
	document.userinfo.usermobile.focus();
    alert("对不起，请留下您的移动电话！");
	return false;
  }
 
if(checkspace(document.userinfo.vcode.value))
{
	document.userinfo.vcode.focus();
    alert("请输入验证码！");
	return false;
}
return true;
}
function isNumberString (InString,RefString)
{
	if(InString.length==0) return (false);
	for (Count=0; Count < InString.length; Count++)  {
		TempChar= InString.substring (Count, Count+1);
		if (RefString.indexOf (TempChar, 0)==-1)
		return (false);
	}
	return (true);
}
//=========验证码=========
function init()
{
	newimg();
}
function newimg()
{
	document.getElementById("verify_img").src='codenumber/GetCode.asp?rand='+ Math.random();
}
//=========checkuser
	function chk_user()
	{
	document.getElementById("err_info").innerHTML="正在获取用户信息..."
	chk.username3.value=document.userinfo.uname.value;   //将GOUWU表单中的USERNAME，USERPASSWORD，VERIFYCODE赋给表单CHK中相对应的值
	chk.submit();//调用表单
	}
	function user_info(msg)
	{
	document.getElementById("err_info").innerHTML="<font color='red'>"+msg+"</font>";
	}