/**
* control de votación 5 estrellas con jquery
*
*/


$(document).ready(function() {
   //$("div.votingpanel").find("a").each(function(i) {
   $("a[id^=votestar]").click(function(event) {
		
				// prevenimos que se vaya al link
   			event.preventDefault(); 

				artmp = $(this).attr("id").split("_");
				
				voto = parseInt(artmp[1]) + 1;
			
				artmp = $(this).attr("id").split("_");

				// La id de noticia va en el id del div. 
				voteid = artmp[2];
			
				posturl = "/?vote&ac=new&id="+voteid;
			
				//alert("amos: " +voto+ " y id:" +voteid+ " url:" +posturl+ "." );
		 		// enviamos petición
	     		$.post(posturl, {vote: voto}, function(xml) {
       		// Resultado 
       			$("#votingpaneln_"+voteid).html($("msg",xml).text());
       
        		});

   });
   
    $("a[id^=votecomment]").click(function(event) {
   		//$(this).click(function(event){
   		event.preventDefault(); 			

			artmp = $(this).attr("id").split("_");

			// La id de noticia va en el id del div. 
			voteid = artmp[2];

			
			voto = (artmp[1]==0)?-1:1;
			posturl = "/"+"?vote&ac=comment&id="+voteid;
			
			//alert("Vamos: " +voto+ " y id:" +voteid+ " url:" +posturl+ ".");

		 // enviamos petición
	     $.post(posturl, {vote: voto}, function(xml) {
       // Resultado 
       		$("#votingpanel_"+voteid).html($("msg",xml).text());
        });
       			// prevenimos que se vaya al link

   
		//});
   });
   
    $("a[id^=votequote]").click(function(event) {
   		//$(this).click(function(event){
   		event.preventDefault(); 			

			artmp = $(this).attr("id").split("_");

			// La id de noticia va en el id del div. 
			voteid = artmp[2];

			
			voto = (artmp[1]==0)?-1:1;
			posturl = "/"+"?vote&ac=quote&id="+voteid;
			
			//alert("Vamos: " +voto+ " y id:" +voteid+ " url:" +posturl+ ".");

		 // enviamos petición
	     $.post(posturl, {vote: voto}, function(xml) {
       // Resultado 
       		$("#votingpanel_"+voteid).html($("msg",xml).text());
        });
       			// prevenimos que se vaya al link

   
		//});
   });   
   
 });