/*
 * js/funciones.js
 */

function verImagen(n)
{
	var offset=getScrollXY();

	var nom="imgs/ready/"+n+".jpg";

	// se esconde el formulario de subida de imagenes
	$("#subir").hide();
	$("#im_det").attr("src", "web_imgs/load.gif");

	// carga de mensajes de la imagen
	$("#comentarios").html("<br><img src=\"web_imgs/load2.gif\" >");
	$("#comentarios").load("ver_mensajes.php?id="+n);

	// se carga la nueva imagen y se muestra
	$("#im_det").attr("src", nom);

	$("#popup").css("top", offset[1]);
	$("#detalle").css("top", offset[1]);

	$("#c_1").html("&iquest;Quieres votar por esta foto?  Env&iacute;a un SMS con el c&oacute;digo "+n+" al 6682 (Valor SMS $290 IVA incl.)<br/>"
	+"Ej: "+n+" al 6682<br/>"
	+"Las fotos m&aacute;s votadas ganar&aacute;n espectaculares premios SAMSUNG"
	+"");

	$("#c_2").html("Comenta esta foto enviando un SMS con el c&oacute;digo "+n+" (dejar un espacio) y tu COMENTARIO al 6682<br>"
	+"Ej: "+n+" saludos a toda la gente que me conoce"
	+"");

	$("#popup").fadeIn("slow");
	$("#detalle").fadeIn("slow");
}

function subirImagen()
{
	var offset=getScrollXY();

	$("#detalle").hide();

	$("#popup").css("top", offset[1]);
	$("#subir").css("top", offset[1]);
	$("#popup").fadeIn("slow");
	$("#subir").fadeIn("slow");
}

function mostrarMensaje(m)
{
	$("#m_1").html(m);
	$("#popup").show();
	$("#mensaje").fadeIn("slow");
}

function cerrarTodo()
{
	$("#subir").fadeOut("slow");
	$("#detalle").fadeOut("slow");
	$("#mensaje").fadeOut("slow");
	$("#popup").fadeOut("slow");
}

function cerrarImagen()
{
	$("#popup").fadeOut();
	$("#detalle").fadeOut();
}

function cerrarSubir()
{
	$("#popup").fadeOut();
	$("#subir").fadeOut();
}

function cerrarMensaje()
{
	$("#popup").fadeOut();
	$("#mensaje").fadeOut();

	location.href="/";
}

function validarUpload()
{
	if ( $("#s_nombre").attr("value")!=""
			&& ($("#s_apellido").attr("value")!="")
			&& ($("#s_rut").attr("value")!="")
			&& ($("#s_celu").attr("value")!="")
			&& ($("#s_email").attr("value")!="")
			&& ($("#imagen").attr("value")!="")
			)
	{
		return true;
	}
	alert("Completa todos los campos por favor");
	return false;
}

function validarBuscar()
{
	if ( $("#b_numero").attr("value")!="")
	{
		return true;
	}
	alert("Debes ingresar tu n\xfamero telef\xf3nico");
	return false;
}
