﻿/**
*
* TopAndBottom
*
* @Version:     1.2
* @Author:      Roy Ding
* Create Date:  2010-7-14
* Last updated: 2010-8-19
*
*/

$(function () {
    if ($.cookie("UserID") != null) {
        $("#LoginTop").html(" <strong>" + $.cookie("UserName") + "</strong> <a href=\"/Page/Member/MemberWelcome.aspx\" title=\"" + Resources.UserControl.Top.MyPanel + "\">[" + Resources.UserControl.Top.MyPanel + "]</a> <a href=\"javascript:void(0);\" title=\"" + Resources.UserControl.Top.SignOut + "\" name=\"SignOut\">[" + Resources.UserControl.Top.SignOut + "]</a>");
    }
    else {
        $("#LoginTop").html(" <a href=\"/Page/MemberLogin.aspx\" title=\"" + Resources.UserControl.Top.Login + "\">[" + Resources.UserControl.Top.Login + "]</a><a href=\"/Page/MemberRegister.aspx\" title=\"" + Resources.UserControl.Top.JoinFree + "\">[" + Resources.UserControl.Top.JoinFree + "]</a>");
    }
});

$(function () {
    $("a[name='SignOut']").live("click", function () {
        $.ajax({
            type: "POST",
            contentType: "application/json;utf-8",
            url: "/Service/UserService.asmx/UserSignOut",
            data: "{}",
            dataType: "json",
            success: function () {
                window.location = "/Page/MemberLogin.aspx";
            },
            error: function (result, status) {
                if (status == "error") {
                    alert(status);
                }
            }
        });
    });
});

