﻿// Creates a cookie with the user settings

function User()
{
    this.data = {};
    
    this.save = function()
    {
        var cookie_date = new Date ( 2111, 01, 15 );
        document.cookie = "userInfo="+$.toJSON(this.data)+";expires=" + cookie_date.toGMTString();

    }
    
    this.load = function()
    {
        var userCookie = this.get_cookie('userInfo');
        
        if(userCookie != null)
        {
            this.data = $.parseJSON(this.get_cookie('userInfo'));
        }
        
        return this.data;
    }
    
    // Helper to load a cookie
    this.get_cookie = function ( cookie_name )
    {
      var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' );

      if ( results )
        return ( unescape ( results[2] ) );
      else
        return null;
    }
}
        
        