﻿RCRMList = Class.create();
RCRMList.prototype =
{
    initialize: function() {

    },

    addItems: function(request, transport) {

        this.list1 = $("offerList1");
        this.list2 = $("offerList2");

        this.numOffers = transport["numOffers"];
        this.offers = transport["offers"];

        for (var i = 0; i < this.numOffers; i++) {
            if (i < 5) {
                new Insertion.Bottom(this.list1, this.offers[i]);
            }
            else {
                new Insertion.Bottom(this.list2, this.offers[i]);
            }
        }

        this.addCssClasses();
    },

    addCssClasses: function() {

        this.list1Children = this.list1.childElements();
        this.list2Children = this.list2.childElements();

        if (this.list1Children.length > 0) {
            for (var i = 0; i < this.list1Children.length; i++) {

                var classNr = i + 1;
                var className = "item-" + classNr;

                if (i == 0) {
                    className = className + " first";
                }

                if (i == this.list1Children.length - 1) {
                    className = className + " last";
                }

                this.list1Children[i].addClassName(className);
            }
        }

        if (this.list2Children.length > 0) {
            for (var i = 0; i < this.list2Children.length; i++) {

                var classNr = i + 6;
                var className = "item-" + classNr;

                if (i == 0) {
                    className = className + " first";
                }

                if (i == this.list1Children.length - 1) {
                    className = className + " last";
                }

                this.list2Children[i].addClassName(className);
            }
        }
    }


};
