function enableDateField(pattern) {
  if (typeof pattern == 'undefined') {
    pattern = '%d/%m/%Y';
  }
  var _now = new Date();

  if ($('birthday1')) {
    $('trigger_birthday1').disabled = false;
    Calendar.setup({ 'inputField': 'birthday1', 'ifFormat': pattern, 'button': 'trigger_birthday1', 'range': [_now.getFullYear()-99, _now.getFullYear()-18], 'weekNumbers': false, 'showOthers': true });
  }
  if ($('birthday2')) {
    $('trigger_birthday2').disabled = false;
    Calendar.setup({ 'inputField': 'birthday2', 'ifFormat': pattern, 'button': 'trigger_birthday2', 'range': [_now.getFullYear()-99, _now.getFullYear()-18], 'weekNumbers': false, 'showOthers': true });
  }
}
function checkNextStep()
{
  if ($('nextstep') !== undefined) {
    $('pass2').className='';
    $('pass3').className='current';
  }
}

function checkHandleAvailability(handle)
{
  new Ajax.Request('/sign/checkHandle?handle='.concat(handle), {
    asynchronous: true,
    method: 'get',
    onSuccess: function(request, json) {
      displayAlert(request.responseText);
    }
  });
}

function displayAlert(data)
{
  var pdata = data.evalJSON();
  $('handle_container').className = pdata[1];
  Element.update('handle_check', pdata[0]);
}
