(function (c) {
    c.localise = function (g, f, e, n, l, k) {
        if (typeof k == "undefined") {
            k = "&univid=1180613747855&fallback=true&assetType=MMM_Image&blobAttribute=ImageFile&version=current";
        }
        if (typeof f != "object" && typeof f != "string") {
            l = n;
            n = e;
            e = f;
            f = "";
        }
        if (typeof e != "boolean") {
            l = n;
            n = e;
            e = false;
        }
        if (typeof n != "string" && !a(n)) {
            l = n;
            n = ["", ""];
        }
        var j = {
            async: c.ajaxSettings.async,
            timeout: c.ajaxSettings.timeout
        };
        f = (typeof f != "string" ? f || {} : {
            language: f,
            loadBase: e,
            path: n,
            timeout: l
        });
        var m = (!f.path ? ["", ""] : (a(f.path) ? f.path : [f.path, f.path]));
        c.ajaxSetup({
            async: false,
            timeout: (f.timeout || 500)
        });
        var h = function (o, p) {
            jQuery.ajaxSetup({
                cache: true
            });
            c.getScript(m[1] + o + "" + p + k, function () {
                handleLocalize(message, accept, deny, dir);
            });
        };
        var d = f.language || c.localise.defaultLanguage;
        g = (a(g) ? g : [g]);
        for (i = 0; i < g.length; i++) {
            h(g[i], d);
        }
        c.ajaxSetup(j);
    };
    c.localize = c.localise;
    c.localise.defaultLanguage = b(navigator.language || navigator.userLanguage);

    function b(d) {
        d = d.replace(/_/, "-").toLowerCase();
        if (d.length > 3) {
            d = d.substring(0, 3) + d.substring(3).toUpperCase();
        }
        return d;
    }

    function a(d) {
        return (d && d.constructor == Array);
    }
})(jQuery);
(function (d) {
    var b = {}, k, m, o, j = d.browser.msie && /MSIE\s(5\.5|6\.)/.test(navigator.userAgent),
        e = false,
        a = false;
    d.fn.extend({
        Tooltip: function (p) {
            p = d.extend({}, d.Tooltip.defaults, p);
            h();
            return this.each(function () {
                this.tSettings = p;
            }).bind("click", l).bind(p.event, g);
        },
        Foottip: function (p) {
            this.each(function () {
                d(d(this).attr("href")).hide();
            });
            p = d.extend({
                bodyHandler: function () {
                    return d(d(this).attr("href")).html();
                },
                showURL: false
            }, p);
            return this.Tooltip(p).click(function () {
                return false;
            });
        },
        Modaltip: function (p) {
            p = d.extend({
                drag: "h3"
            }, p);
            return this.click(function () {
                var q = this;
                e = false;
                b.parent.addClass("modal").append("<span class='resize' />").jqDrag(p.drag).jqResize("span.resize").click(function (r) {
                    r.stopPropagation();
                }).find("span.close").add(document.body).one("click", function (r) {
                    e = false;
                    b.parent.unbind("click").css({
                        height: "",
                        width: ""
                    }).removeClass("modal").find("span.resize, span.close").remove();
                    d(".active1").removeClass("active1");
                    f.call(q, r);
                });
                return false;
            });
        },
        fixPNG: j ? function () {
            return this.each(function () {
                var p = d(this).css("backgroundImage");
                if (p.match(/^url\(["']?(.*\.png)["']?\)$/i)) {
                    p = RegExp.$1;
                    d(this).css({
                        "backgroundImage": "none",
                        "filter": "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=crop, src='" + p + "')"
                    }).each(function () {
                        var q = d(this).css("position");
                        if (q != "absolute" && q != "relative") {
                            d(this).css("position", "relative");
                        }
                    });
                }
            });
        } : function () {
            return this;
        },
        unfixPNG: j ? function () {
            return this.each(function () {
                d(this).css({
                    "filter": "",
                    backgroundImage: ""
                });
            });
        } : function () {
            return this;
        },
        getAndSetAttr: function (q, r) {
            var p = this.attr(q);
            this.attr(q, r);
            return p;
        },
        hideWhenEmpty: function () {
            return this.each(function () {
                d(this)[d(this).html() ? "show" : "hide"]();
            });
        },
        url: function () {
            return this.attr("href") || this.attr("src");
        }
    });

    function h() {
        if (b.parent) {
            return;
        }
        b.parent = d('<div id="tooltip"><h3></h3><p class="body"></p><p class="url"></p></div>').hide().appendTo("body");
        b.title = d("h3", b.parent);
        b.body = d("p.body", b.parent);
        b.url = d("p.url", b.parent);
    }

    function g(p) {
        if (e) {
            return;
        }
        if (this.tSettings.delay) {
            o = setTimeout(n, this.tSettings.delay);
        } else {
            n();
        }
        a = !! this.tSettings.track;
        c(p);
        if (this.tSettings.event != "click") {
            d(this).bind("mouseout", f);
        }
    }

    function l() {
        if (e || this == k || !this.title) {
            return;
        }
        k = this;
        if (this.tSettings.event != "click") {
            m = d(this).getAndSetAttr("title", "");
        }
        if (this.tSettings.bodyHandler) {
            b.title.hide();
            b.body.html(this.tSettings.bodyHandler.call(this)).show();
        } else {
            if (this.tSettings.showBody) {
                var r = m.split(this.tSettings.showBody);
                b.title.html(r.shift()).show();
                b.body.empty();
                for (var q = 0, p; p = r[q]; q++) {
                    if (q > 0) {
                        b.body.append("<br/>");
                    }
                    b.body.append(p);
                }
                b.body.hideWhenEmpty();
            } else {
                b.title.html(m).show();
                b.body.hide();
            }
        } if (this.tSettings.showURL && d(this).url()) {
            b.url.html(d(this).url().replace("http://", "")).show();
        } else {
            b.url.hide();
        }
        b.parent.addClass(this.tSettings.extraClass);
        if (this.tSettings.fixPNG) {
            b.parent.fixPNG();
        }
    }

    function n() {
        o = null;
        b.parent.show();
        c();
    }

    function c(r) {
        if (e) {
            return;
        }
        if (!a && b.parent.is(":visible")) {
            d("body").unbind("mousemove", c);
        }
        if (k == null) {
            d("body").unbind("mousemove", c);
            return;
        }
        var t = b.parent[0].offsetLeft;
        var s = b.parent[0].offsetTop;
        if (r) {
            t = r.pageX + 15;
            s = r.pageY + 15;
            b.parent.css({
                left: t + "px",
                top: s + "px"
            });
        }
        var p = i(),
            q = b.parent[0];
        b.parent.removeClass("viewportRight");
        if (p.x + p.cx < q.offsetLeft + q.offsetWidth) {
            t -= q.offsetWidth + 20;
            b.parent.css({
                left: t + "px"
            });
            b.parent.addClass("viewportRight");
        }
        if (p.y + p.cy < q.offsetTop + q.offsetHeight) {
            s -= q.offsetHeight + 20;
            b.parent.css({
                top: s + "px"
            });
        }
    }

    function i() {
        var s = document.documentElement || {}, p = document.body || {}, q = window;

        function r() {
            var t = Infinity;
            for (var u = 0; u < arguments.length; u++) {
                var w = arguments[u];
                if (w && w < t) {
                    t = w;
                }
            }
            return t;
        }
        return {
            x: q.pageXOffset || s.scrollLeft || p.scrollLeft || 0,
            y: q.pageYOffset || s.scrollTop || p.scrollTop || 0,
            cx: r(s.clientWidth, p.clientWidth, q.innerWidth),
            cy: r(s.clientHeight, p.clientHeight, q.innerHeight)
        };
    }

    function f(p) {
        if (e) {
            return;
        }
        if (o) {
            clearTimeout(o);
        }
        k = null;
        b.parent.hide().removeClass(this.tSettings.extraClass);
        d(this).unbind("mouseout", f).attr("title", m);
        if (this.tSettings.event != "click") {
            d(this).unbind("click", f);
        }
        if (this.tSettings.fixPNG) {
            b.parent.unfixPNG();
        }
    }
    d.Tooltip = {};
    d.Tooltip.defaults = {
        delay: 250,
        event: "mouseover",
        showURL: true,
        extraClass: ""
    };
})(jQuery);
(function (b) {
    b.fn.jqDrag = function (d) {
        b.jqDnR.init(this, d, "d");
        return this;
    };
    b.fn.jqResize = function (d) {
        b.jqDnR.init(this, d, "r");
        return this;
    };
    b.jqDnR = {
        init: function (d, f, e) {
            f = (f) ? b(f, d) : d;
            f.bind("mousedown", {
                w: d,
                t: e
            }, function (j) {
                var i = j.data;
                var g = i.w;
                c = b.extend({
                    oX: a(g, "left"),
                    oY: a(g, "top"),
                    oW: a(g, "width"),
                    oH: a(g, "height"),
                    pX: j.pageX,
                    pY: j.pageY,
                    o: g.css("opacity")
                }, i);
                i.w.css("opacity", 0.8);
                b().mousemove(b.jqDnR.drag).mouseup(b.jqDnR.stop);
                return false;
            });
        },
        drag: function (g) {
            var f = c;
            var d = f.w[0];
            if (f.t == "d") {
                f.w.css({
                    left: f.oX + g.pageX - f.pX,
                    top: f.oY + g.pageY - f.pY
                });
            } else {
                f.w.css({
                    width: Math.max(g.pageX - f.pX + f.oW, 0),
                    height: Math.max(g.pageY - f.pY + f.oH, 0)
                });
            }
            return false;
        },
        stop: function () {
            var d = b.jqDnR;
            c.w.css("opacity", c.o);
            b().unbind("mousemove", d.drag).unbind("mouseup", d.stop);
        },
        h: false
    };
    var c = b.jqDnR.h;
    var a = function (d, e) {
        return parseInt(d.css(e)) || 0;
    };
})(jQuery);
jQuery.cookie = function (b, j, m) {
    if (typeof j != "undefined") {
        m = m || {};
        if (j === null) {
            j = "";
            m = $.extend({}, m);
            m.expires = -1;
        }
        var e = "";
        if (m.expires && (typeof m.expires == "number" || m.expires.toUTCString)) {
            var f;
            if (typeof m.expires == "number") {
                f = new Date();
                f.setTime(f.getTime() + (m.expires * 24 * 60 * 60 * 1000));
            } else {
                f = m.expires;
            }
            e = "; expires=" + f.toUTCString();
        }
        var l = m.path ? "; path=" + (m.path) : "";
        var g = ".3mgraphics.com" ? "; domain=" + (".3mgraphics.com") : "";
        var a = m.secure ? "; secure" : "";
        document.cookie = [b, "=", encodeURIComponent(j), e, l, g, a].join("");
    } else {
        var d = null;
        if (document.cookie && document.cookie != "") {
            var k = document.cookie.split(";");
            for (var h = 0; h < k.length; h++) {
                var c = jQuery.trim(k[h]);
                if (c.substring(0, b.length + 1) == (b + "=")) {
                    d = decodeURIComponent(c.substring(b.length + 1));
					$("#tooltip").hide();
                    break;
                }
            }
        }
        return d;
    }
};
jQuery.fn.makeacolumnlists = function (a) {
    a = jQuery.extend({
        cols: 2,
        colWidth: 0,
        equalHeight: false,
        startN: 1
    }, a);
    if (jQuery("> li", this)) {
        this.each(function (l) {
            var l = jQuery(".li_container").size(),
                o = 0,
                p = 0,
                n = jQuery(this),
                g = n.attr("class"),
                x = jQuery("> li", this).size(),
                h = Math.ceil(x / a.cols),
                e = n.width(),
                c = (isNaN(parseInt(n.css("borderLeftWidth"), 10)) ? 0 : parseInt(n.css("borderLeftWidth"), 10)),
                w = (isNaN(parseInt(n.css("borderRightWidth"), 10)) ? 0 : parseInt(n.css("borderRightWidth"), 10)),
                v = parseInt(n.css("paddingLeft"), 10),
                r = parseInt(n.css("paddingRight"), 10),
                u = parseInt(n.css("marginLeft"), 10),
                q = parseInt(n.css("marginRight"), 10),
                d = Math.floor((e - (a.cols - 1) * (c + w + v + r + u + q)) / a.cols);
            if (a.colWidth) {
                d = a.colWidth;
            }
            var b = 1,
                j = h;
            jQuery(this).addClass("li_cont1").wrap('<div id="li_container' + (++l) + '" class="li_container"></div>');
            for (var s = 0; s <= x; s++) {
                if (s >= j) {
                    j += h;
                    b++;
                }
                var z = jQuery("> li:eq(" + s + ")", this);
                z.addClass("li_col" + b);
                if (jQuery(this).is("ol")) {
                    z.attr("value", "" + (s + a.startN)) + "";
                }
            }
            jQuery(this).css({
                cssFloat: "left",
                width: "" + d + "px"
            });
            for (b = 2; b <= a.cols; b++) {
                if (jQuery(this).is("ol")) {
                    jQuery("li.li_col" + b, this).appendTo("#li_container" + l).wrapAll('<ol class="li_cont' + b + " " + g + '" style="float:left; width: ' + d + 'px;"></ol>');
                } else {
                    jQuery("li.li_col" + b, this).appendTo("#li_container" + l).wrapAll('<ul class="li_cont' + b + " " + g + '" style="float:left; width: ' + d + 'px;"></ul>');
                }
            }
            if (a.equalHeight == "li") {
                for (b = 1; b <= a.cols; b++) {
                    jQuery("#li_container" + l + " li").each(function () {
                        var y = jQuery(this);
                        var i = (isNaN(parseInt(y.css("borderTopWidth"), 10)) ? 0 : parseInt(y.css("borderTopWidth"), 10));
                        var t = (isNaN(parseInt(y.css("borderBottomWidth"), 10)) ? 0 : parseInt(y.css("borderBottomWidth"), 10));
                        o = y.height() + parseInt(y.css("paddingTop"), 10) + parseInt(y.css("paddingBottom"), 10) + i + t;
                        p = (o > p) ? o : p;
                    });
                }
                for (b = 1; b <= a.cols; b++) {
                    var f = jQuery("#li_container" + l + " li");
                    var k = (isNaN(parseInt(f.css("borderTopWidth"), 10)) ? 0 : parseInt(f.css("borderTopWidth"), 10));
                    var m = (isNaN(parseInt(f.css("borderBottomWidth"), 10)) ? 0 : parseInt(f.css("borderBottomWidth"), 10));
                    mh = p - (parseInt(f.css("paddingTop"), 10) + parseInt(f.css("paddingBottom"), 10) + k + m);
                    f.height(mh);
                }
            } else {
                if (a.equalHeight == "ul" || a.equalHeight == "ol") {
                    for (b = 1; b <= a.cols; b++) {
                        jQuery("#li_container" + l + " .li_cont" + b).each(function () {
                            var y = jQuery(this);
                            var i = (isNaN(parseInt(y.css("borderTopWidth"), 10)) ? 0 : parseInt(y.css("borderTopWidth"), 10));
                            var t = (isNaN(parseInt(y.css("borderBottomWidth"), 10)) ? 0 : parseInt(y.css("borderBottomWidth"), 10));
                            o = y.height() + parseInt(y.css("paddingTop"), 10) + parseInt(y.css("paddingBottom"), 10) + i + t;
                            p = (o > p) ? o : p;
                        });
                    }
                    for (b = 1; b <= a.cols; b++) {
                        var f = jQuery("#li_container" + l + " .li_cont" + b);
                        var k = (isNaN(parseInt(f.css("borderTopWidth"), 10)) ? 0 : parseInt(f.css("borderTopWidth"), 10));
                        var m = (isNaN(parseInt(f.css("borderBottomWidth"), 10)) ? 0 : parseInt(f.css("borderBottomWidth"), 10));
                        mh = p - (parseInt(f.css("paddingTop"), 10) + parseInt(f.css("paddingBottom"), 10) + k + m);
                        f.height(mh);
                    }
                }
            }
            jQuery("#li_container" + l).append('<div style="clear:both; overflow:hidden; height:0px;"></div>');
        });
    }
};
jQuery.fn.uncolumnlists = function () {
    jQuery(".li_cont1").each(function (b) {
        var c = jQuery("#li_container" + (++b) + " .li_cont1 > li").size();
        if (jQuery("#li_container" + b + " .li_cont1").is("ul")) {
            jQuery("#li_container" + b + " > ul > li").appendTo("#li_container" + b + " ul:first");
            for (var a = 1; a <= c; a++) {
                jQuery("#li_container" + b + " ul:first li").removeAttr("class").removeAttr("style");
            }
            jQuery("#li_container" + b + " ul:first").removeAttr("style").removeClass("li_cont1").insertBefore("#li_container" + b);
        } else {
            jQuery("#li_container" + b + " > ol > li").appendTo("#li_container" + b + " ol:first");
            for (var a = 1; a <= c; a++) {
                jQuery("#li_container" + b + " ol:first li").removeAttr("class").removeAttr("style");
            }
            jQuery("#li_container" + b + " ol:first").removeAttr("style").removeClass("li_cont1").insertBefore("#li_container" + b);
        }
        jQuery("#li_container" + b).remove();
    });
};
(function (c) {
    c.fn._hover = c.fn.hover;
    c.fn.hover = function (f, e, d) {
        if (d) {
            this.bind("hoverstart", f);
        }
        if (e) {
            this.bind("hoverend", d ? d : e);
        }
        return !f ? this.trigger("hover") : this.bind("hover", d ? e : f);
    };
    var b = c.event.special.hover = {
        delay: 100,
        speed: 100,
        setup: function (d) {
            d = c.extend({
                speed: b.speed,
                delay: b.delay,
                hovered: 0
            }, d || {});
            c.event.add(this, "mouseenter mouseleave", a, d);
        },
        teardown: function () {
            c.event.remove(this, "mouseenter mouseleave", a);
        }
    };

    function a(d) {
        var f = d.data || d;
        switch (d.type) {
        case "mouseenter":
            f.dist2 = 0;
            f.event = d;
            d.type = "hoverstart";
            if (c.event.handle.call(this, d) !== false) {
                f.elem = this;
                c.event.add(this, "mousemove", a, f);
                f.timer = setTimeout(e, f.delay);
            }
            break;
        case "mousemove":
            f.dist2 += Math.pow(d.pageX - f.event.pageX, 2) + Math.pow(d.pageY - f.event.pageY, 2);
            f.event = d;

            break;
        case "mouseleave":
            clearTimeout(f.timer);
            if (f.hovered) {
                d.type = "hoverend";
                c.event.handle.call(this, d);
                f.hovered--;
            } else {
                c.event.remove(f.elem, "mousemove", a);
            }
            break;
        default:
            if (f.dist2 <= Math.pow(f.speed * (f.delay / 1000), 2)) {
                c.event.remove(f.elem, "mousemove", a);
                f.event.type = "hover";
                if (c.event.handle.call(f.elem, f.event) !== false) {
                    f.hovered++;
                }
            } else {
                f.timer = setTimeout(e, f.delay);
            }
            f.dist2 = 0;
            break;
        }

        function e() {
            a(f);
        }
    }
})(jQuery);
var preferences = new mmmUserPreferences();

function mmmUserPreferences() {
    this.DENIED = "preferenceDenied";
    this.NONE = "preferenceNone";
    this.cookieEnabled = (navigator.cookieEnabled) ? true : false;
    this.returnDenial = $.cookie("localePreference") == this.DENIED;
    document.cookie = "testcookie";
    this.cookieEnabled = (document.cookie.indexOf("testcookie") != -1) ? true : false;
    $.cookie("testcookie", null);
    this.isAllowed = true;
    if (!this.cookieEnabled || $.cookie("localePreference") == this.DENIED) {
        this.isAllowed = this.DENIED;
    }
    this.allow = function () {
        this.isAllowed = true;
        $.cookie("localePreference", this.NONE, {
            expires: 365 * 10
        });
    };
    this.deny = function () {
        this.reset();
        this.isAllowed = this.DENIED;
        $.cookie("localePreference", this.isAllowed, {
            expires: 365 * 10
        });
    };
    this.reset = function () {
        $.cookie("localePreference", this.NONE, {
            expires: 365 * 10
        });
    };
    this.clear = function () {
        $.cookie("localePreference", null);
    };
    this.accept = function (c) {
        this.locale = (typeof (c) == "undefined") ? "xx" : c;
        this.localePreference = $("a[lang$='" + this.locale + "']").attr("href") + "?WT.mc_id=ggp_redirect_" + b(this.locale);
        $.cookie("localePreference", this.localePreference, {
            expires: 365 * 10
        });
    };
    this.hasPreference = function () {
		 return (this.getLocaleURL() && (this.getLocaleURL() != this.DENIED && this.getLocaleURL() != this.NONE));
		 $(".location_preference").hide();
    };
    this.getLocaleURL = function () {
        var c = $.cookie("localePreference");
        if (c == this.DENIED || c == this.NONE || c == null) {
            return false;
        } else {
            this.localeURL = c.replace(/\?.*$/, "");
            return this.localeURL;
        }
    };
    this.getLocale = function () {
        var c = $.cookie("localePreference");
        if (c == this.DENIED || c == this.NONE || c == null) {
            return false;
        } else {
            return a(c.replace(/^.*?WT.mc_id=ggp_redirect_/, ""));
        }
    };
    this.isSet = function () {
        return ($.cookie("localePreference") != null);
    };
    this.geolocationCode = null;

    function b(d) {
        var c = d.split("-");
        return c[0] + "_" + c[1].toUpperCase();
    }

    function a(c) {
        return c.replace(/_/, "-").toLowerCase();
    }
}
var localeDefault = new Array();
localeDefault["az"] = "asiapac";
localeDefault["en-az"] = "asiapac";
localeDefault["kz"] = "asiapac";
localeDefault["ru-kz"] = "asiapac";
localeDefault["pk"] = "mea";
localeDefault["en-pk"] = "mea";
localeDefault["tr"] = "europe";
localeDefault["tr-tr"] = "europe";
if (querySt("script") != "false") {
    jQuery(document).ready(function (e) {
        e("body").addClass("alternate");
        e(".locations dd").hide();
        e(".locations").appendTo("#masthead");
        e("#locations-container").appendTo("#masthead");
        var c = "";
        var g = querySt("country");
        var f = querySt("region");
        if (typeof g != "undefined") {
            c = g;
        } else {
            if (typeof f != "undefined") {
                c = f;
            }
        } if (querySt("reset") == "true") {
            preferences.clear();
        }
        if (c != "") {
            showResponse(c);
        } else {
            if (preferences.hasPreference()) {
                myLocale = preferences.getLocale();
				this.cookieEnabled = false;
                if (myLocale != "") {
                    e("dd a[lang$='" + myLocale + "']").parent().siblings("dt").each(function (h) {
                        focusMenuItem(e(this));
                    });
                }
                if (localeDefault[myLocale] != undefined) {
                    focusMenuItem(e(".locations dl." + localeDefault[myLocale] + " dt"));
                }
            } else {
                getGeolocationCode();
            }
        }

        function d() {
            focusMenuItem(e(this));
        }

        function a() {
            return false;
        }
        e(".locations dl dt").hover(d);
        var b;
        e("#masthead,#footer-ggp").mouseenter(function () {
            clearTimeout(b);
        });
        e("#tooltip").live("mouseover", function (h) {
            clearTimeout(b);
        });
        e("#masthead").mouseleave(function () {
            b = setTimeout(function () {
                clearMenuItems();
            }, 800);
        });
        e(".locations dl dt").bind("click", function (h) {
            lockMenuItem(e(this));
        });
        if (preferences.cookieEnabled) {
            e("#masthead").append('<div class="location_preference" ><input type="checkbox" name="disable_preferred_loc" id="disable_preferred_loc" /> <label for="disable_preferred_loc">Do not ask me about saving a 3mgraphics.com location</label></div>');
            if (preferences.isAllowed == preferences.DENIED) {
                e("input#disable_preferred_loc").attr("checked", true);
                dcsMultiTrack("WT.ad", "", "WT.ac", "ggp_returncheckbox");
                e.Tooltip.block;
            }
            e("input#disable_preferred_loc").click(function () {
                var h = e(this).is(":checked");
                if (h) {
                    dcsMultiTrack("WT.ad", "", "WT.ac", "ggp_checkboxon");
                    denyPreference();
                } else {
                    allowPreference();
                }
            });
            toggleCheckboxVisibility();
        }
    });
}

function mmmQuerySt(a, b) {
    gy = a.split("&");
    for (i = 0; i < gy.length; i++) {
        ft = gy[i].split("=");
        if (ft[0] == b) {
            return ft[1];
        }
    }
}

function querySt(a) {
    hu = window.location.search.substring(1);
    gy = hu.split("&");
    for (i = 0; i < gy.length; i++) {
        ft = gy[i].split("=");
        if (ft[0] == a) {
            return ft[1];
        }
    }
}

function resetPreference() {
    $("#locations-container .favoriteIcon").remove();
    $("#locations-container .favorite").removeClass("favorite");
    preferences.reset();
}

function denyPreference() {
    if (preferences.getLocaleURL()) {
        dcsMultiTrack("WT.ad", "", "WT.ac", "ggp_deletedfave");
    }
    $("#locations-container a").unbind("click");
    resetPreference();
    preferences.deny();
}

function allowPreference() {
    preferences.allow();
    setupLocales();
}

function showResponse(a, b) {
    if (a == "") {
        return false;
    }
    myLocale = a.toLowerCase();
    preferences.geolocationCode = myLocale;
    if (myLocale != "") {
        $("a[lang$='" + myLocale + "']").addClass("highlight");
    }
    if ($(".locations dl." + myLocale + " dt").length) {
        focusMenuItem($(".locations dl." + myLocale + " dt"));
    }
    if (myLocale != "") {
        $("a[lang$='" + myLocale + "']").parent().siblings("dt").each(function (c) {
            focusMenuItem($(this));
        });
    }
    if (localeDefault[myLocale] != undefined) {
        focusMenuItem($(".locations dl." + localeDefault[myLocale] + " dt"));
    }
}

function showError(a, b) {
    return false;
}

function getGeolocationCode() {
    if (typeof geocodeURL == "undefined") {
        geocodeURL = "/CountryIP";
    }
    $.ajax({
        url: geocodeURL,
        dataType: "html",
        timeout: (10 * 1000),
        success: showResponse,
        error: showError
    });
}

function focusMenuItem(b) {
    $("#locations-container").css("visibility", "visible");
    $("#locations-container").html("<ul></ul>");
    var a = $("#locations-container ul");
    b.siblings().each(function (c) {
        a.append("<li>" + this.innerHTML + "</li>");
    });
    a.makeacolumnlists({
        cols: 3,
        colWidth: 0,
        equalHeight: "ul",
        startN: 1
    });
    setupFavorites(b);
    setupLocales();
    $(".locations dt").each(function (c) {
        if ($(this).is(".selected")) {
            $(this).removeClass("selected");
        }
    });
    b.addClass("selected");
    toggleCheckboxVisibility();
    $("#tooltip span.close").triggerHandler("click");
    $("#locations-container li a").click(function () {
        lang = $(this).attr("lang");
        var c = $("#disable_preferred_loc").is(":checked");
        if (lang != "" && c) {
            dcsMultiTrack("WT.ad", "", "WT.ac", "ggp_" + lang);
        }
    });
}

function toggleCheckboxVisibility() {
    var a = preferences.isSet();
    if (a) {
        $(".location_preference").show();
    } else {
        $(".location_preference").hide();
    }
}

function clearMenuItems() {
    $("dl dt:not(.locked)").removeClass("selected");
    focusMenuItem($("dl dt.locked"));
    if (!$("dl dt.locked").length) {
        $("#locations-container").css("visibility", "hidden");
        $(".location_preference").hide();
    }
}

function lockMenuItem(a) {
    $(".locations dt").each(function (b) {
        if ($(this).is(".locked")) {
            $(this).removeClass("locked");
        }
    });
    a.addClass("locked");
}

function go(c, f, e) {
    var b = new RegExp(preferences.geolocationCode + "$").test(f);
    var h = new RegExp(preferences.getLocale() + "$").test(f);
    if (typeof f != "undefined" && e == true) {
        dcsMultiTrack("WT.ad", "", "WT.ac", "ggp_" + f + "_favorite");
        if (b) {
            var g = "yes_" + preferences.geolocationCode + "_" + f;
            dcsMultiTrack("WT.ad", "", "WT.ac", g);
        } else {
            if (preferences.geolocationCode) {
                var g = "no_" + preferences.geolocationCode + "_" + f;
                try {
                    var a = WT["co_f"];
                    if (a) {
                        g += "_" + a;
                    }
                } catch (d) {}
                dcsMultiTrack("WT.ad", "", "WT.ac", g);
            }
        }
        preferences.accept(f);
    } else {
        if (typeof f != "undefined" && e == false) {
            if (h || !preferences.isSet()) {
                resetPreference();
            }
            dcsMultiTrack("WT.ad", "", "WT.ac", "ggp_" + f + "_nofavorite");
        }
    }
    $("#tooltip").hide();
    window.location = c;
}
var message;
var accept;
var deny;
var dir;
var url;
var lang;
var favImg;
var content;

function setupLocales() {
    $.extend($.Tooltip.defaults, {
        track: true,
        delay: 0,
        showURL: false,
        event: "click"
    });
    if (preferences.isAllowed != preferences.DENIED) {
        $("#locations-container li a").Tooltip({
            bodyHandler: function () {
                message = "Remember this choice?";
                accept = "Yes";
                deny = "No";
                dir = "ltr";
                mmmSiteRoot = "http://www.3mgraphics.com";
                mmmLocalizationPrefix = mmmSiteRoot + "/3MContentRetrievalAPI/BlobServlet?locale=";
                mmmLocalizationSuffix = "&univid=1180613747855&fallback=true&assetType=MMM_Image&blobAttribute=ImageFile&version=current";
                if ($(this).attr("rev").length) {
                    lang = $(this).attr("rev");
                } else {
                    lang = $(this).attr("lang");
                }
                $.localize("", {
                    language: lang,
                    loadBase: false,
                    path: mmmLocalizationPrefix,
                    timeout: null,
                    pathSuffix: mmmLocalizationSuffix
                });
                url = $(this).attr("href");
                lang = $(this).attr("lang");
                favImg = ' <span class="tooltip_favorite">&nbsp;</span>';
                content = '<span class="message ' + dir + '" dir="' + dir + '">' + favImg + message + '<br clear="all" />' + "<a href=\"javascript:go('" + url + "','" + lang + '\',true)" class="button accept">' + accept + "</a>" + "<a href=\"javascript:go('" + url + "','" + lang + '\',false)" class="button deny">' + deny + "</a>" + "</span>" + '<span class="close close' + dir + '" />';
                return content;
            }
        }).Modaltip();
    }
    $("#locations-container li a").click(function () {
        $("#locations-container li a.active1").removeClass("active1");
        $(this).addClass("active1");
    });
    $("#locations-container").click(function () {
        $("#locations-container li a.active1").removeClass("active1");
    });
}

function handleLocalize(d, b, e, a) {
    var c = '<span class="message ' + a + '" dir="' + a + '">' + favImg + d + '<br clear="all" />';
    c += "<a href=\"javascript:go('" + url + "','" + lang + '\',true)" class="button accept">' + b + "</a>";
    c += "<a href=\"javascript:go('" + url + "','" + lang + '\',false)" class="button deny">' + e + "</a>";
    c += "</span>";
    $("#tooltip .body .message").replaceWith(c);
    $("#tooltip .body .close").removeClass("closeltr").addClass("close" + a);
}

function setupFavorites(b) {
    var a = preferences.getLocale();
    if (a) {
        $("#locations-container a[lang$='" + a + "']").parent().addClass("favorite");
        $("#locations-container .favorite img").remove();
        $("#locations-container .favorite").prepend('<div class="favoriteIcon fav-default"></div>');
        $("#locations-container .favoriteIcon").hover(function () {
            $(this).removeClass("fav-default");
            $(this).addClass("fav-remove");
        }, function () {
            $(this).removeClass("fav-remove");
            $(this).addClass("fav-default");
        });
        $("#locations-container .favoriteIcon").click(function () {
            dcsMultiTrack("WT.ad", "", "WT.ac", "ggp_deletedfave");
            resetPreference();
        });
    }
}
if (!("console" in window) || !("firebug" in console)) {
    var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml", "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];
    window.console = {};
    for (var i = 0; i < names.length; ++i) {
        window.console[names[i]] = function () {};
    }
}
$("#footer-ggp span.legal a.legal-info").live("click", function () {
    dcsMultiTrack("WT.ad", "", "WT.ac", "ggp_legal");
});
$("#footer-ggp span.legal a.legal-privacy").live("click", function () {
    dcsMultiTrack("WT.ad", "", "WT.ac", "ggp_privacy");
});

function checkAndRedirect(){
	var cVal = $.cookie('localePreference');
	//test to see if cookie value is not blank, not null, not = to preferenceNone and url param of change!=true - then do redirect
	if (cVal !== '' && cVal !== null && cVal !== 'preferenceNone' && urlHash['change'] !== 'true'){
		location.href = cVal;
	}
}

checkAndRedirect();