function openWindow(archivo, width, height) {
	var left   = (screen.width  - width)/2;
	var top    = (screen.height - height)/2;
	var params = 'width='+width+', height='+height;
	params += ', top='+top+', left='+left;
	params += ', directories=no';
	params += ', location=no';
	params += ', menubar=no';
	params += ', resizable=no';
	params += ', scrollbars=yes';
	params += ', status=no';
	params += ', toolbar=no';
	
	ventana = window.open(archivo,'Aviso',params);
}

function isInt (str)
{
	var i = parseInt (str);

	if (isNaN (i))
		return false;

	i = i . toString ();
	if (i != str)
		return false;

	return true;
}

function validarEmail(valor) {
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(valor)){
		return (true)
	} else {
		return (false);
	}
}

function validarRegistro()
{
	miss="";
	try {
	if(document.getElementById('nombre').value < 1)
	{
		miss+="\n- El campo Nombre es obligatorio.";
		document.getElementById('nombre').style.borderColor ="#fdc5c5";
	}

	if(document.getElementById('apellidos').value < 1)
	{
		miss+="\n- El campo Apellidos es obligatorio.";
		document.getElementById('apellidos').style.borderColor ="#fdc5c5";
	}
	
	if(document.getElementById('direccion').value < 1)
	{
		miss+="\n- El campo Dirección es obligatorio.";
		document.getElementById('direccion').style.borderColor ="#fdc5c5";
	}
	
	if(document.getElementById('localidad').value < 1)
	{
		miss+="\n- El campo Localidad es obligatorio.";
		document.getElementById('localidad').style.borderColor ="#fdc5c5";
	}
	
	if(document.getElementById('pais').value < 1)
	{
		miss+="\n- El campo País es obligatorio.";
		document.getElementById('pais').style.borderColor ="#fdc5c5";
	}
		
	if(document.getElementById('email').value < 1)
	{
		miss+="\n- El campo Email es obligatorio.";
		document.getElementById('email').style.borderColor ="#fdc5c5";
	}
	else
	{
		if(!validarEmail(document.getElementById('email').value))
		{
			miss+="\n- Direccion email incorrecta.";
			document.getElementById('email').style.borderColorr ="#fdc5c5";
		}
		
	}
	
	if(document.getElementById('usuario_registro').value < 1)
	{
		miss+="\n- El campo Usuario es obligatorio.";
		document.getElementById('usuario_registro').style.borderColor ="#fdc5c5";
	}
	
	if(document.getElementById('password_registro').value < 1)
	{
		miss+="\n- El campo Contraseña es obligatorio.";
		document.getElementById('password_registro').style.borderColor ="#fdc5c5";
	}

	if(document.getElementById('confirmar_password_registro').value < 1)
	{
		miss+="\n- El campo Confirmar Contraseña es obligatorio.";
		document.getElementById('confirmar_password_registro').style.borderColor ="#fdc5c5";
	}
	
	if(document.getElementById('password_registro').value != document.getElementById('confirmar_password_registro').value)
	{
		miss+="\n- Los campos Contraseña y Confirmar Contraseña no coinciden.";
		document.getElementById('password_registro').style.borderColor ="#fdc5c5";
		document.getElementById('confirmar_password_registro').style.borderColor ="#fdc5c5";
	}
	
	if(!document.getElementById('acepto').checked)
	{
		miss+="\n- Debe aceptar las condiciones expresadas en la política de privacidad.";
		document.getElementById('acepto').style.borderColor ="#fdc5c5";
	}

	
	if(miss!="")
	{
		alert("Faltan los siguientes datos:\n"+miss);
		return false;
	}
	return true;
	}
	catch(e)
	{
		alert(e);
	  return false;	
	}
}

function validarContacto()
{
	miss="";
	try {
	if(document.getElementById('nombre').value < 1)
	{
		miss+="\n- El campo Nombre es obligatorio.";
		document.getElementById('nombre').style.borderColor ="#fdc5c5";
	}

	if(document.getElementById('apellidos').value < 1)
	{
		miss+="\n- El campo Apellidos es obligatorio.";
		document.getElementById('apellidos').style.borderColor ="#fdc5c5";
	}
	
	if(document.getElementById('email').value < 1)
	{
		miss+="\n- El campo Email es obligatorio.";
		document.getElementById('email').style.borderColor ="#fdc5c5";
	}
	else
	{
		if(!validarEmail(document.getElementById('email').value))
		{
			miss+="\n- Direccion email incorrecta.";
			document.getElementById('email').style.borderColorr ="#fdc5c5";
		}
		
	}
	
	if(document.getElementById('consulta').value < 1)
	{
		miss+="\n- El campo Consulta es obligatorio.";
		document.getElementById('consulta').style.borderColor ="#fdc5c5";
	}
	
	if(!document.getElementById('acepto').checked)
	{
		miss+="\n- Debe aceptar las condiciones expresadas en la política de privacidad.";
		document.getElementById('acepto').style.borderColor ="#fdc5c5";
	}

	
	if(miss!="")
	{
		alert("Faltan los siguientes datos:\n"+miss);
		return false;
	}
	return true;
	}
	catch(e)
	{
		alert(e);
	  return false;	
	}
}

function validarParticipacion()
{
	miss="";
	try {
	if(!document.getElementById('acepto').checked)
	{
		miss+="\n- Debe aceptar las condiciones expresadas en la política de privacidad.";
		document.getElementById('acepto').style.borderColor ="#fdc5c5";
	}
	
	if(miss!="")
	{
		alert("Faltan los siguientes datos:\n"+miss);
		return false;
	}
	return true;
	}
	catch(e)
	{
		alert(e);
	  return false;	
	}
}

function validarMensajeForo()
{
	miss="";
	try {
	if(document.getElementById('titulo').value < 1)
	{
		miss+="\n- El campo Titulo es obligatorio.";
		document.getElementById('titulo').style.borderColor ="#fdc5c5";
	}
	
	/*if(document.getElementById('texto').value < 1)
	{
		miss+="\n- El campo Texto es obligatorio.";
		document.getElementById('texto').style.borderColor ="#fdc5c5";
	}*/
	
	if(miss!="")
	{
		alert("Faltan los siguientes datos:\n"+miss);
		return false;
	}
	return true;
	}
	catch(e)
	{
		alert(e);
	  return false;	
	}
}

function validarMensajeLibroVisitas()
{
	miss="";
	try {
	if(document.getElementById('nombre').value < 1)
	{
		miss+="\n- El campo Nombre es obligatorio.";
		document.getElementById('nombre').style.borderColor ="#fdc5c5";
	}

	if(document.getElementById('email').value < 1)
	{
		miss+="\n- El campo Email es obligatorio.";
		document.getElementById('email').style.borderColor ="#fdc5c5";
	}
	else
	{
		if(!validarEmail(document.getElementById('email').value))
		{
			miss+="\n- Direccion email incorrecta.";
			document.getElementById('email').style.borderColorr ="#fdc5c5";
		}
		
	}

	if(document.getElementById('texto').value < 1)
	{
		miss+="\n- El campo Texto es obligatorio.";
		document.getElementById('texto').style.borderColor ="#fdc5c5";
	}
	
	if(miss!="")
	{
		alert("Faltan los siguientes datos:\n"+miss);
		return false;
	}
	return true;
	}
	catch(e)
	{
		alert(e);
	  return false;	
	}
}

function validarCompraLimpiezas()
{
	miss="";
	try {
	if(document.getElementById('numero').value < 1 || !isInt(document.getElementById('numero').value))
	{
		miss+="\n- El campo Número de Limpiezas es obligatorio y debe ser un número.";
		document.getElementById('numero').style.borderColor ="#fdc5c5";
	}
	
	if(document.getElementById('nombres').value < 1)
	{
		miss+="\n- El campo Nombres y Apellidos es obligatorio.";
		document.getElementById('nombres').style.borderColor ="#fdc5c5";
	}
	
	if(miss!="")
	{
		alert("Faltan los siguientes datos:\n"+miss);
		return false;
	}
	return true;
	}
	catch(e)
	{
		alert(e);
	  return false;	
	}
}