
$(function () {
    $('.ImageFactoryPicker_Item').each(function (i) {
        var item = $(this);
        $("input[type=radio]", this).change(function (event) {

            if (event.currentTarget.checked) {
                $('.ImageFactoryPicker_Item').css({ borderColor: '#000000' });
                item.css({ borderColor: '#FF0000' });

            }
            else item.css({ borderColor: '#000000' });
        });

        item.click(function (event) {
            $('input', this).attr("checked", "checked");
            $('input', this).change();
            event.stopPropagation();
        });
        $('input[type=radio]', this).each(function (i) {

            if ($(this).attr("checked") == "checked" || this.checked) {
                item.css({ borderColor: '#FF0000' });
            }
            else {
                item.css({ borderColor: '#000000' });
            }
        }).hide();
    });
    $('.deleteLink').click(function (event) {
        if (!confirm('Are you sure you want to delete this item?')) {
            event.stopPropagation();
            event.preventDefault();
        }
    });
});
