         container = $('<div />')
         for user_photo in user_photos.product_photos
             container.append(Mustache.render(templates.product_photo_template, user_photo))
-        ($ '#product_form_wrapper').find('.product-photo:last').after(container)
+        $product_form_wrapper.find('.product-photo:last').after(container)
         ($ '.fetch-more-user-photos').data('maxId', user_photos.max_id)
 
     window.render_user_photos = (user_photos) ->
-        ($ '#product_form_wrapper').find('.product-photos')
+        $product_form_wrapper.find('.product-photos')
             .replaceWith(Mustache.render(templates.product_photos_template, user_photos, product_photo: templates.product_photo_template))
 
     window.render_user_photo_feed = (user_photos) ->
-        ($ '#product_form_wrapper').find('.photo-feed')
+        $product_form_wrapper.find('.photo-feed')
             .replaceWith(Mustache.render(templates.user_photo_feed_template, user_photos, product_photo: templates.product_photo_template))
 
     window.fetch_user_photos = (callback = render_user_photos, options = {}) ->

        ($ '#product_count').text("#{product_count} Products")

    render_product_widgets = (product_widgets) ->
        if product_widgets.length == 0
            ($ '.product-widgets').empty()
        else
            $wrapper = $('<div/>')

    fetch_user_photos(render_user_photo_feed, {product_slug: data.slug})

if gon.page is 'stores_new' or gon.page is 'stores_edit'
    $ -> ($ '#store_form_wrapper').find('form').validate store_form_options

if gon.page is 'stores_show'
    update_alert = (message) ->
        ($ '.rails-alert').removeClass(hide) if ($ '.rails-alert').hasClass(hide)
        ($ '.rails-alert').text(message)
        $window.scrollTop(0)

    update_notice = (message) ->
        ($ '.rails-notice').removeClass(hide) if ($ '.rails-notice').hasClass(hide)
        ($ '.rails-notice').text(message)
        $window.scrollTop(0)

    expire_alert_and_notice_in = (seconds) ->
        clearTimeout(clear_alert_and_notice_timeout) if clear_alert_and_notice_timeout?
        clear_alert_and_notice()
        window.clear_alert_and_notice_timeout = setTimeout ->
            clear_alert_and_notice()
        , seconds

    clear_alert_and_notice = ->
        ($ '.rails-notice, .rails-alert').text('').addClass(hide)

    update_h2 = (text) -> $product_form_wrapper.find('h2').first().html(text)

    reset_h2 = -> update_h2(Mustache.render(templates.stores_h2_add_template, {}))

