/**
 * JS functions for Advanced Coupons
 *
 * @author Justyna Cala <justyna.cala@mtcmedia.co.uk>
 */
$(document).ready(function () {
    'use strict';

    //Browse buttons
    $('.js_findItem').on("click", function () {
        var item_field = $(this).data('field');

        window.open('/shop/admin/products/manage.products.mini.php?field=' + item_field,'productselector',
            'status=yes,scrollbars=yes,resizable=yes,width=500,height=600');
    });

    $('.js_findCategory').on("click", function () {
        var category_field = $(this).data('field');

        window.open('/shop/admin/categories/manage.categories.mini.php?field=' + category_field,'productselector',
            'status=yes,scrollbars=yes,resizable=yes,width=500,height=600');
    });

    $('.js_findBrand').on("click", function () {
        var brand_field = $(this).data('field');

        window.open('/shop/admin/brands/manage.brands.mini.php?field=' + brand_field,'productselector',
            'status=yes,scrollbars=yes,resizable=yes,width=500,height=600');
    });

    //Clear buttons
    $('.js_cancelSelection').on('click', function () {
        var field_id = $(this).data("field"),
            name_clear_id = field_id + '_name';
        $('#' + field_id).val('');

        $('#' + name_clear_id).val('');
    });

}); // end of .ready
