$(document).ready(function() {
	$('#join').click(function(){
		var flag = true;
		$.ajax({
			type:"get",
			url:(shopFolder + 'NewShow.aspx?NoCopyRight=1'),
			data:'type=CheckMember&MemberGroup=' + memberGroup,
			cache:false,
			async:false,
			success:function(msg){
				switch(msg)
				{
					case '^1':
						alert('您还没有登录');
						flag = false;
						window.location =shopFolder+ "login.aspx?ReturnUrl="+shopFolder+"auction/product-"+productID+"."+extend;
						break;
					case '^2':
						alert('您不在允许参与的会员级别范围内');
						flag = false;
						break;
				}
				
			},
			error:function(XMLHttpRequest,textStatus){if(textStatus=='parsererror'){flag = false;alert('身份已过期,请重新登陆!')}else{flag = false;alert('error')};}
		});
		return flag;
	});
	
	$('#btnSure').click(function(){
		var flag = true;
		$.ajax({
		    url:shopFolder + 'NewShow.aspx?NoCopyRight=1&type=CheckMember&MemberGroup=' + memberGroup,
		    cache:false,
		    async:false,
		    success:function(data){
		        switch(data){
		            case '^1':
		                alert('您还没登录');
		                flag = false;
		                break;
		            case '^2':
		                alert('您不在允许参与的会员级别范围内');
		                flag = false;
		                break;    
		        }
		    },error:function(){alert('error');flag = false;}
		});
		if(!flag) return flag;

		if($.trim($('#txtRAddress').val()) == '')
		{
			alert('收货地点必填');return false;
		}
		if($.trim($('#txtRName').val()) == '')
		{
			alert('收货人姓名必填');return false;
		}
		if($.trim($('#txtRPostalcode').val()) == '')
		{
			alert('邮政编码必填');return false;
		}
		if($.trim($('#txtRTelephone').val()) == '')
		{
			alert('收货人电话必填');return false;
		}
		var num = $.trim($('#txtBidding').val());
		if(num == '')
		{
			alert('出价必填');return false;
		}else if(isNaN(num)){
		    alert('价格填写有误');return false;
		}else{
		    var result = '0';
		    $.ajax({
		        url:shopFolder + 'NewShow.aspx?Nocopyright=1&type=CheckBidding&PID='+pid,
		        data:'txtBidding=' + $('#txtBidding').val(),
		        type:'post',
		        cache:false,
		        async:false,
		        success:function(msg){
		            result = msg;
		        },error:function(){alert('error');result='0'}
		    });
		    if(result != '1'){
		        alert('加价幅度不够');return false;
		    };
		}
	});
});