﻿function ETM() {
    this.bT = "http://i.planitdisney.com/api.php";
    this.dA = "http://www.planitdisney.com/bookit/views/Clients/register.php";
    this.da = "http://www.planitdisney.com/index.php?c=xhr.wdwinfo.email_me&poi_id=";
    this.cN = "http://www.planitdisney.com/index.php?c=xhr.wdwinfo.post_review";
    this.dq = "http://www.planitdisney.com/index.php?c=xhr.wdwinfo.get_details&poi_id=";
    this.dy = "http://www.planitdisney.com/index.php?c=xhr.wdwinfo.get_review&poi_id=";
    this.k = null;
    this.dN = [];
    this.bu = [];
    this.dP = [];
    this.aF = [];
    this.ag = [];
    this.bH = [];
    this.aJ = [];
    this.bP = [];
    this.ac = [];
    this.bu = [];
    this.aY = [];
    this.A = [];
    this.ay = [];
    this.am = [];
    this.bB = [];
    this.bA = 0;
    this.ar = "";
    this.bF = 0;
    this.ah = 200;
    this.bJ = "";
    this.aa = -1;
    this.bU = false;
    this.ae = false;
    this.bk = true;
    this.bO = false;
    this.bs = 120;
    this.cE = 50;
};
ETM.prototype.dI = function () {
    this.dJ();
    this.ds();
};
var etm = null;
var map = null;
var isIE = true;
var windowWidth = 0;
var windowHeight = 0;
var mapWidth = 0;
var mapHeight = 0;

function loadPage() {
    if (typeof(window.innerHeight) == "number") {
        isIE = false;
    }
    initStyleMap();
    etm = new ETM();
    etm.dI();
    resizePage();
    eid("loadingDiv").style.display = "none";
    if (typeof(userID) != "undefined") {
        etm.bJ = userID;
        etm.aa = userStatus;
    }
    etm.cT();
    eid("greyDiv").style.display = "none";
};

function resizePage() {
    var mapDiv = eid("mapDiv");
    if (mapDiv && etm) {
        getWindowSize();
        mapHeight = windowHeight - (etm.bs + etm.cE);
        mapWidth = windowWidth;
        mapDiv.style.width = mapWidth + "px";
        mapDiv.style.height = mapHeight + "px";
        if (map) {
            map.checkResize();
        }
        var an = eid("navDiv");
        an.style.height = (mapHeight - 100) + "px";
        var dx = eid("indexDiv");
        dx.style.height = (mapHeight - 250) + "px";
        if (etm) {
            etm.ah = mapHeight - 40;
            if (etm.ah < 612) {
                etm.ah = 612;
            }
            eid("bubbleTable").style.height = etm.ah + "px";
            eid("bubbleInfo").style.height = (etm.ah - 6) + "px";
            if (etm.k) {
                etm.k.bb();
            }
        }
    }
};

function unloadPage() {
    GUnload();
};

function getWindowSize() {
    if (isIE) {
        windowWidth = parseInt(document.documentElement.clientWidth);
        windowHeight = parseInt(document.documentElement.clientHeight);
    } else {
        windowWidth = parseInt(window.innerWidth);
        windowHeight = parseInt(window.innerHeight);
    }
};

function Area(a) {
    this.al = a.id;
    this.B = a.name;
    this.v = new GLatLng(a.y, a.x);
    this.bn = new GLatLng(a.swY, a.swX);
    this.bE = new GLatLng(a.neY, a.neX);
    this.au = new GLatLngBounds(this.bn, this.bE);
    this.ac = [];
    this.dr = true;
};
Area.prototype.aL = function () {
    var L = this;
    var t = new GIcon();
    t.image = "img/markers/ears.png";
    t.iconSize = new GSize(31, 31);
    t.printImage = t.image;
    t.mozPrintImage = t.image;
    t.iconAnchor = new GPoint(15, 15);
    t.infoWindowAnchor = new GPoint(15, 0);
    var D = new GMarker(this.v, {
        "icon": t,
        "title": this.B
    });
    map.addOverlay(D);
    this.G = D;
    this.aH = this.B;
    this.ak = 0;
    GEvent.addListener(D, 'click', function (cn) {
        areaClick(L.al);
    });
    GEvent.addListener(D, "mouseover", function () {
        etm.bl(L, 16, -8);
    });
    GEvent.addListener(D, "mouseout", function () {
        etm.bi();
    });
};
Area.prototype.aG = function () {
    if (this.G) {
        this.G.show();
    } else {
        this.aL();
    }
};
Area.prototype.aA = function () {
    if (this.G) {
        this.G.hide();
    }
};

function areaClick(id) {
    var L = etm.bP[id];
    if (L) {
        var r = (L.al == "wdw") ? 13 : 14;
        map.setCenter(L.v, r);
    }
};
Place.prototype.bb = function () {
    var bY = map.getCurrentMapType().getProjection().fromLatLngToPixel(this.v, map.getZoom());
    var cV = map.fromContainerPixelToLatLng(new GPoint(0, 0));
    var bW = map.getCurrentMapType().getProjection().fromLatLngToPixel(cV, map.getZoom());
    var x = bY.x - bW.x;
    var y = bY.y - bW.y;
    if (x < 0 || x >= windowWidth || y < 0 || y >= mapHeight) {
        etm.bd();
        etm.k = null;
        return;
    }
    var cC = false;
    if (x + 450 > windowWidth) {
        cC = true;
    }
    var C = 200;
    var mapht = mapHeight;
    if (mapht < 650) {
        mapht = 650;
    }
    var iht = Math.round(etm.ah / 2);
    var by = y - iht;
    if (by < -(etm.bs - 10)) {
        by = -(etm.bs - 10);
    }
    if (by + etm.ah > windowHeight - 100) {
        var oby = by;
        by = mapHeight + etm.cE - etm.ah - 8;
    }
    if (cC) {
        x -= 16;
        if (x < 600) {
            C = x - 400;
            if (C < 50) {
                C = 50;
            }
            if (C > 200) {
                C = 200;
            }
        }
        var aq = eid("bubbleDiv");
        aq.style.top = by + "px";
        aq.style.left = (x - C - 404) + "px";
        aq.style.display = "block";
        var ap = eid("bubbleInfo");
        ap.style.top = (by + 2) + "px";
        ap.style.left = (x - C - 402) + "px";
        ap.style.display = "block";
        var ad = eid("rightPointerDiv");
        ad.style.top = (y - 32) + "px";
        ad.style.left = (x - C) + "px";
        ad.style.width = C + "px";
        ad.style.display = "block";
        var dm = C - 200;
        eid("rightPointerImage").style.left = dm + "px";
        eid("leftPointerDiv").style.display = "none";
    } else {
        x += 16;
        if (x + 560 > windowWidth) {
            C = windowWidth - 402 - x;
            if (C < 50) {
                C = 50;
            }
            if (C > 200) {
                C = 200;
            }
        }
        var aq = eid("bubbleDiv");
        aq.style.top = by + "px";
        aq.style.left = (x + C) + "px";
        aq.style.display = "block";
        var ap = eid("bubbleInfo");
        ap.style.top = (by + 2) + "px";
        ap.style.left = (x + C + 2) + "px";
        ap.style.display = "block";
        var ad = eid("leftPointerDiv");
        ad.style.top = (y - 32) + "px";
        ad.style.left = x + "px";
        ad.style.width = C + "px";
        ad.style.display = "block";
        eid("rightPointerDiv").style.display = "none";
    }
    var ht = mapht - 373 - 60;
    if (ht > 0) {
        eid("placeInfoDiv").style.height = ht + "px";
    }
    var dht = mapht - 500 - 60;
    if (dht > 0) {
        eid("placeDetailDiv").style.height = dht + "px";
    }
};
ETM.prototype.bd = function () {
    eid("bubbleDiv").style.display = "none";
    eid("bubbleInfo").style.display = "none";
    eid("leftPointerDiv").style.display = "none";
    eid("rightPointerDiv").style.display = "none";
};
var categoryLookup = [];
var categoryList = [];

function Category(bf, bt, bR, bG) {
    this.M = bf.toString();
    this.B = bt;
    this.ba = bR;
    this.bg = bG;
    this.J = true;
};
ETM.prototype.dn = function (bf, bt, bR, bG) {
    var bZ = new Category(bf, bt, bR, bG);
    this.ag.push(bZ);
    this.bH[bf] = bZ;
};
ETM.prototype.dJ = function () {
    for (var i = 0; i < styles.length; i++) {
        var aj = styles[i];
        this.dn(aj.id, aj.name, aj.icon, aj.icon2);
    }
    this.dH();
};
var categorySelectPos = 0;
var selectChecking = false;
ETM.prototype.dH = function () {
    var html = "";
    html += "<div style='height:8px'></div>";
    html += "<table cellspacing=4 cellpadding=0><tr><td>";
    for (var i = 0; i < this.ag.length; i++) {
        var cat = this.ag[i];
        var bv = "";
        if (cat.ba == cat.bg) {
            bv = "<img src='" + cat.ba + "' width='16' height='16' alt='' border='0' style='padding-right:16px' /> ";
        } else {
            bv = "<img src='" + cat.ba + "' width='16' height='16' alt='' border='0' title='Large' />" + "<img src='" + cat.bg + "' width='16' height='16' alt='' border='0' title='Small' /> ";
        }
        html += "<div style='float:left;width:60px;height:20px;font-size:10px;padding-bottom:8px'>" + "<input id='c" + cat.M + "' type='checkbox' onclick='catCheck(this)' " + (cat.J ? "checked='true'" : "") + " />" + "&nbsp;" + bv + "</br>" + "<a href='javascript:catClick(\"" + cat.M + "\");' >" + cat.B + "</a>" + "</div>";
    }
    html += "</td></tr></table>";
    eid("categoryContentDiv2").innerHTML = html;
	eid("categoryContentDiv").innerHTML = html;
};

function categorySelect() {
    if (eid("categorySelectDiv").style.display != "none") {
        eid("categorySelectDiv").style.display = "none";
        return;
    }
    var panel = eid("categorySelectDiv");
    panel.style.top = "50px";
    panel.style.display = "block";
    eid("locationSelectDiv").style.display = "none";
};

function selectHide() {
    eid("locationSelectDiv").style.display = "none";
    eid("categorySelectDiv").style.display = "none";
};

function catCheck(a) {
    var id = a.id.substr(1);
    var O = etm.bH[id];
    if (O) {
        O.J = a.checked;
        etm.P(true);
    }
};

function catClick(id) {
    for (var i = 0; i < etm.ag.length; i++) {
        var O = etm.ag[i];
        O.J = (id == O.M);
        eid("c" + O.M).checked = O.J;
    }
    etm.P(true);
};

function showAllCategories() {
    for (var i = 0; i < etm.ag.length; i++) {
        var O = etm.ag[i];
        O.J = true;
        eid("c" + O.M).checked = true;
    }
    etm.P(true);
};

function hideAllCategories() {
    for (var i = 0; i < etm.ag.length; i++) {
        var O = etm.ag[i];
        O.J = false;
        eid("c" + O.M).checked = false;
    }
    etm.P(true);
};

function sortChanged(a) {
    etm.bA = a.selectedIndex;
    etm.bQ();
};
ETM.prototype.P = function (cU) {
    if (cU) {
        if (this.k && !this.k.J) {
            closeInfo();
        }
    }
    this.aY = [];
    var r = map.getZoom();
    var K = map.getBounds();
    if (r >= 16 || this.ae) {
        for (var i = 0; i < this.ac.length; i++) {
            var o = this.ac[i];
            o.aA();
            if (K.intersects(o.au) || this.ae) {
                this.aY.push(o);
            }
        }
    }
    for (var i = 0; i < this.ac.length; i++) {
        var o = this.ac[i];
        if (r >= 10 && r < 16 && !this.ae) {
            o.aG();
        } else {
            o.aA();
        }
    }
    for (var i = 0; i < this.aJ.length; i++) {
        var L = this.aJ[i];
        if (r < 10 && !this.ae) {
            L.aG();
        } else {
            L.aA();
        }
    }
    for (var i = 0; i < this.A.length; i++) {
        var f = this.A[i];
        f.J = false;
    }
    var cD = this.A;
    this.A = [];
    this.ay = [];
    var K = map.getBounds();
    var bS = 0;
    var r = map.getZoom();
    if (this.ae) {
        for (var j = 0; j < this.am.length; j++) {
            var f = this.am[j];
            if (f.ab) {
                if (f.Q && f.Q.J) {
                    if (!this.ar || f.U.indexOf(this.ar) > -1) {
                        if (f.F >= this.bF) {
                            f.J = true;
                            this.A.push(f);
                            this.ay[f.l] = f;
                            bS++;
                        }
                    }
                }
            }
        }
    } else if (r > 15) {
        for (var i = 0; i < this.aY.length; i++) {
            var o = this.aY[i];
            for (var j = 0; j < o.bz.length; j++) {
                var f = o.bz[j];
                if (K.contains(f.v)) {
                    if (f.Q && f.Q.J) {
                        if (!this.ar || f.U.indexOf(this.ar) > -1) {
                            if (f.F >= this.bF) {
                                f.J = true;
                                this.A.push(f);
                                this.ay[f.l] = f;
                                bS++;
                            }
                        }
                    }
                }
            }
        }
    } else if (r < 10) {
        for (var i = 0; i < this.aJ.length; i++) {
            var L = this.aJ[i];
            this.A.push(L);
            this.ay[L.al] = L;
        }
    } else {
        for (var i = 0; i < this.ac.length; i++) {
            var o = this.ac[i];
            if (K.intersects(o.au)) {
                this.A.push(o);
                this.ay[o.aw] = o;
            }
        }
    }
    for (var i = 0; i < cD.length; i++) {
        var f = cD[i];
        if (!f.J) {
            f.aA();
        }
    }
    for (var i = 0; i < this.A.length; i++) {
        var f = this.A[i];
        f.aG();
    }
    this.bQ();
    if (this.k && !this.k.J) {
        closeInfo();
    }
};
ETM.prototype.dF = function () {
    var noParkCount = 0;
    var parkCount = 0;
    for (var i = 0; i < areas.length; i++) {
        var area = new Area(areas[i]);
        this.aJ.push(area);
        this.bP[area.al] = area;
    }
    for (var i = 0; i < parks.length; i++) {
        if (typeof(parks[i]) != "undefined") {
            var o = new Park(parks[i]);
            this.ac.push(o);
            this.bu[o.aw] = o;
        }
    }
    var dj = this.ac.length;
    for (var i = 0; i < places.length; i++) {
        var f = new Place(places[i]);
        if (f.Q) {
            var o = null;
            var cy = null;
            var cq = 100000000;
            for (var j = 0; j < dj && !o; j++) {
                var be = this.ac[j];
                if (be.au.contains(f.v)) {
                    o = be;
                } else {
                    var av = f.v.distanceFrom(be.v);
                    if (av < cq) {
                        cq = av;
                        cy = be;
                    }
                }
            }
            if (!o) {
                o = cy;
                o.au.extend(f.v);
            }
            if (o) {
                f.dR = o;
                o.bz.push(f);
                this.aF[f.l] = f;
                parkCount++;
            }
        }
    }
    if ((typeof(itinerary) != "undefined") && (itinerary.length > 0)) {
        var cz = itinerary.split(" ");
        for (var i = 0; i < cz.length; i++) {
            var id = cz[i];
            var f = this.aF[id];
            if (f) {
                f.ab = true;
                this.am.push(f);
                this.bB[f.l] = f;
            }
        }
        this.bj();
    }
};

function applyFilter() {
    var bx = eid("filterText").value.toLowerCase();
    if (bx != etm.ar) {
        etm.ar = bx;
        etm.P(true);
        eid("clearfilterlink").style.display = bx ? "inline" : "none";
    }
};

function clearFilter() {
    eid("filterText").value = "";
    etm.ar = "";
    etm.P(true);
    eid("filterText").focus();
    eid("clearfilterlink").style.display = "none";
};

function applyRating() {
    var de = eid("ratingSelect");
    etm.bF = de.selectedIndex;
    etm.P(true);
};
ETM.prototype.dk = function (g) {
    if (!this.bB[g.l]) {
        this.bB[g.l] = g;
        this.am.push(g);
    }
    g.ab = true;
    var bw = g.bo();
    var aO = eid("it" + g.l);
    if (aO) {
        aO.innerHTML = bw;
    }
    var aD = eid("r" + g.l);
    if (aD) {
        aD.style.fontWeight = "bold";
    }
    g.aW();
    this.bj();
    this.cL(g);
};
ETM.prototype.dv = function (g) {
    g.ab = false;
    var bw = g.bo();
    var aO = eid("it" + g.l);
    if (aO) {
        aO.innerHTML = bw;
    }
    var aD = eid("r" + g.l);
    if (aD) {
        aD.style.fontWeight = "normal";
    }
    g.aW();
    this.bj();
    if (this.ae) {
        closeInfo();
        this.P(true);
    }
    this.cK(g);
};
ETM.prototype.bj = function () {
    var af = 0;
    for (var i = 0; i < this.am.length; i++) {
        var f = this.am[i];
        if (f.ab) {
            af++;
        }
    }
    if (af) {
        eid("itineraryMenuLink").innerHTML = "My Itinerary (" + af + ")";
    } else {
        eid("itineraryMenuLink").innerHTML = "My Itinerary";
    }
};

function itinAdd(id) {
    var f = etm.aF[id];
    if (f) {
        etm.dk(f);
    }
};

function itinRemove(id) {
    var f = etm.aF[id];
    if (f) {
        etm.dv(f);
    }
};

function formatItinName(a) {
    return a.replace("&apos;", "%27");
};
ETM.prototype.cL = function (g) {
    if (g && g.Q && this.aa >= 0) {
        var bp = g.Q.B;
        var I = this.bT + "?method=addEvent" + "&apiKey=YUsdf5430jjQ" + "&guid=" + g.l + "&userID=" + this.bJ + "&title=" + formatItinName(g.B) + "&type=" + bp;
        var T = new JSON(I);
        T.aS();
        T.aU();
        addLog(I);
    }
};
ETM.prototype.cK = function (g) {
    if (g && g.Q && this.aa >= 0) {
        var bp = g.Q.B;
        var I = this.bT + "?method=removeEvent" + "&apiKey=YUsdf5430jjQ" + "&guid=" + g.l + "&userID=" + this.bJ + "&title=" + g.B + "&type=" + bp;
        var T = new JSON(I);
        T.aS();
        T.aU();
        addLog(I);
    }
};

function cbStoreItinerary(a) {};

function cbRemoveEvent(a) {};

function cbAddEvent(a) {};
ETM.prototype.cG = function () {
    var af = 0;
    var K = new GLatLngBounds();
    for (var i = 0; i < this.am.length; i++) {
        var f = this.am[i];
        if (f.ab) {
            af++;
            K.extend(f.v);
        }
    }
    if (af > 0) {
        var bc = K.getCenter();
        var r = map.getBoundsZoomLevel(K);
        if (r > 19) r = 19;
        map.setCenter(bc, r);
    }
};

function JSON(fullUrl) {
    this.cZ = fullUrl;
    this.dz = '&noCacheIE=' + (new Date()).getTime();
    this.cv = document.getElementsByTagName("head").item(0);
    this.cR = 'JscriptId' + JSON.cP++;
};
JSON.cP = 1;
JSON.prototype.aS = function () {
    this.ax = document.createElement("script");
    this.ax.setAttribute("type", "text/javascript");
    this.ax.setAttribute("charset", "utf-8");
    this.ax.setAttribute("src", this.cZ + this.dz);
    this.ax.setAttribute("id", this.cR);
};
JSON.prototype.dO = function () {
    this.cv.removeChild(this.ax);
};
JSON.prototype.aU = function () {
    this.cv.appendChild(this.ax);
};

function sortAtoZ(a, b) {
    if (a.U < b.U) return -1;
    if (a.U > b.U) return 1;
    return 0;
};

function sortByCategory(a, b) {
    if (a.M == b.M) {
        return a.U > b.U;
    } else {
        return a.M - b.M;
    }
};

function sortByRating(a, b) {
    if (a.F == b.F) {
        return a.U > b.U;
    } else {
        return b.F - a.F;
    }
};
ETM.prototype.bQ = function () {
    var bI = sortAtoZ;
    if (this.bA == 1) {
        bI = sortByCategory;
    } else if (this.bA == 2) {
        bI = sortByRating;
    }
    this.A.sort(bI);
    var cl = eid("indexList");
    cl.innerHTML = "";
    var aX = "";
    if (this.k) {
        aX = this.k.l;
    }
    for (var i = 0; i < this.A.length; i++) {
        var f = this.A[i];
        var aR = document.createElement("div");
        var aV = "";
        if (f.l == aX) {
            aV = "background-color:#505050;color:white;";
        }
        if (f.dr) {
            aR.innerHTML = "<div id='r" + f.al + "' class='plrow' style='" + aV + "' onclick='areaClick(\"" + f.al + "\")' onmouseover='rowHi(this)' onmouseout='rowLo(this)'>" + "&bull; " + f.B + "</div>";
        } else if (f.dp) {
            if (f.G) {
                aR.innerHTML = "<div id='r" + f.aw + "' class='plrow' style='" + aV + "' onclick='parkChoose(" + f.aw + ",0)' onmouseover='rowHi(this)' onmouseout='rowLo(this)'>" + "&bull; " + f.B + "</div>";
            }
        } else {
            var ca = "";
            if (f.V && this.bk) {
                ca = f.F;
            }
            var aB = f.bo();
            aB = "<div id='it" + f.l + "' style='display:none'>" + aB + "</div>";
            var cg = "";
            if (f.ab) {
                cg = "font-weight:bold;";
            }
            aR.innerHTML = "<div id='r" + f.l + "' class='plrow' style='" + cg + aV + "' onclick='placeClick(" + f.l + ",0)' onmouseover='rowHi(this)' onmouseout='rowLo(this)'>" + "<table cellspacing=0 cellpadding=0 style='width:272px'><tr valign=top><td style='width:18px'>" + "<img class='mkimg' src='" + f.aI + "' height=16 width=16 alt='' /> " + "</td><td>" + f.B + "</td><td style='width:30px'>" + ca + "</td><td style='width:16px'>" + aB + "</td></tr></table>" + "</div>";
        }
        cl.appendChild(aR);
    }
    var cj = "All Places";
    if (this.ae) {
        cj = "My Itinerary";
    }
    var s = this.A.length == 1 ? "" : "s";
    eid("indexHeader").innerHTML = "<table style='width:296px'><tr><td style='font-weight:bold'>" + cj + "</td><td align='right' style='color:blue'>" + this.A.length + " Marker" + s + "</td></tr></table>";
    if (aX) {
        etm.cB(aX);
    } else {
        eid("indexDiv").scrollTop = 0;
    }
};

function rowHi(a) {
    if (a && a.id && a.id.length > 1) {
        var id = a.id.substr(1);
        if (etm.k && etm.k.l == id) {
            a.style.color = "white";
            a.style.backgroundColor = "#505050";
        } else {
            a.style.color = "black";
            a.style.backgroundColor = "#D0D0D0";
        }
        var aN = eid("it" + id);
        if (aN) {
            aN.style.display = "block";
        }
    }
};

function rowLo(a) {
    if (a && a.id && a.id.length > 1) {
        var id = a.id.substr(1);
        if (etm.k && etm.k.l == id) {
            a.style.color = "white";
            a.style.backgroundColor = "#505050";
        } else {
            a.style.color = "black";
            a.style.backgroundColor = "white";
        }
        var aN = eid("it" + id);
        if (aN) {
            aN.style.display = "none";
        }
    }
};

function showRatingChange(a) {
    etm.bk = a.checked;
    etm.bQ();
};

function autohideSidebarChange(a) {
    etm.bO = a.checked;
    if (a.checked) {
        eid("menuDiv").className = "background";
    } else {
        eid("menuDiv").className = "";
    }
};

function locationSelect() {
    if (eid("locationSelectDiv").style.display != "none") {
        eid("locationSelectDiv").style.display = "none";
        return;
    }
    var panel = eid("locationSelectDiv");
    panel.style.top = "50px";
    panel.style.display = "block";
    eid("categorySelectDiv").style.display = "none";
};
ETM.prototype.ds = function () {
    var mapDiv = eid("mapDiv");
    map = new GMap(mapDiv);
    map.enableDoubleClickZoom();
    map.enableContinuousZoom();
    map.enableScrollWheelZoom();
    // map.enableRotation();
    var y = (areas[0].y + areas[1].y) / 2;
    var x = (areas[0].x + areas[1].x) / 2;
    var centre = new GLatLng(y, x);
    map.setCenter(centre, 4);
    resizePage();
    map.setCenter(centre, 4);
    map.setMapType(G_SATELLITE_MAP);
    resizePage();
};
ETM.prototype.du = function () {
    map.addControl(new GMapTypeControl(), new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(58, 2)));
    map.addControl(new GLargeMapControl3D(), new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(2, 2)));
    map.addControl(new GScaleControl());
    this.ai = document.createElement("toolDiv");
    this.ai.className = "markerTooltip";
    map.getPane(G_MAP_FLOAT_PANE).appendChild(this.ai);
    this.ai.style.visibility = "hidden";
    this.ao = document.createElement("div");
    this.ao.className = "markerTooltip";
    document.body.appendChild(this.ao);
    var an = eid("navDiv");
    an.style.display = "block";
    var db = eid("menuDiv");
    db.style.display = "block";
    resizePage();
    GEvent.addListener(map, "click", function () {
        closeInfo();
        selectHide();
    });
    GEvent.addListener(map, "movestart", function () {
        if (etm.k) {
            etm.bd();
        }
    });
    GEvent.addListener(map, "zoomstart", function () {
        if (etm.k) {
            etm.bd();
        }
    });
    GEvent.addListener(map, "moveend", function () {
        if (etm.k) {
            etm.k.bb();
        }
        etm.P(false);
    });
    GEvent.addListener(map, "zoomend", function () {
        if (etm.k) {
            etm.k.bb();
        }
        etm.P(false);
    });
    if (this.aa <= 1) {
        var cO = new GAdsManager(map, "pub-8816757437249777", {
            maxAdsOnMap: 10,
            style: "adunit",
            channel: "6358337285"
        });
        cO.enable();
    }
    resizePage();
    this.bU = true;
};

function menuAllPlaces() {
    etm.cu();
    closeInfo();
    etm.ae = false;
    etm.P(true);
    navHi();
};

function menuMyItinerary() {
    etm.cu();
    closeInfo();
    etm.cG();
    etm.ae = true;
    etm.P(true);
    navHi();
};

function menuSearchFilters() {
    categorySelect();
};

function menuSelectPark() {
    locationSelect();
};

function menuHi() {
    eid("menuDiv").className = "";
};

function menuLo() {
    if (etm.bO) {
        eid("menuDiv").className = "background";
    }
};

function navHi() {
    var an = eid("navDiv");
    an.className = "";
};

function navLo() {
    if (etm.bO) {
        var an = eid("navDiv");
        an.className = "background";
    }
};

function navHide() {
    eid("navDiv").style.display = "none";
    eid("menuDiv").style.display = "none";
    eid("navSwitchDiv").style.display = "block";
    selectHide();
};
var navLeft = 0;

function navShow() {
    navLeft = -300;
    eid("navDiv").style.left = navLeft + "px";
    eid("navDiv").style.display = "block";
    eid("menuDiv").style.display = "block";
    eid("navSwitchDiv").style.display = "none";
    setTimeout("navAnim()", 1);
};

function navAnim() {
    navLeft += 50;
    eid("navDiv").style.left = navLeft + "px";
    if (navLeft < 0) {
        setTimeout("navAnim()", 20);
    }
};
ETM.prototype.cu = function () {
    eid("locationSelectDiv").style.display = "none";
    eid("categorySelectDiv").style.display = "none";
    eid("greyDiv").style.display = "none";
    eid("bubbleDiv").style.display = "none";
    eid("leftPointerDiv").style.display = "none";
    eid("rightPointerDiv").style.display = "none";
    eid("bubbleInfo").style.display = "none";
};

function Park(a) {
    this.aw = a.id;
    this.B = a.name;
    this.v = new GLatLng(a.y, a.x);
    this.bn = new GLatLng(a.swY, a.swX);
    this.bE = new GLatLng(a.neY, a.neX);
    this.au = new GLatLngBounds(this.bn, this.bE);
    this.al = a.area;
    this.dM = etm.bP[this.al];
    this.bz = [];
    this.dp = true;
};
Park.prototype.aL = function () {
    var o = this;
    var t = new GIcon();
    t.image = "img/park/" + this.aw + ".png";
    t.iconSize = new GSize(70, 60);
    t.printImage = t.image;
    t.mozPrintImage = t.image;
    t.iconAnchor = new GPoint(35, 30);
    t.infoWindowAnchor = new GPoint(35, 0);
    var D = new GMarker(this.v, {
        "icon": t,
        "title": this.B
    });
    map.addOverlay(D);
    this.G = D;
    this.aH = this.B;
    this.ak = 0;
    GEvent.addListener(D, 'click', function (cn) {
        parkSelect(o);
    });
    GEvent.addListener(D, "mouseover", function () {
        etm.bl(o, 36, -8);
    });
    GEvent.addListener(D, "mouseout", function () {
        etm.bi();
    });
};
Park.prototype.aG = function () {
    if (this.G) {
        this.G.show();
    } else {
        this.aL();
    }
};
Park.prototype.aA = function () {
    if (this.G) {
        this.G.hide();
    }
};

function parkSelect(cd) {
    var bc = cd.v;
    var r = map.getBoundsZoomLevel(cd.au);
    if (r < 16) {
        r = 16;
    }
    map.setCenter(bc, r);
    addLog("park select " + bc);
};

function parkChoose(id) {
    addLog("park choose " + id);
    var o = etm.bu[id];
    if (o) {
        parkSelect(o);
    }
    selectHide();
};
var styleMap = [];

function initStyleMap() {
    styleMap[1] = [3, 1];
    styleMap[2] = [6, 0];
    styleMap[3] = [1, 1];
    styleMap[4] = [3, 0];
    styleMap[5] = [4, 1];
    styleMap[7] = [7, 1];
    styleMap[8] = [2, 1];
    styleMap[10] = [1, 0];
    styleMap[25] = [1, 0];
    styleMap[11] = [4, 0];
    styleMap[13] = [2, 0];
    styleMap[14] = [7, 0];
    styleMap[15] = [6, 1];
    styleMap[16] = [5, 0];
    styleMap[19] = [8, 0];
    styleMap[22] = [9, 0];
    styleMap[25] = [11, 0];
    styleMap[6] = [10, 0];
};

function Place(a) {
    if (a && typeof(a) != "undefined") {
        this.l = a[0];
        this.B = a[1];
        this.U = etm.cX(this.B);
        this.y = a[2];
        this.x = a[3];
        this.v = new GLatLng(this.y, this.x);
        var aj = styleMap[a[4]];
        this.Q = null;
        this.aI = "";
        if (aj) {
            this.M = aj[0];
            this.cW = aj[1];
            this.Q = etm.bH[this.M];
            if (this.Q) {
                this.aI = this.cW ? this.Q.ba : this.Q.bg;
            }
        } else {}
        this.aw = null;
        this.V = a[6];
        if (this.V >= 0) {} else {
            this.V = 0;
        }
        this.F = a[7];
        if (this.F >= 0) {} else {
            this.F = 0;
        }
        this.G = null;
        this.aQ = "";
        this.cx = "";
        this.R = null;
        this.dL = false;
        this.dQ = false;
        this.ab = false;
        this.ct = false;
    }
};
Place.prototype.aL = function () {
    var f = this;
    var t = new GIcon();
    t.image = this.aI;
    t.iconSize = new GSize(32, 32);
    t.printImage = this.image;
    t.mozPrintImage = this.image;
    t.iconAnchor = new GPoint(15, 15);
    t.infoWindowAnchor = new GPoint(15, 0);
    var D = new GMarker(this.v, {
        "icon": t
    });
    map.addOverlay(D);
    this.G = D;
    this.aH = "<img src='" + this.aI + "' width='16' height='16' alt='' /> " + this.B;
    if (this.V && etm.bk) {
        this.aH += " (" + this.F + ")";
    }
    this.ak = 0;
    GEvent.addListener(D, 'click', function (cn) {
        f.cA(true);
    });
    GEvent.addListener(D, "mouseover", function () {
        etm.bl(f, 16, -8);
    });
    GEvent.addListener(D, "mouseout", function () {
        etm.bi();
    });
};
Place.prototype.aG = function () {
    if (this.G) {
        this.G.show();
    } else {
        this.aL();
    }
};
Place.prototype.aA = function () {
    if (this.G) {
        this.G.hide();
    }
};
Place.prototype.bo = function () {
    if (this.ab) {
        aB = "<a href='javascript:itinRemove(" + this.l + ")'>" + "<img src='img/button/it-remove.gif' width=16 height=16 alt='' border=0 /></a>";
    } else {
        aB = "<a href='javascript:itinAdd(" + this.l + ")'>" + "<img src='img/button/it-add.gif' width=16 height=16 alt='' border=0 /></a>";
    }
    return aB;
};

function closeInfo() {
    if (etm.k) {
        var aC = eid("r" + etm.k.l);
        etm.bd();
        etm.k = null;
        rowLo(aC);
    }
};
ETM.prototype.cB = function (id) {
    var aC = eid("r" + id);
    if (aC) {
        var aP = 330;
        var y = aC.offsetTop - aP;
        if (y < 0) {
            y = 0;
        }
        eid("indexDiv").scrollTop = y;
    } else {
        eid("indexDiv").scrollTop = 0;
    }
};

function placeClick(id, bN) {
    var f = etm.ay[id];
    if (f) {
        var K = map.getBounds();
        if (!K.contains(f.v)) {
            map.setCenter(f.v);
        }
        f.cA(bN);
    }
};
var currentInfoPlace;
Place.prototype.cA = function (bN) {
    eid("placeMarkerDiv").innerHTML = "<img src='" + this.aI + "' alt='' width='32' height='32' />";
    eid("placeTitleDiv").innerHTML = this.B;
    eid("placeProfileDiv").innerHTML = "";
    eid("placeImageDiv").innerHTML = "";
    eid("starsDiv").innerHTML = "";
    eid("placeDetailDiv").innerHTML = "";
    eid("placeReviewsDiv").innerHTML = "";
    eid("placeReviewsDiv").style.display = "none";
    eid("placeProfileDiv").style.display = "block";
    if (etm.k) {
        var aC = eid("r" + etm.k.l);
        etm.k = null;
        rowLo(aC);
    }
    etm.k = this;
    this.bb();
    var cS = eid("r" + this.l);
    rowHi(cS);
    if (bN) {
        etm.cB(this.l);
    }
    currentInfoPlace = this;
    if (!this.aQ) {
        this.aQ = "&nbsp;";
        var I = etm.dq + this.l;
        var T = new JSON(I);
        T.aS();
        T.aU();
        addLog(I);
    }
    this.aW();
};

function placeShowProfile() {
    eid("placeReviewsDiv").style.display = "none";
    eid("placeProfileDiv").style.display = "block";
};

function placeShowReviews() {
    if (etm.aa < 1) {
        alert("Sign up for a PlanItDisney account to read reviews");
        return;
    }
    if (!currentInfoPlace.V) {
        eid("placeReviewsDiv").innerHTML = "No reviews yet";
    } else if (currentInfoPlace.R == null) {
        currentInfoPlace.R = [];
        var I = etm.dy + currentInfoPlace.l;
        addLog(I);
        var T = new JSON(I);
        T.aS();
        T.aU();
        eid("placeReviewsDiv").innerHTML = "Loading Reviews ...";
    }
    eid("placeReviewsDiv").style.display = "block";
    eid("placeProfileDiv").style.display = "none";
};
Place.prototype.aW = function () {
    var aE = "";
    if (this.V > 0) {
        var s = (this.V == 1) ? "" : "s";
        var aE = "<a href='javascript:placeShowReviews()'>Visitor Rating from " + this.V + " review" + s + "</a> : " + this.F + "<br/>";
        var dh = Math.floor(this.F);
        for (var i = 0; i < dh; i++) {
            aE += "<img src='img/star/star.png' alt='' width=32 height=32 />";
        }
        var co = Math.floor(this.F * 10) % 10;
        if (co > 0) {
            aE += "<img src='img/star/rating" + co + ".png' alt='' width=32 height=32 />";
        }
    } else {
        aE = "No reviews yet";
    }
    eid("starsDiv").innerHTML = aE;
    var bC = "";
    if (etm.aa <= 0) {
        bC += "<p style='color:#565656'><a href='" + etm.dA + "' style='color:#0066cc;font-weight:bold'>Signup</a> " + "for a PlanItDisney account to read discriptions & " + "user reviews, email this point, and add items to the advanced Itinerary calendar." + "</p>";
    }
    if (etm.aa >= 0) {
        bC += this.aQ;
    } else {
        eid("placeDescriptionLink").style.display = "none";
    }
    eid("placeProfileDiv").innerHTML = "<p>" + bC + "</p>";
    if (this.cp) {
        eid("placeImageDiv").innerHTML = "<img src=img/poi/" + this.cp + " style='max-width:250px;max-height:200px' />";
		//eid("placeImageDiv").innerHTML = "<img src='" + this.cp + "' style='max-width:250px;max-height:200px' />";		
    }
    if (this.ab) {
        eid("placeItineraryLink").innerHTML = "<table><tr valign=top><td style='width:36px'>" + "<a href='javascript:itinRemove(" + this.l + ")'><img src='img/button/it-remove-large.png' height=32 width=32 alt='' border=0 /></a>" + "</td><td>" + "Remove From<br/>My Itinerary" + "</td></tr></table>";
    } else {
        eid("placeItineraryLink").innerHTML = "<table><tr valign=top><td style='width:36px'>" + "<a href='javascript:itinAdd(" + this.l + ")'><img src='img/button/it-add-large.png' height=32 width=32 alt='' border=0 /></a>" + "</td><td>" + "Add To My<br/>Itinerary" + "</td></tr></table>";
    }
    eid("placeItineraryInfo").innerHTML = this.ab ? "<p style='color:green'>Stored in <b>My Itinerary</b></p>" : "<p>&nbsp</p>";
    eid("placeDetailDiv").innerHTML = this.cx;
    var s = this.V == 1 ? "" : "s";
    eid("placeReviewsLink").innerHTML = this.V + " review" + s;
    eid("emailThisLink").href = etm.da + this.l;
    if (false) {
        eid("emailThisLink").style.display = "inline";
    } else {
        eid("emailThisLink").style.display = "none";
    }
    if (etm.aa > -1) {
        eid("reviewAddLink").style.display = "inline";
    } else {
        eid("reviewAddLink").style.display = "none";
    }
    if (etm.aa > -1) {
        this.ck();
    }
};
Place.prototype.ck = function () {
    var H = "";
    if (this.R && this.R.length > 0) {
        var as = [];
        for (var i = 0; i < 11; i++) {
            as[i] = 0;
        }
        for (var i = 0; i < this.R.length; i++) {
            var az = this.R[i];
            if (az.F >= 0) as[az.F]++;
        }
        var bq = 1;
        for (var i = 0; i < 11; i++) {
            if (as[i] > bq) {
                bq = as[i];
            }
        }
        var s = this.R.length == 1 ? "" : "s";
        H += "<p><b>" + this.R.length + " review" + s + "</b> courtesy of <a target='_blank' href='http://www.planitdisney.com'>PlanItDisney</a></p>";
        H += "<table cellspacing=0 cellpadding=0 style='width:200px; font-size:10px;'>";
        for (var i = 10; i >= 0; i--) {
            var aT = Math.round(as[i] * 100 / bq);
            var cb = "";
            if (as[i]) {
                cb = Math.round(as[i] * 100 / this.R.length) + " %";
            }
            H += "<tr><td>" + i + "</td><td>" + "<td><div style='height:11px;width:" + aT + "px;background-color:dodgerblue'></div></td>" + "<td style='color:green'>" + cb + "</td>" + "</tr>";
        }
        H += "</table><br/>";
        for (var i = 0; i < this.R.length; i++) {
            var az = this.R[i];
            H += az.dE(i);
            H += "<br/>";
        }
    }
    eid("placeReviewsDiv").innerHTML = H;
};

function cbPlaceDetail(a) {
    var bX = "cbPlaceDetail ";
    if (a.placeID) {
        bX += a.placeID;
    }
    addLog(bX);
    var cw = a.placeID;
    if (cw) {
        var f = etm.aF[cw];
        if (f) {
            f.aQ = a.description;
            f.cx = a.poi;
            f.cp = a.image;
        }
    }
    currentInfoPlace.aW();
};

function cbReview(a) {
    var bh = a.reviews;
    if (bh) {
        for (var i = 0; i < bh.length; i++) {
            var az = new Review(bh[i]);
            currentInfoPlace.R.push(az);
        }
    }
    currentInfoPlace.ck();
};

function zoomInPlace() {
    var r = 19;
    map.setCenter(etm.k.v, r);
};

function zoomOutPlace() {
    var r = map.getZoom() - 1;
    if (r > 0) {
        map.setCenter(etm.k.v, r);
    }
};

function nextPlaceInCategory(id) {
    var at = 0;
    if (etm.k != null) {
        var aZ = false;
        while (!aZ && (at < etm.A.length)) {
            if (etm.A[at].l == etm.k.l) {
                aZ = true;
            } else {
                at++;
            }
        }
    } else {
        aZ = true;
        at = -1;
    }
    if (aZ) {
        var bK = false;
        var aM = at + 1;
        var f = null;
        var af = 0;
        var dB = etm.A.length;
        while (!bK && (aM != at) && (af < dB)) {
            f = etm.A[aM];
            if (f && f.M == id) {
                bK = true;
            } else {
                aM++;
                if (aM >= etm.A.length) {
                    aM = 0;
                }
            }
            af++;
        }
        if (bK) {
            placeClick(f.l, true);
        } else {
            closeInfo();
        }
    }
};

function PostData(url, callback, doc) {
    var httpRequest;
    if (window.XMLHttpRequest) {
        httpRequest = new XMLHttpRequest();
    } else if (window.ActiveXObject) {
        try {
            httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (ex) {
            try {
                httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (ex) {}
        }
    }
    if (!httpRequest) {
        return false;
    }
    httpRequest.open('POST', url, true);
    httpRequest.setRequestHeader("Content-length", doc.length);
    httpRequest.setRequestHeader("Connection", "close");
    httpRequest.onreadystatechange = function () {
        if (httpRequest.readyState == 4) {
            if (httpRequest.status == 200) {
                callback(httpRequest.responseText);
            } else {
                callback("Update Error");
            }
        }
    };
    try {
        httpRequest.overrideMimeType("text/html");
    } catch (ex) {}
    httpRequest.send(doc);
};

function Review(a) {
    this.F = a.rating;
    this.cQ = a.username;
    this.cJ = a.userImageURL;
    this.aK = a.briefReview;
    var ix = this.aK.indexOf("\\n");
    if (ix > -1) {
        this.aK = "<div style='color:darkgreen'>" + this.aK.substr(0, ix) + "</div><div style='color:darkred'>" + this.aK.substr(ix + 2) + "</div>";
    }
    this.dK = a.date;
    this.cF = a.review;
};
Review.prototype.dE = function (ix) {
    var col = (ix % 2) ? "dodgerblue" : "darkblue";
    var bgcol = (ix % 2) ? "white" : "gainsboro";
    var H = "<table style='width:100%; color:" + col + ";background-color:" + bgcol + "'><tr><td>";
    H += "<div style='float:right;padding-left:4px;padding-bottom:4px'><img src='" + this.cJ + "' alt='' /></div>";
    H += "Rating: <b>" + this.F + "</b><br/>";
    H += "User: <b>" + this.cQ + "</b><br/>";
    H += "<p style='color:black'>" + this.aK + "</p>";
    H += this.cF;
    H += "</td></tr></table>";
    return H;
};

function addReview() {
    if (etm.k.ct) {
        alert("You have already reviewed this location");
        return;
    }
    var cc = eid("addReviewDiv");
    cc.style.left = parseInt((mapWidth - 450) / 2) + "px";
    cc.style.top = "-25px";
    if (etm.aa < 0) {
        alert("Please login to write a review");
        return;
    }
    eid("addReviewTitle").innerHTML = "Please write your review for " + etm.k.B;
    eid("greyDiv").style.display = "block";
    eid("addReviewDiv").style.display = "block";
};

function addReviewPost() {
    var cr = eid("addReviewText").value;
    if (!cr) {
        alert("Please enter some review text");
        eid("addReviewText").focus();
        return;
    }
    var cf = eid("reviewRating").value;
    if (cf == 0) {
        alert("Please select a rating");
        return;
    }
    var df = eid("reviewPros").value;
    var cI = eid("reviewCons").value;
    var dg = eid("reviewRecommend").value;
    eid("greyDiv").style.display = "none";
    eid("addReviewDiv").style.display = "none";
    var I = etm.cN + "&poi_id=" + etm.k.l + "&rating=" + cf + "&recommend=" + dg + "&pros=" + formatPostText(df) + "&cons=" + formatPostText(cI) + "&review=" + formatPostText(cr);
    addLog(I);
    eid("addReviewText").value = "";
    eid("reviewPros").value = "";
    eid("reviewCons").value = "";
    eid("reviewRecommend").selectedIndex = 0;
    eid("reviewRating").selectedIndex = 0;
    PostData(I, cbAddReview, "");
    etm.k.ct = true;
    alert("Thank you for writing a review");
};

function cbAddReview(a) {};

function addReviewCancel() {
    eid("greyDiv").style.display = "none";
    eid("addReviewDiv").style.display = "none";
};

function formatPostText(a) {
    var b = "";
    for (var i = 0; i < a.length; i++) {
        var c = a.substr(i, 1);
        if (c == "\n") {
            b += " ";
        }
        if (c == "\r") {}
        if (c == " ") {
            b += "+";
        } else if (c == "&") {
            b += "%26";
        } else if (c == "+") {
            b += "%2B";
        } else if (c == "%") {
            b += "%25";
        } else {
            b += c;
        }
    }
    return b;
};
ETM.prototype.bl = function (g, bm, dw) {
    if (!g.ak) {
        g.ak = this.dC(g.aH);
    }
    var bV = this.dD(g.v);
    var cs = true;
    if (bV < (g.ak + bm)) {
        var dG = this.cY(g.v);
        if (bV < dG) {
            cs = false;
        }
    }
    if (g.ak > 0) {
        this.ai.style.width = g.ak + "px";
    }
    this.ai.innerHTML = "<div class='markerTooltip'>" + g.aH + "</div>";
    var z = map.getZoom();
    var ci = map.getCurrentMapType().getProjection().fromLatLngToPixel(map.fromDivPixelToLatLng(new GPoint(0, 0), true), z);
    var aP = map.getCurrentMapType().getProjection().fromLatLngToPixel(g.v, z);
    var x = aP.x - ci.x;
    var y = aP.y - ci.y;
    if (cs) {
        x += bm;
    } else {
        x -= (bm + g.ak);
    }
    y += dw;
    var dc = new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(x, y));
    dc.apply(this.ai);
    this.ai.style.visibility = "visible";
};
ETM.prototype.bi = function () {
    this.ai.style.visibility = "hidden";
};
ETM.prototype.dC = function (cH) {
    var aT = 0;
    if (this.ao) {
        this.ao.style.display = "inline";
        this.ao.innerHTML = cH;
        aT = this.ao.offsetWidth;
        this.ao.style.display = "none";
    }
    return aT;
};
ETM.prototype.dD = function (bL) {
    var r = map.getZoom();
    var bM = map.getCurrentMapType().getProjection().fromLatLngToPixel(bL, r);
    var K = map.getBounds();
    var ne = K.getNorthEast();
    var bD = map.getCurrentMapType().getProjection().fromLatLngToPixel(ne, r);
    var av = (bD.x - bM.x);
    return av;
};
ETM.prototype.cY = function (bL) {
    var r = map.getZoom();
    var bM = map.getCurrentMapType().getProjection().fromLatLngToPixel(bL, r);
    var K = map.getBounds();
    var sw = K.getSouthWest();
    var bD = map.getCurrentMapType().getProjection().fromLatLngToPixel(sw, r);
    var av = (bM.x - bD.x);
    return av;
};
ETM.prototype.cT = function () {
    if (!this.bU) {
        this.dF();
        this.P(false);
        this.du();
    }
};
ETM.prototype.cX = function (di) {
    var s_str = di.toLowerCase();
    var ce = "";
    for (var i = 0; i < s_str.length; i++) {
        var c = s_str.substr(i, 1);
        if (c != "'" && c != "\"") {
            ce += c;
        }
    }
    return ce;
};

function eid(id) {
    return document.getElementById(id);
};

function formatFloat(n, d) {
    var m = Math.pow(10, d);
    return Math.round(n * m, 10) / m;
};

function addLog(a) {}
