function recuperarClave(pForm)
{
	with(pForm)
	{
		if(Codigo.value.length > 0)
		{
			if(validarEmail(Email.value))
			{
				
				alert("Su clave ha sido enviada a su email.");
				return true;
			}
			else
			{
				alert("Por favor, ingrese un Email válido");
				Email.focus();
				
			}
		}
		else
		{
			alert("Por favor, ingrese su nombre de Usuario.");
			Codigo.focus();
		}
	}
	return false;
}

function GuardarSuscriptor(pForm)
{
	with(pForm)
	{
		if(txtNombresSusc.value.length > 0) {
			if(validarEmail(txtEmailSusc.value))
			{
					x_GuardarSuscriptor(txtNombresSusc.value, txtEmailSusc.value, function(pCadena)
						{
							alert("Gracias por suscribirse a nuestro newsletter.\n");
							txtEmail.value = "";

						});
			}

			else
			{
				alert("Por favor, ingrese un Email válido");
				txtEmailSusc.focus();
			}
		}
		else
		{
			alert("Por favor, ingrese su Nombre");
			txtNombresSusc.focus();
		}
	}
	return false;
}

function recomendarNoticia(pForm)
{
	with(pForm)
	{
		if(validarEmail(txtREmail.value))
		{
			if(validarEmail(txtDEmail.value))
			{
					submit();
					reset();
					alert("Su mensaje ha sido enviado");
			}
			else
			{
				alert("El email del destinatario es invalido. Por favor, ingreselo nuevamente.");
				txtDEmail.focus();
			}
		}
		else
		{
			alert("Su email es invalido. Por favor, ingreselo nuevamente.");
			txtREmail.focus();
		}
	}
	return false;
}

function desplegarRecomendacion()
{
	var tRecomendacion = document.getElementById("trRecomendacion");
	tRecomendacion.className = (tRecomendacion.className == "oculto") ? "visible" : "oculto";
}

function RegistroUsuario(pForm)
{
	with(pForm)
	{
		if(apellido.value.length > 0 && nombres.value.length > 0 && usuario.value.length > 0 && clave.value.length > 0 && localidad.value.length > 0 && provincia.value.length > 0)
		{
			if(validarEmail(email.value))
			{
					x_GuardarUsuarioRegistrado(
											   apellido.value, nombres.value, usuario.value, email.value, clave.value, localidad.value, provincia.value, function(pCadena)
						{
							pForm.reset();
							alert("Sus datos han sido enviados al administrador. Recibira un Email cuando estos sean verificados. Muchas gracias por registrarse.");
						});
			}
			else
			{
				alert("Por favor, ingrese un Email válido");
				email.focus();
			}
		}
		else
		{
			alert("Por favor, ingrese todos los campos obligatorios.");
			apellido.focus();
		}
	}
	return false;
}


function desplegarGaleria(pSrc, pDesc)
{
	var tVideos = document.getElementById("tdImgGaleria");
	var tVideosDesc = document.getElementById("tdImgGaleriaDesc");
//	x_SetearGaleria(pSrc);
	if(tVideos != undefined)
	{
		oFlash = new SWFObject("visor-imagenes-400x300.swf", "", "400", "300", "7", "", true);
		with(oFlash)
		{
			addParam("menu", "false");
			addParam("wmode", "transparent");
			addVariable("IDGaleria", pSrc);
			write("tdImgGaleria");
		}
		tVideosDesc.innerHTML = pDesc;
	}
}

function desplegarAudio (pSrc, pDesc, pAutoPlay)
{
	var tVideos = document.getElementById("tdAudioGaleria");
	var tVideosDesc = document.getElementById("tdAudioGaleriaDesc");
	if(tVideos != undefined)
	{
		oFlash = new SWFObject("player_mp3_maxi.swf", "", "200", "20", "7", "", true);
		with(oFlash)
		{	
			addParam("wmode", "opaque");
			addVariable("mp3", "audios/"+ pSrc +".mp3");
			addVariable("bgcolor1", "CCCCCC");
			addVariable("bgcolor2", "999999");
			addVariable("slidercolor2", "4a4a4a");
			addVariable("buttoncolor", "000000");
			addVariable("buttonovercolor", "AF0917");
			addVariable("sliderovercolor", "AF0917");
			addVariable("autoplay", pAutoPlay)
			addVariable("wmode", "opaque");
			write("tdAudioGaleria");
		}
		if(tVideosDesc != null) {
				tVideosDesc.innerHTML = pDesc;
		}
	}
}

function desplegarVideo (pId, pDesc, pAutoPlay)
{
	var tVideos = document.getElementById("tdVideosGaleria");
	var tVideosDesc = document.getElementById("tdVideosGaleriaDesc");
	var oFlash = null;
	if(tVideos != undefined)
	{
		tVideos.innerHTML = "";
		oFlash = new SWFObject("player_flv.swf", "", "300", "225", "7", "", true);
		with(oFlash)
		{
			addParam("wmode", "transparent");
			addVariable("flv", "videos/"+pId+".flv");
			addVariable("width", "290")
			addVariable("height", "174")
			addVariable("showstop", 1)
			addVariable("showvolume", 1)
			addVariable("startimage", "images/logo-tv.jpg");
			addVariable("autoplay", pAutoPlay)
			addVariable("border", "080808")
			addVariable("bgcolor1", "080808")
			addVariable("bgcolor2", "080808")
			addVariable("playercolor", "080808")
			
			write("tdVideosGaleria");
		}
	}
	if(tVideosDesc != null) {
			tVideosDesc.innerHTML = pDesc;
	}
}

function cargarVideoYouTube(idVid, pDesc)
{
	var tVideosDesc = document.getElementById("tdVideosGaleriaDesc");
	var oFlashV;
	if(document.getElementById("tdVideosGaleria"))
	{
		oFlashV = new SWFObject("http://www.youtube.com/v/"+idVid, "", "290", "174", "7", "", true);
		with(oFlashV)
		{
			addParam("wmode", "transparent");
			addParam("menu", "false");
			addParam("rel", "0");
			addParam("color1", "0x000000");
			addParam("color1", "0xFFFFFF");			
			addParam("allowFullScreen", "true");
			write("tdVideosGaleria");		
		}	
	}
		if(tVideosDesc != null) {
			tVideosDesc.innerHTML = pDesc;
	}
}

function abrirImagen(pIDNoticia, pArchivo, pAncho, pAlto)
{
	var oVentana = new Window(
		{
			className: "alphacube",
			title: "M&eacute;dicos Consultores .com",
			width: pAncho,
			height: pAlto,
			left: 200,
			top: 150,
			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 retornarFecha(pDestino)
{
	var aDias = new Array("Domingo", "Lunes", "Martes",
		"Mi&eacute;rcoles",  "Jueves", "Viernes", "S&aacute;bado");
	var dFecha = new Date();
	with(dFecha)
	{
		var lIDDia = getDay();
		var sDia = new String(getDate());
		var sMes = new String(getMonth() + 1);
		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;
	pDestino = document.getElementById(pDestino);
	if(pDestino)
	{
		pDestino.innerHTML = aDias[lIDDia] + ", " + sDia + "." + sMes + "." + lAno + " - ";
		pDestino.innerHTML += "<span class='encabezado-texto-rojo'>" + sHora + ":" + sMinutos + "<span>";
	}
}

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 guardarComentario(pForm)
{
	with(pForm)
	{
		if(nombres.value != "")
		{
			if(validarEmail(email.value))
			{
				if(mensaje.value != "")
				{
					submit();
					reset();
					alert("Su mensaje ha sido enviado");
				}
				else
				{
					alert("Por favor, ingrese su Comentario");
					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 mostrarCapa(idFormVisible, idFormOculto)
{
	var tFormVisible = document.getElementById(idFormVisible);
	var tFormOculto = document.getElementById(idFormOculto);
	tFormVisible.className = "visible";
	tFormOculto.className =  "oculto";
}


function retornarClima()
{
	var tClima = document.getElementById("tdClima");
	if(tClima)
	{
		tClima.innerHTML = "<img src=\"images/ajax-loader-1.gif\" align=\"right\" />";
		valor = document.frmClima.cbCiudad.options[document.frmClima.cbCiudad.selectedIndex].value;
		valor = valor.split("|");
		x_RetornarClima(valor[0], valor[1], function(pCadena)
			{
					tClima.innerHTML = pCadena;
			});
	}
}


/* CONTACTO */

function enviarContacto(pForm)
{
	with(pForm)
	{
		if(nombres.value.length > 0)
		{
			if(validarEmail(email.value))
			{
				if(mensaje.value.length > 0)
				{
					submit();
					reset();
					alert("Su mensaje ha sido enviado");
				}
				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 visualizarSeccion(pSeccion, pVisible)
{
	var oSeccion = document.getElementById(pSeccion);
	if(oSeccion)
	{
		with(oSeccion)
		{
			if(pVisible && oSeccion.className == "oculto")
				className = "visible";
			else if(!pVisible && (className == "" || className == "visible"))
				className = "oculto";
		}
	}
}


function validarUsuario(pForm)
{
	with(pForm)
	{
		if(Codigo.value.length > 0 && Contrasenia.value.length > 0)
		{
			submit();
			return true;
		}
		else
		{
			alert("Por favor, ingrese su nombre de usuario y contraseńa.");
			Codigo.focus();
		}
	}
	return false;
}

function validarRegistro(pForm)
{
	with(pForm)
	{
		if(Codigo.value.length > 0)
		{
			if(Contrasenia.value.length > 0)
			{
				if(BTN_Contrasenia2.value.length > 0 && Contrasenia.value == BTN_Contrasenia2.value)
				{
					if(validarEmail(Email.value))
					{
						if(Nombre.value.length > 0)
						{
							if(Apellido.value.length > 0)
							{
								if(Provincia.value.length > 0)
								{
									alert("Gracias por registrarse en medicosconsultores.com");
									return true;
								}
								else
								{
									alert("Por favor, ingrese su Provincia");
									Provincia.focus();
								}
							}
							else
							{
								alert("Por favor, ingrese su Apellido");
								Apellido.focus();
							}
						}
						else
						{
							alert("Por favor, ingrese su Nombre");
							Nombre.focus();
						}
					}
					else
					{
						alert("Por favor, ingrese un email valido.");
						Email.focus();
					}
				}
				else
				{
					alert("Por favor, reingrese la Contrasenia. Debe coincidir con la ingresada anteriormente.");
					Contrasenia2.focus();
				}
			}
			else
			{
				alert("Por favor, ingrese una Contrasenia");
				Contrasenia.focus();
			}
		}
		else
		{
			alert("Por favor, ingrese un Codigo de usuario");
			Codigo.focus();
		}
	}
	return false;
}


