﻿$(function(){
  var change_location = $("#change-location");
  var baseURL = $("#home")[0].href;
  // Add a close (X) button to the dialog
  $("#change-location h2").append("<a class='close' href='#'><img alt='close' src='" + baseURL + "images/icon_close.gif' /></a>");
  change_location.jltDialog();

  $(".locale a").click( function() {
    $("#change-location").data("jltDialog").open();
    change_location.width(580);
    // Position the dialog in the centre of the browser window
    var dialogLeft = ($(window).width() - change_location.width()) / 2;
    var dialogTop = ($(window).height() - change_location.height()) / 2;
    change_location.css({
      left: dialogLeft + "px",
      top: (dialogTop + "px"),
      display: "block" // in layout.css, this value is set to 'none' by default so we have to re-display it
    });
    return false;
  });

  $("#change-location a.close").click(function() {
    change_location.data("jltDialog").close();
    return false;
  });
});

