function mailValido(elemento)
{
	return /^[(a-z)][\w-\.]{3,}@([\w-]{2,}\.)*([\w-]{2,}\.)[\w-]{2,4}$/i.test (elemento.toLowerCase());
}
function attach_file( p_script_url )
{
	script = document.createElement( 'script' );
	script.src = p_script_url;
	document.getElementsByTagName( 'head' )[0].appendChild( script );
}
function validarFormNews()
{
	var url = document.getElementById('newsIndBase').value+'ajax/registra_news.php';
	//validar nombre
	var pan = document.getElementById('newsIndName');
	if (null == pan || '' == pan.value.replace(/ /i, "").length)
	{
		alert('NAME');
		return;
	}
	url = url + '?name='+pan.value;
	
	pan = document.getElementById('newsIndMail');
	if (null == pan || !mailValido(pan.value))
	{
		alert('EMAIL');
		return;
	}
	url = url + '&mail='+pan.value;
	url = url + '&lang='+document.getElementById('newsIdioma').value;	
	var a =Math.floor(Math.random()*10)+1;
	var b =Math.floor(Math.random()*10)+1;

	var res = prompt('Captcha: '+a+' + '+b+' = ?');

	if (res != a+b)
	{
		alert("Wrong result");
		return (false);
	}
	document.getElementById('top_frm').style.display='none';
	document.getElementById('newsIco').style.display='';	
	attach_file(url);	
}
function abrirDestino(cbo)
{
	window.open(cbo.value,'_blank');
}
function restaurar()
{
	document.getElementById('top_frm').style.display='';
	document.getElementById('newsIco').style.display='none';
	document.getElementById('newsMsj').style.display='none';
}
