﻿Ext.ns("OXX.Product", "OXX.ProductCollection");


OXX.Product = Ext.extend(Object, {

    constructor: function(id, aid, index, title, price, imageSmall) {
        this.id = id;
        this.aid = aid;
        this.index = index;
        this.title = title;
        this.price = price;
        this.imageSmall = imageSmall;
    },

    init: function() {

    }
});


OXX.ProductCollection = function() {

    var indexProducts = new Array();
    var hashProducts = {};

    return {
        redirectToProduct: function(id) {
            document.location = '?aid=' + hashProducts[id].aid + '&pid=' + hashProducts[id].id;
        },

        getProduct: function(id) {
            return hashProducts[id];
        },

        addProduct: function(id, aid, title, price, imageSmall) {
            hashProducts[id] = new OXX.Product(id, aid, 0, title, price, imageSmall);
        }
    };
} ();

