-@popups = Popup
-@popups = @popups.where(:enabled => true)
-@popups = @popups.where("start_at IS NULL or start_at <= ?",Time.now)
-@popups = @popups.where("end_at IS NULL or end_at >= ?",Time.now)
-@popups = @popups.where("lang_site_id = ?", @lang.id)
-@popups = @popups.order("rand()")

-if @article 
  -@popupable = @article
-if @menu_item
  -@popupable = @menu_item
-@popups.each do |popup|
  -if popup.nbr_occurrences.to_i > cookies["popup_"+popup.session_id].to_i
    -if popup.popup_popupables.count > 0 and @popupable
      -popup.popup_popupables.each do |popup_popupable|
        -if popup_popupable.popupable_id == @popupable.id and popup_popupable.popupable_type == @popupable.class.name
        
          =render popup
          -break
    -else
      -if @menu_item and @menu_item_lang and @menu_item_lang.permalink == "index"
        =render popup
        -break
    
-if params[:force_popup_id]
  -popup = Popup.where(:id => params[:force_popup_id]).first
  -if popup
    =render popup
    