(function ( $ ) {

	// Autofill & clear text inputs
	$( 'input:text[title]' )
		.bind( 'focusin focusout', function ( e ) {
			var $this = $( this ), value = $this.val(), blank = ! $.trim( value ), match = value == this.title;
			$this.toggleClass( 'default', e.type === 'focusin' ? false : match || blank  );
			if ( blank || match )
				$( this ).val( e.type === 'focusin' ? '' : this.title );
		})
		.trigger( 'focusout' );

	// Clear out autofill on submit
	$( 'form' ).submit(function () {
		$( '.default' ).filter( 'input:text' ).val( '' );
	});

	// New window for external links
	$( 'a' ).each(function () {
		if  ( this.href && this.href.indexOf( window.location.host ) === -1 )
			$( this ).attr( 'target', '_blank' );
		});

})( jQuery );
