function reloadForm(formulario)
{
	document.getElementById(formulario).submit();
}
function limpiaCampo(campo, original)
{
	if(document.getElementById(campo).value == original)
	{
		document.getElementById(campo).value = '';
	}
}
function rellenaCampo(campo, alternativo)
{
	if(document.getElementById(campo).value == '')
	{
		document.getElementById(campo).value = alternativo;
	}
}
function submitForm(campos, etiquetas, formulario)
{
	var mensaje = 'Los siguientes campos son obligatorios';
	for(x = 0; x < campos.length; x++)
	{
		if(document.getElementById(campos[x]).value == '')
		{
			mensaje += '\n - '+etiquetas[x]+'.';
		}
	}
	if(mensaje != 'Los siguientes campos son obligatorios')
	{
		alert(mensaje);
	}
	else
	{
		document.getElementById('accion').value = 'registrar';
		document.getElementById(formulario).submit();
	}
}
function calendario(objetivo){
	var ruta = 'calendario.php?objetivo=';
	ruta += objetivo;
	nuevoPopUp(ruta,'calendario');
}

function nuevoPopUp(ruta, nombre)
{
	var ancho = 350;
	var alto = 150;
	izquierda=(screen.width)?(screen.width - ancho)/2:100;
	arriba=(screen.height)?(screen.height - alto)/2:100;
	var opciones = 'width='+ancho+',height='+alto+',top='+arriba+',left='+izquierda+',scrollbars=no,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
	window.open(ruta, nombre, opciones);
}
function PopUpDevolucion(ruta, nombre){
	var ancho = 800;
	var alto = 600;
	izquierda=(screen.width)?(screen.width - ancho)/2:100;
	arriba=(screen.height)?(screen.height - alto)/2:100;
	var opciones = 'width='+ancho+',height='+alto+',top='+arriba+',left='+izquierda+',scrollbars=yes,location=no,directories=no,status=no,menubar=no,toolbar=yes,resizable=no';
	window.open(ruta, nombre, opciones);
}
function retornaValor(valor, objetivo){
	window.opener.recibeValor(valor, objetivo);
	window.close();
}

function recibeValor(valor, objetivo){
	document.getElementById(objetivo).value = valor;
}