var SNShout = { lastComment:null, lastID:0, lastUname:"", lastTP:"", takeTheMic:function(cmnt) { var am = new AMAX('/App_Info/TakeTheMic.aspx', true); am.onLoad = function() { if (this.success) { var dd = processData(this.data, am); SNShout.lastID = dd.ID; SNShout.lastComment = dd.Comment; SNShout.lastUname = dd.LastName; SNShout.lastTP = dd.TP; SNShout.onSuccess(); } } am.send('action=add&cmnt=' + am.encode(cmnt)+'&rand='+Math.ceil(Math.random()*10000000000), 'get'); }, getLastShout:function() { var am = new AMAX('/App_Info/TakeTheMic.aspx', true); am.onLoad = function() { if (this.success) { var dd = processData(this.data, am); SNShout.lastID = dd.ID; SNShout.lastComment = dd.Comment; SNShout.lastUname = dd.LastName; SNShout.lastTP = dd.TP; SNShout.onSuccess(); } } am.send('action=fetch&rand='+Math.ceil(Math.random()*10000000000), 'get'); }, onSuccess:function(){} }; function processData(data, am) { return { ID: parseInt(data.getElementsByTagName('mid').item(0).childNodes[0].nodeValue), Comment: am.decode(data.getElementsByTagName('cmnt').item(0).childNodes[0].nodeValue), LastName: am.decode(data.getElementsByTagName('uname').item(0).childNodes[0].nodeValue), TP: data.getElementsByTagName('tp').item(0).childNodes[0].nodeValue }; }