document.observe("dom:loaded", function() {
  var time_zone = $("signup[time_zone]");
  if (!time_zone) return;
  if (time_zone.selectedIndex > 0) return;
  
  var offset = - new Date().getTimezoneOffset();

  var option = time_zone.childElements().detect(function(option) {
    var parts = option.innerHTML.match(/GMT(\+|-)(\d{2}):(\d{2})/)
    if (!parts) return false;

    var sign = parts[1];
    var hours = parseInt(parts[2]);
    var minutes = parseInt(parts[3]);
    
    var value = (hours * 60) + minutes
    if (sign == "-") value = -value;
    
    return offset == value;
  });
  
  if (option) option.selected = 1
});
