/*
	Shows the search field on the bottom left of the page. Also changes the background image
	of the search container and focusses on the input field for direct text input.
*/
$(document).ready(function(){
	
	
	// Adds a class if the screen width of the user is smaller than 1100px.
	if ($(window).width() < 1100) {
		$('body').addClass('smallWidth');
	}
	
	$('#search').click(function() {
		$('#searchfield').show();
		$("#searchfield :input:visible:enabled:first").focus();
		$('#search').addClass('active');
	});
	
	// Check whether the entered search term is non-empty and submit the form if everything
	// is ok. Shows an error message otherwise.
	$('#searchfield .submit').click(function() {
		if ($('#searchfield .search').val() != '') {
			return true;
		} else {
			$('#search').append('<div id="searcherror">Bitte geben Sie einen Suchbegriff ein.</div>');
			$('#searcherror').fadeIn('slow');
			return false;
		}
	});
});
