Type.registerNamespace( "GG" );

GG.CurrentUser = Sys.Serialization.JavaScriptSerializer.deserialize( '{"EmailAlertsEnabled":false,"IsRegistered":false,"IsVerified":false,"AvatarImageUrl":"http://globalgrind.com/images/AnonAvatar.gif","UserName":"","Quote":""}' );

GG.CurrentUser.update = function()
{	
	GlobalGrind.Web.Components.MembershipWebService.UpdateCurrentUser( GG.CurrentUserInternal.update_callback );
}

GG.CurrentUser.updateDefaultTabID = function( tabID )
{
	GG.CurrentUser.DefaultTabID = tabID;
	GlobalGrind.Web.Components.GadgetWebService.UpdateDefaultTabID( GG.CurrentUser.DefaultTabID );
}

GG.CurrentUser.logout = function()
{
	if ( $get( lnkLogout ) )
		location.href = $get( lnkLogout ).getAttribute("logout");	
};

GG.CurrentUserInternal = function() { };

GG.CurrentUserInternal.update_callback = function( userObject )
{
	GG.CurrentUser = userObject;
	GG.CurrentUser.update = function()
	{	
		GlobalGrind.Web.Components.MembershipWebService.UpdateCurrentUser( GG.CurrentUserInternal.update_callback );
	};
	
	GG.Events.Instance._onUserRefreshed();
}



Sys.Application.notifyScriptLoaded();
