function Store() {
    this.store = {};
    this.current = null;
    this.start = this.setStart(); 
    return this;
};


Store.prototype = {

    
    initalise: function(a, o) {
        this.store.items = a;
        o.callback.call(o.scope, this.getItemsLength());
    },


    setStart: function() {
        var id = parseInt(window.location.href.split('id=').pop());
        // check for competition page variable...;
        if (typeof cPos !== 'undefined') {
            // ...and map to if availible;
            id = $.inArray(id, cPos);
        };
        return id >= 0 ? id : null;
    },


    getStoreItemById: function(id) {
        return $.grep(this.store.items, function(n, i) {
            return (n.identifer === 'ci_'+id);   
        });
    },


    getItemsLength: function() {
        return this.store.items.length;
    },


    get: function(id, prop) {
        var o = this.getStoreItemById(id).shift();
        this.setCurrent(id);
        return o[prop];
    },


    getStart: function() {
        return this.start;
    },


    getGroup: function(i) {
        return this.get(i !== undefined ? i : this.getStart() || 3, 'group');
    },


    setCurrent: function(i) {
        //console.log('setCurrent',i);
        this.store.index = i;
        return;
    },


    getCurrent: function() {
        return this.store.index;
    }

};