var attrib = {
		encuestas:{relLink:"encuestas/control.php", elId:"polls", conn:0, method:"GET"},
		votaEncuesta:{relLink:"encuestas/procesaVoto.php", elId:"polls", conn:1},
		reporteros:{relLink:"Reporteros/topNoticiaReportero.php", elId:"reporteros", conn:2, method:"GET"},
		header:{relLink:"encabezado/encabezado.php", elId:"encabezadoDinamico"},
		calendario:{relLink:"Calendario/cal.php", elId:"calendar"}
};

function getResponse(target) {
  AjaxRequest.get(
    {
      'url':target.relLink,
      'onSuccess':function(req){ document.getElementById(target.elId).innerHTML = req.responseText; }
    }
  );
}

///////////////////////////////////////////////////////////////////
//// Limpia el formulario de notas.php
function cleanComments() {
	
	document.getElementById("nombreComentarios").value="";
	document.getElementById("correoComentarios").value="";
	document.getElementById("contenidoComentarios").value="";
	document.getElementById("notaIdComentarios").value="";
	
}

///////////////////////////////////////////////////////////////////
//// Limpia el formulario de post.php
function cleanComments2() {
	
	document.getElementById("nombreComentarios").value="";
	document.getElementById("correoComentarios").value="";
	document.getElementById("contenidoComentarios").value="";
	document.getElementById("blogIdComentarios").value="";

}
///////////////////////////////////////////////////////////////////
//// Manda valores del formulario para comentarios de notas.php a la base de datos
function comentar() {
	AjaxRequest.get(
		{
			'parameters':{
				nombre : document.getElementById("nombreComentarios").value,
				correo : document.getElementById("correoComentarios").value,
				contenido : document.getElementById("contenidoComentarios").value,
				notaId : document.getElementById("notaIdComentarios").value
				}
		    ,'anotherParameter':'true'
		    ,'url':"Comentarios/control.php"
		    ,'onSuccess':function(req) { document.getElementById("comentarios").innerHTML = req.responseText; cleanComments();}
		}
	);
}

////////////////////////////////////////////////////////////////////
//// Manda valores del formulario para comentarios de post.php a la base de datos
function comentarBlog() { 
	AjaxRequest.get( 
		{ 
			'parameters':{ 
				nombre : document.getElementById("nombreComentarios").value, 
				correo : document.getElementById("correoComentarios").value, 
				contenido : document.getElementById("contenidoComentarios").value, 
				blogId : document.getElementById("blogIdComentarios").value 
				} 
			,'anotherParameter':'true' 
			,'url':"Comentarios/control2.php" 
			,'onSuccess':function(req) { document.getElementById("comentarios").innerHTML = req.responseText; cleanComments2();}
		} 
	); 
}


function verCalificacion() {
	AjaxRequest.get(
		{
			'url': "votarNoticia/control.php",
			'parameters': {noticiaId:document.getElementById("hNoticiaId").value},
			'onSuccess': function(req) {document.getElementById("calificarNota").innerHTML = req.responseText;}
		}
	);
}

function seeInterviewGrade() {
	AjaxRequest.get(
		{
			'url': "includes/interviewControl.php",
			'parameters': {noticiaId:document.getElementById("hNoticiaId").value},
			'onSuccess': function(req) {document.getElementById("calificarEntrevista").innerHTML = req.responseText;}
		}
	);
}

function votarNoticia(g, id) {
	AjaxRequest.get(
		{
			'url' : "votarNoticia/votar.php",
			'parameters' : {
				'g' : g,
				'noticiaId' : id
			},
			'onSuccess' : function(req) {document.getElementById('calificarNota').innerHTML = req.responseText;}
		}
	);
}


function votarNews(g, id) {
	AjaxRequest.get(
		{
			'url' : "includes/ajaxVotarEntrevista.php",
			'parameters' : {
				'g' : g,
				'noticiaId' : id
			},
			'onSuccess' : function(req) {document.getElementById('calificarEntrevista').innerHTML = req.responseText;}
		}
	);
}


function votarEntrevista(g) {
	AjaxRequest.get(
		{
			'url':"includes/ajaxVotarEntrevista.php",
			'parameters':{'g':g, 'noticiaId':document.getElementById("hNoticiaId").value},
			'onSuccess':function(req){document.getElementById('calificarEntrevista').innerHTML = req.responseText;}
		}
	);
}


function displayVista() {
	AjaxRequest.get(
		{
			'url' : "includes/ajaxMostViewed.php",
			'onSuccess': function(req) {document.getElementById("notasRelacionadas").innerHTML = req.responseText;}
		}
	);
}

function displayVotada() {
	AjaxRequest.get(
		{
			'url' : "includes/ajaxMostVoted.php",
			'onSuccess': function(req) {document.getElementById("notasRelacionadas").innerHTML = req.responseText;}
		}
	);
}


//YAHOO.util.Event.on('botonformacomentario', 'click', submitForm, 'formacomentarios');
YAHOO.util.Event.on("notasRelacionadas", displayVista, null, null);
YAHOO.util.Event.onAvailable('calificarNota',       verCalificacion, null, true, true);
YAHOO.util.Event.onAvailable('calificarEntrevista', seeInterviewGrade, null, true, true);
YAHOO.util.Event.onAvailable('polls',               getResponse, attrib.encuestas,  true, true);
YAHOO.util.Event.onAvailable('reporteros',          getResponse, attrib.reporteros, true, true);
YAHOO.util.Event.onAvailable('calendarios',         getResponse, attrib.calendario, true, true);