$(document).ready(function() {
	$("a.vp").bind("click", function() {
		UserPoint.Action();
		return false;
	});
});

/*
**用户积分JS类，用于异步获取用户的积分
**
*/
var UserPoint = {
	//检查用户是否登陆了，如果没有登陆就登陆，如果已经登陆了，就直接返回查询用户的积份
	Action: function() {
		MiniLogin.Action(UserPoint, "", "");
	},
	//检查完登陆后的回调方法，用户查询用户的积分
	Callback: function() {
		var show = this.ShowTip;
		$.AjaxLoader2(ajaxServiceAddress.UserPoints, "{}",
        function(data) {
        	var strJson = eval('(' + data + ')');
        	var strResult = eval(strJson.d);
        	if (strResult[0].Status == "YES")//登陆成功"{Result:\"YES\",MemberShipId:" + passProt.MemberShipId + "}";
        	{
        		setTimeout(function() {
        			$("#Points_pop_wait").remove();
        			show(strResult[0].Points);
        		}, 1500);
        	}
        },
        function() {
        	alert("联接服务器失败！");
        }
        ,
        function() {
        },
        function() {
        	var myDiv2 = $("<div id=\"Points_pop_wait\" style=\"display:none;\" class=\"detail-pop\"><div class=\"title\">积分详情</div><p><img src=\"http://img.m18.com/web/i/comm/load.gif\"/></p><div class=\"close-favlist\"><a href=\"#\" name=\"fClose\">关闭</a></div></div>");
        	$("body").append(myDiv2);
        	$("#Points_pop_wait").fadeIn("slow");
        }
        );
	},
	//此方法用于将用户的积分显示出来
	ShowTip: function(points) {
		var myDiv = $("<div id=\"Points_pop\" style=\"display:none;\" class=\"detail-pop\"><div class=\"title\">积分详情</div><p>您的当前积分为：" + points + "</p><div class=\"close-favlist\"><a href=\"#\" name=\"fClose\">关闭</a></div></div>");
		$("body").append(myDiv);
		$("#Points_pop").fadeIn("slow");

		var timeOut = setTimeout(function() {
			$("#Points_pop").fadeOut("slow", function() {
				$(this).remove();
			});
		}, 4000);

		myDiv.find("a[name='fClose']").bind("click", function() {
			clearTimeout(timeOut);
			$("#Points_pop").remove();
			return false;
		});
	}
};

//----------------------------------Static Method-----------------------
$.AjaxLoader2 = function(url, data, callback, error, wait, start) {
	$.ajax({
		url: url,
		data: data,
		type: "POST",
		contentType: "application/json; charset=utf-8",
		success: callback,
		error: error,
		complete: wait,
		beforeSend: start
	});
}