function retornarFecha(pDestino)
{
	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 dDia = new Date();
	with(dDia)
	{
		var lIDDia = getDay();
		var lDia = getDate();
		var lMes = getMonth();
		var lAno = getYear();
		if(lAno < 1900) lAno += 1900;
	}
	var tFecha = document.getElementById(pDestino);
	tFecha.innerHTML = aDias[lIDDia] + ", " + lDia + " de " + aMeses[lMes] + " de " + lAno;
}


function abrirImagenDepartamento(pIDDepartamento, pArchivo, pAncho, pAlto)
{
	var oVentana = new Window(
		{
			className: "alphacube",
			title: "Espacios Temporarios - Vista ampliada",
			width: pAncho,
			height: pAlto,
			left: 400,
			top: 150,
			draggable: true,
			resizable: true,
			minimizable: false,
			maximizable: false,
			destroyOnClose: true
		}
	);
	oVentana.show();
	var sURL = "ver-imagen.php?iddepartamento=" + pIDDepartamento + "&archivo=" + pArchivo;
	oVentana.setAjaxContent(sURL);
}

function abrirImagenCasa(pIDCasa, pArchivo, pAncho, pAlto)
{
	var oVentana = new Window(
		{
			className: "alphacube",
			title: "Espacios Temporarios - Vista ampliada",
			width: pAncho,
			height: pAlto,
			left: 400,
			top: 150,
			draggable: true,
			resizable: true,
			minimizable: false,
			maximizable: false,
			destroyOnClose: true
		}
	);
	oVentana.show();
	var sURL = "ver-imagen.php?idcasa=" + pIDCasa + "&archivo=" + pArchivo;
	oVentana.setAjaxContent(sURL);
}

function abrirImagenLocal(pIDLocal, pArchivo, pAncho, pAlto)
{
	var oVentana = new Window(
		{
			className: "alphacube",
			title: "Espacios Temporarios - Vista ampliada",
			width: pAncho,
			height: pAlto,
			left: 400,
			top: 150,
			draggable: true,
			resizable: true,
			minimizable: false,
			maximizable: false,
			destroyOnClose: true
		}
	);
	oVentana.show();
	var sURL = "ver-imagen.php?idlocal=" + pIDLocal + "&archivo=" + pArchivo;
	oVentana.setAjaxContent(sURL);
}
//####################################################################################################################################
function abrirGaleriaDeImagenes(titulo,url,ancho,alto)
{
		
	var oVentana = new Window(
		{
			className: "alphacube",
			title: titulo,
			width: ancho,
			height: alto+14,
			left: 260,
			top: 110,
			draggable: true,
			resizable: true,
			minimizable: false,
			maximizable: false,
			destroyOnClose: true
		}
	);
	oVentana.show();
	var oFlash = new SWFObject(url, "", ancho, alto, "7", "", true);
	with(oFlash)
	{
		addParam("menu", "false");
		//addParam("wmode", "transparent");
		write(oVentana.getContent().id);
	}	
}
//####################################################################################################################################
function viewpage(titulo,url,ancho,alto)
{
	var oVentana = new Window(
		{
			className: "alphacube",
			title: titulo,
			width: ancho,
			height: alto+14,
			left: 260,
			top: 110,
			draggable: true,
			resizable: true,
			minimizable: false,
			maximizable: false,
			destroyOnClose: true
		}
	);
	oVentana.show();
	var sURL = url;
	oVentana.setURL(sURL);
}

function desplegarVideo(pIDVideo, pURL)
{
	var tContenedor = document.getElementById("trVideo-" + pIDVideo);
	var tVideo = document.getElementById("tdVideo-" + pIDVideo);
	if(tContenedor.className == "oculto")
	{
		tContenedor.className = "visible";
		var oFlash = new SWFObject(pURL, "", "255", "213", "7", "", true);
		with(oFlash)
		{
			addParam("menu", "false");
			addParam("wmode", "transparent");
			write("tdVideo-" + pIDVideo);
		}
	}
	else
	{
		tVideo.innerHTML == "&nbsp;"
		tContenedor.className = "oculto";
	}
}

function desplegarMenu()
{
	var dMenu = document.getElementById("divMenuGalerias");
	dMenu.className = (dMenu.className == "oculto") ? "visible" : "oculto";
}

function enviarContacto(pForm)
{
	with(pForm)
	{
		if(txtApellido.value.length > 0 && txtNombres.value.length > 0)
		{
			if(validarEmail(txtEmail.value) && txtTelefono.value.length > 0 )
			{
				if(txtComentarios.value.length > 0)
				{
					x_EnviarContacto(txtApellido.value, txtNombres.value, txtEmail.value, txtTelefono.value,
						txtCiudad.value, txtProvincia.value, txtPais.value, txtComentarios.value, function(pCadena)
						{
							alert("Su mensaje ha sido enviado");
							txtComentarios.value = "";
						});
				}
				else
				{
					alert("Por favor, ingrese un Comentario");
					txtComentarios.focus();
				}
			}
			else
			{
				alert("Por favor, ingrese un Email válido y un Teléfono válido");
				txtEmail.focus();
			}
		}
		else
		{
			alert("Por favor, ingrese su Apellido y Nombre");
			txtApellido.focus();
		}
	}
	return false;
}

function enviarContactoPropiedad(pForm)
{
	with(pForm)
	{
		if(txtApellido.value.length > 0 && txtNombres.value.length > 0)
		{
			if(validarEmail(txtEmail.value) && txtTelefono.value.length > 0 )
			{
				if(txtComentarios.value.length > 0)
				{
					x_EnviarContactoPropiedad(txtApellido.value, txtNombres.value, txtEmail.value, txtTelefono.value,
						txtCiudad.value, txtProvincia.value, txtPais.value, txtPropiedad.value, txtFechaDesde.value, txtFechaHasta.value, txtOcupantes.value, txtComentarios.value, function(pCadena)
						{
							alert("Su mensaje ha sido enviado");
							txtComentarios.value = "";
						});
				}
				else
				{
					alert("Por favor, ingrese un Comentario");
					txtComentarios.focus();
				}
			}
			else
			{
				alert("Por favor, ingrese un Email válido y un Teléfono válido");
				txtEmail.focus();
			}
		}
		else
		{
			alert("Por favor, ingrese su Apellido y Nombre");
			txtApellido.focus();
		}
	}
	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 validarMensaje(pForm)
{
	with(pForm)
	{
		if(nombres.value.length > 0)
		{
			if(validarEmail(email.value))
			{
				if(mensaje.value.length > 0)
				{
					return true;
				}
				else
				{
					alert("Por favor, ingrese un Mensaje");
					mensaje.focus();
				}
			}
			else
			{
				alert("Por favor, ingrese un Email válido");
				email.focus();
			}
		}
		else
		{
			alert("Por favor, ingrese su Nombre");
			nombres.focus();
		}
	}
	return false;
}

function guardarComentario(pForm)
{
	with(pForm)
	{
		if(nombres.value.length > 0)
		{
			if(validarEmail(email.value))
			{
				if(mensaje.value.length > 0)
				{
					x_GuardarComentario(idregistro.value, nombres.value, email.value, mensaje.value, function(pCadena)
						{
							alert("Su mensaje ha sido enviado.\nEn breve estará en línea");
							mensaje.value = "";
						});
				}
				else
				{
					alert("Por favor, ingrese un Mensaje");
					mensaje.focus();
				}
			}
			else
			{
				alert("Por favor, ingrese un Email válido");
				email.focus();
			}
		}
		else
		{
			alert("Por favor, ingrese su Nombre");
			nombres.focus();
		}
	}
	return false;
}

function desplegarRecomendacion()
{
	var tRecomendacion = document.getElementById("trRecomendacion");
	tRecomendacion.className = (tRecomendacion.className == "oculto") ? "visible" : "oculto";
}

function recomendarNoticia(pForm, pIDNoticia)
{
	with(pForm)
	{
		if(validarEmail(txtREmail.value))
		{
			if(validarEmail(txtDEmail.value))
			{
				x_RecomendarNoticia(pIDNoticia, txtRNombres.value, txtREmail.value,
					txtDNombres.value, txtDEmail.value, txtMensaje.value, function(pCadena)
					{
						alert("Su mensaje ha sido enviado");
						txtDNombres.value = "";
						txtDEmail.value = "";
					});
			}
			else
			{
				alert("Por favor, ingrese un Email válido");
				txtDEmail.focus();
			}
		}
		else
		{
			alert("Por favor, ingrese un Email válido");
			txtREmail.focus();
		}
	}
	return false;
}