function createSession() {

	var win = window.top || window;
	var store = (win.name ? JSON.parse(win.name) : {});

	function Save() {
		win.name = JSON.stringify(store);
	};

	if (window.addEventListener) 
    window.addEventListener("unload", Save, false);
	else 
    if (window.attachEvent) 
      window.attachEvent("onunload", Save);
	   else window.onunload = Save;

	// public methods
	return {
		set: function(name, value) {
			store[name] = value;
		},
		get: function(name) {
			return (store[name] ? store[name] : undefined);
		},
		clear: function() { 
      store = {}; 
    },
		dump: function() { 
      return JSON.stringify(store); 
    }
	};
}

if (JSON && JSON.stringify && JSON.parse) 
  var Session = Session || createSession();
  
  
 

