var NewsLetter = {
  
  sendData: function (type) {

  	$('nl_error').show();
  	$('nl_form').hide();  	
  	 	
  	new Ajax.Request('index.php?op=newsletter&action=' + type, {
  		postBody: $('newsl_form').serialize() + '&ajax=1',
  		
  		onComplete: function(request) {
  		  
  		  var errorCode = parseInt(request.responseText.substring(0, 1));
  		  
  		  if (isNaN(errorCode)) {
  		    $('nl_errortext').update('<table><tr><td>DATA ERROR</td></tr></table>');  		    
  		  } else {
  		    $('nl_errortext').update('<table><tr><td>' + request.responseText.substring(1) + '</td></tr></table>');
  		  }
  		  
  		  if (isNaN(errorCode) || (errorCode == 1) || (errorCode == 2)) {
  		    $('newsl_form').reset();
  		  }
  		   		   		  
  		},
  		
  		onFailure: function () { $('nl_errortext').update('<table><tr><td>LOAD ERROR</td></tr></table>'); }
  	  
  	}); 	
  },

  backForm: function () {
  	$('nl_error').hide();
  	$('nl_form').show();
  	$('nl_errortext').update();
  }

}
