﻿/*
* jQuery UI Tabs extension
* 
* Redefined/added $.ui.tabs methods here
*
* Depend on this - Productnavigation tabs
*/

$.extend($.ui.tabs.prototype, {
    tab: 0,
    _tabId: function(a) {
        return a.title && a.title.replace(/\s/g, '_').replace(/[^A-Za-z0-9\-_:\.]/g, '') ||
			    this.options.idPrefix + (++this.tab);
    },
    load: function(index) {
        var self = this, o = this.options, a = this.anchors.eq(index)[0], url = $.data(a, 'load.tabs');

        this.abort();

        if (!url || this.element.queue("tabs").length !== 0 && $.data(a, 'cache.tabs')) {
            this.element.dequeue("tabs");
            return;
        }

        self._trigger('load', null, self._ui(self.anchors[index], self.panels[index]));
        self.element.dequeue("tabs");

        return this;
    },
    loadbyhash: function(hash) {
        var index = -1;

        $.each(this.anchors, function(i, value) {
            //trim (in ie prevents page scroll) and compare hash
            if (value.hash == "#" + hash.replace(/^\s+|\s+$/g, "")) index = i;
        });
        
        if (index > -1) this.select(index);

        return this;
    }
});