/* UPDATED : 20/11/2008 */
_global_["@namespace"]("ndm.util.cookies");
ndm.util.cookies = function() {
    return {
        create: function(C, D, E) {
            var B = new Date(),
            A;
            if (E) {
                B.setTime(B.getTime() + (E * 24 * 60 * 60 * 1000));
                A = "; expires=" + B.toGMTString();
            } else {
                A = "";
            }
            document.cookie = C + "=" + D + A + "; path=/";
        },
        read: function(B) {
            var D = B + "=",
            A = document.cookie.split(";"),
            E,
            C;
            for (C = 0; C < A.length; C++) {
                E = A[C];
                while (E.charAt(0) == " ") {
                    E = E.substring(1, E.length);
                }
                if (E.indexOf(D) === 0) {
                    return E.substring(D.length, E.length);
                }
            }
            return null;
        },
        erase: function(A) {
            ndm.util.cookies.create(A, "", -1);
        }
    };
} ();
/*ndm.controls.popups = function() {
    var C = "640";
    var B = "480";
    var A = {
        digg: function(D) {
            return D + "?phase=2&url" + encodeURIComponent(window.location.href);
        },
        delicious: function(D) {
            return D + ";url=" + encodeURIComponent(window.location.href) + ";title=" + encodeURIComponent(document.title);
        },
        newsvine: function(D) {
            return D + "?u=" + encodeURIComponent(window.location.href) + ";title=" + encodeURIComponent(document.title);
        },
        facebook: function(D) {
            return D + "?u=" + encodeURIComponent(window.location.href) + ";t=" + encodeURIComponent(document.title);
        },
        travelgallery: function(D) {
            return [750, 700];
        }
    };
    return {
        listen: function() {
            console.log("Now listening on the document for popups");
            var D = "click";
            if (ndm.dom.isIE()) {
                D = "mouseup";
            }
            ndm.dom.events.add(document, D, function(N) {
                var J = N;
                var L = ndm.dom.getEventTarget(J);
                if (L.nodeName.toLowerCase() !== "a") {
                    L = L.parentNode;
                }
                if (typeof L.getAttribute !== "function" && typeof L.getAttribute !== "object") {
                    return;
                }
                var P = L.getAttribute("rel");
                var E = L.getAttribute("href");
                if (/^popup/.test(P)) {
                    if (P.indexOf("to-") >= 0) {
                        var H = P.replace(/to-([\S]*)/gi, "$1");
                        if ( !! (A.func) && typeof A.func === "function") {
                            var Q = A.func(E);
                            if (Q instanceof Array) {
                                P = P.replace(/^popup/, "popup[" + Q.toString() + "]");
                            } else {
                                L.setAttribute("href", Q);
                            }
                        }
                    }
                    var K = ndm.util.parseUri(E);
                    var I = K.host.replace(/[^a-zA-Z]/gi, "") + K.directory.replace(/[^a-zA-Z]/gi, "");
                    if (P.indexOf("[") >= 0) {
                        var M = (/\[[0-9]{2,4},[0-9]{2,4}\]/.exec(P)[0]).replace(/[\[\]]/gi, "").split(",");
                        if (M.length === 2) {
                            var F = M[0];
                            var O = M[1];
                            var G = window.open(E, I, "width=" + F + ",height=" + O + " ,scrollbars=yes,status=yes,toolbar=no,menubar=no,location=no,resizable=yes");
                            J.preventDefault();
                            if ( !! G) {
                                G.focus();
                            }
                        } else {
                            return;
                        }
                    } else {
                        var G = window.open(E, I, "width=" + C + ",height=" + B + " ,scrollbars=yes,status=yes,toolbar=no,menubar=no,location=no,resizable=yes");
                        J.preventDefault();
                        if ( !! G) {
                            G.focus();
                        }
                    }
                    return;
                }
                return;
            });
        },
        addHandler: function(E, F) {
            var D = F();
            if (typeof D === "string" || D instanceof Array) {
                A.key = F;
            } else {
                console.log("Bad handler in ndm.controls.popups. Ignored. Proceeding.");
            }
        }
    };
} ();*/
_global_["@namespace"]("ndm.controls.tabs");

/*ndm.controls.tabs.Base = function() {
    return {
        set: function(A) {
            this.elems = A;
        },
        get: function(A) {
            return this.elems[A];
        },
        show: function(C) {
            for (var B = 0, A = this.elems.length; B != A; B++) {
                if (this.elems[B] !== C) {
                    this.elems[B].className = this.elems[B].className.replace(/active/gi, "");
                } else {
                    if (!/active/.test(this.elems[B].className)) {
                        this.elems[B].className += " active";
                    }
                }
            }
            return false;
        }
    };
} ();*/
/*ndm.controls.tabs.Standard = function(G) {
    var F = object(ndm.controls.tabs.Base);
    var B = ndm.dom.getElementsByClassName(G.tabClass, G.rootNode, G.tabElem);
    F.set(B, G.tabOnClass);
    var C = ndm.dom.getElementsByClassName(G.tabActorClass, G.rootNode, G.tabActorElem);
    for (var E = 0, A = C.length; E != A; E++) {
        clickee = C[E].getElementsByTagName("a")[0];
        var D = function() {
            F.show(ndm.dom.findParent(this, G.tabClass));
            return false;
        };
        clickee.onmousedown = function() {
            D.call(this);
        };
        clickee.onfocus = function() {
            D.call(this);
        };
        clickee.onclick = function(H) {
            return false;
        };
    }
    return F;
};
ndm.controls.tabs.Listed = function(H) {
    var F, A, D;
    var G = object(ndm.controls.tabs.Base);
    var B = ndm.dom.getElementsByClassName(H.tabClass, H.rootNode, H.tabElem);
    console.log(H.tabClass);
    G.set(B);
    var C = ndm.dom.getElementsByClassName(H.tabActorClass, H.rootNode, H.tabActorElem);
    var E = function() {
        var K = ndm.util.parseUri(this.getAttribute("href")).anchor || ndm.util.parseUri(this.getElementsByTagName("a")[0].getAttribute("href")).anchor;
        G.show(document.getElementById(K));
        for (var J = 0, I = C.length; J != I; J++) {
            C[J].className = C[J].className.replace(/active/gi, "");
        }
        if (this.parentNode.nodeName.toLowerCase() == H.tabActorElem.toLowerCase()) {
            if (!/active/.test(this.parentNode.className)) {
                this.parentNode.className += " active";
            }
        } else {
            if (this.nodeName.toLowerCase() == H.tabActorElem.toLowerCase()) {
                if (!/active/.test(this.className)) {
                    this.className += " active";
                }
            }
        }
        return false;
    };
    for (F = 0, A = C.length; F != A; F++) {
        D = C[F];
        if (D.nodeName.toLowerCase() !== "a") {
            D = C[F].getElementsByTagName("a")[0];
        }
        if (typeof D !== "object") {
            C[F].style.cursor = "pointer";
            C[F].onmousedown = function() {
                E.call(this);
            };
        } else {
            D.onmousedown = function() {
                E.call(this);
            };
        }
        D.onfocus = function() {
            E.call(this);
        };
        D.onclick = function(I) {
            return false;
        };
    }
    G.clickers = C;
    return G;
};
ndm.controls.tabs.Cycled = function(E) {
    var D = object(ndm.controls.tabs.Listed(E));
    for (var C = 0, A = D.elems.length; C < A; C++) {
        if (/active/.test(D.elems[C].className)) {
            D.activeIdx = C;
        }
    }
    var B = function() {
        var H = ndm.util.parseUri(this.getAttribute("href")).anchor || ndm.util.parseUri(this.getElementsByTagName("a")[0].getAttribute("href")).anchor;
        D.show(document.getElementById(H));
        for (var G = 0, F = D.clickers.length; G != F; G++) {
            D.clickers[G].className = D.clickers[G].className.replace(/active/gi, "");
        }
        if (this.parentNode.nodeName.toLowerCase() == E.tabActorElem.toLowerCase()) {
            if (!/active/.test(this.parentNode.className)) {
                this.parentNode.className += " active";
            }
        } else {
            if (this.nodeName.toLowerCase() == E.tabActorElem.toLowerCase()) {
                if (!/active/.test(this.className)) {
                    this.className += " active";
                }
            }
        }
        return false;
    };
    ndm.dom.scheduler.addSchedule(function() {
        D.activeIdx = D.elems[D.activeIdx + 1] ? D.activeIdx + 1 : 0;
        D.show(D.elems[D.activeIdx]);
        B.call(D.clickers[D.activeIdx]);
    });
    E.rootNode.onmouseover = function() {
        ndm.dom.scheduler.stop();
    };
    return D;
};
var Delegate = function() {};
Delegate.create = function(E, D) {
    var B = [];
    var A = arguments.length;
    for (var C = 2; C < A; C++) {
        B[C - 2] = arguments[C];
    }
    return function() {
        var F = [].concat(arguments, B);
        D.apply(E, F);
    };
};*/
tanto.namespace("ndm.controls");
ndm.controls.Tween = function(G, H, D, C, B, F, A, E) {
    this.init(G, H, D, C, B, F, A, E);
};
ndm.controls.Tween.___set = function(A) {
    var B = ndm.controls.Tween.prototype;
    B.obj = {};
    B.prop = "";
    B.func = function(D, C, F, E) {
        return F * D / E + C;
    };
    B.begin = 0;
    B.change = 0;
    B.prevTime = 0;
    B.prevPos = 0;
    B.looping = false;
    B._duration = 0;
    B._time = 0;
    B._pos = 0;
    B._position = 0;
    B._startTime = 0;
    B._finish = 0;
    B.name = "";
    B.suffixe = "";
    B._listeners = [];
    B.setTime = function(C) {
        this.prevTime = this._time;
        if (C > this.getDuration()) {
            if (this.looping) {
                this.rewind(C - this._duration);
                this.update();
                this.broadcastMessage("onMotionLooped", {
                    target: this,
                    type: "onMotionLooped"
                });
            } else {
                this._time = this._duration;
                this.update();
                this.stop();
                this.broadcastMessage("onMotionFinished", {
                    target: this,
                    type: "onMotionFinished"
                });
            }
        } else {
            if (C < 0) {
                this.rewind();
                this.update();
            } else {
                this._time = C;
                this.update();
            }
        }
    };
    B.getTime = function() {
        return this._time;
    };
    B.setDuration = function(C) {
        this._duration = (C === null || C <= 0) ? 100000 : C;
    };
    B.getDuration = function() {
        return this._duration;
    };
    B.setPosition = function(D) {
        this.prevPos = this._pos;
        var C = this.suffixe !== "" ? this.suffixe: "";
        if (!this.preffixe) {
            _a = " ";
        } else {
            _a = this.preffixe;
        }
        this.obj[this.prop] = _a + Math.round(D) + C;
        this._pos = D;
        this.broadcastMessage("onMotionChanged", {
            target: this,
            type: "onMotionChanged"
        });
    };
    B.getPosition = function(C) {
        if (typeof C === undefined) {
            C = this._time;
        }
        return this.func(C, this.begin, this.change, this._duration);
    };
    B.setFinish = function(C) {
        this.change = C - this.begin;
    };
    B.getFinish = function() {
        return this.begin + this.change;
    };
    B.init = function(I, J, F, E, D, H, C, G) {
        if (!arguments.length) {
            return;
        }
        this._listeners = [];
        this.addListener(this);
        if (C) {
            this.suffixe = C;
        }
        if (G) {
            this.preffixe = G;
        }
        this.obj = I;
        this.prop = J;
        this.begin = E;
        this._pos = E;
        this.setDuration(H);
        if (F !== null && F !== "") {
            this.func = F;
        }
        this.setFinish(D);
    };
    B.start = function() {
        this.rewind();
        this.startEnterFrame();
        this.broadcastMessage("onMotionStarted", {
            target: this,
            type: "onMotionStarted"
        });
    };
    B.rewind = function(C) {
        this.stop();
        this._time = (C === undefined) ? 0 : C;
        this.fixTime();
        this.update();
    };
    B.fforward = function() {
        this._time = this._duration;
        this.fixTime();
        this.update();
    };
    B.update = function() {
        this.setPosition(this.getPosition(this._time));
    };
    B.startEnterFrame = function() {
        this.stopEnterFrame();
        this.isPlaying = true;
        this.onEnterFrame();
    };
    B.onEnterFrame = function() {
        if (this.isPlaying) {
            this.nextFrame();
            setTimeout(Delegate.create(this, this.onEnterFrame), 0);
        }
    };
    B.nextFrame = function() {
        this.setTime((this.getTimer() - this._startTime) / 1000);
    };
    B.stop = function() {
        this.stopEnterFrame();
        this.broadcastMessage("onMotionStopped", {
            target: this,
            type: "onMotionStopped"
        });
    };
    B.stopEnterFrame = function() {
        this.isPlaying = false;
    };
    B.continueTo = function(C, D) {
        this.begin = this._pos;
        this.setFinish(C);
        if (typeof this._duration !== undefined) {
            this.setDuration(D);
        }
        this.start();
    };
    B.resume = function() {
        this.fixTime();
        this.startEnterFrame();
        this.broadcastMessage("onMotionResumed", {
            target: this,
            type: "onMotionResumed"
        });
    };
    B.yoyo = function() {
        this.continueTo(this.begin, this._time);
    };
    B.addListener = function(C) {
        this.removeListener(C);
        return this._listeners.push(C);
    };
    B.removeListener = function(E) {
        var C = this._listeners;
        var D = C.length;
        while (D--) {
            if (C[D] == E) {
                C.splice(D, 1);
                return true;
            }
        }
        return false;
    };
    B.broadcastMessage = function() {
        var C = [];
        for (var G = 0; G < arguments.length; G++) {
            C.push(arguments[G]);
        }
        var H = C.shift();
        var E = this._listeners;
        var D = E.length;
        for (var F = 0; F < D; F++) {
            if (E[F][H]) {
                E[F][H].apply(E[F], C);
            }
        }
    };
    B.fixTime = function() {
        this._startTime = this.getTimer() - this._time * 1000;
    };
    B.getTimer = function() {
        return new Date().getTime() - this._time;
    };
} ();
ndm.controls.Tween.functors = {
    backEaseIn: function(C, A, G, F, B, E) {
        if (typeof D === undefined) {
            var D = 1.70158;
        }
        return G * (C /= F) * C * ((D + 1) * C - D) + A;
    },
    backEaseOut: function(C, A, G, F, B, E) {
        if (typeof D === undefined) {
            var D = 1.70158;
        }
        return G * ((C = C / F - 1) * C * ((D + 1) * C + D) + 1) + A;
    },
    backEaseInOut: function(C, A, G, F, B, E) {
        if (typeof D === undefined) {
            var D = 1.70158;
        }
        if ((C /= F / 2) < 1) {
            return G / 2 * (C * C * (((D *= (1.525)) + 1) * C - D)) + A;
        }
        return G / 2 * ((C -= 2) * C * (((D *= (1.525)) + 1) * C + D) + 2) + A;
    },
    elasticEaseIn: function(C, A, G, F, B, E) {
        if (C === 0) {
            return A;
        }
        if ((C /= F) == 1) {
            return A + G;
        }
        if (!E) {
            E = F * 0.3;
        }
        if (!B || B < Math.abs(G)) {
            B = G;
            var D = E / 4;
        } else {
            var D = E / (2 * Math.PI) * Math.asin(G / B);
        }
        return - (B * Math.pow(2, 10 * (C -= 1)) * Math.sin((C * F - D) * (2 * Math.PI) / E)) + A;
    },
    elasticEaseOut: function(C, A, G, F, B, E) {
        if (C === 0) {
            return A;
        }
        if ((C /= F) == 1) {
            return A + G;
        }
        if (!E) {
            E = F * 0.3;
        }
        if (!B || B < Math.abs(G)) {
            B = G;
            var D = E / 4;
        } else {
            var D = E / (2 * Math.PI) * Math.asin(G / B);
        }
        return (B * Math.pow(2, -10 * C) * Math.sin((C * F - D) * (2 * Math.PI) / E) + G + A);
    },
    elasticEaseInOut: function(C, A, G, F, B, E) {
        if (C === 0) {
            return A;
        }
        if ((C /= F / 2) == 2) {
            return A + G;
        }
        if (!E) {
            var E = F * (0.3 * 1.5);
        }
        if (!B || B < Math.abs(G)) {
            var B = G;
            var D = E / 4;
        } else {
            var D = E / (2 * Math.PI) * Math.asin(G / B);
        }
        if (C < 1) {
            return - 0.5 * (B * Math.pow(2, 10 * (C -= 1)) * Math.sin((C * F - D) * (2 * Math.PI) / E)) + A;
        }
        return B * Math.pow(2, -10 * (C -= 1)) * Math.sin((C * F - D) * (2 * Math.PI) / E) * 0.5 + G + A;
    },
    bounceEaseOut: function(B, A, D, C) {
        if ((B /= C) < (1 / 2.75)) {
            return D * (7.5625 * B * B) + A;
        } else {
            if (B < (2 / 2.75)) {
                return D * (7.5625 * (B -= (1.5 / 2.75)) * B + 0.75) + A;
            } else {
                if (B < (2.5 / 2.75)) {
                    return D * (7.5625 * (B -= (2.25 / 2.75)) * B + 0.9375) + A;
                } else {
                    return D * (7.5625 * (B -= (2.625 / 2.75)) * B + 0.984375) + A;
                }
            }
        }
    },
    bounceEaseIn: function(B, A, D, C) {
        return D - ndm.controls.Tween.functors.bounceEaseOut(C - B, 0, D, C) + A;
    },
    bounceEaseInOut: function(B, A, D, C) {
        if (B < C / 2) {
            return ndm.controls.Tween.functors.bounceEaseIn(B * 2, 0, D, C) * 0.5 + A;
        } else {
            return ndm.controls.Tween.functors.bounceEaseOut(B * 2 - C, 0, D, C) * 0.5 + D * 0.5 + A;
        }
    },
    strongEaseInOut: function(B, A, D, C) {
        return D * (B /= C) * B * B * B * B + A;
    },
    regularEaseIn: function(B, A, D, C) {
        return D * (B /= C) * B + A;
    },
    regularEaseOut: function(B, A, D, C) {
        return - D * (B /= C) * (B - 2) + A;
    },
    regularEaseInOut: function(B, A, D, C) {
        if ((B /= C / 2) < 1) {
            return D / 2 * B * B + A;
        }
        return - D / 2 * ((--B) * (B - 2) - 1) + A;
    },
    strongEaseIn: function(B, A, D, C) {
        return D * (B /= C) * B * B * B * B + A;
    },
    strongEaseOut: function(B, A, D, C) {
        return D * ((B = B / C - 1) * B * B * B * B + 1) + A;
    },
    strongEaseInOut: function(B, A, D, C) {
        if ((B /= C / 2) < 1) {
            return D / 2 * B * B * B * B * B + A;
        }
        return D / 2 * ((B -= 2) * B * B * B * B + 2) + A;
    },
    linearTween: function(B, A, D, C) {
        return D * B / C + A;
    },
    easeInQuad: function(B, A, D, C) {
        return D * (B /= C) * B + A;
    },
    easeOutQuad: function(B, A, D, C) {
        return - D * (B /= C) * (B - 2) + A;
    },
    easeInOutQuad: function(B, A, D, C) {
        if ((B /= C / 2) < 1) {
            return D / 2 * B * B + A;
        }
        return - D / 2 * ((--B) * (B - 2) - 1) + A;
    },
    easeInCubic: function(B, A, D, C) {
        return D * (B /= C) * B * B + A;
    },
    easeOutCubic: function(B, A, D, C) {
        return D * ((B = B / C - 1) * B * B + 1) + A;
    },
    easeInOutCubic: function(B, A, D, C) {
        if ((B /= C / 2) < 1) {
            return D / 2 * B * B * B + A;
        }
        return D / 2 * ((B -= 2) * B * B + 2) + A;
    },
    easeInQuart: function(B, A, D, C) {
        return D * (B /= C) * B * B * B + A;
    },
    easeOutQuart: function(B, A, D, C) {
        return - D * ((B = B / C - 1) * B * B * B - 1) + A;
    },
    easeInOutQuart: function(B, A, D, C) {
        if ((B /= C / 2) < 1) {
            return D / 2 * B * B * B * B + A;
        }
        return - D / 2 * ((B -= 2) * B * B * B - 2) + A;
    },
    easeInQuint: function(B, A, D, C) {
        return D * (B /= C) * B * B * B * B + A;
    },
    easeOutQuint: function(B, A, D, C) {
        return D * ((B = B / C - 1) * B * B * B * B + 1) + A;
    },
    easeInOutQuint: function(B, A, D, C) {
        if ((B /= C / 2) < 1) {
            return D / 2 * B * B * B * B * B + A;
        }
        return D / 2 * ((B -= 2) * B * B * B * B + 2) + A;
    }
};
ndm.controls.OpacityTween = function(E, B, D, A, C) {
    this.targetObject = E;
    this.init({},
    "x", B, D, A, C);
};
ndm.controls.OpacityTween.prototype = new ndm.controls.Tween();
ndm.controls.OpacityTween.prototype.constructor = ndm.controls.Tween;
ndm.controls.OpacityTween.superclass = ndm.controls.Tween.prototype;
ndm.controls.OpacityTween.__set = function(A) {
    var B = ndm.controls.OpacityTween.prototype;
    B.targetObject = {};
    B.onMotionChanged = function(C) {
        var D = C.target._pos;
        var E = this.targetObject;
        E.style["opacity"] = D / 100;
        E.style["-moz-opacity"] = D / 100;
        E.style.zoom = "1";
        if (E.filters) {
            try {
                E.filters.alpha["opacity"] = D;
            } catch(F) {}
        }
    };
} ();
ndm.controls.ColorTween = function(E, F, B, A, C, D) {
    this.targetObject = E;
    this.targetProperty = F;
    this.fromColor = A;
    this.toColor = C;
    this.init({},
    "x", B, 0, 100, D);
    this.listenerObj = {};
    this.listenerObj.onMotionChanged = Delegate.create(this, this.onColorChanged);
    this.addListener(this.listenerObj);
};
ndm.controls.ColorTween.prototype = new ndm.controls.Tween();
ndm.controls.ColorTween.prototype.constructor = ndm.controls.Tween;
ndm.controls.ColorTween.superclass = ndm.controls.Tween.prototype;
(function() {
    var A = ndm.controls.ColorTween.prototype;
    A.targetObject = {};
    A.targetProperty = {};
    A.fromColor = "";
    A.toColor = "";
    A.currentColor = "";
    A.listenerObj = {};
    A.onColorChanged = function() {
        this.currentColor = this.getColor(this.fromColor, this.toColor, this._pos);
        this.targetObject[this.targetProperty] = this.currentColor;
    };
    A.getColor = function(C, F, G) {
        var E = this.hex2dec(C.slice(0, 2));
        var B = this.hex2dec(C.slice(2, 4));
        var J = this.hex2dec(C.slice(4, 6));
        var D = this.hex2dec(F.slice(0, 2));
        var K = this.hex2dec(F.slice(2, 4));
        var I = this.hex2dec(F.slice(4, 6));
        var H = G / 100;
        r = Math.floor(E + (H * (D - E)) + 0.5);
        g = Math.floor(B + (H * (K - B)) + 0.5);
        b = Math.floor(J + (H * (I - J)) + 0.5);
        return ("#" + this.dec2hex(r) + this.dec2hex(g) + this.dec2hex(b));
    };
    A.dec2hex = function(B) {
        return (this.hexDigit[B >> 4] + this.hexDigit[B & 15]);
    };
    A.hexDigit = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"];
    A.hex2dec = function(B) {
        return (parseInt(B, 16));
    };
} ());
tanto.namespace("ndm.user");
ndm.user.prefs = function() {
    if (typeof ndm.controls.Tween === "undefined") {
        return false;
    }
    if (typeof StorageList === "undefined") {
        StorageList = function() {
            return false;
        };
    }
    var R = {
        LOADED: "Sto caricando...",
        SAVED: "Sto salvando...",
        POSITION_SAVED: "Posizione Salvata"
    },
    a = !((typeof globalStorage === "undefined") || !(globalStorage instanceof StorageList)),
    T = ndm.dom.isIE(),
    C = "ndm-user-preferences",
    V = document.domain,
    X = 1000,
    H = "",
    B = {
        version: 0
    },
    J = false,
    F = "_",
    P = "",
    Z = null,
    K = [],
    Q = false,
    A = "http://www.riminibeach.it",
    D = [],
    O = "pref",
    N,
    G,
    S,
    Y = false,
    I = function(d) {
        if (!isNaN(parseInt(d, 2))) {
            return parseInt(d, 2).toString(36);
        } else {
            if (!isNaN(parseInt(d, 10))) {
                return parseInt(d, 10).toString(36);
            }
        }
    },
    c = function(e, d) {
        if (d == 2) {
            return parseInt(e, 36).toString(d);
        } else {
            if (d == 10) {
                return parseInt(e, 36).toString(d);
            }
        }
        return e;
    },
    M = function(e, h) {
        if (!Z || Q) {
            return;
        }
        Q = true;
        if (h && h.length == 2) {
            Z.style.top = (h[1] - ndm.dom.getPageScroll()[1]) + 10 + "px !important";
            Z.style.left = h[0] + 525 + "px !important";
            Z.style.width = "150px !important";
        } else {
            Z.style.top = "0px !important";
            Z.style.left = "48% !important";
        }
        Z.style.display = "block";
        var f, d;
        Z.innerHTML = e;
        f = new ndm.controls.OpacityTween(Z, ndm.controls.Tween.functors.easeOutQuad, 0, 100, 0.2);
        f.start();
        f.onMotionFinished = function() {
            window.setTimeout(function() {
                d = new ndm.controls.OpacityTween(Z, ndm.controls.Tween.functors.easeOutQuad, 100, 0, 0.8);
                d.start();
                Q = false;
            },
            500);
        };
    },
    E = function(e) {
        var h, f, d = [];
        P = "";
        K.forEach(function(i) {
            if (B.hasOwnProperty(i)) {
                d.push(B[i]);
            } else {
                d.push("_");
            }
        });
        P = d.join(F);
        P = P.replace(/_*$/gi, "");
        P = P.replace(/_____/gi, "~");
        P = P.replace(/__/gi, "+");
        P += "&v=" + B.version;
        if (e) {
            P = "u=" + B.userMD5 + "&h=" + P;
        }
        return P;
    },
    U = function() {
        var d, h;
        if (a) {
            try {
                h = globalStorage[V].COOKIE_NAME || "";
            } catch(f) {
                if (f.code == X) {
                    h = ndm.util.cookies.read(O);
                }
            }
        } else {
            if (T) {
                d = document.getElementById(C);
                if (!d) {
                    h = "";
                } else {
                    try {
                        d.load(O);
                        h = d.getAttribute("ndmUserData");
                    } catch(f) {
                        h = ndm.util.cookies.read(O);
                    }
                }
            } else {
                h = ndm.util.cookies.read(O);
            }
        }
        return h + "";
    },
    L = function(j) {
        var f = j || U(),
        h = [],
        e = [],
        d;
        if (!f) {
            return {};
        }
        f = f.replace(/~/gi, "_____");
        f = f.replace(/\+/gi, "__");
        h = f.split("&");
        for (d = 0; d != h.length; d++) {
            if (h[d].indexOf("u=") >= 0) {
                B.userMD5 = h[d].slice(h[d].indexOf("u=") + 2, h[d].length);
            } else {
                if (h[d].indexOf("h=") >= 0) {
                    e = h[d].slice(h[d].indexOf("h=") + 2, h[d].length).split("_");
                } else {
                    if (h[d].indexOf("v=") >= 0) {
                        B.version = h[d].slice(h[d].indexOf("v=") + 2, h[d].length);
                    }
                }
            }
        }
        d = 0;
        K.forEach(function(i) {
            if (!/[^a-z0-9|]/.test(e[d])) {
                B[i] = e[d];
            } else {
                B[i] = e[d].replace(/[^a-z0-9|]/gi, "-");
            }
            d++;
        });
        return B;
    },
    W = function() {
        var f, i, d;
        if (a) {
            try {
                globalStorage[V].COOKIE_NAME = E(true);
            } catch(h) {
                ndm.util.cookies.create(O, E(true), 300);
            }
        } else {
            if (T) {
                f = document.getElementById(C);
                Y = !!f;
                try {
                    if (Y) {
                        f.style.behaviour = "url('#default#userData')";
                        f.setAttribute("ndmUserData", E(true));
                        i = new Date();
                        i.setUTCFullYear("2012");
                        d = objDate.toUTCString();
                        f.expires = d;
                        f.save(O);
                    }
                } catch(h) {
                    T = false;
                    ndm.util.cookies.create(O, E(true), 300);
                }
            } else {
                ndm.util.cookies.create(O, E(true), 300);
            }
        }
    };
    ndm.dom.addLoadEvent(function() {
        if (!document.getElementById(C)) {
            var d = document.createElement("div");
            d.id = C;
            document.body.appendChild(d);
        }
        document.getElementById(C).style.behaviour = "url('#default#userData')";
        Y = true;
    });
    tanto.load("http://www.inmilano.com/extension/ezwebin/design/ezwebin/javascript/ndm.util.hash.js").oncomplete(function() {
        ndm.util.hash.listen(function() {
            B = L();
            D.forEach(function(d) {
                d();
            });
        });
    });
    return {
        map: function(d) {
            K = d;
        },
        register: function(d) {
            if (J) {
                J = true;
                L();
                return B.userMD5;
            }
            S = true;
            var e = new Date().format("yyyy.mm.dd.hh.MM.ss").replace(/[.]/gi, "");
            B.userMD5 = Math.random() * 10000000 + "" + e;
            W();
            if (!U()) {
                console.log("Sembra che i cookie siano disabilitati \n\nNon potrò salvare la configurazione.");
                M("Hai i cookie disabilitati");
            }
            J = true;
            return B.userMD5;
        },
        load: function(d) {
            var f = object(B),
            e = window.location.hash,
            h;
            V = document.domain;
            if (! (K || []).length) {
                throw new Error("Devi fornire una mappa di configurazione prima del caricamento");
            }
            L();
            h = E();
            h = h.substring(0, h.indexOf("&"));
            if ( !! e) {
                e = e.substring(e.indexOf("h=")).substring(0, e.indexOf("&")).replace("#", "");
                if (e !== h) {
                    if (confirm("Attenzione:\n\n Stai per sovrascrivere le impostazioni della homepage di inmilano.com. \n\nProcedere?")) {
                        B = L(e);
                        B.userMD5 = f.userMD5;
                    } else {
                        window.location.hash = "";
                    }
                }
            }
            B = B || "{}";
            if ( !! G && G !== B.version) {}
            if ( !! B.userMD5) {
                if ( !! Z) {
                    M(R.LOADED);
                }
                J = true;
            } else {
                ndm.user.prefs.register();
            }
            return B.userMD5;
        },
        set: function(f, j, h, l, d, k) {
            if (!J) {
                return false;
            }
            try {
                if (d) {
                    B[f] = I(j);
                } else {
                    B[f] = j;
                }
                W();
                if (h) {
                    if (typeof k == "function") {
                        k();
                    } else {
                        if ( !! l) {
                            M(R.POSITION_SAVED, l);
                        } else {
                            M(R.SAVED);
                        }
                    }
                }
                return true;
            } catch(i) {
                throw i;
            }
        },
        clear: function() {
            B = {};
            W();
        },
        exists: function(d) {
            return !! B[d];
        },
        get: function(d, e, f) {
            if (e) {
                return c(B[d], f) || -1;
            } else {
                return B[d] || -1;
            }
        },
        deregister: function() {
            ndm.util.cookies.erase(O);
            J = false;
            B = {};
            return true;
        },
        isRegistered: function() {
            J = !!ndm.util.cookies.read(O);
            return J;
        },
        showUrl: function() {
            window.location.hash = E();
        },
        showUrlInInput: function(d) {
            document.getElementById(d).value = A + "/#" + H + E();
        },
        feedback: function(d) {
            Z = document.getElementById(d);
        },
        hintsEnabled: function() {
            return S;
        },
        enableHints: function() {
            S = true;
        },
        disableHints: function() {
            S = false;
        },
        setVersion: function(d) {
            G = d;
        },
        getVersion: function() {
            return G;
        },
        setPrefix: function(d) {
            H = d;
        },
        addSubscriber: function(d) {
            D.push(d);
        },
        log: function(d) {
            _hbSet(d, E);
            _hbSend();
        },
        getHash: function() {
            return E();
        }
    };
} ();
ndm.util.hash = function() {
    var D = window.location.hash,
    C = [],
    E,
    A = false,
    B = function() {
        var G;
        C.forEach(function(H) {
            H();
        });
    },
    F = function() {
        if (window.location.hash != D) {
            D = window.location.hash;
            B(D);
        }
        E = window.setTimeout(function() {
            F();
        },
        1000);
    };
    return {
        listen: function(G) {
            D = window.location.hash;
            C.push(G);
            if (!A) {
                window.setTimeout(function() {
                    F();
                },
                1000);
                A = true;
            }
        },
        kill: function() {
            window.clearTimeout(E);
            C = [];
        }
    };
} ();
if (!this.JSON) {
    JSON = {};
} (function() {
    function f(n) {
        return n < 10 ? "0" + n: n;
    }
    if (typeof Date.prototype.toJSON !== "function") {
        Date.prototype.toJSON = function(key) {
            return this.getUTCFullYear() + "-" + f(this.getUTCMonth() + 1) + "-" + f(this.getUTCDate()) + "T" + f(this.getUTCHours()) + ":" + f(this.getUTCMinutes()) + ":" + f(this.getUTCSeconds()) + "Z";
        };
        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];
            if (typeof c === "string") {
                return c;
            }
            return "\\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 (typeof value.length === "number" && !value.propertyIsEnumerable("length")) {
                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);
            }
            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");
        };
    }
})();
