$(function() { // on DOM ready
	$('#qa_input').inlineLabel().quickaccess({
		links:[
			{selector:'#qa_articles a',title:'Inside the Whale:',className:'results_articles'},
			{selector:'#qa_staff a',title:'Staff:',className:'results_staff'},
			{selector:'#qa_blogposts a',title:'Blog posts:',className:'results_blogposts'},
			{selector:'#qa_services a',title:'Services:',className:'results_services'},
			{selector:'#qa_clients a',title:'Clients:',className:'results_clients'},
		],
		maxResults:10,
		noneFound:'Press [enter] to search this term on our Web site.'
	});
});

$.fn.extend({ // add jQuery plugins
	inlineLabel: function(style,text) { // places labels inside of text inputs
		if(typeof style !='string') { // if no style is specified (including empty strings)
			style ='inline_label'; // the default CSS class for placeholder text	
		}
		text = text || $('label[for='+this.attr('id')+']').hide().text(); // if text is not specified, use the label text
		var self = this,
			blur = function() { // a blur function that doesn't fire the browser blur event
				var val = $.trim(self.val());
				if(!val||val==text) { // if this input has no contents or the contents are identical to the placeholder text
					self.addClass(style) // add the inline_label class
						.val(text) // set the appropriate text
						.one('focus',function() { // and, on the first focus
							self.val('') // remove that text
								.removeClass(style); // and the inline_label class
						});
				}
			};
		self.blur(blur); // on blur, fire the blur function
		blur(); // and fire it now (without firing the browser blur event)
		return this; // return original element for chaining
	}
});