refactoring common behavior to js object I want to refactor this code into js object, 
but not sure how. How should I do it?

I initialize an object for every item in the  DS.data_per_folder array.
how can I define it in a higher level? Where should I init it then?

   .. 
    DS.data_per_folder[CurrentContextMgr.current.folder.attr('id')] = {
                allAttachments_vector: [],
                allAttachments_vector_counter : 0,
                attachment_position_dict : {},
                extraDetails_dict: {},
                getAttachmentsPerPage: function (pageNum) {
                    var result = this.allAttachments_vector.slice(global_vars.NUM_OF_ATTACH_PER_PAGE * (pageNum - 1), global_vars.NUM_OF_ATTACH_PER_PAGE * (pageNum));
                    return result.length == 0 ? null : result;
                },

                getAttachmentsMarkupPerPage: function (pageNum) {
                    var attachmentsMarkup = "";
                    var attachments = this.getAttachmentsPerPage(pageNum);
                    for (key in attachments) {
                        attachmentsMarkup += attachments[key].attachment_markup + " ";
                    }
                    return (attachmentsMarkup == "") ? "No attachments to display" : attachmentsMarkup;
                },

                pushAttachment: function (attachment, position) {

                    //not in dict yet
                    if (this.attachment_position_dict[attachment.attachmentId] == undefined)
                    {
                    if (position ==  null)
                    {
                    position = this.allAttachments_vector_counter;
                    }

                    this.allAttachments_vector[position] = attachment;

                this.allAttachments_vector_counter++;
                this.attachment_position_dict[attachment.attachmentId] = position;
                //this.extraDetails_dict[attachment.attachmentId] = {};
                }
            },       };
    }
..
I would recommend using a constructor function to create the objects:

function FolderData() {

    this.allAttachments_vector_counter = 0;
    this.allAttachments_vector = [];
    this.attachment_position_dict = {};
    this.extraDetails_dict = {};

}

FolderData.prototype = {

    constructor: FolderData,

    getAttachmentsPerPage: function (pageNum) {
        var result = this.allAttachments_vector.slice(
            global_vars.NUM_OF_ATTACH_PER_PAGE * (pageNum - 1), 
            global_vars.NUM_OF_ATTACH_PER_PAGE * (pageNum)
        );
        return result.length == 0 ? null : result;
    },

    getAttachmentsMarkupPerPage: function (pageNum) {
        var attachmentsMarkup = "";
        var attachments = this.getAttachmentsPerPage(pageNum);
        for (key in attachments) {
            attachmentsMarkup += attachments[key].attachment_markup + " ";
        }
        return (attachmentsMarkup == "") ? "No attachments to display" : attachmentsMarkup;
    },

    pushAttachment: function (attachment, position) {
        //not in dict yet
        if (this.attachment_position_dict[attachment.attachmentId] == undefined) {
            if (position ==  null) {
              position = this.allAttachments_vector_counter;
            }
            this.allAttachments_vector[position] = attachment;
            this.allAttachments_vector_counter++;
            this.attachment_position_dict[attachment.attachmentId] = position;
            //this.extraDetails_dict[attachment.attachmentId] = {};
        }   
    }

};


...

DS.data_per_folder[CurrentContextMgr.current.folder.attr('id')] = new FolderData();




The benefit of this, other than readability, is that you don't create a separate copy of every function property for each object. The functions are instead attached to the constructor's prototype, so there is only one instance of each function, and functions are shared by each constructed object instance.