module ApplicationHelper

  # Google Analytic code
  def analytics_codes
    code = Configurations::GoogleAnalytic.code
    unless code.blank?
      code.html_safe
    end
  end

  # Show profile question wizard
  def show_profile_question_wizard?
    next_profile_question != 'complete' && (params[:controller] != 'users' and params[:action] != 'index')
  end

  def sub_header_active_tab_class(tab)
    match = case tab
      when :tasks
        request.url =~ /\/tasks/
      when :calendar
        request.url =~ /\/personal_calendar/
      when :pay
        request.url =~ /\/invoices\?tab=pay/
      when :charge
        request.url =~ /\/invoices\?tab=charge/
      when :my_accounts
        request.url =~ /\/settings/
      else
        nil
    end
    return 'active' if match
  end

end
