/*获取对象的引用*/
function $(id){ return document.getElementById(id);}
/*获取对象的样式集*/
function $S(id){ return document.getElementById(id).style;}
/*获取对象赋值*/
function $V(id){ return document.getElementById(id).value;}

//验证真实姓名(订单专用)
function checkRealName()
{
	var realName = $('realname');
	var realnamemsg = $('realnamemsg');
	var realName_Pattern = /^[\u4e00-\u9fa5]{2,4}$/;
	if(realName.value == ''){
        realnamemsg.innerHTML = '<font color="#FF0000">*</font>请输入2~4个汉字';
    }else{
        realnamemsg.innerHTML = '<img src="images/suc.gif">';
    }
}
//验证QQ（订单专用）
function checkQQ()
{
	var QQ = $('QQ');
    var QQmsg = $('QQmsg');
    var QQ_Pattern =/^[\d]{5,10}$/;
	if(QQ.value == ''){
		QQmsg.innerHTML = '<font color="#FF0000">*</font>请输入5~10位的QQ号码';	
	}else{
        QQmsg.innerHTML = '<img src="images/suc.gif">';
    }	
}
//验证联系方式（订单专用）
function checkMobilephone()
{
	var phoneNO_pattern = /^([\d]{11}|[\d]{3,5}-[\d]{6,9})$/; //手机11位,小灵通/固定电话
	if(document.getElementById('tel').value == ''){
		$('telmsg').innerHTML = '<font color="#FF0000">*</font>手机（11位），固定电话/小灵通（区号 - 号码）';
	}else if(!phoneNO_pattern.test(document.getElementById('tel').value)){
		$('telmsg').innerHTML = '<img src="images/err.gif">手机（11位），固定电话/小灵通（区号 - 号码）';
	}else{
		$('telmsg').innerHTML = '<img src="images/suc.gif">';	
	}
}
function  OerrRed(id){   
	$S(id).color="#F00";
} 
function clearRed(id){
	$S(id).color="#000";
	}
function Orders() {
var errMsg = $("errMsg");
	if($S("hiddenSpan").display=="")
	{
		if( $V("game_user_id")== "" ) {
			errMsg.innerHTML = "收货角色名称";
			$("game_user_id").focus();
			OerrRed("game_user_id_text");
			return false;
		}
		if( $V("game_user_id1")== "") {
			errMsg.innerHTML = "请输入确认收货角色名称";
			$("game_user_id1").focus();
			OerrRed("game_user_id1_text");
			return false;	
		}
		if( $V("game_user_id")!= $V("game_user_id1") ) {
			errMsg.innerHTML = "二次输游戏帐号不一致";
			$("game_user_id1").focus();
			OerrRed("game_user_id1_text");
			return false;	
		}
		
		if( $V("Game_usergrade")== "") {
			errMsg.innerHTML = "请输入确认收货角色等级";
			$("Game_usergrade").focus();
			OerrRed("Game_usergrade_text");
			return false;	
		}
		var game_user_pwd=$("game_user_pwd");
		if (game_user_pwd){
			if( $V("game_user_pwd")== ""  ) {
			  errMsg.innerHTML = "请输入帐号密码";
			  $("game_user_pwd").focus();
			  OerrRed("game_user_pwd_text");
			  return false;
			}
			if( $V("game_user_pwd1")== "") {
				errMsg.innerHTML = "请输入确定帐号密码";
				$("game_user_pwd1").focus();
				OerrRed("game_user_pwd1_text");
				return false;	
			}
			if( $V("game_user_pwd")!= $V("game_user_pwd1") ) {
				errMsg.innerHTML = "二次输帐号密码不一致";
				$("game_user_pwd1").focus();
				OerrRed("game_user_pwd1_text");
				return false;	
			}
			if( $V("game_user_name")== "") {
				errMsg.innerHTML = "请输入角色名称";
				$("game_user_name").focus();
				OerrRed("game_user_name_text");
				return false;	
			}
		}
	}
	else
	{
		if( $V("game_user_id")== "" ) {
			errMsg.innerHTML = "请输入收货QQ号码";
			$("game_user_id").focus();
			OerrRed("game_user_id_text");
			return false;
		}
	
		}
if ($V("realname") == "" & $V("realname").length < 2 ){
	errMsg.innerHTML="真实姓名，请按要求填写";
	OerrRed ("realname_text")
	setTimeout('document.getElementById("realname").focus()',1000);			
	return false;
}
if ($V("qq") == "" & $V("qq").length < 5  ){
	errMsg.innerHTML="ＱＱ号码，请按要求填写";
	OerrRed ("qq_text")
	setTimeout('document.getElementById("qq").focus()',1000);			
	return false;
}
if ($V("tel") == "" & $V("tel").length < 11 ){
	errMsg.innerHTML="联系方式，请按要求填写";
	OerrRed ("tel_text")
	setTimeout('document.getElementById("tel").focus()',1000);			
	return false;
}
if (OrderForm.agree.checked== "" ){
	errMsg.innerHTML="您未同意《6870交易平台服务协议》";
	OerrRed ("agree_text")
	setTimeout('document.getElementById("agree").focus()',1000);			
	return false;	
}
}
function buyOrders() {
var errMsg = $("errMsg");
		if( $V("game_user_id")== "" ) {
			errMsg.innerHTML = "请输入游戏帐号";
			$("game_user_id").focus();
			OerrRed("game_user_id_text");
			return false;
		}
		if( $V("game_user_id1")== "") {
			errMsg.innerHTML = "请输入确认游戏帐号";
			$("game_user_id1").focus();
			OerrRed("game_user_id1_text");
			return false;	
		}
		if( $V("game_user_id")!= $V("game_user_id1") ) {
			errMsg.innerHTML = "二次输游戏帐号不一致";
			$("game_user_id1").focus();
			OerrRed("game_user_id1_text");
			return false;	
		}
			if( $V("game_user_pwd")== ""  ) {
			errMsg.innerHTML = "请输入帐号密码";
			$("game_user_pwd").focus();
			OerrRed("game_user_pwd_text");
			return false;
		}
		if( $V("game_user_pwd1")== "") {
			errMsg.innerHTML = "请输入确定帐号密码";
			$("game_user_pwd1").focus();
			OerrRed("game_user_pwd1_text");
			return false;	
		}
		if( $V("game_user_pwd")!= $V("game_user_pwd1") ) {
			errMsg.innerHTML = "二次输帐号密码不一致";
			$("game_user_pwd1").focus();
			OerrRed("game_user_pwd1_text");
			return false;	
		}
		if( $V("game_user_name")== "") {
			errMsg.innerHTML = "请输入角色名称";
			$("game_user_name").focus();
			OerrRed("game_user_name_text");
			return false;	
		}
if ($V("qq") == "" & $V("qq").length < 5  ){
	errMsg.innerHTML="ＱＱ号码，请按要求填写";
	OerrRed ("qq_text")
	setTimeout('document.getElementById("qq").focus()',1000);			
	return false;
}
if ($V("tel") == "" & $V("tel").length < 11 ){
	errMsg.innerHTML="联系方式，请按要求填写";
	OerrRed ("tel_text")
	setTimeout('document.getElementById("tel").focus()',1000);			
	return false;
}
if (OrderForm.agree.checked== "" ){
	errMsg.innerHTML="您未同意《6870交易平台服务协议》";
	OerrRed ("agree_text")
	setTimeout('document.getElementById("agree").focus()',1000);			
	return false;	
}
}
function pay(){
	var errMsg = $("errMsg");
	if ($V("logpass")==""){
		errMsg.innerHTML="<font color='#FF0000'>请输入超级密码</font>";
		return false;
		}
	}

function copyText(obj)   
{ 
var rng = document.body.createTextRange(); 
rng.moveToElementText(obj); 
rng.scrollIntoView(); 
rng.select(); 
rng.execCommand("Copy"); 
rng.collapse(false);
alert("复制成功!"); 
} 

//验证游戏名称是否一致
function checkname(str)
{
  if (str.length==0){ 
    $("txtHint").innerHTML="";
    return;
    }
  xmlHttp=GetXmlHttpObject()
  if (xmlHttp==null){
    alert ("不支持");
    return;
    }
  var id1 = $V("game_user_id");
  var id2 = $V("game_user_id1");
  if ((id2 == null) || (id2 == "")) return;
  var url = "checkstring.do?id=1&id1=" + escape(id1) +"&id2=" + escape(id2)+"&"+Math.random();
  xmlHttp.open("GET",url,true);
  xmlHttp.send(null);
  xmlHttp.onreadystatechange=function(){
	if (xmlHttp.readyState==4){ 
		$("txtHint").innerHTML=xmlHttp.responseText;
		}  
	}
} 
//验证游戏密码是否一致
function checkpwd(str)
{
  if (str.length==0){ 
    $("txtHint1").innerHTML="";
    return;
    }
  xmlHttp=GetXmlHttpObject()
  if (xmlHttp==null){
    alert ("不支持");
    return;
    }
  var ps1 = $V("game_user_pwd");
  var ps2 = $V("game_user_pwd1");
  if ((ps2 == null) || (ps2 == "")) return;
  var url = "checkstring.do?id=2&ps1=" + escape(ps1) +"&ps2=" + escape(ps2)+"&"+Math.random();
  xmlHttp.open("GET",url,true);
  xmlHttp.send(null);
  xmlHttp.onreadystatechange=function(){
	if (xmlHttp.readyState==4){ 
	$("txtHint1").innerHTML=xmlHttp.responseText;
	}
  }
}