function get_from_loc_stor(key)
{
     if(typeof(localStorage) != "undefined"){
        var a = localStorage.getItem('l_s_session');
        a = $.parseJSON(a);
        if(a==null)
            return false;
        if(typeof(key)!='undefined')
          return a[key];
        else
          return a;
     }
     else return false;
}

function update_loc_stor_obj(key,value,dontupdate)
{
    if(typeof(localStorage) != "undefined"){
        if(dontupdate==null)
            dontupdate = false;
        var a = localStorage.getItem('l_s_session');
        a = $.parseJSON(a); 
        if(a==null)
          a = new Object();
        a[key] = value;
        a=JSON.stringify(a);
        localStorage.setItem('l_s_session', a); 
        if(!dontupdate)
          update_loc_stor_session();
    }
    else return false;
}

function update_loc_stor_session()
{
    if(typeof(localStorage) != "undefined"){
        var a = localStorage.getItem('l_s_session'); 
        $.ajax({ 
            url: "/resources/ajax.php",
            dataType: 'json',
            data: 
            {   
              localstorage: a,
              action: 'set_local_storage_session'
            },                
            success: function(data) {
               //do nothing as this is background job
            },
            error: function(data) {
              //do also nothing as this is background job
            },
            type: 'GET'
        }); 
    }
    else return false;
}

function local_storage_obj()
{
  this.get=get_from_loc_stor;  
  this.update=update_loc_stor_obj;  
  this.update_session=update_loc_stor_session;  
}

loc_sto_obj = new local_storage_obj();   
loc_sto_obj.update_session();   

