	// --------------------------------------------------------------------------
	//		Document ready 
	// --------------------------------------------------------------------------	 
	
	
	$(document).ready(function()
	{

		// Frontpage - Delete searchhistory item
		$('#frontpage #searchHistory a.delete').click(function()
		{
		    elem = $(this).parent();
		    $(this).find('img').attr('src', $(this).find('img').attr('src').replace('clear.gif', 'loading.gif'));
		    
		    $.ajax({
			    url: $(this).attr('href'),
			    success: function() 
			    {
			        $(elem).slideUp(500, function(){ $(this).remove() })
			        
                    if ($('#frontpage #searchHistory li').length < 2)
			        {
			            $('#searchHistory').slideUp(750)
				    }
				}
	        })
	        
			return false
		})
		
		
		//	Frontpage - Delete all history items
		$('#frontpage #searchHistory a.deleteAll').click(function()
		{
		    if (confirm($(this).attr('title')))
			{
    			$('#searchHistory').slideUp(750)
			
	    		$.ajax({
	    		    url: $(this).attr('href')
	            })
	        }		
			return false
		})
		
		
		// History delete item
		$('#searchHistory td.delHistory')
			.hover(function() 
			{
				iconHistoryHover(this);
			}) 
			.click(function(event)
			{
				event.stopImmediatePropagation();
				
				elem = $(this).find('img');
				src = $(elem).attr('src');			
			    fullUrl = $(elem).parents('a').attr('href');
			    
			    $(elem).attr('src', src.replace('clear.gif', 'loading.gif'));
			    	    
			    $.ajax({
			        url: fullUrl,
			        success: function() 
			        {
			            setTimeout(function()
			            {
			                $(elem).parents('tr').fadeOut(750, function()
			                {
			                    table = $(elem).parents('table')
			                    
			                    $(this).remove();
			                    
			                    if ($(table).find('tbody tr').length < 1)
			                    {
			                        window.location.reload(true);
			                    }
			                })
			            }, ajaxLoadingDelay)
			        }
			    })

				return false
			})
	});


	// --------------------------------------------------------------------------
	//		Functions
	// --------------------------------------------------------------------------	 
	
	
	function iconHistoryHover(e)
	{
		if (! $(e).is('img'))
		{
			e = $(e).find('img.icon16')
		}
		
		$(e).toggleClass('history').toggleClass('historyDelete')
		
		$(e).blur()
	}
