(function() { var DEFAULT_COMMAND_NAME = 'cookie'; msnbc.misc.CookieCommand = Class.extend({ init: function(m){ this.module = m; this.commandsByName = {}; }, addCommand: function(c, v){ if (v == undefined) { if (parseInt(c)!=NaN && parseInt(c)!='NaN') this.commandsByName[DEFAULT_COMMAND_NAME] = parseInt(c); } else { if (parseInt(v)!=NaN && parseInt(v)!='NaN') this.commandsByName[c] = parseInt(v);; } }, toPartString: function(){ var s = ''; s += this.module; jQuery.each(this.commandsByName, function(k,v){ if (k!=DEFAULT_COMMAND_NAME) s+='-'+k; s+='-'+v; }); return s; } }); msnbc.misc.StorypageCookie = msnbc.core.EventDispatcher.extend({ init: function(name, rawValue){ this.name = name; this.rawValue = rawValue; this.commandsByModule = {}; this.parse(); }, parse: function(){ var self = this; if (this.rawValue=='') return; var cs = this.rawValue.split('|'); jQuery.each(cs,function(i,c){ var m; var i = 1; var parts = c.split('-'); m = parts[0]; if (parts.length>1) { var cookieCmd = new msnbc.misc.CookieCommand(m); if (parts.length%2 == 0) { // even number, must include default first cookieCmd.addCommand(DEFAULT_COMMAND_NAME, parseInt(parts[1])); i = 2; } while(i