////////////////////////////////////////////////////////////////////////////////
//
//  KORE
//      Andrea Pradarelli Feb - 2009
//
function $(name) {
    var ret=document.getElementById(name);
    return ret;
}
function $$$(id) {
    return document.getElementById(id);
}
function deJSON(str) {
    var a=eval( "["+str +"]" );
    return a[0];
}
function getAjax() {
    var req;
    if(window.XMLHttpRequest) {
        try {
            req = new XMLHttpRequest();
        } catch(e) {
            req = false;
        }
    } else if(window.ActiveXObject) {
        try {
            req = new ActiveXObject("Msxml2.XMLHTTP.4.0");
        } catch(e) {
            try {
                req = new ActiveXObject("Microsoft.XMLHTTP");
            } catch(e) {
                req = false;
            }
        }
    }
    return req;
}
function getSync(url,param) {
    var req=getAjax();
    var ret='';
    try {
        if(req) {
            req.open("POST", url, false);
            req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
            req.setRequestHeader("Content-length", param.length);
            req.setRequestHeader("Connection", "close");
            //req.overrideMimeType('text/xml');
            req.send( param );
            ret=req.responseText;
        } else {
            error( 'no XMLHttpRequest ! ') ;
        }
    }catch(e) {
        alert(e);
    }
    return ret;
}

function getAsync(url,param, callback) {
    var req=getAjax();
    var ret='';
    try {
        if(req) {
            req.open("POST", url, true);
            req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
            req.setRequestHeader("Content-length", param.length);
            req.setRequestHeader("Connection", "close");
		req.onreadystatechange  = function() { 
				if(req.readyState  == 4) {
					if(req.status  == 200) 
						callback(req.responseText); 
					else 
						alert("Ajax error code " + xhr.status);
				}
		}; 
            
            //req.overrideMimeType('text/xml');
            req.send( param );
        } else {
            error( 'no XMLHttpRequest ! ') ;
        }
    }catch(e) {
        alert(e);
    }
}

if (!Object.prototype.toJSONString) {
    Array.prototype.toJSONString = function () {
        var a = ['['],  // The array holding the text fragments.
        b,          // A boolean indicating that a comma is required.
        i,          // Loop counter.
        l = this.length,
        v;          // The value to be stringified.

        function p(s) {
            if (b) {
                a.push(',');
            }
            a.push(s);
            b = true;
        }
        for (i = 0; i < l; i += 1) {
            v = this[i];
            switch (typeof v) {
                case 'undefined':
                case 'function':
                case 'unknown':
                    break;
                case 'object':
                    if (v) {
                        if (typeof v.toJSONString === 'function') {
                            p(v.toJSONString());
                        }
                    } else {
                        p("null");
                    }
                    break;
                default:
                    p(v.toJSONString());
            }
        }
        a.push(']');
        return a.join('');
    };
    Boolean.prototype.toJSONString = function () {
        return String(this);
    };
    Date.prototype.toJSONString = function () {
        function f(n) {
            return n < 10 ? '0' + n : n;
        }
        return '"' + this.getFullYear() + '-' +
            f(this.getMonth() + 1) + '-' +
            f(this.getDate()) + 'T' +
            f(this.getHours()) + ':' +
            f(this.getMinutes()) + ':' +
            f(this.getSeconds()) + '"';
    };
    Number.prototype.toJSONString = function () {
        return isFinite(this) ? String(this) : "null";
    };
    Object.prototype.toJSONString = function () {
        var a = ['{'],  // The array holding the text fragments.
        b,          // A boolean indicating that a comma is required.
        k,          // The current key.
        v;          // The current value.

        function p(s) {
            if (b) {
                a.push(',');
            }
            a.push(k.toJSONString(), ':', s);
            b = true;
        }
        for (k in this) {
            if (this.hasOwnProperty(k)) {
                v = this[k];
                switch (typeof v) {
                    case 'undefined':
                    case 'function':
                    case 'unknown':
                        break;
                    case 'object':
                        if (v) {
                            if (typeof v.toJSONString === 'function') {
                                p(v.toJSONString());
                            }
                        } else {
                            p("null");
                        }
                        break;
                    default:
                        p(v.toJSONString());
                }
            }
        }
        a.push('}');
        return a.join('');
    };


    (function (s) {
        var m = {
            '\b': '\\b',
            '\t': '\\t',
            '\n': '\\n',
            '\f': '\\f',
            '\r': '\\r',
            '"' : '\\"',
            '\'' : '\\\'',
            '\\': '\\\\'
        };

        s.parseJSON = function (filter) {
            try {
                if (/^("(\\.|[^"\\\n\r])*?"|[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t])+?$/.
                    test(this)) {
                    var j = eval('(' + this + ')');
                    if (typeof filter === 'function') {
                        function walk(k, v) {
                            if (v && typeof v === 'object') {
                                for (var i in v) {
                                    if (v.hasOwnProperty(i)) {
                                        v[i] = walk(i, v[i]);
                                    }
                                }
                            }
                            return filter(k, v);
                        }
                        walk('', j);
                    }
                    return j;
                }
            } catch (e) {
            }
            throw new SyntaxError("parseJSON:"+this);
        };
        s.toJSONString = function () {
            if (/["\\\x00-\x1f]/.test(this)) {
                return '"' + this.replace(/([\x00-\x1f\\"])/g, function(a, b) {
                    var c = m[b];
                    if (c) {
                        return c;
                    }
                    c = b.charCodeAt();
                    return '\\u00' +
                        Math.floor(c / 16).toString(16) +
                        (c % 16).toString(16);
                }) + '"';
            }
            return '"' + this + '"';
        };
    })(String.prototype);
}
function deJSONZ(str) {
    return str.parseJSON();
}
function JSON(oggio) {
    if( oggio ) {
        return oggio.toJSONString();
    }
    return undefined;
}
////////////////////////////////////////////////////////////////////////////////

var routes=[
    {
        id: 1,
        points: [
            [43.835340933173796,11.960818227488923],[43.83525402867989,11.96052397073034],[43.83525402867989,11.96052397073034],[43.835195957727464,11.960332975783833],[43.835195957727464,11.960332975783833],[43.83518363755153,11.960287279240545],[43.835042169534006,11.959840294236212],[43.83498676201209,11.959720172029748],[43.834865345031425,11.959541592440216],[43.83478388754953,11.959384423979174],[43.83457995646491,11.958915698556968],[43.83454184741174,11.958822863606516],[43.83454283317114,11.958784822062693],[43.83455307218775,11.958737132516516],[43.83455307218775,11.958737132516516],[43.83461017068535,11.958792038828127],[43.83471122198204,11.958887986624346],[43.835216195392206,11.959378599671313],[43.83566035750428,11.959783811812336],[43.83582324310751,11.959925577505626],[43.836066228917076,11.960103179339514],[43.83647742044863,11.9603909421092],[43.836755909318505,11.960588184603445],[43.8368576232149,11.960658518229117],[43.8368576232149,11.960658518229117],[43.837534215916826,11.961127341183207],[43.837724557991024,11.961251816874757],[43.83810030277048,11.961517628998568],[43.83862421338783,11.961971915790617],[43.838769192973565,11.962109698662184],[43.83910342524912,11.962413890904285],[43.83931608723927,11.962719062441439],[43.83933768008383,11.962754338127358],[43.83933768008383,11.962754338127358],[43.839903404414294,11.96367872540257],[43.84012465135427,11.96399987955771],[43.84031593815916,11.96426124436663],[43.84032472828503,11.964269454232518],[43.84032472828503,11.964269454232518],[43.84051774803885,11.964464047670262],[43.84060554830888,11.964550029185986],[43.84067572799449,11.964621143883315],[43.84073709737906,11.964684825196292],[43.84082935298525,11.964772583060043],[43.841094143970444,11.964976956849904],[43.841530743679456,11.965325901961442],[43.84194964112657,11.965663090370434],[43.84242101509925,11.966059640039806],[43.84254867142113,11.966170926934536],[43.84280823746212,11.96640304266141],[43.84309899137293,11.966647591835837],[43.84333597625818,11.966882479141612],[43.843616264364734,11.967183269132239],[43.84428053982996,11.96795171905174],[43.8445633626242,11.968328060703938],[43.84484751022371,11.968826537174744],[43.845039181716395,11.969245788321174],[43.845335067582454,11.969985101469632],[43.84543795810533,11.970183029500712],[43.84552472338705,11.970308627761336],[43.84552472338705,11.970308627761336],[43.84561167032405,11.970427237945225],[43.84600063665918,11.971049120575197],[43.846061698980044,11.971124461742065],[43.846061698980044,11.971124461742065],[43.846279720515994,11.97139575717552],[43.84656203671777,11.971618156252354],[43.84686395248712,11.971779330413176],[43.84734950897865,11.971976067918904],[43.84784746090977,11.972215411278116],[43.84784746090977,11.972215411278116],[43.847900662704795,11.97224682390549],[43.84796267417919,11.972285672191454],[43.84796267417919,11.972285672191454],[43.84833767391245,11.972406167196196],[43.848422467578615,11.972434485349448],[43.848422467578615,11.972434485349448],[43.84846706177295,11.972450697513718],[43.84846706177295,11.972450697513718],[43.848766016648995,11.972552641499089],[43.849271111275186,11.972690492762293],[43.849271111275186,11.972690492762293],[43.84944545701847,11.972737259437334],[43.84966300178743,11.972853820762753],[43.849870341628574,11.973016528753572],[43.84998853353273,11.973145258420994],[43.84998853353273,11.973145258420994],[43.8501109379758,11.973285083839265],[43.85093451305119,11.974330649834837],[43.85116143651657,11.974605533175279],[43.85166726797252,11.97523331762929],[43.85187177079997,11.975504759478397],[43.852015922428286,11.975673669473666],[43.852377657553895,11.976130229331034],[43.852665270190855,11.976494459792887],[43.8528793484477,11.97674383724706],[43.853251285392396,11.977154262682902],[43.85358494583396,11.977478806347436],[43.853707546934686,11.977610883233192],[43.8538565959646,11.977764495571979],[43.8538565959646,11.977764495571979],[43.85400779170778,11.977835789395751],[43.854092705184485,11.977859458711656],[43.854092705184485,11.977859458711656],[43.854186529196234,11.977886682334997],[43.854401131612555,11.977943250008002],[43.854401131612555,11.977943250008002],[43.854799048154206,11.978047829675837],[43.85562608785552,11.978268657337345],[43.85563949415783,11.978272435684667],[43.85625079667578,11.97848018922074],[43.85651944922053,11.978535566042394],[43.85672516086049,11.978587807547516],[43.85702018013846,11.978667828458342],[43.85723451852479,11.978734498446771],[43.8579855331898,11.978936004917411],[43.8579855331898,11.978936004917411],[43.858258215053674,11.979009472822453],[43.85879515441393,11.979134216305427],[43.85920195937111,11.979243144552767],[43.859572919595756,11.979345621852227],[43.859989202169466,11.979436361228467],[43.860203762780706,11.979494494397946]

        ]
    }
];

