$(document).ready(function() {
	$("a.addthis_button").bind("click", function() { intervalSmall = setInterval("manageSmallList()", 10); });
});

/*** START ADDTHIS ***/
// GLOBAL variables
var bUpdatedSmall = false;
var bUpdatedFull  = false;
var intervalSmall = "";
var intervalFull  = "";

// To manage small list
function manageSmallList()
{
	if ( !bUpdatedSmall )
	{
		// Each tool management
		$("div#at_hover div").each( function() {
			if ( $(this).attr("id").indexOf( "atic" ) != -1 )
			{
				$("span", $(this)).each( function() {
					$(this).html( "<a href=\"#\" class=\"noclass1\" title=\"" + $(this).html() + "\">" + $(this).html() + "</a>" );
				});
				
				// Css to change
				$("a.noclass1").css("text-decoration", "none");
				$("a.noclass1").css("color", "#000");
				
				// Special case for 'more' item
				if ( $(this).attr("id") == "atic_more" ) 
				{
					$(this).bind("click", function() 
					{ 
						bUpdatedFull = false; 
						intervalFull = setInterval("manageFullList()", 10); 
					});
				}
			}
			
			// Reset
			bUpdatedSmall = true;
			clearInterval( intervalSmall );
		});
	}
}

// To manage full list
function manageFullList()
{
	if ( !bUpdatedFull )
	{
		if ( $("div#at16ps div.at_item span a").size() == 0 )
		{
			$("div#at16ps div.at_item span").each( function() {
				$(this).html( "<a href=\"#\" class=\"noclass2\" title=\"" + $(this).html() + "\">" + $(this).html() + "</a>" );
			});
		
			// Css to change
			$("a.noclass2").css("text-decoration", "none");
			$("a.noclass2").css("color", "#000");
		}
		
		// Reset
		bUpdatedFull = true;
		clearInterval( intervalFull );
	}
}
/*** END ADDTHIS ***/

