/**
 * labs_json Script by Giraldo Rosales.
 * Version 1.0
 * Visit www.liquidgear.net for documentation and updates.
 *
 *
 * Copyright (c) 2009 Nitrogen Design, Inc. All rights reserved.
 * 
 * Permission is hereby granted, free of charge, to any person
 * obtaining a copy of this software and associated documentation
 * files (the "Software"), to deal in the Software without
 * restriction, including without limitation the rights to use,
 * copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following
 * conditions:
 * 
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 * OTHER DEALINGS IN THE SOFTWARE.
 **/

jQuery.json={encode:function(a,e,c){var d;var g=gap="";if(typeof c==="number")for(d=0;d<c;d+=1)g+=" ";if((rep=e)&&typeof e!=="function"&&(typeof e!=="object"||typeof e.length!=="number"))throw new Error("JSON.encode");return this.str("",{"":a})},decode:function(a,e){function c(g,i){var f,b,h=g[i];if(h&&typeof h==="object")for(f in h)if(Object.hasOwnProperty.call(h,f)){b=c(h,f);if(b!==undefined)h[f]=b;else delete h[f]}return e.call(g,i,h)}var d=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g; d.lastIndex=0;if(d.test(a))a=a.replace(d,function(g){return"\\u"+("0000"+g.charCodeAt(0).toString(16)).slice(-4)});if(/^[\],:{}\s]*$/.test(a.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,""))){a=eval("("+a+")");return typeof e==="function"?c({"":a},""):a}throw new SyntaxError("JSON.parse");},f:function(a){return a<10?"0"+a:a},DateToJSON:function(){return this.getUTCFullYear()+"-"+this.f(this.getUTCMonth()+ 1)+"-"+this.f(this.getUTCDate())+"T"+this.f(this.getUTCHours())+":"+this.f(this.getUTCMinutes())+":"+this.f(this.getUTCSeconds())+"Z"},StringToJSON:function(){return this.valueOf()},quote:function(a){var e={"\u0008":"\\b","\t":"\\t","\n":"\\n","\u000c":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},c=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;c.lastIndex=0;return c.test(a)?'"'+a.replace(c,function(d){var g=e[d];return typeof g=== "string"?g:"\\u"+("0000"+d.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+a+'"'},str:function(a,e){var c="",d,g,i=c,f,b=e[a];if(b&&typeof b==="object")switch(typeof b){case "date":this.DateToJSON(a);break;default:this.StringToJSON(a);break}if(typeof rep==="function")b=rep.call(e,a,b);switch(typeof b){case "string":return this.quote(b);case "number":return isFinite(b)?String(b):"null";case "boolean":case "null":return String(b);case "object":if(!b)return"null";c+="";f=[];if(Object.prototype.toString.apply(b)=== "[object Array]"){g=b.length;for(a=0;a<g;a+=1)f[a]=this.str(a,b)||"null";return e=f.length===0?"[]":c?"[\n"+c+f.join(",\n"+c)+"\n"+i+"]":"["+f.join(",")+"]"}if(rep&&typeof rep==="object"){g=rep.length;for(a=0;a<g;a+=1){d=rep[a];if(typeof d==="string")if(e=this.str(d,b))f.push(this.quote(d)+(c?": ":":")+e)}}else for(d in b)if(Object.hasOwnProperty.call(b,d))if(e=this.str(d,b))f.push(this.quote(d)+(c?": ":":")+e);return e=f.length===0?"{}":c?"{\n"+c+f.join(",\n"+c)+"\n"+i+"}":"{"+f.join(",")+"}"}}};
