var nlEL = null;
function subscripe(addr) {
  if (nlEL != null)
    closeNL(true);
  
  nlEL = $('#newsletterResponse');
  nlEL.html($('#responseTemplate').html());
  nlEL.show().animate({
    height: '112px',
    top: '190px'
  }, 500, 'swing');
  
  $.ajax({
    url: "/subscribe.json?email=" + $('#email').val(),
    type: "post",
    dataType: "json",
    success: function( data, status ) {
      if (data == null) {
        return;
      }
      
      $('#nlResponseText').text(data[0].result);
    }
  });
  
  return false;
}

function closeNL(now) {
  if (nlEL == null)
    return;
  
  if (now) {
    nlEL.hide().html('').css({'height' : '0px', 'top' : '251px'});
    nlEL = null;
    $('#nlResponseText').text('');
    return;
  }
  
  nlEL.animate({
    height: '0px',
    top: '251px'
  }, 200, 'swing', function() {
    nlEL.hide().html('');
    nlEL = null;
    $('#nlResponseText').text('');
  });
  
  return false;
}

