var account = {
	doAccountInit: function() {
		$("#vippoints").click(function() {
			$.dialog({
				id: 'vippoints',
				title: false,
				border: false,
				follow: $(this)[0],
				content: '确认要开通月VIP么？',
				okValue: '确认',
				ok: function() {
					$.ajax({
						type: "POST",
						global: false,
						url: zone_domain + "do.php?p=account&a=vippoints",
						dataType: "text",
						success: function(data) {
							if (data == 20001) {
								user.userNotLogin('您未登录无法执行此操作！');
								return false;
							} else if (data == 10001) {
								$.tipMessage('出错了，系统已关闭自助开通VIP服务！', 1, 3000);
								return false;
							} else if (data == 10002) {
								$.tipMessage('抱歉，您的帐号金币余额不足！', 1, 3000);
								return false;
							} else if (data == 10003) {
								$.tipMessage('您已经是VIP会员了，到期后可再次申请！', 1, 3000);
								return false;
							} else if (data == 10004) {
								$.tipMessage('恭喜，续费月VIP会员成功！', 0, 3000, 0,
								function() {
								location.href = location.href;
						});
							} else if (data == 10005) {
								$.tipMessage('恭喜，成功开通月VIP会员！', 0, 3000, 0,
								function() {
									location.href = location.href;
						});
					}
				},
				error: function() {
					$.tipMessage('数据执行意外错误！', 2, 3000);
				}
				});
				},
				cancelValue: '取消',
				cancel: function() {}
			});
		});
	},
	doAccountInita: function() {
		$("#vipyearspoints").click(function() {
			$.dialog({
				id: 'vipyearspoints',
				title: false,
				border: false,
				follow: $(this)[0],
				content: '确认要开通年VIP么？',
				okValue: '确认',
				ok: function() {
					$.ajax({
						type: "POST",
						global: false,
						url: zone_domain + "do.php?p=account&a=vipyearspoints",
						dataType: "text",
						success: function(data) {
							if (data == 20001) {
								user.userNotLogin('您未登录无法执行此操作！');
								return false;
							} else if (data == 10001) {
								$.tipMessage('出错了，系统已关闭自助开通VIP服务！', 1, 3000);
								return false;
							} else if (data == 10002) {
								$.tipMessage('抱歉，您的帐号金币余额不足！', 1, 3000);
								return false;
							} else if (data == 10003) {
								$.tipMessage('您已经是VIP会员了，到期后可再次申请！', 1, 3000);
								return false;
							} else if (data == 10004) {
								$.tipMessage('恭喜，续费年VIP会员成功！', 0, 3000, 0,
								function() {
								location.href = location.href;
						});
							} else if (data == 10005) {
								$.tipMessage('恭喜，成功开通年VIP会员！', 0, 3000, 0,
								function() {
									location.href = location.href;
						});
					}
				},
				error: function() {
					$.tipMessage('数据执行意外错误！', 2, 3000);
				}
				});
				},
				cancelValue: '取消',
				cancel: function() {}
			});
		});
	},
	payRecharge: function() {
		$("#delpay").click(function() {
			var did = $(this).attr("did");
			$.dialog({
				id: 'delDance',
				title: false,
				border: false,
				follow: $(this)[0],
				content: '确认要取消这笔订单么？',
				okValue: '确认',
				ok: function() {
					$.getJSON(zone_domain + "do.php?p=account&a=delpay&callback=?", "did=" + escape(did),
					function(data) {
						if (data['error'] == 001) {
						$.tipMessage("您需要先登录才能进行此操作!", 1, 3000, 0, function(){location.href = "login.php"});
					} else	if (data['error'] == 002) {
						$.tipMessage("您无权撤销该笔订单！", 1, 1500, 0,function() {location.href = zone_domain +"space.php?do=assets&view=pointsorder"});
					} else	if (data['error'] == 003) {
						$.tipMessage("抱歉，订单不存在！", 1, 1500, 0,function() {location.href = zone_domain +"space.php?do=assets&view=pointsorder"});
					} else	if (data['error'] == 004) {
						$.tipMessage("订单撤销成功！", 0, 1500, 0,function() {location.href = zone_domain +"space.php?do=assets&view=pointsorder"});
						} else {
							$.tipMessage("未知结果，请与管理员联系！", 0, 1500, 0,
							function() {
								location.href = location.href;
							});
						}
					});
				},
				cancelValue: '取消',
				cancel: function() {}
			});
		});
	},
	vipRecharge: function() {
		$("#recharge").click(function() {
			var myDialog = $.dialog({
				id: 'sendMsg',
				title: 'VIP会员充值',
				lock: true,
				okValue: '确认',
				ok: function() {
					var pid = $("input[name=pid]:checked");
					if (pid.val() == undefined) {
						$.tipMessage('请先选择您购买的类型！', 1, 3000);
						return false;
					} else {
						$.ajax({
							type: "POST",
							global: false,
							url: zone_domain + "do.php?p=account&a=order",
							data: {
								'pid': pid.val()
							},
							dataType: "text",
							success: function(data) {
								if (data == 20001) {
									user.userNotLogin('您未登录无法执行此操作！');
								} else if (data == 10004) {
									$.tipMessage('非法操作，请指定操作对象！', 1, 2000);
									return false;
								} else {
									$.dialog({
										id: 'sendMsg',
										title: '充值',
										lock: true,
										content: data,
										okValue: '确认并支付',
										ok: function() {
											var cd_type = $("input[name=cd_type]:checked");
											if (cd_type.val() == undefined) {
												$.tipMessage('请先选择一种支付方式！', 1, 3000);
												return false;
											} else {
												frmadd.submit();
												$.tipMessage('订单创建成功！', 0, 1000, 0,function() {location.href = zone_domain + "space.php?do=assets&view=pointsorder"})
												return false;
											}
										},
										cancelValue: '取消',
										cancel: function() {}
									});
								}
							}
						});
					}
				},
				cancelValue: '取消',
				cancel: function() {}
			});
			$.ajax({
				type: "POST",
				global: false,
				url: zone_domain + "do.php?p=account&a=Recharge",
				data: {
					'uidKey': 1
				},
				dataType: "text",
				success: function(data) {
					if (data == 20001) {
						user.userNotLogin('您未登录无法执行此操作！');
						return false;
					} else {
						myDialog.content(data);
					}
				}
			});
		});
	},
	pointsRecharge: function() {
		$("#topupRecharge").click(function() {
			var myDialog = $.dialog({
				id: 'sendMsg',
				title: '金币充值',
				lock: true,
				okValue: '确认',
				ok: function() {
					var pid = $('#pid2');
					if (pid.val() == "") {
						$.tipMessage('请先输入充值金额！', 1, 3000);
						return false;
					} else {
						$.ajax({
							type: "POST",
							global: false,
							url: zone_domain + "do.php?p=account&a=topuporder",
							data: {
								'pid': pid.val()
							},
							dataType: "text",
							success: function(data) {
								if (data == 20001) {
									user.userNotLogin('您未登录无法执行此操作！');
								} else if (data == 10004) {
									$.tipMessage('非法操作，请指定操作对象！', 1, 2000);
									return false;
								} else {
									$.dialog({
										id: 'sendMsg',
										title: '充值',
										lock: true,
										content: data,
										okValue: '确认并支付',
										ok: function() {
											var cd_type = $("input[name=cd_type]:checked");
											if (cd_type.val() == undefined) {
												$.tipMessage('请先选择一种支付方式！', 1, 3000);
												return false;
											} else {
												frmadd.submit();
												$.tipMessage('订单创建成功！', 0, 1000, 0,function() {location.href = zone_domain + "space.php?do=assets&view=pointsorder"})
												return false;
											}
										},
										cancelValue: '取消',
										cancel: function() {}
									});
								}
							}
						});
					}
				},
				cancelValue: '取消',
				cancel: function() {}
			});
			$.ajax({
				type: "POST",
				global: false,
				url: zone_domain + "do.php?p=account&a=topupRecharge",
				data: {
					'uidKey': 1
				},
				dataType: "text",
				success: function(data) {
					if (data == 20001) {
						user.userNotLogin('您未登录无法执行此操作！');
						return false;
					} else {
						myDialog.content(data);
					}
				}
			});
		});
	}
};