jQuery(document).ready(function() {
    //$('[class=rate-tbl] .threedecimals,[class=rate-prod-tbl] .threedecimals').each(
    jQuery('[class*="rate-tbl"] .threedecimals,[class*="rate-prod-tbl"] .threedecimals').each(
            function(index){jQuery(this).html("%.3f\%".printf(jQuery(this).html().replace(/[^0-9.]*/g,'')*1));}
    );
    //$('.twodecimals').each(
    jQuery('[class*="rate-tbl"] .twodecimals,[class*="rate-prod-tbl"] .twodecimals').each(
        function(index){
            jQuery(this).html("%.2f\%".printf(jQuery(this).html().replace(/[^0-9.]+/g,'')*1));
        }
    );
    jQuery('.rate_rows .commify').each(function(index){jQuery(this).html(commify(jQuery(this).html()));});
});

function IsNullorUndefined(A) {
    if (typeof(A) == "undefined" || A == "undefined" || A == null) {
        return true;
    } else {
        return false;
    }
}

if(!window.console){
    var console = {};
    var methods = ['assert','clear','count','debug','dir','dirxml',
        'error','exception','group','groupCollapsed','groupEnd','info','log','notifyFirebug',
        'profile','profileEnd','table','time','timeEnd','trace','warn'
            ];
    for(var i=0;i<methods.length;i++){
        console[methods[i]] = function(){};
    }
}

comp_method = function(sortrow){
    switch(sortrow.compoundMethod){
        case 'D':
           sortrow.compounding_format = 'Compounded daily';
           break;
        case 'M':
           sortrow.compounding_format = 'Compounded monthly';
           break;
        case 'Q':
           sortrow.compounding_format = 'Compounded quarterly';
           break;
        case 'A':
           sortrow.compounding_format = 'Compounded annually';
           break;
        case 'H':
           sortrow.compounding_format = 'Compounded semi-Annually';
           break;
        case 'W':
           sortrow.compounding_format = 'Compounded weekly';
           break;
        default:
           sortrow.compounding_format = 'Simple interest';
           break;
    }
}

function commify(num){
    num += '';
    var cents = num.match(/\.\d+$/)?num.match(/\.\d+$/):'';
    num = num.replace(cents,'');
    return num.replace(/[^\d$+-]+/g,'').split('').reverse()
        .join('').replace(/(\d\d\d)/g,"$1,").replace(/,([$+-]?)$/,'$1')
        .split("").reverse().join("") + cents;
}

function brJsonDecode(json){
    var j = eval("(" + json + ")");
    var r = eval("(" + j.Response + ")");
    return(eval("(" + r.Buffer + ")"));
}

//Singleton
var BrDialogAd = new function BrDialogAd(){
    this.ads = 0;
    this.hide_ads = function(){
        var ad_div = arguments[0];
        var ads_in_dialog = arguments[1];
        if(ads_in_dialog && typeof(AdManager) == 'object'){
            AdManager.loadAdScripts(adsrv_url,'lightbox',ad_div);
        }
        jQuery('#UAC_AD_1').hide();
        jQuery('#UAC_AD_2').hide();
        jQuery('#UAC_AD_3').hide();
        jQuery('#UAC_AD_4').hide();
        this.ads++;
    }
    this.show_ads = function (b){
        this.ads--;
        if(this.ads == 0 || this.ads < 0){
            jQuery('#UAC_AD_1').show();
            jQuery('#UAC_AD_2').show();
            jQuery('#UAC_AD_3').show();
            jQuery('#UAC_AD_4').show();
            this.ads = 0;
        }
    }
}
var TemplateDialog  = function(){
        this.dialogPosition ='top';
        this.dialogWidth= 720;
        this.dialogHeight= 'auto';
        this.dialogAutoOpen= true;
        this.dialogModal= true;
        this.dialogTitle= "Please set dialogTitle";
        this.resizable= false;
        this.hide= 'fade';
        this.open= null;
        this.display= function(struct){
            if(BrDialogAd.ads){ return; }
            var row = struct.details.row;
            var controlID = struct.details.controlID;
            this.ads_in_dialog = (typeof(struct.details.ads_in_dialog) == 'undefined')?false:struct.details.ads_in_dialog;
            jQuery("#"+controlID).remove();
            // It is hard to get the close text in there because the information comes from the title of the div
            if(! this.dialogTitle.match(/>Close</)){
            this.dialogTitle = '<a class="'+controlID+'_close" style="float:right;text-decoration:none;display:inline;"'
                                +' onclick="jQuery(\'#'+controlID+'\').dialog(\'close\')">Close</a>'+this.dialogTitle;
            }
            // Create our dialog div on the fly.
            jQuery('body').append(
                    '<div id="'+controlID+'" ></div>'
                    );
            this.title  = '<div style="width:'+(this.dialogWidth - 44)+'px;margin-top:-2px;">'+this.dialogTitle+'</div>';
            // This just uses a template that was set up from the php and is now in the html.
            // We are going to inject it into the div we just created

            row['UAC_AD_'+controlID+'_LIGHTBOX_8'] = 'UAC_AD_'+controlID+'_LIGHTBOX_8';
            row['UAC_AD_'+controlID+'_LIGHTBOX_9'] = 'UAC_AD_'+controlID+'_LIGHTBOX_9';

            jQuery("#"+controlID).html(
                jQuery('#'+controlID+'_template')
                    .html()
                    .replace(/#{(\w+)}/g,function(m,m1){return (row[m1] && typeof row[m1]!= 'object')?row[m1]:'';})
                );
            jQuery("#"+controlID+" .minDeposit").each(function(){
                        jQuery(this).html(commify(jQuery(this).html()));
            });
            jQuery("#"+controlID+" .commify").each(function(){
                        jQuery(this).html(commify(jQuery(this).html()));
            });
            jQuery("#"+controlID+" .threedecimals").each(function(){
                       jQuery(this).html("%.3f\%".printf(jQuery(this).html().replace(/[^0-9.]+/,'')));
            });
            jQuery("#"+controlID+" .twodecimals").each(function(){
                jQuery(this).html("%.2f\%".printf(jQuery(this).html().replace(/[^0-9.]+/g,'')*1));
            });
            // Override these from your controlID function
            jQuery("#"+controlID).dialog({
                position: this.dialogPosition,
                width: this.dialogWidth,
                height: this.dialogHeight,
                autoOpen: this.dialogAutoOpen,
                modal: this.dialogModal,
                resizable: this.resizable,
                title: this.title,
                hide: this.hide,
                open: this.open,
                close: function(){
                    BrDialogAd.show_ads();
                    jQuery('.contact a').css({'cursor':'pointer'});
                }
            });
            jQuery('.ui-widget-overlay').click(function(){jQuery("#"+controlID).dialog('close')});
            BrDialogAd.hide_ads(controlID,this.ads_in_dialog);
        }
};
function assign_sort(rows,dir){
        switch(dir){
            case 'a': // alphabetical
                rows.sort(function(a, b) {
                    if (a.sk < b.sk) return -1;
                    if (a.sk > b.sk) return 1;
                    return 0;
                });
                break;
            case 'ra': // reverse alphabetical
                rows.sort(function(a, b) {
                    if (b.sk < a.sk) return -1;
                    if (b.sk > a.sk) return 1;
                    return 0;
                });
                break;
            case 'n': // sort lowest to highest
                rows.sort(function(a, b) {return a.sk - b.sk;});
                break;
            default: // sort higest to lowest
                rows.sort(function(a, b) {return b.sk - a.sk;});
        }
}
function nested_sort(arr,dir,k){
        switch(dir){
            case 'a': // alphabetical
                arr.sort(function(a, b) {
                    if (a[k] < b[k]) return -1;
                    if (a[k] > b[k]) return 1;
                    return 0;
                });
                break;
            case 'ra': // reverse alphabetical
                arr.sort(function(a, b) {
                    if (b[k] < a[k]) return -1;
                    if (b[k] > a[k]) return 1;
                    return 0;
                });
                break;
            case 'n': // sort lowest to highest
                arr.sort(function(a, b) {return a[k] - b[k];});
                break;
            default: // sort higest to lowest
                arr.sort(function(a, b) {return b[k] - a[k];});
        }
}
function GetEvent(e){
    return (e) ? e : (window.event) ? window.event : "";
}
function GetSrc(e){
        this.eSrc =  (e.target) ? e.target : e.srcElement;
        if(this.eSrc.nodeType == 3) this.eSrc.nodeType = this.eSrc.parentNode;
        return  this.eSrc;
}
// jquery ui combobox  jQeury("#selectname").combobox();
(function( $ ) {
$.widget( "ui.combobox", {
    _create: function() {
        var self = this,
            select = this.element.hide(),
            selected = select.children( ":selected" ),
            value = selected.val() ? selected.text() : "";
        var input = this.input = $( "<input>" )
            .insertAfter( select )
            .val( value )
            .autocomplete({
                delay: 0,
                minLength: 0,
                source: function( request, response ) {
                    var matcher = new RegExp( $.ui.autocomplete.escapeRegex(request.term), "i" );
                    response( select.children( "option" ).map(function() {
                        var text = $( this ).text();
                        if ( this.value && ( !request.term || matcher.test(text) ) )
                            return {
                                label: text.replace(
                                    new RegExp(
                                        "(?![^&;]+;)(?!<[^<>]*)(" +
                                        $.ui.autocomplete.escapeRegex(request.term) +
                                        ")(?![^<>]*>)(?![^&;]+;)", "gi"
                                    ), "<strong>$1</strong>" ),
                                value: text,
                                option: this
                            };
                    }) );
                },
                select: function( event, ui ) {
                    ui.item.option.selected = true;
                    self._trigger( "selected", event, {
                        item: ui.item.option
                    });
                },
                change: function( event, ui ) {
                    if ( !ui.item ) {
                        var matcher = new RegExp( "^" + $.ui.autocomplete.escapeRegex( $(this).val() ) + "$", "i" ),
                            valid = false;
                        select.children( "option" ).each(function() {
                            if ( $( this ).text().match( matcher ) ) {
                                this.selected = valid = true;
                                return false;
                            }
                        });
                        if ( !valid ) {
                            // remove invalid value, as it didn't match anything
                            $( this ).val( "" );
                            select.val( "" );
                            input.data( "autocomplete" ).term = "";
                            return false;
                        }
                    }
                }
            })
            .addClass( "ui-widget ui-widget-content ui-corner-left" );

        input.data( "autocomplete" )._renderItem = function( ul, item ) {
            return $( "<li></li>" )
                .data( "item.autocomplete", item )
                .append( "<a>" + item.label + "</a>" )
                .appendTo( ul );
        };

        this.button = $( "<button type='button'>&nbsp;</button>" )
            .attr( "tabIndex", -1 )
            .attr( "title", "Show All Items" )
            .insertAfter( input )
            .button({
                icons: {
                    primary: "ui-icon-triangle-1-s"
                },
                text: false
            })
            .removeClass( "ui-corner-all" )
            .addClass( "ui-corner-right ui-button-icon" )
            .click(function() {
                if ($( this ).hasClass('disabled')){return;}

                // close if already visible
                if ( input.autocomplete( "widget" ).is( ":visible" ) ) {
                    input.autocomplete( "close" );
                    return;
                }

                // work around a bug (likely same cause as #5265)
                $( this ).blur();

                // pass empty string as value to search for, displaying all results
                input.autocomplete( "search", "" );
                input.focus();
            });
    },

    destroy: function() {
        this.input.remove();
        this.button.remove();
        this.element.show();
        $.Widget.prototype.destroy.call( this );
    }
});
})( jQuery );
ToolTips = {
    display: function(from){
        this.details = from.details;
        this.context = from.context;

        this.evt = GetEvent(from.e);
        this.eSrc = GetSrc(this.evt);

        // Allow for a header in the tooltips
        this.context.header = this.context.header?this.context.header:'';
        this.context.header = "<div class='ui-widget-header tooltip-header'>"+this.context.header+"</div>";

        if(!jQuery(this.eSrc).attr('title') && this.details.row){
            jQuery(this.eSrc).attr('title',this.context.header + "<div class='tooltip-body'>"+this.details.row+"</div>");
        }else if($(this.eSrc).attr('title') && this.details.row.length > 0 ){
            jQuery(this.eSrc).attr('title',this.context.header
                                        + "<div class='tooltip-body'>"+ this.details.row
                                        +jQuery(this.eSrc).attr('title') + "</div> "
                            );
        }else if (jQuery(this.eSrc).attr('title')){
            jQuery(this.eSrc).attr('title',this.context.header + "<div class='tooltip-body'>"+jQuery(this.eSrc).attr('title')+"</div>");
        }

        // Take the mouseover that created me out of the javascript.
        // We should allow this to be sent in the "details" or "context" obj so we can replace it with
        // a new function once the tooltip has been made...

        jQuery(this.eSrc).attr('onmouseover','');
        jQuery(this.eSrc).tooltip({position: "bottom right",effect:'fade'}).dynamic();
        // Once we have created the tooltip we need to fire it off for the first time.
        jQuery(this.eSrc).trigger('mouseover');
    }
};



// sprintf functionality
(function(i){var h=function(d){if(typeof d!="string")throw"sprintf: The first arguments need to be a valid format string.";for(var f=RegExp(/%(\+)?([0 ]|'(.))?(-)?([0-9]+)?(\.([0-9]+))?([%bcdfosxX])/g),a=[],e=1;part=f.exec(d);){if(e>=arguments.length)throw"sprintf: At least one argument was missing.";a[a.length]={begin:part.index,end:part.index+part[0].length,sign:part[1]=="+",negative:parseInt(arguments[e])<0?true:false,padding:part[2]==undefined?" ":part[2].substring(0,1)=="'"?part[3]:part[2],alignLeft:part[4]== "-",width:part[5]!=undefined?part[5]:false,precision:part[7]!=undefined?part[7]:false,type:part[8],data:part[8]!="%"?String(arguments[e++]):false}}f="";for(var b=e=0;b<a.length;++b){f+=d.substring(e,a[b].begin);e=a[b].end;var c="";switch(a[b].type){case "%":c="%";break;case "b":c=Math.abs(parseInt(a[b].data)).toString(2);break;case "c":c=String.fromCharCode(Math.abs(parseInt(a[b].data)));break;case "d":c=String(Math.abs(parseInt(a[b].data)));break;case "f":c=a[b].precision==false?String(Math.abs(parseFloat(a[b].data))): Math.abs(parseFloat(a[b].data)).toFixed(a[b].precision);break;case "o":c=Math.abs(parseInt(a[b].data)).toString(8);break;case "s":c=a[b].data.substring(0,a[b].precision?a[b].precision:a[b].data.length);break;case "x":c=Math.abs(parseInt(a[b].data)).toString(16).toLowerCase();break;case "X":c=Math.abs(parseInt(a[b].data)).toString(16).toUpperCase();break;default:throw'sprintf: Unknown type "'+a[b].type+'" detected. This should never happen. Maybe the regex is wrong.';}if(a[b].type!="%"){if(a[b].width!= false)if(a[b].width>c.length)for(var j=c.length,g=0;g<a[b].width-j;++g)c=a[b].alignLeft==true?c+a[b].padding:a[b].padding+c;if(a[b].type=="b"||a[b].type=="d"||a[b].type=="o"||a[b].type=="f"||a[b].type=="x"||a[b].type=="X")if(a[b].negative==true)c="-"+c;else if(a[b].sign==true)c="+"+c}f+=c}f+=d.substring(e,d.length);return f};i.sprintf=h;String.prototype.printf=function(){var d=Array.prototype.slice.call(arguments);d.unshift(String(this));return h.apply(undefined,d)}})(window);
// ToolTips http://flowplayer.org/tools/tooltip/index.html
(function(f){function p(a,b,c){var h=c.relative?a.position().top:a.offset().top,d=c.relative?a.position().left:a.offset().left,i=c.position[0];h-=b.outerHeight()-c.offset[0];d+=a.outerWidth()+c.offset[1];if(/iPad/i.test(navigator.userAgent))h-=f(window).scrollTop();var j=b.outerHeight()+a.outerHeight();if(i=="center")h+=j/2;if(i=="bottom")h+=j;i=c.position[1];a=b.outerWidth()+a.outerWidth();if(i=="center")d-=a/2;if(i=="left")d-=a;return{top:h,left:d}}function u(a,b){var c=this,h=a.add(c),d,i=0,j=0,m=a.attr("title"),q=a.attr("data-tooltip"),r=o[b.effect],l,s=a.is(":input"),v=s&&a.is(":checkbox, :radio, select, :button, :submit"),t=a.attr("type"),k=b.events[t]||b.events[s?v?"widget":"input":"def"];if(!r)throw'Nonexistent effect "'+b.effect+'"';k=k.split(/,\s*/);if(k.length!=2)throw"Tooltip: bad events configuration for "+t;a.bind(k[0],function(e){clearTimeout(i);if(b.predelay)j=setTimeout(function(){c.show(e)},b.predelay);else c.show(e)}).bind(k[1],function(e){clearTimeout(j);if(b.delay)i=setTimeout(function(){c.hide(e)},b.delay);else c.hide(e)});if(m&&b.cancelDefault){a.removeAttr("title");a.data("title",m)}f.extend(c,{show:function(e){if(!d){if(q)d=f(q);else if(b.tip)d=f(b.tip).eq(0);else if(m)d=f(b.layout).addClass(b.tipClass).appendTo(document.body).hide().append(m);else{d=a.next();d.length||(d=a.parent().next())}if(!d.length)throw"Cannot find tooltip for "+a;}if(c.isShown())return c;d.stop(true,true);var g=p(a,d,b);b.tip&&d.html(a.data("title"));e=e||f.Event();e.type="onBeforeShow";h.trigger(e,[g]);if(e.isDefaultPrevented())return c;g=p(a,d,b);d.css({position:"absolute",top:g.top,left:g.left});l=true;r[0].call(c,function(){e.type="onShow";l="full";h.trigger(e)});g=b.events.tooltip.split(/,\s*/);if(!d.data("__set")){d.bind(g[0],function(){clearTimeout(i);clearTimeout(j)});g[1]&&!a.is("input:not(:checkbox, :radio), textarea")&&d.bind(g[1],function(n){n.relatedTarget!=a[0]&&a.trigger(k[1].split(" ")[0])});d.data("__set",true)}return c},hide:function(e){if(!d||!c.isShown())return c;
e=e||f.Event();e.type="onBeforeHide";h.trigger(e);if(!e.isDefaultPrevented()){l=false;o[b.effect][1].call(c,function(){e.type="onHide";h.trigger(e)});return c}},isShown:function(e){return e?l=="full":l},getConf:function(){return b},getTip:function(){return d},getTrigger:function(){return a}});f.each("onHide,onBeforeShow,onShow,onBeforeHide".split(","),function(e,g){f.isFunction(b[g])&&f(c).bind(g,b[g]);c[g]=function(n){n&&f(c).bind(g,n);return c}})}f.tools=f.tools||{version:"1.2.5"};f.tools.tooltip={conf:{effect:"toggle",fadeOutSpeed:"fast",predelay:0,delay:30,opacity:1,tip:0,position:["top","center"],offset:[0,0],relative:false,cancelDefault:true,events:{def:"mouseenter,mouseleave",input:"focus,blur",widget:"focus mouseenter,blur mouseleave",tooltip:"mouseenter,mouseleave"},layout:"<div/>",tipClass:"tooltip"},addEffect:function(a,b,c){o[a]=[b,c]}};var o={toggle:[function(a){var b=this.getConf(),c=this.getTip();b=b.opacity;b<1&&c.css({opacity:b});c.show();a.call()},function(a){this.getTip().hide();a.call()}],fade:[function(a){var b=this.getConf();this.getTip().fadeTo(b.fadeInSpeed,b.opacity,a)},function(a){this.getTip().fadeOut(this.getConf().fadeOutSpeed,a)}]};f.fn.tooltip=function(a){var b=this.data("tooltip");if(b)return b;a=f.extend(true,{},f.tools.tooltip.conf,a);if(typeof a.position=="string")a.position=a.position.split(/,?\s/);this.each(function(){b=new u(f(this),a);f(this).data("tooltip",b)});return a.api?b:this}})(jQuery);
// Dynamic for tooltips
(function(g){function j(a){var c=g(window),d=c.width()+c.scrollLeft(),h=c.height()+c.scrollTop();return[a.offset().top<=c.scrollTop(),d<=a.offset().left+a.width(),h<=a.offset().top+a.height(),c.scrollLeft()>=a.offset().left]}function k(a){for(var c=a.length;c--;)if(a[c])return false;return true}var i=g.tools.tooltip;i.dynamic={conf:{classNames:"top right bottom left"}};g.fn.dynamic=function(a){if(typeof a=="number")a={speed:a};a=g.extend({},i.dynamic.conf,a);var c=a.classNames.split(/\s/),d;this.each(function(){var h=g(this).tooltip().onBeforeShow(function(e,f){e=this.getTip();var b=this.getConf();d||(d=[b.position[0],b.position[1],b.offset[0],b.offset[1],g.extend({},b)]);g.extend(b,d[4]);b.position=[d[0],d[1]];b.offset=[d[2],d[3]];e.css({visibility:"hidden",position:"absolute",top:f.top,left:f.left}).show();f=j(e);if(!k(f)){if(f[2]){g.extend(b,a.top);b.position[0]="top";e.addClass(c[0])}if(f[3]){g.extend(b,a.right);b.position[1]="right";e.addClass(c[1])}if(f[0]){g.extend(b,a.bottom);b.position[0]="bottom";e.addClass(c[2])}if(f[1]){g.extend(b,a.left);b.position[1]="left";e.addClass(c[3])}if(f[0]||f[2])b.offset[0]*=-1;if(f[1]||f[3])b.offset[1]*=-1}e.css({visibility:"visible"}).hide()});h.onBeforeShow(function(){var e=this.getConf();this.getTip();setTimeout(function(){e.position=[d[0],d[1]];e.offset=[d[2],d[3]]},0)});h.onHide(function(){var e=this.getTip();e.removeClass(a.classNames)});ret=h});return a.api?ret:this}})(jQuery);
// Slide for tooltips
(function(d){var i=d.tools.tooltip;d.extend(i.conf,{direction:"up",bounce:false,slideOffset:10,slideInSpeed:200,slideOutSpeed:200,slideFade:!d.browser.msie});var e={up:["-","top"],down:["+","top"],left:["-","left"],right:["+","left"]};i.addEffect("slide",function(g){var a=this.getConf(),f=this.getTip(),b=a.slideFade?{opacity:a.opacity}:{},c=e[a.direction]||e.up;b[c[1]]=c[0]+"="+a.slideOffset;a.slideFade&&f.css({opacity:0});f.show().animate(b,a.slideInSpeed,g)},function(g){var a=this.getConf(),f=a.slideOffset,b=a.slideFade?{opacity:0}:{},c=e[a.direction]||e.up,h=""+c[0];if(a.bounce)h=h=="+"?"-":"+";b[c[1]]=h+"="+f;this.getTip().animate(b,a.slideOutSpeed,function(){d(this).hide();g.call()})})})(jQuery);

//JSON for retarded browsers
if(!this.JSON){this.JSON={};}
(function(){"use strict";function f(n){return n<10?'0'+n:n;}
if(typeof Date.prototype.toJSON!=='function'){Date.prototype.toJSON=function(key){return isFinite(this.valueOf())?this.getUTCFullYear()+'-'+
f(this.getUTCMonth()+1)+'-'+
f(this.getUTCDate())+'T'+
f(this.getUTCHours())+':'+
f(this.getUTCMinutes())+':'+
f(this.getUTCSeconds())+'Z':null;};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(key){return this.valueOf();};}
var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'},rep;function quote(string){escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==='string'?c:'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4);})+'"':'"'+string+'"';}
function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==='object'&&typeof value.toJSON==='function'){value=value.toJSON(key);}
if(typeof rep==='function'){value=rep.call(holder,key,value);}
switch(typeof value){case'string':return quote(value);case'number':return isFinite(value)?String(value):'null';case'boolean':case'null':return String(value);case'object':if(!value){return'null';}
gap+=indent;partial=[];if(Object.prototype.toString.apply(value)==='[object Array]'){length=value.length;for(i=0;i<length;i+=1){partial[i]=str(i,value)||'null';}
v=partial.length===0?'[]':gap?'[\n'+gap+
partial.join(',\n'+gap)+'\n'+
mind+']':'['+partial.join(',')+']';gap=mind;return v;}
if(rep&&typeof rep==='object'){length=rep.length;for(i=0;i<length;i+=1){k=rep[i];if(typeof k==='string'){v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}else{for(k in value){if(Object.hasOwnProperty.call(value,k)){v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}
v=partial.length===0?'{}':gap?'{\n'+gap+partial.join(',\n'+gap)+'\n'+
mind+'}':'{'+partial.join(',')+'}';gap=mind;return v;}}
if(typeof JSON.stringify!=='function'){JSON.stringify=function(value,replacer,space){var i;gap='';indent='';if(typeof space==='number'){for(i=0;i<space;i+=1){indent+=' ';}}else if(typeof space==='string'){indent=space;}
rep=replacer;if(replacer&&typeof replacer!=='function'&&(typeof replacer!=='object'||typeof replacer.length!=='number')){throw new Error('JSON.stringify');}
return str('',{'':value});};}
if(typeof JSON.parse!=='function'){JSON.parse=function(text,reviver){var j;function walk(holder,key){var k,v,value=holder[key];if(value&&typeof value==='object'){for(k in value){if(Object.hasOwnProperty.call(value,k)){v=walk(value,k);if(v!==undefined){value[k]=v;}else{delete value[k];}}}}
return reviver.call(holder,key,value);}
text=String(text);cx.lastIndex=0;if(cx.test(text)){text=text.replace(cx,function(a){return'\\u'+
('0000'+a.charCodeAt(0).toString(16)).slice(-4);});}
if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,'@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,']').replace(/(?:^|:|,)(?:\s*\[)+/g,''))){j=eval('('+text+')');return typeof reviver==='function'?walk({'':j},''):j;}
throw new SyntaxError('JSON.parse');};}}());



