JSON_stringify

implement JSON.stringify serialization 

// implement JSON.stringify serialization 
// source: http://stackoverflow.com/questions/4715373/json-object-undefined-in-internet-explorer-8-dom
function JSON_stringify(obj) {

    var t = typeof (obj);
    if (t != "object" || obj === null) {

        // simple data type
        
        if (t == "string") obj = '"'+ obj.replace(/\\/ig,"\\\\").replace(/"/ig,'\\"').replace(/\n/ig,"\\n").replace(/\t/ig,"\\t") +'"';
        return String(obj);

    }
    else {

        // recurse array or object
        var n, v, json = [], arr = (obj && obj.constructor == Array);

        for (n in obj) {
            v = obj[n]; t = typeof(v);

            if (t == "string") v = '"'+v.replace(/\\/ig,"\\\\").replace(/"/ig,'\\"').replace(/\n/ig,"\\n").replace(/\t/ig,"\\t") +'"';
            else if (t == "object" && v !== null) v = JSON_stringify(v);

            json.push((arr ? "" : '"' + n + '":') + String(v));
        }

        return (arr ? "[" : "{") + String(json) + (arr ? "]" : "}");
    }
    };