function initNews() {
	$('name').focus();
	$('news_form').onsubmit = validateForm;
}

function validateForm() {
	var res = true;
	var required = new Array();
	// Si ya ha habido un mensaje de error lo quitamos
	if ($('js_errors')) {
	  $('js_errors').destroy();
	  }
	  
	// Cambiamos el style del div de confirmacion a oculto por si fué mostrado anteriormente
	$('confirmacion').setStyle('display', 'none');
	
	required.push('email','name','category');
	if (!checkEmail($('email').get('value'))) {
		markError($('email'));
		res = false;
	}
	for (var i=0;i<required.length;++i) {
		if ($(required[i]).get('value').length == 0) {
			markError($(required[i]));
			res = false;
		}
	}
	if (!res) {
		displayErrorMessageHTML(errorMessage1, this);
	} else {
		if ($('privacy')) {
			if (!checkPolicyDos()) {
				displayErrorMessageHTML(errorMessage2,'news_form');
				markError($('privacy'));
				res = false;
			}
			else {
				this.set('send', {
						 //method: 'get',
						 onRequest: function() { $('loader').addClass('cargando'); },
						 onComplete: function(responseHTML) { 
						 	$('confirmacion').setStyle('display', 'block');
							//$('confirmacion').set('html',responseHTML);
							$('loader').removeClass('cargando'); }
						 });
				this.send();
				res = false;
			}
		} // fin if privacy
		else {
			this.set('send', {
						 //method: 'get',
						 onRequest: function() { $('loader').addClass('cargando'); },
						 onComplete: function(responseHTML) { 
						 	$('confirmacion').setStyle('display', 'block');
							//$('confirmacion').set('html',responseHTML);
							$('loader').removeClass('cargando'); }
						 });
			this.send();
			res = false;
		} // fin else privacy
	}
	return res;
}

function checkPolicyDos() {
	return $('privacy').get('checked');
}

window.addEvent('domready', initNews);