function hideTarget(target){
	/*for the close button*/
	jQuery('.' + target).fadeOut('fast');

}

(function($){
	$(function(){
	
		var docBound = false;
	
		/*Capture input elements that have a target class*/	
		$("input[class*='target:']").each(function(){
			var className = $(this).attr('class');
			var colophon = (className).match(/:.*(\W?)/)[0];
			var target = colophon.substr(1);	
			var isFocus = false;
			//Capture click events from the document. If the dropdown is open, close.
			//If the click event has already been bound, then return false.
			if(docBound == false){
				$(document).click(function(e){
					if($(e.target).parents('.' + target).length > 0 || isFocus == true){
						
						return false;
					}else{
						hideTarget(target);					
					}
			
				});						
				docBound = true;			
			}
			
			$(this).focus(function(){
				isFocus = true;
				
				$('.' + target).parents().each(function(){
						$(this).css({zIndex:'994'});
					});
				$('.' + target).fadeIn('fast');					   							   
			});
			
			$(this).blur(function(){
				isFocus = false;				   		
			});
					
		});
		
		/*Capture changes to the fields in the original form, and stock them into hidden fields of the clone form*/
		var updateClonedSearchFields = function() {
			$('#' + this.id + '_clone').val($('#' + this.id).val());
			//console.log(this.id, $('#' + this.id + '_clone').val());
		}
		
		/*Prevent submits with enter key..forcing users to hit the search key*/
		$('.button[type="submit"]').click(function(){											 
			$(this).parents('form:first').submit();	
		});

	});/*end document ready*/




})(jQuery);