$(function () {
	$('div.tooltip').each(
		function () {
			$(this).prepend($('<div class="arrow" />'));
		}
	);
	$('fieldset input,fieldset textarea').bind(
		'focus keyup',
		function () {
			var type = '.tooltip';
			if ($(this).parent('.form_element').hasClass('error')) {
				type = '.tooltip.errors';
			}
			else {
				type = '.tooltip.hint'
			}
			//console.log(type);
			var tooltip = $(type, $(this).parent('.form_element'));
			if (tooltip.length) {
				tooltip.show();
				$('.arrow', tooltip).show();
			}
		}
	);
	$('fieldset input,fieldset textarea').bind(
		'blur',
		function () {
			$('.tooltip, .tooltip > .arrow', $(this).parent('.form_element')).hide();
		}
	);
});
