	
 	// 
	$(document).ready(function()
	{
		var postID;
 		var voteUpScript = 'ajax/ajax_art_glosuj.php?glos=tak';
		var voteDownScript = 'ajax/ajax_art_glosuj.php?glos=nie';
 			 
 		//
		$("a.art-glos-gora").hover( 
		
			function () 
			{ 
				if ($(this).hasClass('art-glos-oddany')) 
				{ 
					return false; 
				
				} else {
	
					$(this).removeClass('art-glos-gora_active'); 
					$(this).addClass('art-glos-gora'); 
				}
			},	
			function () 
			{ 
				if ($(this).hasClass('art-glos-oddany')) 
				{ 
					return false; 
				
				} else {
								
					$(this).removeClass('art-glos-gora'); 
					$(this).addClass('art-glos-gora_active'); 
				}
			}
 		);
		
		//
		$("a.art-glos-dol").hover( 
		
			function () 
			{
				if ($(this).hasClass('art-glos-oddany')) 
				{ 
					return false; 
				
				} else {
			
					$(this).removeClass('art-glos-dol_active'); 
					$(this).addClass('art-glos-dol'); 
				}
			}, 
			function () 
			{ 
				if ($(this).hasClass('art-glos-oddany')) 
				{ 
					return false; 
				
				} else {
			
					$(this).removeClass('art-glos-dol'); 
					$(this).addClass('art-glos-dol_active'); 
				}
			} 
		);
 		 		
		// 
		$("a.art-glos-gora").click(function()
		{  
			itemID = $(this).attr("id"); // pobiera id

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

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