$( document ).ready( function() {

	var searchInit = function() {
		var fieldObject = $( '#searchField' );
		if( !fieldObject.length ) {
			throw new Error( 'Не найдено поле поиска' )
		}

		var submitButton = $( '#searchSubmit' );
		if( !submitButton.length ) {
			throw new Error( 'Не найдена кнопка отсылки' )
		}

		var initValue = fieldObject.val();
		var currentValue = '';

		submitButton
			.bind( 'click', function( event ) {
				currentValue = fieldObject.val();
				if( currentValue == '' || currentValue == initValue ) {
					alert( 'Вы не ввели слово для поиска' );
					return false;
				}

				return true;
			});

		fieldObject
			.bind( 'focus', function( event ) {
				currentValue = fieldObject.val();
				if( currentValue == initValue ) {
					fieldObject.val( '' );
				}
			})
			.bind( 'blur', function( event ) {
				currentValue = fieldObject.val();
				if( currentValue == initValue || currentValue == '' ) {
					fieldObject.val( initValue );
					return;
				}

				fieldObject.unbind();
				initValue = null;
			});
	}


	try {
		searchInit();
	}
	catch( e ) {}

});