module Www::PagesHelper

  def draw_side_menu
    html = ""
    unless @side_menu.blank?
      html << %(<div id="side-menu">)
        html << %(<div class="timeline-action">)
          @side_menu.each_with_index do |item_menu, i|
            if item_menu.active == true
              html << %(<div class="action-comment">)
                if item_menu.id == @page.id || (item_menu.content.blank? && item_menu.link.nil?)
                  html << %(<span class="timeline-title timeline-item-disable #{@side_menu.count == i +1 ? '' : 'timeline-divider'}">#{item_menu.name}</span>)
                else
                  html << link_to(item_menu.name, "#{item_menu.link.nil? ? www_page_path(item_menu) : item_menu.link}", class: "timeline-title link-title #{@side_menu.count == i +1 ? '' : 'timeline-divider'}")
                end
                html << %(<div class="clearfix"></div>)
              html << %(</div>)
            end
          end
        html << %(</div>)
      html << %(</div>)
    end
    raw(html)
  end

  def draw_banners
    html = ""
    #html << %(<div style="width: 100%; height: 200px; background: blue; margin-bottom: 20px;" class="visible-lg-block">)
    #html << %(</div>)
    #html << %(<div style="width: 100%; height: 200px; background: green;" class="visible-lg-block">)
    #html << %(</div>)
    raw(html)
  end

  def draw_customized_side_menu
    html = ""
    unless @applications_category.blank?
      html << %(<div id="side-menu">)
        html << %(<div class="timeline-action">)
          html << %(<div class="action-comment">)
            html << link_to(@applications_category.name, "#{!@applications_category.link.nil? ? www_page_path(@applications_category) : @applications_category.link}", class: "timeline-title link-title timeline-divider")
          html << %(</div>)
          html << %(<div class="action-comment">)
            html << %(<a href="#{infoutil_root_url}" class="timeline-title link-title timeline-divider">Infoutil</a>)
            html << %(<div class="clearfix"></div>)
          html << %(</div>)
          html << %(<div class="action-comment">)
            html << %(<a href="https://play.google.com/store/apps/details?id=com.ionicframework.vehicledenouncement481207" class="timeline-title link-title timeline-divider">#YoReporto</a>)
            html << %(<div class="clearfix"></div>)
          html << %(</div>)
          html << %(<div class="action-comment">)
            html << %(<a href="#{infoutil_saving_route_index_url}" class="timeline-title link-title timeline-divider">Ruta del Ahorro</a>)
            html << %(<div class="clearfix"></div>)
          html << %(</div>)
          html << %(<div class="action-comment">)
            html << %(<a href="http://infoutil.gobiernoabierto.gob.sv/camino-a-la-u/" class="timeline-title link-title timeline-divider">Camino a la U</a>)
            html << %(<div class="clearfix"></div>)
          html << %(</div>)

        html << %(</div>)
      html << %(</div>)
    end
    raw(html)
  end

  def get_icon_for_document_type(document_type=nil)
    html = ""
    case document_type
      when "application/octet-stream", "application/zip"
        html << image_tag("icons/icon-zip.png")
      when "application/pdf"
        html << image_tag("icons/icon-pdf.png")
      when "video/mp4"
        html << image_tag("icons/icon-video.png")
      when "audio/mpeg"
        html << image_tag("icons/icon-music.png")
      when "application/vnd.ms-powerpoint", "vnd.openxmlformats-officedocument.presentationml.presentation"
        html << image_tag("icons/icon-power-point.png")
      when "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
        html << image_tag("icons/icon-word.png")
      when "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
        html << image_tag("icons/icon-excel.png")
      else
        html << image_tag("icons/icon-download.png")
    end
    raw(html)
  end

end
