$(function(){

	target = $('input[name="k"]');
	
//	defaultValue = target.val();

	target.click(function(){
//		if(target.val() == defaultValue)
			$(this).val('');
	});

//	target.blur(function(){
//		if(target.val() == '')
//			target.val(defaultValue);
//	});

	$('.categories > select').change(function(){
		$(this).closest('form').submit();
	});

	var autocompleteTarget = "input[name='k']";
	
	if ($(autocompleteTarget).autocomplete)	{
		$(autocompleteTarget).autocomplete({
			source: '/ajax_autocompletion.html',
			minLength: 1,
			close: function(event, ui){$(this).blur();},
			change: function(event, ui){$(this).closest('form').submit();}
		});
	}
	
	$('#fav').children('a').click(function(){
		var bookmarkUrl = this.href;
		var bookmarkTitle = this.title;
		
		if ($.browser.mozilla) // For Mozilla Firefox Bookmark
			window.sidebar.addPanel(bookmarkTitle, bookmarkUrl, "");
		else if($.browser.msie) // For IE Favorite
			window.external.AddFavorite(bookmarkUrl, bookmarkTitle);
		else if($.browser.opera) // For Opera Browsers
		{
			$(this).attr("href",bookmarkUrl);
			$(this).attr("title",bookmarkTitle);
			$(this).attr("rel","sidebar");
			$(this).click();
		}
		else // for other browsers which does not support
			alert('Pour ajouter ce site dans vos favoris, appuyez sur CTRL+D.');

		return false; 
	});
})

