function clearWatchedItem( id )
{
	new Ajax.Request( getRootPath(), 
	{
		parameters: { 
			act: 				'user.watchlist.markSeen', 
			software: 			id
		},
		onSuccess: 	function( response )
		{
			if( response.responseJSON.result ) {
				
				$( 'watchedStatus_' + id ).innerHTML = '<img src="images/watchlist/not_updated.png"> ' +
													   '<span class="productListingToolLabel">' + DC_NO_UPDATE + '</span>';
				
				$( 'watchedClear_' + id ).hide();
			}
		}
	} );
}

function toggleWatchedItem( id )
{
	if( $( 'watchlistControl_' + id ).hasClassName( 'inWatchlist' ))
		removeWatchedItem( id );
	else
		addWatchedItem( id );
}

function removeWatchedItem( id )
{
	new Ajax.Request( getRootPath(), 
	{
		parameters: { 
			act: 				'user.watchlist.remove', 
			software: 			id
		},
		onSuccess: 	function( response )
		{
			if( response.responseJSON.result ) {
				var ctrl = $( 'watchlistControl_' + id );
				var status = $( 'watchedStatus_' + id );
				
				ctrl.innerHTML = '<img src="images/watchlist/add.png"> ' +
								 '<span class="productListingToolLabel">' + DC_ADD + '</span>';
				
				ctrl.removeClassName( 'inWatchlist' );
				
				if( status ) {
					status.hide();
					$( 'watchedClear_' + id ).hide();
				}
			}
		}
	} );
}

function addWatchedItem( id )
{
	new Ajax.Request( getRootPath(), 
	{
		parameters: { 
			act: 				'user.watchlist.add', 
			software: 			id
		},
		onSuccess: 	function( response )
		{
			if( response.responseJSON.result ) {
				var ctrl = $( 'watchlistControl_' + id );
				
				ctrl.innerHTML = '<img src="images/watchlist/remove.png"> ' +
								 '<span class="productListingToolLabel">' + DC_REMOVE + '</span>';

				ctrl.addClassName( 'inWatchlist' );
			}
		}
	} );
}
