/**
 * search.js
 *
 * @author Iván Rodríguez
 * @date 2009-04-15
 * @brief Funcionalidad para controlar los campos de búsqueda
 * @version 0.1
 */

window.addEvent('domready', function() {
	$$('.InputBuscador').each(function(el) {
		el.set({
			'events' : {
				'focus' : function() {
					this.set('value', '');
				},
				'blur' : function() {
					if(this.get('value')=='')
						this.set('value', 'introduce texto...');
				}
			}
		});
	});
	
	$$('.Search').each(function(el) {
		el.set({
			'events' : {
				'submit' : function(e) {
					el.getElements('.InputBuscador').each(function(el) {
						if(!el.get('value') || el.get('value').contains("introduce texto...")) {
							new Event(e).stop();
							
							//alert('Es necesario introducir un texto de búsqueda');
							var _MyWindow = new MyWindow({
								'width' 	: '450px',
								'height' 	: '100px',
								'msg'		: '<h1>Es necesario introducir un texto de búsqueda</h1>',
								'windowType': 'modal',
								'notification' : true,
								'duration'	: 2
							});
														
							return false;
						}
					});
				}
			}
		});
	});
});

