﻿Ext.BLANK_IMAGE_URL = './images/default/s.gif';

String.prototype.endsWith = function(str) {
    return (this.match(str + "$") == str)
}

/*
Override to make the paging toolbar work
with data loaded
*/
Ext.PagingToolbar.prototype.doLoad = function(start) {
    var o = this.store.lastOptions.params || {}, pn = this.paramNames;
    o[pn.start] = start;
    o[pn.limit] = this.pageSize;
    if (this.fireEvent('beforechange', this, o) !== false) {
        this.store.load({ params: o });
    }
}

/**
* Clone Function
*/

/** * Clone Function */
Ext.ux.clone = function(o) {
    if (!o || 'object' !== typeof o) {
        return o;
    }
    var c = '[object Array]' === Object.prototype.toString.call(o) ? [] : {};
    var p, v;
    for (p in o) {
        if (o.hasOwnProperty(p)) {
            v = o[p];
            if (v && 'object' === typeof v) {
                c[p] = Ext.ux.clone(v);
            }
            else {
                c[p] = v;
            }
        }
    }
    return c;
};


Ext.ns('Ext.ux.layout');

Ext.ux.layout.CenterLayout = Ext.extend(Ext.layout.FitLayout, {
    // private
    setItemSize: function(item, size) {
        this.container.addClass('ux-layout-center');
        item.addClass('ux-layout-center-item');
        if (item && size.height > 0) {
            if (item.width) {
                size.width = item.width;
            }
            item.setSize(size);
        }
    }
});
Ext.Container.LAYOUTS['ux.center'] = Ext.ux.layout.CenterLayout;

Ext.form.Label = Ext.extend(Ext.BoxComponent, {
    onRender: function(B, A) {
        if (!this.el) {
            this.el = document.createElement("label");
            this.el.id = this.getId();
            this.el.innerHTML = this.text ? Ext.util.Format.htmlEncode(this.text) : (this.html || "");
            if (this.forId) {
                this.el.setAttribute("htmlFor", this.forId)
            }
        }
        Ext.form.Label.superclass.onRender.call(this, B, A)
    },
    setText: function(A, B) {
        this.text = A;
        if (this.rendered) {
            this.el.dom.innerHTML = B !== false ? Ext.util.Format.htmlEncode(A) : A
        }
        return this
    }
});
Ext.reg("label", Ext.form.Label);