function register(){
	$.fn.colorbox({width:"500",href:'register.php', open:true}); 
}
function loginwindow(){
	$.fn.colorbox({width:"400",href:'loginwindow.php', open:true}); 
}


function submitreg(){
	a = 0;
	$("#nameTextTips").html('');
	$("#passwordTextTips").html("");
	$("#confirmpwdTextTips").html("");
	$("#mobiletelTextTips").html("");
	$("#emailTextTips").html("");
	$("#zipTextTips").html("");
	$("#contactTextTips").html("");
	
	if($("#name").val()==""){
		$("#nameTextTips").html("不能为空");
		a = 1;
	}
	if($("#password").val()==""){
		$("#passwordTextTips").html("不能为空");
		a = 1;
	}
	if($("#confirmpwd").val()==""){
		$("#confirmpwdTextTips").html("不能为空");
		a = 1;
	}
	if($("#password").val()!=$("#confirmpwd").val()){
		$("#confirmpwdTextTips").html("密码和确认密码不相同");
		a = 1;
	}
	if($("#mobiletel").val()==""){
		$("#mobiletelTextTips").html("不能为空");
		a = 1;
	}
	strtelmobile = $("#mobiletel").val();
	if(isNaN(strtelmobile) || strtelmobile.length!=11){
		$("#mobiletelTextTips").html("手机号只能为11位数字");
		a = 1;
	}
	if($("#email").val()==""){
		$("#emailTextTips").html("不能为空");
		a = 1;
	}
	if($('#email').val()!=""){
		email = $('#email').val();
		pattern = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/;
		chkFlag = pattern.test(email);
		if(!chkFlag){
			$('#emailTextTips').html("E-mail格式不正确");
			a = 1;
		}
	}
/*	if($("#zip").val()==""){
		$("#zipTextTips").html("不能为空");
		a = 1;
	}
	if($("#contact").val()==""){
		$("#contactTextTips").html("不能为空");
		a = 1;
	}*/
	if(a==1){
		return false;	
	}
	
	$.ajax({
		type: "POST",
		url: "action.php?action=submitreg",
		data: $('#regform').serialize(),
		success: function(msg){
			//alert(msg);
			if(msg==""){
				return false;	
			}
			$.fn.colorbox({width:"350",href:'tipsregister.php?action='+msg, open:true}); 
		}
	});
}
function loginYz(){
	
	if($("#mobiletel").val()=="" || $("#psw").val()==""){
		alert("请输入手机号和密码");
		return false;
	}
	$.ajax({
		type: "POST",
		url: "action.php?action=login",
		data: $('#form1').serialize(),
		success: function(msg){
			//alert(msg);
			if(msg==""){
				return false;	
			}
			$.fn.colorbox({width:"350",href:'tipsregister.php?action='+msg, open:true}); 
		}
	});
}
function openX(id){
	$.fn.colorbox({width:"480",href:'openxgift.php?id='+id+'&z='+ Math.random(), open:true}); 
}
function redeem(id){
	if(!confirm("请确定您的配送地址无误，并确定兑换这件礼品?")){
		return false;
	}
	$.ajax({
		type: "POST",
		url: "action.php?action=redeem",
		data: "id="+id,
		success: function(msg){
			if(msg==""){
				return false;	
			}
			$.fn.colorbox({width:"350",href:'tipsregister.php?action='+msg, open:true}); 
		}
	});
}
function updatepoints(){
	//setTimeout("updatepiont()",3000);
	$.ajax({
		type: "GET",
		url: "action.php?action=chktime",
		success: function(msg){
			if(msg != 0){
				alert(msg);
				a = false;
			}else{
				updatepiont();
				a = true;
			}
		},
		async:false
	});
	return a;
}
function updatepiont()
{
		$.ajax({
		type: "GET",
		url: "action.php?action=getpoints",
		success: function(msg){
			if(document.getElementById("userpoints"))
			{
				document.getElementById("userpoints").innerHTML=msg;
			}
		}
	});
}