<!--    FUNCION DE VOTACIONES    -->


		 
  $(function votar (){
		
	$("a.vote_up_album").click(function(){
	//get the id
	the_id = $(this).attr('name');
	span_id = $(this).attr('tabindex');
		//modificar ruta en funcion del title del enlace
		title= $(this).attr('title');
	// alert(this.the_id);
		switch (this.title){
		case "album": url2="vote_album.php";
						break;
		case "band": url2="vote_band.php";
					 break;
		case "lyric": url2="vote_lyric.php";
					 break;
	
	}

//	alert(url2);
//alert(this.the_id);
	
	// show the spinner
	$(this).parent().html("<img src='../images/spinner.gif'/>");
	
	//fadeout the vote-count 
	$("span#votes_count"+the_id).fadeOut("fast");
	
	//the main ajax request
		$.ajax({
			type: "POST",
			data: "action=vote_up&id="+$(this).attr("name"),
			url: url2,
			success: function(msg)
			{
				$("span#votes_count"+the_id+span_id).html(msg);
				//fadein the vote count
				$("span#votes_count"+the_id+span_id).fadeIn();
				//remove the spinner
				$("span#vote_buttons"+the_id+span_id).remove();
			}
		});
	});
	
	$("a.vote_down_album").click(function(){
	//get the id
	the_id = $(this).attr('name');
		span_id = $(this).attr('tabindex');
	//modificar ruta en funcion del title del enlace
	title= $(this).attr('title');
		//	 alert(this.title);
	switch (this.title){
		case "album": url2="vote_album.php";
						break;
		case "band": url2="vote_band.php";
					 break;
		case "lyric": url2="vote_lyric.php";
					 break;
	
	}
	//	alert(url2);
	
	// show the spinner
	$(this).parent().html("<img src='../images/spinner.gif'/>");
	
	//the main ajax request
		$.ajax({
			type: "POST",
			data: "action=vote_down&id="+$(this).attr("name"),
			url: url2,
			success: function(msg)
			{
				$("span#votes_count"+the_id+span_id).fadeOut();
				$("span#votes_count"+the_id+span_id).html(msg);
				$("span#votes_count"+the_id+span_id).fadeIn();
				$("span#vote_buttons"+the_id+span_id).remove();
			}
		});
	});
});	



