// JavaScript Document

	function cargarNoticia(cod)
	{
		$.ajax ({
			type: "GET",
			url: "detallenoticia.php",
			data: "ajax=true&codigo="+ cod,
			async: true,
			dataType: "HTML",
			success: function(datos){
				$('#div' + cod).html(datos);
				$('#div' + cod).slideToggle();
			},
			error: function(data, errortxt, objerror){
				alert("error");
			},
			timeout: 0
		});
	}
	
	function cargarNovedad(cod)
	{
		$.ajax ({
			type: "GET",
			url: "detallenovedad.php",
			data: "ajax=true&codigo="+ cod,
			async: true,
			dataType: "HTML",
			success: function(datos){
				$('#div' + cod).html(datos);
				$('#div' + cod).slideToggle();
			},
			error: function(data, errortxt, objerror){
				alert("error");
			},
			timeout: 0
		});
	}
	
	function RespuestaNovedad(destinatario, cod)
	{		
		document.getElementById("codNovedad").value=cod;
		$("#tituloModal").html("<h3>Enviar email a: <b>" + destinatario + "</b></h3>");
	}
	
	
	function EnviarRespuestaNovedad()
	{	
		if ($("#txtMensaje").val()!="")
		{
			$.ajax ({
				type: "GET",
				url: "enviacorreonovedad.php",
				data: "ajax=true&codigo="+ $("#codNovedad").val() + "&texto=" + escape($("#txtMensaje").val()),
				async: true,
				dataType: "HTML",
				beforeSend: function(){
					$("#botonEnviar").attr("value","Enviando...");
					$("#botonEnviar").attr("disabled","disabled");
	
				},
				success: function(datos){
					if (datos=="ok")
					{
						$.modal.close();
					}
					else
					{
						alert("Error al intentar enviar el email: " + datos)		
					}
				},
				error: function(data, errortxt, objerror){
					alert("error");
				},
				timeout: 0
			});
		}
		else
		{
			alert("Introduzca su mensaje");
		}
	}
