	
 	// 
	$(document).ready(function()
	{
		var postID;
 		var voteUpScript = 'ajax/ajax_kom_glosuj.php?glos=tak';
		var voteDownScript = 'ajax/ajax_kom_glosuj.php?glos=nie';
		
		var wszystkichkomentarzy = $(".ile-kom").attr("id");
		
 		for ( i = 0 ; i <= wszystkichkomentarzy; i++ )
		{ 		
   			$("a.komr-"+[i]).animate({opacity: "0.3"}, 300);
  		}
 		
		//
		$("ol.lista-komentarzy li").hover(function() { $(this).find('.ratebtn').stop().animate({ opacity: "1.0" }, 200); }, function() { $(this).find('.ratebtn').stop().animate({ opacity: "0.3" }, 400); });		
			 
 		//
		$("a.glos-gora").hover( 
		
			function () 
			{ 
				if ($(this).hasClass('glos-oddany')) 
				{ 
					return false; 
				
				} else {
	
					$(this).removeClass('glos-gora_active'); 
					$(this).addClass('glos-gora'); 
				}
			},	
			function () 
			{ 
				if ($(this).hasClass('glos-oddany')) 
				{ 
					return false; 
				
				} else {
								
					$(this).removeClass('glos-gora'); 
					$(this).addClass('glos-gora_active'); 
				}
			}
 		);
		
		//
		$("a.glos-dol").hover( 
		
			function () 
			{
				if ($(this).hasClass('glos-oddany')) 
				{ 
					return false; 
				
				} else {
			
					$(this).removeClass('glos-dol_active'); 
					$(this).addClass('glos-dol'); 
				}
			}, 
			function () 
			{ 
				if ($(this).hasClass('glos-oddany')) 
				{ 
					return false; 
				
				} else {
			
					$(this).removeClass('glos-dol'); 
					$(this).addClass('glos-dol_active'); 
				}
			} 
		);
 		 		
		// 
		$("a.glos-gora").click(function()
		{  
			itemID = $(this).attr("id"); // pobiera id

 			if($(this).hasClass('glos-oddany'))
			{	
 				$("span#status"+ itemID +"").stop().html('<span>Już głosowała(e)¶ !</span>').delay(1000).fadeOut(1000, function () {
						$(this).remove();
				});
  				
			} else {
				
 				$("a.ggid-"+ itemID +"").html('<img src="media/layout/ladowanie-m.gif" alt="">'); // pokaż ładowanie
	 
				$.post(voteUpScript,{id:itemID},function(response)
				{ 
					$("div#wynik"+ itemID +"").html(response); // pokaż response
					//$("span#status"+ itemID +"").stop().html('Twój głos został dodany').delay(1000).fadeOut(1000, function () {
					//	$(this).remove();
					//});
					$("a.ggid-"+ itemID +"").each(function() {
						var image = $(this).children("img");
						image.remove();
					});
					
					$("a.ggid-"+ itemID +"").removeClass('glos-gora_active').addClass('glos-gora').addClass('glos-oddany');	
					$("a.gdid-"+ itemID +"").removeClass('glos-dol_active').addClass('glos-dol_done').addClass('glos-oddany');			
	
					$("a.ggid-"+ itemID +"").stop().animate({opacity: "1.0"}, 200);
					$("a.gdid-"+ itemID +"").stop().animate({opacity: "1.0"}, 200);
 				});
			}
  			
			// $(this).attr({"disabled":"disabled"}); // disable button
		});
		
		// 
 		$("a.glos-dol").click(function()
		{
			itemID = $(this).attr("id"); // pobiera id 

 			if($(this).hasClass('glos-oddany'))
			{
				$("span#status"+ itemID +"").stop().html('<span>Już głosowała(e)¶ !</span>').delay(1000).fadeOut(1000, function () {
						$(this).remove();
				});
 				
			} else {
			
				$("a.gdid-"+ itemID +"").html('<img src="media/layout/ladowanie-m.gif" alt="">'); // pokaż ładowanie
	
				$.post(voteDownScript,{id:itemID},function(response)
				{ 
 					$("div#wynik"+ itemID +"").html(response); // pokaż response
					//$("span#status"+ itemID +"").stop().html('Twój głos został dodany').delay(1000).fadeOut(1000, function () {
					//	$(this).remove();
					//});
					$("a.gdid-"+ itemID +"").each(function() {
						var image = $(this).children("img");
						image.remove();
					});
					
					$("a.gdid-"+ itemID +"").removeClass('glos-dol_active').addClass('glos-oddany');	  
					$("a.ggid-"+ itemID +"").removeClass('glos-gora_active').addClass('glos-gora_done').addClass('glos-oddany');			
		
					$("a.gdid-"+ itemID +"").stop().animate({opacity: "1.0"}, 200);
					$("a.ggid-"+ itemID +"").stop().animate({opacity: "1.0"}, 200);
				});
			}
 		});
		
		// $(this).attr({"disabled":"disabled"}); // disable button 
	});
	

