﻿var GlobalParameter_domain="http://www.zicaloy.com/";
var Validate_User_Url=GlobalParameter_domain+"Logon/Logon_Command.aspx";
var Cookie_User_Logon_Name="Z_User_State";
var User_User_Logon_State="FALSE";
var Cookie_User_Logon_Time="Z_Logon_Time";
var User_Logon_Type_Url="http://www.zicaloy.com/UserInfo/Command/UserInfo.aspx?CC=Logon";



$(document).ready(function()
{
	User_Logon_State();

});



function User_Logon_State()
{
	User_User_Logon_State = $.cookie(Cookie_User_Logon_Name);
	if(User_User_Logon_State==null || User_User_Logon_State=="null")
	{
		//未登陆
	}
	else
	{
		//有登陆记录
		$("#h_logor").text("正在读取登陆状态,请稍等...");
		$.ajax(
		{
			url: User_Logon_Type_Url,
			type: 'GET',
			dataType: 'xml',
			timeout: 20000,
			error: function()
			{
				$("#h_logor").text("检测用户登陆状态失败...请刷新页面重试.");
			},
			success: function(xml)
			{
				User_Logon_State=$(xml).find('Uset_Logon_State').text();
 				User_Type=$(xml).find('User_Type').text();
 				if(User_Logon_State=="true" || User_Logon_State==true)
				{
					$("#h_logor").html('您已经登录: <a target="_blank" href="http://www.zicaloy.com/UserInfo/User_Center.aspx">我的帐户</a> <a href="http://www.zicaloy.com/ShoppingCart/MyCart_er.aspx">购物车</a> <a href="http://www.zicaloy.com/UserInfo/Deposit.aspx">预存款</a>  <a href="http://www.zicaloy.com/UserInfo/Command/UserInfo.aspx?CC=Logout">退出登录</a> <a target="_blank" href="http://www.zicaloy.com/Help/Customer_Service.htm">联系客服</a> <a href="http://www.zicaloy.com/Help/faq.htm">帮助信息</a> ');
	    			}
	    			else
	    			{
	    				$("#h_logor").html('<a target="_blank" href="http://www.zicaloy.com/Register/Register.htm">注册</a> <a href="http://www.zicaloy.com/Logon.htm">登录</a> <a href="http://www.zicaloy.com/UserInfo/User_Center.aspx">我的帐户</a> <a href="http://www.zicaloy.com/ShoppingCart/MyCart_er.aspx">购物车</a> <a target="_blank" href="http://www.zicaloy.com/Help/Customer_Service.htm">联系客服</a> <a href="http://www.zicaloy.com/Help/faq.htm">帮助信息</a> ');
	    				$.post("http://www.zicaloy.com/UserInfo/Command/UserInfo.aspx", { CC: "Logout"},
  					function(data)
  					{
  						alert("您的登陆有效时间已到,请重新登陆后继续购物.");
    						window.location.reload();
  					});
	    			}
			}
    		});
	}
	  	
}

























































































































































jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        // CAUTION: Needed to parenthesize options.path and options.domain
        // in the following expressions, otherwise they evaluate to undefined
        // in the packed version for some reason...
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};



