// --------------------------------------------------------=
// 易聚网 2007.10.25
// --------------------------------------------------------=
//
//=--------------------------------------------------------=
// User Name
// --------------------------------------------------------
// 1-2.4-16 个字符(包括英文字母,中文,数字,下划线)，1个汉字为2个字符，
// 不能使用纯数字、空格或 @ . # * 等特殊符号，请重新设置。
// 3.是否包含非法字符
// 4-5.正则表达式判断
// 6.包含非法单词
// 7.包含内置帐号名
// 8.用户已存在
// --------------------------------------------------------
// EMail
// --------------------------------------------------------
// 9.EMAIL空字符
// 10.是否包含非法字符
// 11.正则表达式判断
// 12.邮件格式是否正确
// 13.用户库中是否存在相同的EMAIL地址
// --------------------------------------------------------
// Password
// --------------------------------------------------------
// 14.密码空字符
// 15.密码有误
// 16.两次输入的密码不一致
// --------------------------------------------------------
// Other
// --------------------------------------------------------
// 17.邮箱限制			- [EMAIL]
// 18.会员名和密码相同		- [USER.PWD]
//=--------------------------------------------------------=

//validator info
var msgInfo = ["",	
    "4-16个字符(包括汉字、字母、数字、下划线)组成，请重新设置。",//msgInfo[1]
    "联系方式是email或手机号，不能使用空格，请重新设置。",//msgInfo[2]
    "该email已被注册，请重新输入！",//msgInfo[3]
    "该手机号已被注册，请重新输入！",//msgInfo[4]
    "对不起，你输入的联系方式不是email,请重新输入！",//msgInfo[5]
    "Email地址格式不正确,请输入正确的Email地址。",//msgInfo[6]
    "手机号格式不正确,请输入正确的手机号。",//msgInfo[7]
    "联系方式是email，不能使用空格，请重新设置。",//msgInfo[8]
    "请填写正确的联系方式，可以用来登录和找回密码。",//msgInfo[9]
    "联系方式是email，不能使用空格，请重新设置。",//msgInfo[10]
    "联系方式是email，不能使用空格，请重新设置。",//msgInfo[11]
    "联系方式是email，不能使用空格，请重新设置。",//msgInfo[12]
    "联系方式是email，不能使用空格，请重新设置。",//msgInfo[13]
    "密码由6-20个字符，区分大小写(A-Z, a-z, 0-9和符号)。",//msgInfo[14]
    "您设置的密码有误，密码由6-20个英文字母、数字或符号组成，请重新设置。",//msgInfo[15]
    "两次输入的密码不一致，请重新输入。",//msgInfo[16]
    "很抱歉，没有此类邮箱，您需要更换一个Email。",//msgInfo[17]
    "与会员联系方式相同的密码将无法通过注册，请重新输入。",//msgInfo[18]
    "请输入您的联系方式",//msgInfo[19]
    "恭喜您，该联系方式可以使用 :)",//msgInfo[20]
    "您的浏览器设置已被禁用 Cookies，您必须设置浏览器允许使用 Cookies 选项后才能使用本系统。",//msgInfo[21]
    "验证码输入错误，请重新输入！",//msgInfo[22]
    "验证码为4纯数字，不能使用空格，请重新设置。",//msgInfo[23]
    "验证码由4位纯数字组成",//msgInfo[24]
    "验证码输入正确 :)"];//msgInfo[25]
 var firstlogimsgInfo = ["",
    "4-20个字符，不能包含空格或特殊符号，请重新设置。",//firstlogimsgInfo[1]
    "此用户名已注册，请重新输入。",//firstlogimsgInfo[2]
    "恭喜你，该用户名可以使用 :)",//firstlogimsgInfo[3]    
    
    "很抱歉，该图片不存在，请重新选择！",//firstlogimsgInfo[4]
    "很抱歉，你选择的不是图片文件，请重新选择！",//firstlogimsgInfo[5]  
    "很抱歉，你选择的图片超过2M，请重新选择！",//firstlogimsgInfo[6]  
    "恭喜你，该图片可以上传 :)",//firstlogimsgInfo[7]  
    
    "Email地址格式不正确,请输入正确的Email地址。",//msgInfo[8]
    "该email已被注册，请重新输入！",//msgInfo[9]
    "恭喜你，该email可以使用 :)",//firstlogimsgInfo[10]  
    
    "手机号格式不正确,请输入正确的手机号。",//msgInfo[11]
    "该手机号已被注册，请重新输入！",//msgInfo[12]
    "恭喜你，该手机号可以使用 :)",//firstlogimsgInfo[13]  
    
    "4-20个字符(包括汉字、字母、数字、下划线)",//msgInfo[14]
    "请输入你的Email",//msgInfo[15]
    "请输入你的手机号",//firstlogimsgInfo[16] 
    "用户名不能包含空格或<font color=\"#ff0000\">@ . # * </font>等特殊符号",//msgInfo[17]
    "用户名由由4-20个字符(包括汉字、字母、数字、下划线)组成，1个汉字为2个字符",//msgInfo[18]
     
    
    "验证码输入正确 :)"];//firstlogimsgInfo[14]	

     
var IsEmailNeedCheck=true;  
var IsTellNeedCheck=true;  
var picCheck=false;  
var truecolor="#2BAF31";
var falsecolor="#FF2D00";
var normalcolor="#777777";

// 验证所有数据项
function validate(){
	var regButton = document.getElementById("reg");
	var infoColor = "#FF2D00";
	var userlianxi = document.getElementById("user.userlianxi").value;
	var pwd1 = document.getElementById("password1").value;
	var pwd2 = document.getElementById("password2").value;
//	var email = document.getElementById("user.email").value;
	var result = 0;
	
	    result=checkusernameoutfocus();	
	    if(result>0 && result!=3){showInfoStyle( "validateusername", firstlogimsgInfo[14], falsecolor);; regButton.disabled = false; return false;}
	result = validateUserlianxi(userlianxi);
	if(result>0 && result!=20){showResult(result,true); regButton.disabled = false; return false;}
	result = validateSafePassword(pwd1, pwd2, userlianxi);
	if(result>0){showResult(result,true); regButton.disabled = false; return false;}
//	result = validateEmail(email);
//	if(result>0){showResult(result,foucs); regButton.disabled = false; return false;}
	result=checkValidatecode();
	if(result>0){ regButton.disabled = false; return false;}
	window.document.all('reg').style.display='none';
	window.document.all('waitsubmit').style.display='';
//	regButton.style.display='none';
////    regButton.disabled="disabled";
	return true;
}

// 触发用户名Input焦点
function userFocus(obj){	
	var msg = msgInfo[19];
	var infoColor = "#FF2D00";
	var userId = document.getElementById(obj.id);
	if( userId.value.length < 1 ){	
		showInfoStyle( "validateuserlianxi", msg, infoColor);	
	}
}
// 输入时检测联系方式是否符合规范
function checkUserLianxi( obj ){
	var userId = document.getElementById("user.userlianxi");
	var userLianxi = userId.value;
	var msg = "";
	var infoColor = "#FF2D00";
	var result=validateUserlianxi( userLianxi );
	if( result != 20 ){
		msg = msgInfo[result];
		infoColor = "#FF2D00";
	}	
	else{
		msg =  msgInfo[9];
		infoColor = "#777777";
	}	
	showInfoStyle( "validateuserlianxi", msg, infoColor);	
}
// 验证用户名是否正确
function validateUsernamestr(str){
	var patn = /^[\u0391-\uFFE5a-zA-Z0-9][\u0391-\uFFE5\w]{2,17}$/; 
	if(patn.test(str)){
		return 0;
	}
	return 1; 
}
// 验证纯数字
function checkInteger( str ){
	var patten = /\D/;
	if( str.match( patten ) ){
		return 0;
	}
	return 1;
}
// 验证用户联系方式是否是email
function validateUserlianxi(str){
//	if (validateTel(str)==0) //正确的手机格式，下面检查是否已经注册过
//	{
//	    var resultRequest = ajaxRequest.ajaxRequestUrl("/page/other/checktel.aspx?userTel=" + str);
//	    if (resultRequest == 1)//表示没有被注册过
//	    {
//	        return 20;
//	    }
//	    else
//	    {
//	        return 4;//手机号已经被注册的错误报告
//	    }
//	}
//	else 
if (validateEmail(str)==0)
	{
	    var resultRequest = ajaxRequest.ajaxRequestUrl("/page/other/checkemail.aspx?userEmail=" + str);
	    if (resultRequest == 1)//表示没有被注册过
	    {
	        return 20;
	    }
	    else
	    {
	        return 3;//email已经被注册的错误报告
	    }
	}
	return 5;
}

// 验证EMAIL地址是否正确
function validateEmail(str){
	var patn = /^[_a-zA-Z0-9\-]+(\.[_a-zA-Z0-9\-]*)*@[a-zA-Z0-9\-]+([\.][a-zA-Z0-9\-]+)+$/;
	if(patn.test(str)){
		return 0;
	}else{
		return 6; //incorrect format
	}
}

// 验证手机号格式是否正确
function validateTel(str){
	var patn  =/^1(3|5)\d{9}$/gi;
	if(patn.test(str)){
		return 0;
	}else{
		return 7; //incorrect format
	}
}

// 检测是否存在空格，存在则返回true，不存在返回false
function scan_space(s){
	return -1!=s.indexOf(" ")? true: false;
}

// 密码长度验证
function validatePassword(str){
	if(scan_space(str)) return 15;
	var patn = /.{6,20}/; 
	if(patn.test(str)) return 0;
	return 15; 
}

// 密码安全验证
function validateSafePassword(pwd1, pwd2, user){
	var ret = validatePassword(pwd1);
	//check length and alphabet
	if(ret>0) return ret;
	//check if same as password2
	if(pwd1 != pwd2) return 16;
	//check if same as username
	if(pwd1 == user) return 18;
	return 0;
}
// 触发密码Input焦点
function pwd1Focus(obj){	
	var msg = "请输入密码";
	var infoColor = "#FF2D00";
	var userId = document.getElementById(obj.id);
	if( userId.value.length < 1 ){	
		showInfoStyle( "validatepassword1", msg, infoColor);	
	}
}
// 触发密码Input焦点
function pwd2Focus(obj){	
	var msg = "请再输入一遍您上面输入的密码";
	var infoColor = "#FF2D00";
	var userId = document.getElementById(obj.id);
	if( userId.value.length < 1 ){	
		showInfoStyle( "validatepassword2", msg, infoColor);	
	}
}

// 触发密码验证码焦点
function validatecodeFocus(obj){	
	var msg = "请输入验证码";
	var userId = document.getElementById(obj.id);
	if( userId.value.length < 1 ){	
		showInfoStyle( "validatevalidatecode", msg, falsecolor);	
	}
}

// 密码检测
function checkPwd(){
	var passId = document.getElementById("password1");
	var password = passId.value;
	var msg = "";
	var infoColor = "#FF2D00";
	if( scan_space(password) ){
		msg = "不允许有空格存在";		
	}
	else if( password.length < 1 ){
		msg = "请输入密码";
	}
	else if( password.length < 6 ){
		msg = "密码太短了，继续..";		
	}
	else if( password.length >= 6 && password.length <= 10 ){
		msg = "密码安全度:低";
		infoColor = "#2BAF31";
	}	
	else if( password.length > 10 && password.length <= 15 ){
		msg = "密码安全度:中";
		infoColor = "#2BAF31";
	}
	else if( password.length > 15 && password.length <= 20 ){
		msg = "密码安全度:高";
		infoColor = "#2BAF31";
	}
	else{
		msg = "6-20&nbsp;个字符(包括英文字母、数字、符号)，区分大小写";
		infoColor = "#777777";
	}	
	showInfoStyle( "validatepassword1", msg, infoColor);	
}

// 密码再次检测
function checkPwd2(){
	var passId1 = document.getElementById("password1");
	var password1 = passId1.value;
	var passId2 = document.getElementById("password2");
	var password2 = passId2.value;	
	var msg = "";
	var infoColor = "#FF2D00";
	if( password1.length < 6 ){
		msg = "密码太短了";
		showInfoStyle( "validatepassword1", msg, infoColor);		
	}
	if( password2.length < 1 ){
		msg = "请再输入一遍您上面输入的密码";
	}
	else if( password2 != password1 ){
		msg = "两次密码不符，请重新输入";
	}
	else if( password2 == password1 ){
		msg = "两次密码输入完全符合 :)";
		infoColor = "#2BAF31";
	}
	showInfoStyle( "validatepassword2", msg, infoColor);	
}

// 验证码检测
function checkValidatecode(){
    if (!cookieEnabled)
    {
        msg=msgInfo[21];
	    showInfoStyle( "validatevalidatecode", msg, falsecolor);	
	    return 21;
    }
	var validatecodeID = document.getElementById("validatecode");
	var validatecode = validatecodeID.value;
	var msg = "";
    if ((scan_space(validatecode) || checkInteger(validatecode) ==0 ) && validatecode.length!=0)//判断是否是纯数字，是否有空格
    {
        msg=msgInfo[23];
	    showInfoStyle( "validatevalidatecode", msg, falsecolor);	
	    return 23;
    }
    else if (validatecode.length==4 && scan_space(validatecode) ==0  && checkInteger(validatecode))
    {
        var cookiename="CheckCode";
        var validatecodecookie=null;
        var arr = document.cookie.match(new RegExp("(^| )"+cookiename+"=([^;]*)(;|$)"));
        if(arr != null) 
        {
            validatecodecookie = unescape(arr[2]);
        }
        if (validatecodecookie != null)
        {
            if (validatecodecookie != validatecode)
            {
                msg=msgInfo[22];
	            showInfoStyle( "validatevalidatecode", msg, falsecolor);	
	            return 22;
             }
            else
             {
                msg=msgInfo[25];
	            showInfoStyle( "validatevalidatecode", msg, truecolor);	
	            return 0;
	         }
	    }
	    else
	    {
	        msg=msgInfo[23];
	        showInfoStyle( "validatevalidatecode", msg, falsecolor);	
	        return 23;
	    }
	}
	else if (validatecode.length ==0)
	{
	        var msg = "请输入验证码";
	        showInfoStyle( "validatevalidatecode", msg, falsecolor);	
	        return 24;
	}
	else if ( validatecode.length >0 && validatecode.length < 5)
	{
	         msg=msgInfo[24];
	        showInfoStyle( "validatevalidatecode", msg, falsecolor);
	        return 24;
	}
	else if (validatecode.length>4)
	{
	        msg=msgInfo[23];
	        showInfoStyle( "validatevalidatecode", msg, falsecolor);
	        return 23;
	}
}

function checkcookie()
{
    if (!cookieEnabled)
    {
        msg=msgInfo[21];
	    showInfoStyle( "validatevalidatecode", msg, falsecolor);	
	    return 21;
    }
}
//// 触发email的Input焦点
//function emailFocus(obj){	
//	var msg = "请输入您的email";
//	var infoColor = "#FF2D00";
//	var userId = document.getElementById(obj.id);
//	if( userId.value.length < 1 ){	
//		showInfoStyle( "validateemail", msg, infoColor);	
//	}
//}
// 输入时检测email、手机是否符合规范
function checkEmail( obj ){
	var lianxiId = document.getElementById("user.lianxi");
	var lianxi = lianxiId.value;
	var msg = "";
	var infoColor = "#FF2D00";
	if( validateTel( lianxi ) != 0 || validateEmail(lianxi) != 0 ){
		msg = msgInfo[5];
		infoColor = "#FF2D00";
	}	
	else{
		msg = "重要！这是您找回密码的唯一方式！";
		infoColor = "#2BAF31";
	}	
	showInfoStyle( "validatelianxi", msg, infoColor);	
}
// String去除前后空格
String.prototype.trim = function(){
    return this.replace(/(^\s*)|(\s*$)/g, "");
}
// 统计字符串字节数
String.prototype.ByteCount = function(){
	txt = this.replace(/([\u0391-\uFFE5])/ig,'11');
	var count = txt.length;
	return count;
}

// 获取EMAIL服务器地址
function getMailServer(str){
	//be sure str is a correct email address
	str = str.trim();
	return str.substr(str.indexOf("@")+1);
}
// 显示信息的样式
function showInfoStyle(id, msg, infoColor){
	var obj = document.getElementById(id);	
	obj.innerHTML = msg;
	obj.style.color = infoColor;
}
// 改变输入框底色
function changeInputColor( obj , over){	
	var InputId = document.getElementById(obj.id);
	if( over == 1 ){
		InputId.style.border = "2px solid";	
		InputId.style.borderColor = "#FF2D00";
	}else{
		InputId.style.border = "2px solid";	
		InputId.style.borderColor = "#7F9DB9";
	}
}

// 显示样式
function showStyle(id, msg){
	var obj = document.getElementById(id);
	obj.style.display = "";
	obj.innerHTML = msg+"<BR />";
}

//显示返回结果
function showResult(data, foucs){
	var obj = null; // document.getElementById("errmsg");
	var msg = "";
	var infoColor = "#FF2D00";
	if(data>0){
		msg = msgInfo[data];
	}
	switch(data){
	case 2: ; case 3: ; case 4: ; case 5: ; case 6: ; case 7: ; case 8: ; case 9: ; case 10: ; case 11: ; case 12: ; case 13: ; case 17:
		// Username
		if(foucs){document.getElementById("user.userlianxi").focus();}
		//showStyle("infousername", msg);
		showInfoStyle("validateuserlianxi", msg, infoColor);
//		traceInputError("dm_reg_username"); // 用户名
		break;
	case 14: ; case 15: ; case 18:
		// Password
		if(foucs){document.getElementById("password1").focus();}
		showInfoStyle("validatepassword1", msg, infoColor);
//		traceInputError("dm_reg_pwd"); // 设密码
		break;
	case 16:
		// Password 2
		if(foucs){document.getElementById("password2").focus();}
		showInfoStyle("validatepassword2", msg, infoColor);
//		traceInputError("dm_reg_pwd2"); // 设密码
		break;
	}
}

//function traceInputError(name){
//	try{
//		var url = "http://ap.koubei.com/TraceRoutine/KoubeiAddJS.php?addname=";
//		var node = document.getElementById(name);
//		url = url + name + "&random=" + Math.random(); 
//		node.setAttribute("src", url);
//	}catch(e){}
//}

//function do_signup(){
//	var signupform = document.signup_form;
//	if(0 == signupform.password1.value.length){
//		signupform.password1.focus();
//		return false;
//	}
//	if(0 == signupform.password2.value.length){
//		signupform.password2.focus();
//		return false;
//	}
//	if(signupform.password1.value != signupform.password2.value){
//		signupform.password2.focus();
//		return false;
//	}
//	signupform.submit();
//}
function hideInputInfo(spanid,value) {
	var spanid = getElementId(spanid);
	var info = "info" + spanid;
	var valid = "validate" + spanid;
	try {
	    //document.getElementById(info).style.display = "none" ; 
	    document.getElementById(valid).style.display = "" ; 
	    document.getElementById(valid).innerHTML += "<br />"; 
    } catch(e){}	
}
function getElementId(objectName){
	var spanid = objectName;
	if (spanid.indexOf(".") > 0) {
		try {
			while (spanid.indexOf(".") > 0) {
				spanid = getInputLastName(spanid);
			}
		} catch(e){}
	}
	return spanid;
}
function remoteAlert(data){
	showResult(data, true);
}
function gotFocus(obj){
	var id = obj.name;
	var spanid = getElementId(id);
	var info = "info" + spanid;
	var valid = "validate" + spanid;
	document.getElementById(info).style.display = "" ; 
	//document.getElementById(valid).style.display = "none" ; 
	if("user.userlianxi"==id)
	{
		validateUserlianxi(obj.value);
	}
}

function lostFocus(obj){
	var userlianxi = document.getElementById("user.userlianxi").value;
	var pwd1 = document.getElementById("password1").value;
	var pwd2 = document.getElementById("password2").value;
//	var email = document.getElementById("user.email").value;
	var result = 0;
	var id = obj.name;
	var spanid = getElementId(obj.name);
	var info = "info" + spanid;
	var valid = "validate" + spanid;
	//document.getElementById(info).style.display = "" ; 
	//document.getElementById(valid).style.display = "none" ; 
	
    result=checkusernameoutfocus();	
    
	if("user.userlianxi"==id){
		// 输入框为空，不提示错误信息
		if(""==obj.value){return;}
        result = validateUserlianxi(obj.value);	
        if (result==20)
        {
        showInfoStyle("validateuserlianxi", msgInfo[result], "#2BAF31");
        }
        else
        {
        showInfoStyle("validateuserlianxi", msgInfo[result], "#FF2D00");
        }
        result = 0;
	}
	if("password1"==id){
		// 输入框为空，不提示错误信息
		if(""==obj.value){return;}
		//check if same as username
		if(obj.value == userlianxi){
			result = 18;
		}else{
			result = validatePassword(obj.value);
		}
		if(result==0){document.getElementById("validatepassword1").style.display = "none";}
	}
	if("password2"==id){
		// 输入框为空，不提示错误信息
		if(""==obj.value){return;}
		//check if same as password2
		if(pwd1 != pwd2) result = 16;
		if(result==0){document.getElementById("validatepassword2").style.display = "none";}
	}
	if(result>0){showResult(result, false);}
}

//显示返回结果
function showEmailError(data, foucs){
	var obj = null; // document.getElementById("errmsg");
	var msg = "";
	if(data>0){
		msg = msgInfo[data];
	}
	switch(data){
	case 9: ; case 10: ; case 11: ; case 12: ; case 13: ; case 17: 
		// Email
		if(foucs){document.getElementById("user.email").focus();}
		//showStyle("validateemail", msg);
		showInfoStyle("validateemail", msg, "#FF2D00");
		break;
	default:
		showInfoStyle("validateemail","恭喜您，该Email可以使用 :)","#2BAF31");
	}
}

function showUserError(data, foucs){
	var obj = null; // document.getElementById("errmsg");
	var msg = "";
	if(data>0){
		msg = msgInfo[data];
	}
	switch(data){
	case 1: ; case 2: ; case 3: ; case 4: ; case 5: ; case 6: ; case 7: ; case 8: ; case 18:
		// Username
		if(foucs){document.getElementById("user.username").focus();}
		showInfoStyle("validateusername", msg, "#FF2D00");
		break;
	default:
		//document.getElementById("infousername").style.color = "#777777" ; 
		showInfoStyle("validateusername",msgInfo[20],"#2BAF31");	
	}
}

//同意服务条款
function acceptjointTerms(h)
{
    var regButton = document.getElementById("reg");
    if (h.checked)
    {
        regButton.disabled=""
    }
    else
    {
        regButton.disabled="disabled"
    }
}


// 验证所有数据项
function validatefirstlogin(){
	var regButton = document.getElementById("reg");
	var infoColor = "#FF2D00";
	var realname = document.getElementById("user.realname").value;
	var usertel = document.getElementById("user.usertel").value;
	var userpic = document.getElementById("uploadInputFile").value;
	
	var result = 0;
	result = checkuserrealnameoutfocus();
	if(result>0 && result!=3){regButton.disabled = false; return false;}
	if(userpic.length>0 && !picCheck){ regButton.disabled = false; return false;}
	    result = chuckuserteloutfocus();
	    if(result>0 ){ regButton.disabled = false; return false;}
	window.document.all('reg').style.display='none';
	window.document.all('waitsubmit').style.display='';
	return true;
}

//头像预览
var imgtype="U";
function userpicFocus(obj)
{
    var userpicId = document.getElementById(obj.id);
	if( userpicId.value.length < 1 ){	
		var msg="请选择图片";
        showInfoStyle("validateuserpic",msg,falsecolor);	
	}
}
function userpicoutFocus(obj)
{
    var userpicId = document.getElementById(obj.id);
	if( userpicId.value.length < 1 ){	
		var msg="请选择图片";
        showInfoStyle("validateuserpic",msg,normalcolor);	
	}
}
function CheckInputFileImg(type)
{
    var x = document.getElementById("uploadInputFile");
    var y = document.getElementById("userImg");
    var a=document.getElementById("imgDiv");
    imgtype=type

    if (!document.uniqueID)
    {
	    a.innerHTML="";
        picCheck=true;
	    return;
    }
    if(!x || !x.value) return;
    var patn = /\.jpg$|\.jpeg$|\.gif$/i;
    if(patn.test(x.value))
    {
//        z.innerHTML ="";
    }
    else
    {
        alert("您选择的不是图像文件。");
        picCheck=false;
        showInfoStyle("validateuserpic",firstlogimsgInfo[4],falsecolor);	
        x.value="";
        if (imgtype=="U")
	    {
		    y.src="/images/userPic/Default.gif";
	    }
	    else if (imgtype=="E")
	    {
		    y.src="/images/eventPic/Default.gif";
	    }
	    else if (imgtype=="P")
	    {
		    y.src="/images/placePic/Default.gif";
	    }
	    else if (imgtype=="C")
	    {
	    	y.src="/images/clubPic/Default.gif";
	    }
        return ;
    }
    
    if (x.value!="")
    {
	    y.src=x.value;
    }
    else
    {
        var msg="请选择图片";
        showInfoStyle("validateuserpic",msg,normalcolor);	
    }
}

// 验证用户名
function validateUserName(str){
    if (str.length<1)
    {
		showInfoStyle( "validateusername", firstlogimsgInfo[14], falsecolor);	
		return 14;
    }
	if (validateTel(str)==0) //正确的手机格式，下面检查是否已经注册过
	{
	    return 0;
	}
	else if (validateEmail(str)==0)
	{
	    return 0;
	}
	return 5;
}


// 触发用户名Input焦点
function usernameFocus(obj){	
	var userId = document.getElementById(obj.id);
	if( userId.value.length < 1 ){	
		showInfoStyle( "validateusername", firstlogimsgInfo[14], falsecolor);	
	}
}

// 触发用户名Input焦点
function userrealnameFocus(obj){	
	var userId = document.getElementById(obj.id);
	if( userId.value.length < 1 ){	
		showInfoStyle( "validateuserrealname", "4-20个字符(包括汉字、字母、数字、下划线)组成", falsecolor);	
	}
}
function checkusername()
{
    var usernameId = document.getElementById("user.username");
	var username = usernameId.value;
	if (username.length<1)
	{
	    showInfoStyle( "validateusername", firstlogimsgInfo[14], falsecolor);	
	    return 14
	}
	var result=validateUsernamestr(username);
	if (result==1 || username.trim().ByteCount() < 4 || username.trim().ByteCount() > 20 || scan_space(username))
	{
	    showInfoStyle( "validateusername", firstlogimsgInfo[1], falsecolor);	
	    return 1;
	}
	return 0;
//	var resultRequest = ajaxRequest.ajaxRequestUrl("/page/other/checkname.aspx?username=" + username);
//	if (resultRequest==1)
//	{
//	    showInfoStyle( "validateusername", firstlogimsgInfo[3], truecolor);	
//	    return 3;
//	}
//	else
//	{
//	    showInfoStyle( "validateusername", firstlogimsgInfo[2], falsecolor);	
//	    return 2;
//	}
	
}
function checkusernameoutfocus()
{
    var usernameId = document.getElementById("user.username");
	var username = usernameId.value;
	if (username.length<1)
	{
	    showInfoStyle( "validateusername", firstlogimsgInfo[14], falsecolor);	
	    return 14
	}
	var result=validateUsernamestr(username);
	if (result==1 || username.trim().ByteCount() < 4 || username.trim().ByteCount() > 20 || scan_space(username))
	{
	    showInfoStyle( "validateusername", firstlogimsgInfo[1], falsecolor);	
	    return 1;
	}
	
	var resultRequest = ajaxRequest.ajaxRequestUrl("/page/other/checkname.aspx?username=" + username);
	if (resultRequest==1)
	{
	    showInfoStyle( "validateusername", firstlogimsgInfo[3], truecolor);	
	    return 3;
	}
	else
	{
	    showInfoStyle( "validateusername", firstlogimsgInfo[2], falsecolor);	
	    return 2;
	}
	
}

function checkuserrealnameoutfocus()
{
    var userrealnameId = document.getElementById("user.realname");
	var userrealname = userrealnameId.value;
	if (userrealname.length<1)
	{
	    showInfoStyle( "validateuserrealname", "4-20个字符(包括汉字、字母、数字、下划线)组成", normalcolor);	
	    return 0
	}
	var result=validateUsernamestr(userrealname);
	if (result==1 || userrealname.trim().ByteCount() < 4 || userrealname.trim().ByteCount() > 20 || scan_space(userrealname))
	{
	    showInfoStyle( "validateuserrealname", "4-20个字符(包括汉字、字母、数字、下划线)组成", falsecolor);	
	    return 1;
	}
	showInfoStyle( "validateuserrealname", "4-20个字符(包括汉字、字母、数字、下划线)组成", truecolor);	
	return 0;
}

// 触发用户email Input焦点
function useremailFocus(obj){	
	var userId = document.getElementById(obj.id);
	if( userId.value.length < 1 ){	
		showInfoStyle( "validateuseremail", firstlogimsgInfo[15], falsecolor);	
	}
}

// 触发用户手机Input焦点
function usertelFocus(obj){	
	var userId = document.getElementById(obj.id);
	if( userId.value.length < 1 ){	
		showInfoStyle( "validateusertel", firstlogimsgInfo[16], falsecolor);	
	}
}

function chuckuseremail()
{
    var useremailId = document.getElementById("user.useremail");
	var useremail = useremailId.value;
	if (useremail.length<1)
	{
		showInfoStyle( "validateuseremail", firstlogimsgInfo[15], normalcolor);	
	    return 0
	}
	if (validateEmail(useremail)==0) //正确的手机格式，下面检查是否已经注册过
	{
//	    var resultRequest = ajaxRequest.ajaxRequestUrl("/page/other/checkemail.aspx?userEmail=" + useremail);
//	    if (resultRequest == 1)//表示没有被注册过
//	    {
//	        showInfoStyle( "validateuseremail", firstlogimsgInfo[10], truecolor);	
//	        return 0;
//	    }
//	    else
//	    {
//	        showInfoStyle( "validateuseremail", firstlogimsgInfo[9], falsecolor);	
//	        return 12;//手机号已经被注册的错误报告
//	    }
showInfoStyle( "validateuseremail", firstlogimsgInfo[15], normalcolor);	
        return 0;
	}
	showInfoStyle( "validateuseremail", firstlogimsgInfo[8], falsecolor);	
	return 11;
}
function chuckuseremailoutfocus()
{
    var useremailId = document.getElementById("user.useremail");
	var useremail = useremailId.value;
	if (useremail.length<1)
	{
		showInfoStyle( "validateuseremail", firstlogimsgInfo[15], normalcolor);	
	    return 0
	}
	if (validateEmail(useremail)==0) //正确的手机格式，下面检查是否已经注册过
	{
	    var resultRequest = ajaxRequest.ajaxRequestUrl("/page/other/checkemail.aspx?userEmail=" + useremail);
	    if (resultRequest == 1)//表示没有被注册过
	    {
	        showInfoStyle( "validateuseremail", firstlogimsgInfo[10], truecolor);	
	        return 0;
	    }
	    else
	    {
	        showInfoStyle( "validateuseremail", firstlogimsgInfo[9], falsecolor);	
	        return 12;//手机号已经被注册的错误报告
	    }
	}
	showInfoStyle( "validateuseremail", firstlogimsgInfo[8], falsecolor);	
	return 11;
}

function chuckusertel()
{
    var usertelId = document.getElementById("user.usertel");
	var usertel = usertelId.value;
	if (usertel.length<1)
	{
		showInfoStyle( "validateusertel", firstlogimsgInfo[16], normalcolor);	
	    return 0
	}
	if (validateTel(usertel)==0) //正确的手机格式，下面检查是否已经注册过
	{
        return 0;
	}
	showInfoStyle( "validateusertel", firstlogimsgInfo[11], falsecolor);	
	return 11;
}
function chuckuserteloutfocus()
{
    var usertelId = document.getElementById("user.usertel");
	var usertel = usertelId.value;
	if (usertel.length<1)
	{
		showInfoStyle( "validateusertel", firstlogimsgInfo[16], normalcolor);	
	    return 0
	}
	if (validateTel(usertel)==0) //正确的手机格式，下面检查是否已经注册过
	{
	    var resultRequest = ajaxRequest.ajaxRequestUrl("/page/other/checktel.aspx?userTel=" + usertel);
	    if (resultRequest == 1)//表示没有被注册过
	    {
	        showInfoStyle( "validateusertel", firstlogimsgInfo[13], truecolor);	
	        return 0;
	    }
	    else
	    {
	        showInfoStyle( "validateusertel", firstlogimsgInfo[12], falsecolor);	
	        return 12;//手机号已经被注册的错误报告
	    }
	}
	showInfoStyle( "validateusertel", firstlogimsgInfo[11], falsecolor);	
	return 11;
}
//document.getElementById("userImg").onreadystatechange = function ()
//{
//    if (document.getElementById("userImg").readyState == "complete")
//    {
//        checkSize();
//    }
//}
//function checkSize()
//{
//    if (document.getElementById("userImg").fileSize > 2000000) 
//    { 
//        showInfoStyle("validateuserpic",firstlogimsgInfo[6],"#FF2D00");	
//        return;
//    } 
//}

//function loadImgErr()
//{
//    var x = document.getElementById("uploadInputFile");
//    var y = document.getElementById("userImg");
//    
//	alert(x.value + " 文件不存在！");
//	showInfoStyle("validateuserpic",firstlogimsgInfo[5],"#FF2D00");	
//	if (type=="U")
//	{
//		y.src="/images/userPic/Default.gif";
//	}
//	else if (type=="E")
//	{
//		y.src="/images/eventPic/Default.gif";
//	}
//	else if (type=="P")
//	{
//		y.src="/images/placePic/Default.gif";
//	}
//	else if (type=="C")
//	{
//		y.src="/images/clubPic/Default.gif";
//	}
//}
