var LocationChanger = { 
    curtainElem: null, 
    dialogContainerElem: null, 
    dialogContentsElem: null, 
    closeLink: null, 
    loginLink: null, 
    positionInterval: null, 
    currentCountry: "", 
    currentCityId: -1, 
    workingCountry: "", 
    workingCountryName: "", 
    workingCityId: -1, 
    loadingImg: null, 
    loadingImgElem: null, 
    windowTitle: null, 
    windowText: null, 
    languagesLink: null, 
    chooseLocationTitle: "", 
    chooseLocationText: "", 

    SelectCity: function(initialCountryCode, initialCountryName) { 
        LocationChanger.ShowDialog();
        
        if (initialCountryCode != null && initialCountryCode != undefined && initialCountryCode.length > 0 && initialCountryName != null && initialCountryName != undefined && initialCountryName.length > 0)
            LocationChanger.CountrySelected(initialCountryName, initialCountryCode);
        else
            LocationChanger.ShowSelectCountry();
    }, 
    
    ShowDialog: function() { 
        var pageHeight = Math.max(document.documentElement.clientHeight, ((document.height != undefined) ? document.height : document.body.offsetHeight));
        var pageWidth = Math.max(document.body.clientWidth, 980);
        
        LocationChanger.loadingImg = new Image();
        LocationChanger.loadingImg.src = "/images/bubbles/bubble_loading.gif";
        
        var dropbox = Get("EntityDropbox");
        
        LocationChanger.curtainElem = document.createElement("div");
        LocationChanger.curtainElem.style.position = "absolute";
        LocationChanger.curtainElem.style.width = pageWidth + "px";
        LocationChanger.curtainElem.style.height = pageHeight + "px";
        LocationChanger.curtainElem.style.zIndex = 600;
        LocationChanger.curtainElem.style.backgroundColor = "#252038";
	    LocationChanger.curtainElem.style.opacity = 0.85;
	    LocationChanger.curtainElem.style.filter  = "alpha(opacity=85)";
        LocationChanger.curtainElem.appendChild(document.createTextNode(" "));
        
        LocationChanger.dialogContainerElem = document.createElement("div");
        var dialogCorner1 = document.createElement("div");
        var dialogCorner2 = document.createElement("div");
        var dialogCorner3 = document.createElement("div");
        var dialogCorner4 = document.createElement("div");
        LocationChanger.dialogContentsElem = document.createElement("div");
        
        LocationChanger.dialogContainerElem.className = "Dialog";
        dialogCorner1.className = "Dialog-tl";
        dialogCorner2.className = "Dialog-tr";
        dialogCorner3.className = "Dialog-bl";
        dialogCorner4.className = "Dialog-br";
        LocationChanger.dialogContentsElem.className = "Dialog-padding";
        
        LocationChanger.dialogContainerElem.style.position = "absolute";
        LocationChanger.dialogContainerElem.style.width = "580px";
        LocationChanger.dialogContainerElem.style.height = "400px";
        LocationChanger.dialogContainerElem.style.zIndex = 601;
        
        dialogCorner4.appendChild(LocationChanger.dialogContentsElem);
        dialogCorner3.appendChild(dialogCorner4);
        dialogCorner2.appendChild(dialogCorner3);
        dialogCorner1.appendChild(dialogCorner2);
        LocationChanger.dialogContainerElem.appendChild(dialogCorner1);
        dropbox.appendChild(LocationChanger.dialogContainerElem);
        dropbox.appendChild(LocationChanger.curtainElem);
        dropbox = dialogCorner1 = dialogCorner2 = dialogCorner3 = dialogCorner4 = null;
        
        LocationChanger.PositionDialog();
        LocationChanger.positionInterval = setInterval("LocationChanger.PositionDialog()", 500);
        
        LocationChanger.closeLink = document.createElement("div");
        var closeLinkElem = document.createElement("a");
        if (typeof(LocationChanger.closeLink.style.cssFloat) != "undefined") LocationChanger.closeLink.style.cssFloat = "right";
        else LocationChanger.closeLink.style.styleFloat = "right";
        LocationChanger.closeLink.style.margin = "-10px -30px 0 0";
        closeLinkElem.className = "CloseLink";
        closeLinkElem.onclick = function() { LocationChanger.HideDialog(); return false; };
        closeLinkElem.href = "#";
        closeLinkElem.appendChild(document.createTextNode(Translation.Close));
        LocationChanger.closeLink.appendChild(closeLinkElem);
        
        LocationChanger.languagesLink = document.createElement("div");
        var locationLinkElem = document.createElement("a");
        //LocationChanger.languagesLink.style.margin = "0 -30px -10px 0";
        LocationChanger.languagesLink.style.position = "absolute";
        LocationChanger.languagesLink.style.bottom = "5px";
        LocationChanger.languagesLink.style.right = "10px";
        locationLinkElem.onclick = function() { Flags.ShowLanguagesDialog();  return false; };
        locationLinkElem.href = "#";
        locationLinkElem.appendChild(document.createTextNode("Choose Your Language"));
        LocationChanger.languagesLink.appendChild(locationLinkElem);
        
        LocationChanger.loginLink = document.createElement("div");
        var loginLinkElem = document.createElement("a");
        var loginTextElem = document.createElement("em");
        if (typeof(LocationChanger.loginLink.style.cssFloat) != 'undefined') LocationChanger.loginLink.style.cssFloat = "right";
        else LocationChanger.loginLink.style.styleFloat = "right";
        LocationChanger.loginLink.style.margin = "-12px -28px 0 0";
        LocationChanger.loginLink.style.color = "#696969";
        loginLinkElem.href = "http://www.metrodate.com/asp/login.aspx";
        loginLinkElem.onclick = function() { loginForm.Show(); return false; };
        loginLinkElem.style.color = "#010078";
        loginLinkElem.style.fontWeight = "bold";
        loginLinkElem.appendChild(document.createTextNode("Log In Here"));
        loginTextElem.appendChild(document.createTextNode("Already a Metrodate Member?  "));
        loginTextElem.style.padding = "0 6px 0 0";
        LocationChanger.loginLink.appendChild(loginTextElem);
        LocationChanger.loginLink.appendChild(loginLinkElem);
        
        LocationChanger.loadingImgElem = document.createElement("div");
        var loadingImgTag = document.createElement("img");
        loadingImgTag.src = LocationChanger.loadingImg.src;
        loadingImgTag.width = 100;
        loadingImgTag.height = 100;
        loadingImgTag.alt = "Loading...";
        LocationChanger.loadingImgElem.style.textAlign = "center";
        LocationChanger.loadingImgElem.style.margin = "35px auto";
        LocationChanger.loadingImgElem.appendChild(loadingImgTag);
        
        LocationChanger.windowTitle = document.createElement("h2");
        LocationChanger.windowTitle.appendChild(document.createTextNode(LocationChanger.chooseLocationTitle));
        LocationChanger.windowText = document.createElement("em");
        LocationChanger.windowText.style.fontSize = "11px";
        LocationChanger.windowText.appendChild(document.createTextNode(LocationChanger.chooseLocationText));
    }, 
    
    ShowSelectCountry: function() { 
        LocationChanger.NewDialog();
        LocationChanger.dialogContentsElem.appendChild(LocationChanger.loadingImgElem);
        
        GetAjaxContent("/ajax/locationchanger/getcountries.ashx?c=" + LocationChanger.currentCountry, LocationChanger.SelectCountryLoaded);
    }, 
    
    SelectCountryLoaded: function(response) { 
        LocationChanger.NewDialog();
        
        if (response == null || response == undefined || response == "ERROR") { 
            LocationChanger.dialogContentsElem.appendChild(document.createTextNode("We're sorry, but we could not process your request due to an unexpected communication error.  Please wait a moment and try again. (ERROR CODE: 1)"));
            return;
        }
        
        var responseType = response.split("[sectionbreak]")[0];
        var responseData = response.split("[sectionbreak]")[1].split("[break]");
        
        if (responseType == "GOTO") {
            LocationChanger.CountrySelected(responseData[0].split("[split]")[1], responseData[0].split("[split]")[0]);
            return;
        }
        
        var countriesList = document.createElement("div");
        countriesList.style.width = "180px";
        if (typeof(countriesList.style.cssFloat) != "undefined") countriesList.style.cssFloat = "right";
        else countriesList.style.styleFloat = "right";
        LocationChanger.dialogContentsElem.appendChild(countriesList);
        
        var mapContainer = document.createElement("div");
        mapContainer.style.width = "316px";
        mapContainer.style.height = "155px";
        mapContainer.style.overflow = "hidden";
        mapContainer.style.margin = "8px 0 0 0";
        mapContainer.style.background = "transparent url(/images/layout2008/home/map_1085_155ea.jpg) no-repeat scroll 0px 0px";
        LocationChanger.dialogContentsElem.appendChild(mapContainer);
        
        var mapLabel = document.createElement("div");
        mapLabel.style.textAlign = "center";
        mapLabel.style.fontSize = "10px";
        mapLabel.style.margin = "5px 0 0 0";
        mapLabel.appendChild(document.createTextNode("Click on a continent to view its countries."));
        LocationChanger.dialogContentsElem.appendChild(mapLabel);
        
        var countriesMap = document.createElement("map");
        var naArea = document.createElement("area");
        var saArea = document.createElement("area");
        var euArea = document.createElement("area");
        var afArea = document.createElement("area");
        var asArea = document.createElement("area");
        var ocArea = document.createElement("area");
        countriesMap.appendChild(naArea);
        countriesMap.appendChild(saArea);
        countriesMap.appendChild(euArea);
        countriesMap.appendChild(afArea);
        countriesMap.appendChild(asArea);
        countriesMap.appendChild(ocArea);
        
        countriesMap.id = "MapCountries";
        countriesMap.name = "MapCountries";
        
        naArea.shape = "polygon";
        naArea.coords = "13,13,8,29,23,33,29,29,22,54,40,76,66,76,84,70,69,53,109,37,111,27,128,17,141,14,143,3,53,2";
        naArea.onmouseover = function() { LocationChanger.ShiftToCountryView(mapContainer, 1); };
        naArea.onmouseout = function() { LocationChanger.ShiftToCountryView(mapContainer, 0); };
        naArea.onclick = function() { LocationChanger.ShowSelectRegion("NA", countriesList); };
        naArea.href = "#";
        
        saArea.shape = "polygon";
        saArea.coords = "59,93,67,78,95,76,121,98,100,139,98,154,76,155,67,115";
        saArea.onmouseover = function() { LocationChanger.ShiftToCountryView(mapContainer, 2); };
        saArea.onmouseout = function() { LocationChanger.ShiftToCountryView(mapContainer, 0); };
        saArea.onclick = function() { LocationChanger.ShowSelectRegion("SA", countriesList); };
        saArea.href = "#";
        
        euArea.shape = "polygon";
        euArea.coords = "152,2,195,5,197,15,192,32,191,42,177,42,166,49,132,50,139,23";
        euArea.onmouseover = function() { LocationChanger.ShiftToCountryView(mapContainer, 3); };
        euArea.onmouseout = function() { LocationChanger.ShiftToCountryView(mapContainer, 0); };
        euArea.onclick = function() { LocationChanger.ShowSelectRegion("EU", countriesList); };
        euArea.href = "#";
        
        afArea.shape = "polygon";
        afArea.coords = "195,95,204,109,187,133,153,132,146,92,126,81,129,52,176,51,186,68,190,78,202,74,197,86";
        afArea.onmouseover = function() { LocationChanger.ShiftToCountryView(mapContainer, 4); };
        afArea.onmouseout = function() { LocationChanger.ShiftToCountryView(mapContainer, 0); };
        afArea.onclick = function() { LocationChanger.ShowSelectRegion("AF", countriesList); };
        afArea.href = "#";
        
        asArea.shape = "polygon";
        asArea.coords = "288,102,288,84,274,65,297,22,296,10,232,3,196,5,198,18,193,43,179,44,171,48,180,51,183,59,190,75,199,73,210,67,221,87,233,87,236,76,245,98,256,107,266,104";
        asArea.onmouseover = function() { LocationChanger.ShiftToCountryView(mapContainer, 5); };
        asArea.onmouseout = function() { LocationChanger.ShiftToCountryView(mapContainer, 0); };
        asArea.onclick = function() { LocationChanger.ShowSelectRegion("AS", countriesList); };
        asArea.href = "#";
        
        ocArea.shape = "polygon";
        ocArea.coords = "255,129,252,111,275,106,281,104,289,103,290,90,305,104,299,113,316,123,316,149,285,147,258,136";
        ocArea.onmouseover = function() { LocationChanger.ShiftToCountryView(mapContainer, 6); };
        ocArea.onmouseout = function() { LocationChanger.ShiftToCountryView(mapContainer, 0); };
        ocArea.onclick = function() { LocationChanger.ShowSelectRegion("OC", countriesList); };
        ocArea.href = "#";
        
        mapContainer.appendChild(countriesMap);
        
        var countriesImg = document.createElement("img");
        countriesImg.src = "/images/spacer.gif";
        countriesImg.width = "316";
        countriesImg.height = "155";
        countriesImg.useMap = "#MapCountries";
        
        mapContainer.appendChild(countriesImg);
        
        if (responseType == "TOPCOUNTRIES") LocationChanger.DisplayTopCountriesList(responseData, countriesList);
        if (responseType == "REGION") LocationChanger.DisplayRegionalCountriesList(responseData, countriesList);
    }, 
    
    DisplayRegionalCountriesList: function(countries, elem) { ClearChildNodes(elem); LocationChanger.DisplayCountriesList(countries, elem); }, 
    DisplayTopCountriesList: function(countries, elem) { 
        ClearChildNodes(elem); 
        
        var title = document.createElement("div");
        title.appendChild(document.createTextNode("Common Selections:"));
        title.style.margin = "20px 0 -12px 0";
        title.style.fontWeight = "bold";
        elem.appendChild(title);
        
        LocationChanger.DisplayCountriesList(countries, elem);
    }, 
    
    DisplayCountriesList: function(countries, elem) { 
        var scroller = document.createElement("div");
        scroller.style.width = "180px";
        scroller.style.height = "250px";
        scroller.style.overflow = "auto";
        scroller.style.padding = "1px";
        scroller.style.margin = "20px 0 0 0";
        if (countries.length > 10) scroller.style.border = "1px solid #F1F1F1";
    
        for (var c=0, country; country = countries[c]; c++) { 
            var code = country.split("[split]")[0];
            var name = country.split("[split]")[1];
            
            var countryLink = document.createElement("a");
            countryLink.href="#";
            countryLink.onclick = function(name, code) { return function() { LocationChanger.CountrySelected(name, code); return false; }; }(name, code);
            countryLink.appendChild(document.createTextNode(name));
            
            scroller.appendChild(countryLink);
            scroller.appendChild(document.createElement("br"));
        }
        
        elem.appendChild(scroller);
    }, 
    
    ShiftToCountryView: function(viewElem, viewNum) { 
        viewElem.style.backgroundPosition = "0px " + (viewNum * -155) + "px";
    }, 
    
    ShowSelectRegion: function(region, viewElem) { 
        GetAjaxContent("/ajax/locationchanger/getcountries.ashx?c=" + LocationChanger.currentCountry + "&r=" + region, function(response) { LocationChanger.SelectRegionLoaded(response, viewElem); });
    }, 
    
    SelectRegionLoaded: function(response, viewElem) { 
        if (response == null || response == undefined || response == "ERROR") { 
            LocationChanger.dialogContentsElem.appendChild(document.createTextNode("We're sorry, but we could not process your request due to an unexpected communication error.  Please wait a moment and try again. (ERROR CODE: 1)"));
            return;
        }
        
        var responseType = response.split("[sectionbreak]")[0];
        var responseData = response.split("[sectionbreak]")[1].split("[break]");
        
        if (responseType == "TOPCOUNTRIES") LocationChanger.DisplayTopCountriesList(responseData, viewElem);
        if (responseType == "REGION") LocationChanger.DisplayRegionalCountriesList(responseData, viewElem);
    }, 
    
    CountrySelected: function(countryName, countryCode) { 
        LocationChanger.NewDialog();
        LocationChanger.dialogContentsElem.appendChild(LocationChanger.loadingImgElem);
    
        LocationChanger.workingCountryName = countryName;
        LocationChanger.workingCountry = countryCode;
        GetAjaxContent("/ajax/locationchanger/getcountryaction.ashx?c=" + LocationChanger.workingCountry, LocationChanger.DoGetCityAction);
    }, 
    
    DoGetCityAction: function(response) { 
        if (response == null || response == undefined || response == "ERROR") { 
            LocationChanger.NewDialog();
            LocationChanger.dialogContentsElem.appendChild(document.createTextNode("We're sorry, but we could not process your request due to an unexpected communication error.  Please wait a moment and try again. (ERROR CODE: 2)"));
            return;
        }
        
        var action = response.split("[sectionbreak]")[0];
        var instructions = response.split("[sectionbreak]")[1];
        
        if (action == "SINGLECITY") { 
            LocationChanger.workingCityId = instructions.split("[split]")[0];
            var countryDirectory = instructions.split("[split]")[1];
            document.location.href = "http://www.metrodate.com/" + countryDirectory + "/";
        }
        else if (action == "ZIPLOOKUP") { 
            LocationChanger.ShowZipLookup(instructions);
        }
        else if (action == "CITIESLIST") { 
            LocationChanger.ShowCitiesListDialog(instructions);
        }
    }, 
    
    ShowZipLookup: function(zipLabel) { 
        LocationChanger.NewDialog();
        LocationChanger.dialogContentsElem.appendChild(LocationChanger.GetSelectedCountryText());
        
        var formSubmitAction = function() { LocationChanger.DoZipLookup(zipField.value, zipLabel, zipListing, zipErrors); return false; };
        var zipForm = document.createElement("div");
        zipForm.style.margin = "12px 0 0 35px";
        
        var title = document.createElement("h3");
        title.appendChild(document.createTextNode("Please enter your " + LocationChanger.workingCountryName + " " + zipLabel + ":"));
        zipForm.appendChild(title);
        zipForm.appendChild(document.createElement("br"));
    
        var fieldTitle = document.createElement("strong");
        fieldTitle.style.display = "block";
        fieldTitle.appendChild(document.createTextNode(zipLabel + ":"));
        zipForm.appendChild(fieldTitle);
        
        var zipField = document.createElement("input");
        zipField.type = "text";
        zipField.maxlength = "16";
        zipField.value = ReadCookie("zip");
        zipField.style.width = "150px";
        zipField.onkeypress = function(event) { return SubmitOnEnter(event, formSubmitAction); };
        zipForm.appendChild(zipField);
        
        var zipButton = document.createElement("input");
        zipButton.type = "button";
        zipButton.className = "btnPurple_100";
        zipButton.value = "Go    ";
        zipButton.style.margin = "0 0 10px 10px";
        zipButton.onclick = formSubmitAction;
        zipForm.appendChild(zipButton);
        zipForm.appendChild(document.createElement("br"));
        
        var zipListing = document.createElement("div");
        zipForm.appendChild(zipListing);
        
        var zipErrors = document.createElement("div");
        zipErrors.style.fontWeight = "bold";
        zipErrors.style.color = "#B8001A";
        zipForm.appendChild(zipErrors);
        
        LocationChanger.dialogContentsElem.appendChild(zipForm);
        setTimeout(function() { zipField.focus(); zipField.select(); }, 150);
    }, 
    
    DoZipLookup: function(zipCode, zipLabel, listingElem, errorElem) { 
        ClearChildNodes(errorElem);
        ClearChildNodes(listingElem);
    
        if (zipCode == null || zipCode == undefined || zipCode.length <= 0) { 
            errorElem.appendChild(document.createTextNode("Please enter a " + zipLabel + " to search for."));
            return;
        }
    
        errorElem.appendChild(LocationChanger.loadingImgElem);
        GetAjaxContent("/ajax/locationchanger/getzipsearch.ashx?c=" + LocationChanger.workingCountry + "&z=" + zipCode, function(response) { LocationChanger.ShowZipLookupResults(zipCode, zipLabel, listingElem, errorElem, response); });
    }, 
    
    ShowZipLookupResults: function(zipCode, zipLabel, listingElem, errorElem, response) { 
        if (response == null || response == undefined || response == "ERROR") { 
            LocationChanger.NewDialog();
            LocationChanger.dialogContentsElem.appendChild(document.createTextNode("We're sorry, but we could not process your request due to an unexpected communication error.  Please wait a moment and try again. (ERROR CODE: 3)"));
            return;
        }
        
        ClearChildNodes(errorElem);
        ClearChildNodes(listingElem);
        
        if (response == "INVALIDZIP")
            errorElem.appendChild(document.createTextNode("The " + zipLabel + " \"" + zipCode + "\" is not in the correct format for " + LocationChanger.workingCountryName + ".  Please correct any errors and try again."));
        else if (response == "NOMATCH")
            errorElem.appendChild(document.createTextNode("We could not locate any cities near this " + zipLabel + "."));
        else { 
            CreateCookie("zip", zipCode, 60);
            CreateCookie("country", LocationChanger.workingCountry, 60);
            
            /*         
            // This lets the user select their closest city
            // However, we currently automatically take them to their closest city
            
            var listingTitle = document.createElement("h3");
            listingTitle.appendChild(document.createTextNode("Search Results"));
            listingElem.appendChild(listingTitle);
            LocationChanger.ShowCitiesList(response, listingElem);
            */
            
            var cities = response.split("[break]");
            var cityDirectory = cities[0].split("[split]")[1];
            var cityID = cities[0].split("[split]")[2];
            var locationEdition = cities[0].split("[split]")[3];
            
            // if we can change dynamically (have the changer script and have only changed city, not country, and are not on an alternate domain)
            if (document.location.href.indexOf("metrodate.com") >= 0 && LocationChanger.currentCountry == LocationChanger.workingCountry && typeof(HomepageBranding) != "undefined")
            { 
                HomepageBranding.CheckNewZipResponse(zipCode, LocationChanger.workingCountry, -1, cityID + "|" + locationEdition);
                LocationChanger.HideDialog();
            }
            else
            { 
            	// Reload the page because of the new country
            	// No longer need to link to city directory here, which causes problems if the user is too far from mdcity and we want to show country name
            	// The country and zip cookie is all we need
                document.location.href = "http://www.metrodate.com/"; // + cityDirectory + "/";
            }
        }
    }, 
    
    ShowCitiesListDialog: function(citiesData) { 
        LocationChanger.NewDialog();
        LocationChanger.dialogContentsElem.appendChild(LocationChanger.GetSelectedCountryText());
        
        var citiesList = document.createElement("div");
        citiesList.style.margin = "12px 0 0 35px";
        
        var title = document.createElement("h3");
        title.appendChild(document.createTextNode("Select Your Closest City"));
        citiesList.appendChild(title);
        
        LocationChanger.ShowCitiesList(citiesData, citiesList);
        LocationChanger.dialogContentsElem.appendChild(citiesList);
    }, 
    
    ShowCitiesList: function(citiesData, containerElem) { 
        var cities = citiesData.split("[break]");
        for (var c=0, city; city = cities[c]; c++) { 
            var cityName = city.split("[split]")[0];
            var cityDirectory = city.split("[split]")[1];
            var cityID = city.split("[split]")[2];
            var locationEdition = city.split("[split]")[3];
            
            var cityLink = document.createElement("a");
            cityLink.href = "http://www.metrodate.com/" + cityDirectory + "/";
            if (document.location.href.indexOf("metrodate.com") >= 0 && LocationChanger.currentCountry == LocationChanger.workingCountry && typeof(HomepageBranding) != "undefined") // if this is the same country, the user is on the home page already, and they are not on an alternate domain, we can change by AJAX
                cityLink.onclick = function(thisCityID, thisLocationEdition) { 
                        return function() { 
                            HomepageBranding.CheckNewZipResponse("", LocationChanger.workingCountry, -1, thisCityID + "|" + thisLocationEdition); 
                            LocationChanger.HideDialog();
                            return false;
                        }
                    }(cityID, locationEdition);
            cityLink.appendChild(document.createTextNode(cityName));
            
            containerElem.appendChild(cityLink);
            containerElem.appendChild(document.createElement("br"));
        }
        
        var instrText = document.createElement("div");
        instrText.style.fontSize = "11px";
        instrText.style.fontStyle = "italic";
        instrText.appendChild(document.createTextNode("If you don't see your city, simply select the city closest to you."));
        
        containerElem.appendChild(document.createElement("br"));
        containerElem.appendChild(instrText);
    }, 
    
    GetSelectedCountryText: function() { 
        var countryblock = document.createElement("em");
        countryblock.style.display = "block";
        countryblock.style.margin = "10px 0 0 0";
        countryblock.style.fontSize = "11px";
        
        var boldlabel = document.createElement("strong");
        boldlabel.appendChild(document.createTextNode(LocationChanger.workingCountryName));
        
        var restartLink = document.createElement("a");
        restartLink.href = "#";
        restartLink.onclick = function() { LocationChanger.HideDialog(); LocationChanger.SelectCity(); return false; };
        restartLink.style.fontStyle = "normal";
        restartLink.style.fontSize = "11px";
        restartLink.appendChild(document.createTextNode("\u00abChange Country"));

        countryblock.appendChild(document.createTextNode("You selected "));
        countryblock.appendChild(boldlabel);
        countryblock.appendChild(document.createTextNode("."));
        
        countryblock.appendChild(document.createElement("br"));
        countryblock.appendChild(restartLink);
        return countryblock;
    }, 
    
    NewDialog: function() { 
        ClearChildNodes(LocationChanger.dialogContentsElem);
        if (LocationChanger.currentCityId > 0) LocationChanger.dialogContentsElem.appendChild(LocationChanger.closeLink);
        else LocationChanger.dialogContentsElem.appendChild(LocationChanger.loginLink);
        LocationChanger.dialogContentsElem.appendChild(LocationChanger.windowTitle);
        LocationChanger.dialogContentsElem.appendChild(LocationChanger.windowText);
        LocationChanger.dialogContentsElem.appendChild(LocationChanger.languagesLink);
    }, 
    
    PositionDialog: function() { 
        LocationChanger.dialogContainerElem.style.left = GetScreenCenteredX(580) + "px";
        LocationChanger.dialogContainerElem.style.top = GetScreenCenteredY(400) + "px";
    }, 
    
    HideDialog: function() { 
        clearInterval(LocationChanger.positionInterval);
        var dropbox = Get("EntityDropbox");
        dropbox.removeChild(LocationChanger.dialogContainerElem);
        dropbox.removeChild(LocationChanger.curtainElem);
        dropbox = null;
    }
};