function abrirImagen(pIDNoticia, pArchivo, pAncho, pAlto)
{
	var oVentana = new Window(
		{
			className: "alphacube",
			title: "Murten Sistemas de Control - Vista ampliada",
			width: pAncho,
			height: pAlto,
			left: 275,
			top: 180,
			draggable: true,
			resizable: true,
			minimizable: false,
			maximizable: false,
			destroyOnClose: true
		}
	);
	oVentana.show();
	var sURL = "ver-imagen.php?idregistro=" + pIDNoticia + "&archivo=" + pArchivo;
	oVentana.setAjaxContent(sURL);
}

function cerrarSesion()
{
		location.href = "index.php?exit=1";
}

function validarLoginUsuario(pForm, $sURL)
{
	with(pForm)
		if (txtUsuario.value.length > 0 && txtClave.value.length > 0) {
		x_ValidarLoginUsuario(txtUsuario.value, txtClave.value, function(pCadena)
		{
			if(pCadena == "S")
				//location.reload(true);
				location.href=$sURL;
			else
				alert(pCadena);
		});
		} else {
			alert("Ingrese su nombre de usuario y contraseña");
			txtUsuario.focus();
			return false;
		}
	return false;
}

function validarEmail(pEmail)
{
	var oRegExp = /^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$/;
	return oRegExp.test(pEmail);
}

function validarBusqueda(pForm)
{
	with(pForm)
	{
		if(q.value.length > 0)
			return true;
		else
		{
			alert("Por favor, ingrese un parámetro de búsqueda");
			q.focus();
		}
	}
	return false;
}

function retornarFecha()
{
	var aDias = new Array("Domingo", "Lunes", "Martes",
		"Mi&eacute;rcoles",  "Jueves", "Viernes", "S&aacute;bado");
	var aMeses = new Array("Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre");
	
	var dFecha = new Date();
	with(dFecha)
	{
		var lIDDia = getDay();
		var sDia = new String(getDate());
		//var sMes = new String(getMonth() + 1);
		var sMes = getMonth();
		var lAno = getYear();
		var sHora = new String(getHours());
		var sMinutos = new String(getMinutes());
	}
	if(sDia.length == 1) sDia = "0" + sDia;
	if(sMes.length == 1) sMes = "0" + sMes;
	if(lAno < 1900) lAno += 1900;
	if(sHora.length == 1) sHora = "0" + sHora;
	if(sMinutos.length == 1) sMinutos = "0" + sMinutos;
	pFecha = document.getElementById("tdFecha");
	//pFecha.innerHTML = aDias[lIDDia] + ", " + sDia + " de " + aMeses[sMes] + " de " + lAno + " - " + sHora + ":" + sMinutos;
	pFecha.innerHTML = aMeses[sMes] + " de " + lAno;
}

function EnviarContacto(pForm)
{
	with(pForm)
	{
		if(txtNombres.value.length > 0)
		{
			if(txtEmpresa.value.length > 0)
			{
				if(txtCargo.value.length > 0)
				{
					if(txtEmail.value.length > 0)
					{
						if(validarEmail(txtEmail.value))
						{
							if(txtTelefono.value.length > 0)
							{
								x_EnviarContacto(txtNombres.value, txtEmpresa.value, txtCargo.value, txtEmail.value, txtTelefono.value, txtDireccion.value, txtCiudad.value, txtProvincia.value, txtPais.value, negocioTipo.value, negocioInd.value, conocio.value, controladores.checked, paneles.checked, sensores.checked, sistmedida.checked, sistvision.checked, lectores.checked, senstemp.checked, senscolor.checked, otros.value, chkinformacion.checked, chkproyecto.checked, chkvisita.checked, chkenvioinfo.checked, txtMensaje.value, function(pCadena)
											{
												alert("Su mensaje ha sido enviado");
												pForm.reset();
											});
									}
									else
									{
										alert("Por favor, ingrese un Telefono");
										txtTelefono.focus();
									}
							}
							else
							{
									alert("Por favor, ingrese un Email válido");
									txtEmail.focus();
							}
						}
						else
						{
							alert("Por favor, ingrese un Email");
							txtEmail.focus();
						}
					}
					else
					{
						alert("Por favor, ingrese un Cargo");
						txtCargo.focus();
					}
				}
				else
				{
					alert("Por favor, ingrese un Empresa");
					txtEmpresa.focus();
				}
		}		
		else
		{
			alert("Por favor, ingrese su Nombre");
			txtNombres.focus();
		}
	}
	return false;
}

function mostrarInput()
{
	var check = document.getElementById('chkotros');
	var input = document.getElementById('td_input');
	
	if(check.checked)
	{
		input.style.display = 'block';
	}
	else
	{
		input.style.display = 'none';
	}
}

function EnviarInscripcion(pForm)
{
	with(pForm)
	{
		if(txtNombres.value.length > 0)
		{
			if(txtDomicilio.value.length > 0)
			{
				if(txtCiudad.value.length > 0)
				{
					if(txtProvincia.value.length > 0)
					{
						if(validarEmail(txtEmail.value))
						{
							if(txtMensaje.value.length > 0)
							{
									x_GuardarInscripcion(txtIDCapacitacion.value, txtFecha.value, txtNombres.value, txtEmail.value,
										txtCiudad.value, txtDomicilio.value, txtProvincia.value, txtTelefono.value, txtMensaje.value, function(pCadena)
											{
												alert("Su mensaje ha sido enviado");
												pForm.reset();
											});
									}
									else
									{
										alert("Por favor, ingrese un Mensaje");
										txtMensaje.focus();
									}
								}
								else
								{
									alert("Por favor, ingrese un Email válido");
									txtEmail.focus();
								}
							}
						else
						{
							alert("Por favor, ingrese una Provincia");
							txtProvincia.focus();
						}
					}
					else
					{
						alert("Por favor, ingrese una Localidad");
						txtCiudad.focus();
					}
				}
			else
				{
					alert("Por favor, ingrese un Domicilio");
					txtDomicilio.focus();
				}
			}
			
		else
		{
			alert("Por favor, ingrese su Nombre y Apellido");
			txtNombres.focus();
		}
	}
	return false;
}

function guardarRegistro(pForm)
{
	with(pForm)
	{
		if(nombres.value.length > 0)
		{
			if(apellido.value.length > 0)
			{
				if(validarEmail(email.value))
				{
					if(usuario.value.length > 0)
					{
						if(clave.value.length > 0)
						{
							if(localidad.value.length > 0)
							{
								if(provincia.value.length > 0)
								{
										
											x_GuardarRegistro(nombres.value, apellido.value, email.value, usuario.value, clave.value, localidad.value, provincia.value, function(pCadena)
													{
														alert("Gracias por Registrarse");
														pForm.reset();
													});									
			
									}
									else
									{
										alert("Por favor, ingrese una Provincia");
										provincia.focus();
									}
			
								}
								else
								{
									alert("Por favor, ingrese una Ciudad");
									localidad.focus();
								}
								
							}
							else
							{
								alert("Por favor, ingrese una Clave");
								clave.focus();
							}
					}
					else
					{
						alert("Por favor, ingrese un Usuario");
						usuario.focus();
					}
				}
				else
					{
						alert("Por favor, ingrese un Email válido");
						email.focus();
					}
				}
			else
				{
					alert("Por favor, ingrese su Apellido");
					apellido.focus();
				}
			}
		else
		{
			alert("Por favor, ingrese su Nombre");
			nombres.focus();
		}
	}
	return false;
}

//****Banners***//

function GuardarClic(pIDBanner)
{
	x_GuardarClic(pIDBanner, function(pCadena)
		{
		});
}

function mostrarForm()
{
	var tConsulta = document.getElementById("trConsulta");
	tConsulta.className = (tConsulta.className == "oculto") ? "visible" : "oculto";
	location.href = "#Consulta";
}

function mostrar(catalogo)
{
	var menu = document.getElementById(catalogo);
	if(menu.style.display == 'none')
		menu.style.display = 'block';
	else
		menu.style.display = 'none';
}
function mostrarSubMenu2()
{
	var menu = document.getElementById('submenu2');
	if(menu.style.display == 'none')
	menu.style.display = 'block';
	else
	menu.style.display = 'none';
}
