/**
 * События onblur/onfocus для всех форм.
 * Значение по умолчанию берется из аттрибута rel соответвующего элемента.
 *
 * @version 1.1
 * @author Pavel @ Extyl-PRO LLC
 */
;jQuery(document).ready(function($){
	$('form input[type=text][rel], form textarea[rel]')
	.blur(function(){
		if(!$(this).val().replace(/\s/g, '')){
			$(this).val($(this).attr('rel'));
		}
	})
	.focus(function(){
		if($(this).val().replace(/^\s+|\s+$/g, '') == $(this).attr('rel')){
			$(this).val('');
		}
	})
	.each(function(){
		$(this).blur();
	})
	.end();

	$('form').submit(function(){
		$(this).find('input[type=text][rel], textarea[rel]').each(function(){
			var events = $(this).data('events');

			$(this).focus().unbind().blur();

			for (var type in events){
				for(var handler in events[type]){
					$(this).bind(type, handler);
				}
			}
		});
	});
});
