$(document).ready(function() {
	
	// select all desired input fields and attach tooltips to them 
	$("form :input").not("form :input[type='submit']").tooltip({ 

	    // place tooltip on the right edge 
	    position: "center right", 

	    // a little tweaking of the position 
	    offset: [-2, 10], 

	    // use the built-in fadeIn/fadeOut effect 
	    effect: "fade", 

	    // position so that tooltip appears next to input and not at top of screen
	    relative: false, 

	    // use this single tooltip element 
	    tip: 'div.form-tooltips',
	
		// add focus CSS class to input
		onShow: function() {
		        this.getTrigger().addClass('focusField');
		},
		
		// remove focus CSS class from input
		onBeforeHide: function() {
		        this.getTrigger().removeClass('focusField');
		},

		// hide closest item error
		onBeforeShow: function() {
		        this.getTrigger().parent().find('.itemError').fadeOut('fast');
		}

	});
	
});

