/**
 * The JSON encode/decode feature
 *
 * Copyright (C) 2009-2010 Nikolay V. Nemshilov
 */
var JSON=(function(d){var a=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,f={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\': '\\\\'},q=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;function e(s){return s.replace(q,function(c){return f[c]||'\\u'+('0000'+c.charCodeAt(0).toString(16)).slice(-4)})};var z=function(n){return(n<10?'0':'')+n};var g=d?d.stringify:function(v){if(v===null)return 'null';else if(v.toJSON)return v.toJSON();else switch(typeof(v)){case 'boolean':return String(v);case 'number':return String(v+0);case 'string':return '"'+e(v)+'"';case 'object':if(v instanceof Array)return '['+v.map(JSON.stringify).join(',')+']';else if(v instanceof Date)return v.getUTCFullYear()+'-'+z(v.getUTCMonth()+1)+'-'+z(v.getUTCDate())+'T'+z(v.getUTCHours())+':'+z(v.getUTCMinutes())+':'+z(v.getUTCSeconds())+'.'+z(v.getMilliseconds())+'Z';else{var r=[];for(var k in v)r.push(JSON.encode(k)+":"+JSON.encode(v[k]));return '{'+r.join(',')+'}'}}};var p=d?d.parse:function(s){if(isString(s)&&s){s=s.replace(a,function(b){return '\\u'+('0000'+b.charCodeAt(0).toString(16)).slice(-4)});if(/^[\],:{}\s]*$/.test(s.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,'@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,']').replace(/(?:^|:|,)(?:\s*\[)+/g,'')))return eval('('+s+')')}throw "JSON parse error: "+s};return{stringify:g,parse:p,encode:g,decode:p}})(self.JSON);if(window['Cookie'])(function(C){var a=C.set,o=C.get;$ext(C,{set:function(v){return a.call(this,JSON.stringify(v))},get:function(){return JSON.parse(o.call(this))}})})(Cookie.prototype);Xhr.prototype.sanitizedJSON=function(){try{return JSON.decode(this.text)}catch(e){if(this.secureJSON)throw e;else return null}};