﻿var ProfileManager =
{
    _profileApi: null,
    _showProfileApi: null,
    _editProfileUrl: null,
    _viewProfileUrl: null,

    Init: function(editProfileUrl, viewProfileUrl)
    {
        this._editProfileUrl = editProfileUrl;
        this._viewProfileUrl = viewProfileUrl;
        this._profileApi = $("#profile-link[rel]").overlay(
        {
            api: true,
            onLoad: function()
            {
                $("#profile-content").load(ProfileManager._editProfileUrl, function()
                {
                    ProfileManager.SetAjaxForm();
                    $("#profile-birthdate").simpleDatepicker(
                    {
                        startdate: 1900,
                        enddate: 2000,
                        chosendate: $("#profile-birthdate").val()
                    });
                    pageTracker._trackPageview("/editprofile");
                });
            }
        });
        this._showProfileApi = $(".profile-overlay").overlay(
        {
    });
},

ShowEditProfile: function()
{
    ProfileManager._profileApi.load();
},

SetAjaxForm: function()
{
    $("#profile-info-form").ajaxForm(
		{
		    success: function(data)
		    {
		        ProfileManager._profileApi.close();
		    }
		});
},

ViewProfile: function(userId)
{
    $("#profile-content").load(ProfileManager._viewProfileUrl + "?userid=" + userId, function()
    {
        ProfileManager._showProfileApi.load();
        pageTracker._trackPageview("/viewrofile");
    });
}
}
