$('#headerimg').click(function(event){
var $target = $(event.target);
// Stop it from executing for search form and children
if ($target.is('#search_form') == true || $target.parents('#search_form').length > 0)
{
return;
}
});
And yes I know I could cut down the code, but I chose not to for readability